# UTO Manager β€” Development Status _Last updated: 2026-08-09_ --- ## Current Branch `main` (feature/phase-3-templates-validation-export merged) ## Overall Progress | Phase | Title | Status | |-------|-------|--------| | 1 | Domain Foundation | βœ… Complete | | 2 | Canvas Engine & Persistence | βœ… Complete | | 3 | Template Library & Import/Export | βœ… Complete | | 4 | Reporting & Analytics | πŸ”² Not started | | 5 | Multi-user / Sync | πŸ”² Not started | --- ## Phase 1 β€” Domain Foundation βœ… **Completed items:** - `Echelon` entity with doctrinal hierarchy validation (`isValidParent`, `isValidChild`) - `DoctrinalBranch` entity with display names - `AuthorizedRank` entity with pay grade, category flags, `meetsMinimum`, `gradeLevel` - `DutyMos` value object with MOS dictionary validation and `unvalidated` constructor - `UnitNode` entity with `copyWith`, `isRoot`, `isValidParentNode` - `PositionSlot` entity with `isVacant`, `isFilled`, `isKeyLeader` - `PersonnelRecord` entity with `ReadinessState`, `copyWith`, `isUnassigned` - `UnitRepository` abstract interface - `PersonnelRepository` abstract interface - `domain_entities.dart` barrel export - Full unit test coverage for all domain entities and value objects **Test count (Phase 1):** 60 tests --- ## Phase 2 β€” Canvas Engine & Persistence βœ… **Completed items:** ### Domain Services - `UnitTreeService` β€” `buildTree`, `getSubtree`, `getAncestors`, `validateReparent`, `validateAssignment`, `calculateFillRate`, `getVacantKeyLeaderSlots`, `getMosMismatches` - `AssignmentService` β€” `assign`, `unassign`, `aggregateReadiness` with `ReadinessColor` ### Infrastructure β€” Database - Drift schema: `Units`, `PositionSlots`, `Personnel`, `Templates` tables - `AppDatabase` with `forTesting(NativeDatabase.memory())` constructor - `UnitDao` β€” full CRUD + watch streams - `PersonnelDao` β€” full CRUD + `assignToSlot` / `unassignFromSlot` + watch streams - `PositionSlotDao` β€” full CRUD + `assignPersonnel` / `clearAssignment` + watch streams - `TemplateDao` β€” full CRUD + `upsertTemplate` - build_runner code generation (`.g.dart` files) ### Infrastructure β€” Repositories - `DriftUnitRepository` β€” implements `UnitRepository` with domain↔Drift mapping - `DriftPersonnelRepository` β€” implements `PersonnelRepository` with domain↔Drift mapping - `DriftPositionSlotRepository` β€” concrete slot repository ### Application β€” BLoC - `UnitTreeCubit` / `UnitTreeState` (sealed) β€” tree loading, selection, reparent, subtree delete - `PersonnelCubit` / `PersonnelState` (sealed) β€” roster loading, filter, assign/unassign - `TemplateCubit` / `TemplateState` (sealed) β€” template save/load/delete ### Presentation - `HomeScreen` β€” three-pane adaptive layout (personnel | canvas | inspector) - `UtoCanvasWidget` β€” `InteractiveViewer` pan/zoom org chart with drag-and-drop reparent - `UnitNodeCard` β€” echelon-colored card with fill rate progress bar - `PositionSlotCard` β€” `DragTarget` slot card with MOS badge and readiness color - `PersonnelListTile` β€” `Draggable` soldier tile for assignment - Status bar with live unit/slot fill counts ### App Wiring - `main.dart` β€” `MultiBlocProvider` wiring all cubits with production database **Test count (Phase 2):** 77 new tests (137 total) --- ## Phase 3 β€” Template Library & Import/Export βœ… **Completed items:** ### Domain Services - `DoctrinalTemplates` β€” Pure-Dart library of all five 2026 BCT templates: - `mbct` β€” Mobile Brigade Combat Team (3Γ— Mobile Infantry Battalions, Cav Squadron, FA Battalion, MDEP, HKP, Engineer Battalion, Support Battalion) - `sbct` β€” Stryker Brigade Combat Team (3Γ— Stryker Infantry Battalions, Cav Recon Squadron, FA Battalion, Engineer Battalion, Support Battalion) - `abct` β€” Armored Brigade Combat Team (2Γ— Armor-Heavy CABs, 1Γ— Infantry-Heavy CAB, Armored Cav Squadron, M109A7 FA Battalion, Engineer Battalion) - `cabHeavy` β€” Combat Aviation Brigade Heavy (Attack Bn AH-64E, Assault Bn UH-60M/CH-47F, Air Ambulance Co, Aviation Support Bn) - `cabLight` β€” Combat Aviation Brigade Light (Attack Recon Bn AH-64E+MQ-9A, Assault Bn, Medical Assault Bn, Aviation Support Bn) - `TemplateInstantiator` β€” Converts `UnitDefinition` trees into concrete `UnitNode` + `PositionSlot` domain objects with injected ID generator - `MtoeValidationEngine` β€” Pure-domain validation engine with 7 rules: - **V001** MOS mismatch (warning) - **V002** Rank mismatch (warning) - **V003** Vacant key leader (critical) - **V004** Missing combat medic 68W in platoon (advisory) - **V005** Missing fire support specialist 13F in platoon (advisory) - **V006** Structural hierarchy violation (critical) - **V007** Manning below 70% (warning) ### Infrastructure β€” Codecs - `UnitTreeCodec` β€” JSON encode/decode for full unit tree snapshots (units + slots + personnel) - Schema version 1 with `exportedAt` timestamp - `encode` / `decode` (JSON string) - `encodeToMap` / `decodeFromMap` (Map) - Handles all optional fields (null parentUnitId, null assignedPersonnelId, qualifications list) ### Application β€” BLoC - `TemplateCubit` β€” Extended with: - `instantiateDoctrinalTemplate(key)` β€” instantiates any of the five BCT templates into the live database - `saveSnapshot(name, bctType, units, slots)` β€” saves current tree as a named template - `exportToJson(units, slots)` β€” encodes tree to JSON string for export - `importFromJson(json, {replaceExisting})` β€” decodes and persists imported tree - `ValidationCubit` / `ValidationState` (sealed) β€” wraps `MtoeValidationEngine`: - `validate(units, slots, personnel)` β€” runs all rules, emits `ValidationComplete` - `clear()` β€” resets to `ValidationInitial` - `ValidationComplete` exposes `.critical`, `.warnings`, `.advisories`, `.findingsForUnit(id)`, `.isClean` ### Domain Value Objects - `DutyMos` β€” Extended format validation to accept 4-character aviation AOC codes (e.g., `153A` = 3 digits + 1 letter) in addition to standard 3-character codes ### App Wiring - `main.dart` β€” Added `ValidationCubit` to `MultiBlocProvider` - `TemplateCubit` β€” Now requires `unitRepository` and `slotRepository` parameters **Test count (Phase 3):** 54 new tests (191 total) --- ## Test Summary | File | Tests | Status | |------|-------|--------| | `authorized_rank_test.dart` | 16 | βœ… | | `echelon_test.dart` | 17 | βœ… | | `personnel_record_test.dart` | 13 | βœ… | | `unit_node_test.dart` | 15 | βœ… | | `duty_mos_test.dart` | 32 | βœ… | | `assignment_service_test.dart` | 16 | βœ… | | `unit_tree_service_test.dart` | 27 | βœ… | | `mtoe_validation_engine_test.dart` | 22 | βœ… | | `template_instantiator_test.dart` | 18 | βœ… | | `unit_tree_codec_test.dart` | 14 | βœ… | | `widget_test.dart` | 1 | βœ… | | **Total** | **191** | **βœ… All pass** | --- ## Known Limitations / Next Steps (Phase 4) - No PDF/Excel export of readiness reports (Phase 4) - No Protobuf binary export (Phase 4) - No multi-user or sync capability (Phase 5) - Canvas layout is vertical tree only; horizontal layout not yet implemented - No undo/redo for assignment operations - No search/filter on the canvas itself - `ValidationCubit` findings not yet surfaced as visual node indicators on canvas (Phase 4 UI integration) - `MtoeValidationEngine` runs synchronously; background Isolate offloading deferred to Phase 4 - Template instantiation does not yet persist to database in a single Drift transaction (uses sequential inserts) --- ## Architecture Notes ``` lib/ β”œβ”€β”€ domain/ β”‚ β”œβ”€β”€ entities/ # Pure Dart domain models (no Flutter deps) β”‚ β”œβ”€β”€ value_objects/ # DutyMos (supports 3-char and 4-char AOC formats) β”‚ β”œβ”€β”€ repositories/ # Abstract interfaces β”‚ └── services/ # UnitTreeService, AssignmentService, β”‚ # MtoeValidationEngine, TemplateInstantiator, β”‚ # DoctrinalTemplates β”œβ”€β”€ infrastructure/ β”‚ β”œβ”€β”€ codecs/ # UnitTreeCodec (JSON encode/decode) β”‚ β”œβ”€β”€ database/ # Drift schema, DAOs, generated code β”‚ └── repositories/ # Drift-backed implementations β”œβ”€β”€ application/ β”‚ └── blocs/ # UnitTreeCubit, PersonnelCubit, β”‚ # TemplateCubit, ValidationCubit └── presentation/ β”œβ”€β”€ screens/ # HomeScreen └── widgets/ # Canvas, cards, tiles ```