# Coordinator Refactoring Status ## βœ… Completed 1. **SupervisorTransport trait created** - `lib/clients/supervisor` 2. **Mycelium transport moved** - `lib/clients/supervisor/src/transports/mycelium.rs` 3. **SupervisorClient made generic** - `SupervisorClient` 4. **Coordinator client updated** - Uses `SupervisorClient` 5. **Job type migrated** - Now uses `hero_job::Job` 6. **Job validation added** - `job.validate_required_fields()`, `job.validate_context()` 7. **Old validation removed** - Removed `validate_job()` from service.rs ## πŸ”„ In Progress - Coordinator Code Updates The coordinator needs updates throughout to use the new Job API: ### Required Changes: 1. **Method calls β†’ Field access**: - `job.id()` β†’ `job.id` - `job.caller_id()` β†’ `job.caller_id` - `job.context_id()` β†’ `job.context_id` 2. **Field name changes**: - `job.script` β†’ `job.payload` - `job.script_type` β†’ `job.executor` 3. **ID type changes**: - Change from `u32` to `String` throughout - Update HashMap keys, function signatures, database queries 4. **Status handling**: - Remove `job.status()` calls - Status is tracked separately in coordinator state 5. **Workflow fields** (depends, prerequisites): - These don't exist on `hero_job::Job` - Stored in `JobSummary` for DAG operations - Need separate storage/tracking ### Files Needing Updates (~41 errors): - `service.rs` - Job CRUD operations, methodβ†’field changes - `dag.rs` - Workflow orchestration, depends/prerequisites handling - `rpc.rs` - RPC handlers, ID type changes - `router.rs` - Job routing, already partially updated - Database queries - ID type changes ### Next Steps: 1. Update `service.rs` - Replace method calls with field access 2. Update `dag.rs` - Handle workflow fields from JobSummary 3. Update `rpc.rs` - Handle String IDs 4. Update database layer - String ID support 5. Test compilation 6. Integration testing ## Architecture Summary ``` lib/clients/supervisor/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ lib.rs (SupervisorClient, HttpTransport, trait) β”‚ └── transports/ β”‚ β”œβ”€β”€ mod.rs β”‚ └── mycelium.rs (MyceliumClient, MyceliumTransport, SupervisorHub) bin/coordinator/ β”œβ”€β”€ models/ β”‚ └── job.rs (re-exports hero_job::Job with validation) β”œβ”€β”€ service.rs (needs updates) β”œβ”€β”€ dag.rs (needs updates) β”œβ”€β”€ rpc.rs (needs updates) └── router.rs (updated) ``` ## Notes - `hero_job::Job` uses String UUIDs for IDs - Workflow orchestration (depends, prerequisites) handled by JobSummary - Job status tracked separately in coordinator state machine - Validation methods added to Job model for coordinator use