@code-migration/wow-migrator 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +59 -58
  2. package/bin/{kmp-skills.js → wow-migrator.js} +65 -17
  3. package/package.json +16 -8
  4. package/skills/android-project-analyst/MIGRATION.md +39 -23
  5. package/skills/android-project-analyst/SKILL.md +54 -44
  6. package/skills/android-project-analyst/bind.md +22 -14
  7. package/skills/android-project-analyst/dependencies.yaml +8 -4
  8. package/skills/android-project-analyst/roles/analysis-workspace-state.md +118 -0
  9. package/skills/android-project-analyst/roles/behavior-logic.md +163 -0
  10. package/skills/android-project-analyst/roles/data-contract-flow.md +167 -0
  11. package/skills/android-project-analyst/roles/presentation-resource.md +296 -0
  12. package/skills/android-project-analyst/roles/project-architecture.md +171 -0
  13. package/skills/android-project-analyst/workflow.md +118 -70
  14. package/skills/android-to-kmp-migrator/MIGRATION.md +61 -1
  15. package/skills/android-to-kmp-migrator/SKILL.md +96 -134
  16. package/skills/android-to-kmp-migrator/bind.md +33 -11
  17. package/skills/android-to-kmp-migrator/roles/completion-report.md +72 -0
  18. package/skills/android-to-kmp-migrator/roles/dependency-platform-gate.md +63 -0
  19. package/skills/android-to-kmp-migrator/roles/logic-implementation.md +66 -0
  20. package/skills/android-to-kmp-migrator/roles/migration-analysis-planning.md +65 -0
  21. package/skills/android-to-kmp-migrator/roles/migration-verification.md +77 -0
  22. package/skills/android-to-kmp-migrator/roles/migration-workspace-state.md +13 -1
  23. package/skills/android-to-kmp-migrator/roles/module-node-review-fix.md +74 -0
  24. package/skills/android-to-kmp-migrator/roles/presentation-integration.md +65 -0
  25. package/skills/android-to-kmp-migrator/roles/state-data-prep.md +63 -0
  26. package/skills/android-to-kmp-migrator/roles/ui-implementation.md +64 -0
  27. package/skills/android-to-kmp-migrator/workflow.md +175 -149
  28. package/skills/kmp-test-validator/MIGRATION.md +18 -3
  29. package/skills/kmp-test-validator/SKILL.md +44 -79
  30. package/skills/kmp-test-validator/bind.md +8 -8
  31. package/skills/kmp-test-validator/dependencies.yaml +3 -3
  32. package/skills/kmp-test-validator/roles/validation-intake-fidelity.md +67 -0
  33. package/skills/kmp-test-validator/roles/validation-plan-gate.md +66 -0
  34. package/skills/kmp-test-validator/roles/validation-remediation.md +7 -7
  35. package/skills/kmp-test-validator/roles/validation-report.md +8 -10
  36. package/skills/kmp-test-validator/roles/validation-test-runner.md +61 -0
  37. package/skills/kmp-test-validator/roles/validation-workspace-state.md +2 -2
  38. package/skills/kmp-test-validator/workflow.md +87 -119
  39. package/skills/migration-task-adapter/MIGRATION.md +34 -0
  40. package/skills/migration-task-adapter/SKILL.md +134 -0
  41. package/skills/migration-task-adapter/bind.md +113 -0
  42. package/skills/migration-task-adapter/dependencies.yaml +26 -0
  43. package/skills/migration-task-adapter/roles/task-reporter.md +129 -0
  44. package/skills/migration-task-adapter/roles/task-understanding-router.md +134 -0
  45. package/skills/migration-task-adapter/roles/workflow-orchestrator.md +140 -0
  46. package/skills/migration-task-adapter/roles/workspace-state-discipline-inspector.md +189 -0
  47. package/skills/migration-task-adapter/workflow.md +183 -0
  48. package/skills/android-project-analyst/roles/android-ecosystem.md +0 -141
  49. package/skills/android-project-analyst/roles/api-list.md +0 -136
  50. package/skills/android-project-analyst/roles/architecture-pattern.md +0 -131
  51. package/skills/android-project-analyst/roles/data-flow.md +0 -143
  52. package/skills/android-project-analyst/roles/logic-understand.md +0 -154
  53. package/skills/android-project-analyst/roles/resource-understand.md +0 -151
  54. package/skills/android-project-analyst/roles/ui-understand.md +0 -136
  55. package/skills/android-to-kmp-migrator/roles/api-contract-parity.md +0 -95
  56. package/skills/android-to-kmp-migrator/roles/dataflow-logic-implementation.md +0 -130
  57. package/skills/android-to-kmp-migrator/roles/dependency-resolution.md +0 -106
  58. package/skills/android-to-kmp-migrator/roles/incremental-build-check.md +0 -105
  59. package/skills/android-to-kmp-migrator/roles/legacy-spec-delta-review.md +0 -104
  60. package/skills/android-to-kmp-migrator/roles/migration-alignment.md +0 -119
  61. package/skills/android-to-kmp-migrator/roles/migration-report.md +0 -108
  62. package/skills/android-to-kmp-migrator/roles/module-node-migration-fix.md +0 -111
  63. package/skills/android-to-kmp-migrator/roles/module-node-migration-review.md +0 -108
  64. package/skills/android-to-kmp-migrator/roles/navigation-migration.md +0 -104
  65. package/skills/android-to-kmp-migrator/roles/platform-api-replacement.md +0 -104
  66. package/skills/android-to-kmp-migrator/roles/prd-completion-check.md +0 -124
  67. package/skills/android-to-kmp-migrator/roles/resource-migration.md +0 -109
  68. package/skills/android-to-kmp-migrator/roles/source-set-placement-guard.md +0 -95
  69. package/skills/android-to-kmp-migrator/roles/state-model-mapping.md +0 -109
  70. package/skills/android-to-kmp-migrator/roles/target-project-understand.md +0 -118
  71. package/skills/android-to-kmp-migrator/roles/theme-design-system-mapping.md +0 -101
  72. package/skills/android-to-kmp-migrator/roles/ui-mockup-implementation.md +0 -121
  73. package/skills/android-to-kmp-migrator/roles/ui-render-fidelity-check.md +0 -100
  74. package/skills/kmp-test-validator/roles/android-kmp-fidelity-audit.md +0 -102
  75. package/skills/kmp-test-validator/roles/build-preview-gate.md +0 -109
  76. package/skills/kmp-test-validator/roles/kmp-validation-plan.md +0 -108
  77. package/skills/kmp-test-validator/roles/test-case-decomposition.md +0 -103
  78. package/skills/kmp-test-validator/roles/test-execution.md +0 -104
  79. package/skills/kmp-test-validator/roles/validation-input-contract.md +0 -111
@@ -1,101 +1,150 @@
1
- # Workflow: Legacy Android source → verified node artifacts → SPEC package
1
+ # Workflow: Legacy Android source → module artifacts → global representation → SPEC package
2
2
 
3
- This Swarm Skill is **Mixed B+C**: a parallel decomposition (Stage A foundation nodes) feeding a specialization pipeline with hard handoff gates (Stage B resource/data-flow, Stage C logic), integrated by the Leader (`android-project-analyst` controller) into the SPEC package. Each node owns a disjoint analysis slice; the Leader never does node work and never invents claims that no node traced to source.
3
+ This Swarm Skill is **module-first Mixed B+C with workspace-state tracking**: the Leader first partitions the Legacy Android project into bounded analysis modules, maintains a ledger of module/node artifacts and stale inputs, then runs the clustered node schedule inside each module before combining the verified module representations into one global project representation and SPEC package. Each node owns a bounded module slice; the Leader never does node work and never invents claims that no node traced to source.
4
4
 
5
5
  ## Overview
6
6
 
7
7
  ```mermaid
8
8
  graph TD
9
- L0[Leader: Step 0 dependency pre-flight] --> L1[Leader: Step 1 trigger + mode + shared brief]
9
+ L0[Leader: Step 0 dependency pre-flight] --> L1[Leader: Step 1 trigger + output root lock]
10
10
  L1 --> G0{Android evidence + valid scope?}
11
11
  G0 -- No --> STOP[Stop: explain failed check / recommend Explore]
12
- G0 -- Yes --> S1{Input scale OK?}
13
- S1 -- "Over-scale (see bind.md)" --> DEG[Degraded mode<br/>narrow scope / fewer nodes]
14
- S1 -- Yes --> F1[ui-understand]
15
- S1 -- Yes --> F2[architecture-pattern]
16
- S1 -- Yes --> F3[android-ecosystem]
17
- S1 -- Yes --> F4[api-list]
12
+ G0 -- Yes --> WS0[analysis-workspace-state]
13
+ WS0 --> M0[Leader: Step 3 module inventory]
14
+ M0 --> WSM[Refresh analysis-workspace-state]
15
+ WSM --> S1{Module schedule valid?}
16
+ S1 -- "Over-scale (see bind.md)" --> DEG["Degraded mode: narrow module scope"]
17
+ S1 -- Yes --> LOOP[For each module_id in module_order]
18
+ LOOP --> MB[Leader: write module brief]
19
+ MB --> F1[presentation-resource]
20
+ MB --> F2[project-architecture]
21
+ MB --> F3[data-contract-flow]
18
22
  F1 --> GA{Foundation outputs verified?}
19
23
  F2 --> GA
20
24
  F3 --> GA
21
- F4 --> GA
22
- GA -- "missing/empty/!=completed" --> RR1[Re-dispatch failed node<br/>with failure reason]
25
+ GA -- "missing/empty/!=completed" --> RR1[Re-dispatch failed foundation node]
23
26
  RR1 --> GA
24
- GA -- Yes --> D1[resource-understand]
25
- GA -- Yes --> D2[data-flow]
26
- D1 --> GB{Dependent outputs verified?}
27
- D2 --> GB
28
- GB -- fail --> RR2[Re-dispatch failed node]
27
+ GA -- Yes --> WSA[Refresh analysis-workspace-state]
28
+ WSA --> B1[behavior-logic]
29
+ B1 --> GB{Behavior output verified?}
30
+ GB -- fail --> RR2[Re-dispatch behavior-logic]
29
31
  RR2 --> GB
30
- GB -- Yes --> C1[logic-understand]
31
- C1 --> GC{Logic output verified?}
32
- GC -- fail --> RR3[Re-dispatch logic-understand]
33
- RR3 --> GC
34
- GC -- Yes --> INT[Leader: Step 5 reconcile + coverage/evidence matrix]
35
- DEG --> INT
36
- INT --> OUT[Leader: Step 6 write SPEC + verification verdict]
32
+ GB -- Yes --> MR[Leader: Step 5 write module representation]
33
+ MR --> WSR[Refresh analysis-workspace-state]
34
+ WSR --> NEXT{More modules?}
35
+ NEXT -- Yes --> LOOP
36
+ NEXT -- No --> GR[Leader: Step 6 global representation]
37
+ DEG --> GR
38
+ GR --> WSG[Refresh analysis-workspace-state]
39
+ WSG --> OUT[Leader: Step 8 write SPEC + verification verdict]
37
40
  ```
38
41
 
42
+ ## Strict Output Paths
43
+
44
+ The Leader MUST lock one `output_root` before dispatch and MUST reject or rerun any node that writes outside its assigned directory. Defaults:
45
+
46
+ - `output_root`: `<output_dir or ~/.a2c_agents/understand>/android-project-analyst`
47
+ - `workspace_state_dir`: `<output_root>/workspace-state`
48
+ - `module_index_dir`: `<output_root>/module-index`
49
+ - `module_root`: `<output_root>/modules/<module_id>`
50
+ - `module_node_dir`: `<module_root>/node-results/<node_id>`
51
+ - `module_representation_dir`: `<module_root>/representation`
52
+ - `global_dir`: `<output_root>/global`
53
+ - `spec_dir`: `<output_root>/SPEC`
54
+
55
+ Required durable artifacts:
56
+
57
+ | Schedule point | Required artifacts |
58
+ |---|---|
59
+ | Output root lock | `<output_root>/run_manifest.json` |
60
+ | Workspace state | `<workspace_state_dir>/analysis_workspace_state.json`, `<workspace_state_dir>/analysis_workspace_state.md` |
61
+ | Module inventory | `<module_index_dir>/module_inventory.json`, `<module_index_dir>/module_inventory.md` |
62
+ | Per module brief | `<module_root>/module_brief.json` |
63
+ | Per module node outputs | `<module_node_dir>/<node_artifact>.json`, `<module_node_dir>/<node_artifact>.md` |
64
+ | Per module representation | `<module_representation_dir>/module_representation.json`, `<module_representation_dir>/module_representation.md` |
65
+ | Global representation | `<global_dir>/global_representation.json`, `<global_dir>/global_representation.md` |
66
+ | SPEC package | `<spec_dir>/prd.md`, `<spec_dir>/design.md`, `<spec_dir>/verification.md`, plus `<spec_dir>/plan.md` in migration mode |
67
+
68
+ No node may choose its own output path. `presentation-resource` may write downloaded resources only under `<module_root>/node-results/presentation-resource/downloaded_resources/`.
69
+
39
70
  ## Detailed Steps
40
71
 
41
72
  ### Step 0 — Pre-flight: dependency check
42
73
 
43
74
  - **Executor**: Leader (`android-project-analyst` controller)
44
75
  - **Input**: [dependencies.yaml](dependencies.yaml)
45
- - **Action**: verify each `tools[]` entry (`rg`, `curl`) is available; built-in Grep/Read substitute when `rg` is absent. Resource downloads degrade to `download_gaps` when `curl` is absent.
76
+ - **Action**: verify each `tools[]` entry (`rg`, `curl`, `git`) is available; built-in Grep/Read substitute when `rg` is absent. Presentation/resource downloads degrade to `download_gaps` when `curl` is absent. Stale-input detection degrades to artifact-path/status comparison when `git` is absent.
46
77
  - **Output**: pre-flight note to the user
47
78
  - **Quality gate**: all deps are `required: false` → the run proceeds even if missing; user is informed of any degraded mode. The Leader does NOT auto-skip nodes.
48
79
 
49
- ### Step 1 — Trigger verification + mode selection + shared brief
80
+ ### Step 1 — Trigger verification + mode selection + output root lock
50
81
 
51
82
  - **Executor**: Leader
52
83
  - **Input**: `source_project_path`, optional `analysis_scope` / `mode` / `target_project_path` / `output_dir` / `language`, optional `jetbrains` MCP context
53
- - **Action**: verify the target is an Android project (`AndroidManifest.xml`, `settings.gradle(.kts)`, `build.gradle(.kts)`, or a `com.android.*` module) and that the request needs structured analysis, not a one-off lookup. Select `exploration` or `migration`. Build a minimal shared brief (confirmed paths, scope, output root, Android evidence, module/build files, optional MCP evidence, known constraints).
54
- - **Output**: announced mode banner + shared brief; default `output_dir` = `~/.a2c_agents/understand/` (SPEC under `<output_dir>/SPEC`, node artifacts under `<output_dir>/node-results/<node>`)
84
+ - **Action**: verify the target is an Android project (`AndroidManifest.xml`, `settings.gradle(.kts)`, `build.gradle(.kts)`, or a `com.android.*` module) and that the request needs structured analysis, not a one-off lookup. Select `exploration` or `migration`. Lock `output_root`, `module_index_dir`, `global_dir`, and `spec_dir`. Write `run_manifest.json` with source path, mode, target path, scope, schedule version, allowed path roots, and timestamp.
85
+ - **Output**: announced mode banner + `run_manifest.json`; default `output_root` = `~/.a2c_agents/understand/android-project-analyst`
55
86
  - **Serial / Parallel**: serial (precedes all dispatch)
56
- - **Quality gate**: Android evidence present AND scope valid → proceed; otherwise STOP and explain the failed check (recommend a generic exploration agent for simple lookups). Migration mode without `target_project_path` → ask before producing `plan.md`.
87
+ - **Quality gate**: Android evidence present AND scope valid AND `run_manifest.json` exists/non-empty → proceed; otherwise STOP and explain the failed check. Migration mode without `target_project_path` → ask before producing `plan.md`.
57
88
 
58
- ### Step 2 — Stage A: dispatch foundation nodes (parallel, B-pattern)
89
+ ### Step 2 — Workspace state ledger
59
90
 
60
- - **Executor**: `ui-understand`, `architecture-pattern`, `android-ecosystem`, `api-list`
61
- - **Input**: per-node contract `{ source_project_path, analysis_scope, mode, shared_brief, skill_spec_path (roles/<id>.md), output_dir: <output_dir>/node-results/<node>, return_format: json }`; `api-list` may also receive `ui_entry_points`
62
- - **Action**: each node validates inputs, performs its bounded slice, writes its JSON+MD artifacts, and returns the controller JSON shape
63
- - **Output**: `ui_understanding.*`, `architecture_pattern.*`, `android_ecosystem.*`, `api_list.*`
64
- - **Serial / Parallel**: parallel all four run together (slices are dispatch-time fixed, not negotiated)
65
- - **Quality gate**: each return must be `status: "completed"` with `output_files` that exist and are non-empty. On missing/empty/non-`completed` output → re-dispatch that node with the same contract plus the failure reason (retry policy in [bind.md](bind.md) § Failure Handling). Do NOT synthesize around a failed node.
91
+ - **Executor**: `analysis-workspace-state`
92
+ - **Input**: output root, run manifest, current controller step, known module/node/artifact outputs, source change/timestamp evidence, rerun reports, blockers
93
+ - **Action**: initialize and refresh the analysis ledger. Track module status, node output inventory, artifact inventory, stale upstream inputs, rerun history, blockers, and next safe controller actions.
94
+ - **Output**: `analysis_workspace_state.json`, `analysis_workspace_state.md`
95
+ - **Serial / Parallel**: serial; refreshed after module inventory, Stage A, Stage B, module representation, global representation, and SPEC.
96
+ - **Quality gate**: downstream stages do not consume artifacts marked stale; rerun the responsible module/node or mark the affected module `blocked`.
66
97
 
67
- ### Step 3 — Stage B: dispatch resource + data-flow nodes (gated handoff, C-pattern)
98
+ ### Step 3 — Module inventory and schedule
68
99
 
69
- - **Executor**: `resource-understand`, `data-flow`
70
- - **Input**: Stage A verified output paths. `resource-understand` receives optional `ui_understanding_path` / `api_list_path` / `android_ecosystem_path`; `data-flow` receives required `api_list_path` + optional `architecture_pattern_path` / `android_ecosystem_path` / `ui_understanding_path`
71
- - **Action**: `resource-understand` maps local + online resources and safely downloads concrete URLs into `<output_dir>/node-results/resource-understand/downloaded_resources/`; `data-flow` traces sources→repositories→streams→UI state, aligning API IDs to `api_list`
72
- - **Output**: `resource_understanding.*`, `data_flow.*`
73
- - **Serial / Parallel**: starts only after Stage A gate passes; the two nodes may run in parallel with each other
74
- - **Quality gate**: same return-shape + output-file checks as Step 2. If a node needs upstream data that is missing/stale, it returns `needs_rerun`/`blocked` rather than rebuilding another node's catalog.
100
+ - **Executor**: Leader
101
+ - **Input**: source path, analysis scope, Android evidence, module/build files, optional MCP module context
102
+ - **Action**: partition the project into explicit `analysis_modules`. Prefer Gradle modules and feature packages; when one Gradle module contains multiple independent features, split by package/route/feature boundary. Each module entry MUST include `module_id` (stable slug), `module_type` (`app | feature | ui | logic | data | platform | shared | test | unknown`), `source_roots`, `ui_scope`, `logic_scope`, `data_scope`, `resource_scope`, `depends_on`, and `module_output_root`. Include UI-only and logic-only modules when they exist; if a module has no UI or no logic, record `none` with evidence.
103
+ - **Output**: `module_inventory.json`, `module_inventory.md`
104
+ - **Serial / Parallel**: serial (precedes all module dispatch)
105
+ - **Quality gate**: module inventory exists/non-empty, every in-scope source root is assigned to one module or `out_of_scope`, and `module_order` is deterministic.
75
106
 
76
- ### Step 4 — Stage C: dispatch logic node (final pipeline stage)
107
+ ### Step 4 — Stage A per module: dispatch clustered foundation nodes (parallel, B-pattern)
77
108
 
78
- - **Executor**: `logic-understand`
79
- - **Input**: required `ui_understanding_path`, `architecture_pattern_path`, `android_ecosystem_path`, `api_list_path`, `data_flow_path`
80
- - **Action**: synthesize user-action / lifecycle / state-machine / business-rule behavior, referencing (not rebuilding) upstream catalogs
81
- - **Output**: `logic_understanding.*`
82
- - **Serial / Parallel**: serialruns last, after Stage B gate passes
83
- - **Quality gate**: return-shape + output-file checks; every major UI module from `ui_understanding_path` has logic coverage or an explicit reason for none.
109
+ - **Executor**: `presentation-resource`, `project-architecture`, `data-contract-flow`
110
+ - **Input**: per-node contract `{ source_project_path, module_id, module_scope, analysis_scope, mode, module_brief_path, skill_spec_path (roles/<id>.md), output_dir: <output_root>/modules/<module_id>/node-results/<node_id>, return_format: json }`; `data-contract-flow` may also receive `presentation_hints` when known.
111
+ - **Action**: each node validates inputs, performs its bounded clustered slice, writes its JSON+MD artifacts, and returns the controller JSON shape.
112
+ - **Output**: `presentation_resource.*`, `project_architecture.*`, `data_contract_flow.*`
113
+ - **Serial / Parallel**: parallel within one module all three run together for the same `module_id`. Do not start the next module until the current module representation is written unless the user explicitly allows concurrent modules.
114
+ - **Quality gate**: each return must be `status: "completed"` with `output_files` that exist and are non-empty. Refresh `analysis-workspace-state` after the group; on missing/empty/non-`completed`/stale output re-dispatch that node with the same contract plus the failure reason (retry policy in [bind.md](bind.md) § Failure Handling). Do NOT synthesize around a failed node.
115
+
116
+ ### Step 5 — Stage B per module: dispatch behavior logic node (gated handoff, C-pattern)
117
+
118
+ - **Executor**: `behavior-logic`
119
+ - **Input**: required `module_id`, `module_scope`, `presentation_resource_path`, `project_architecture_path`, `data_contract_flow_path`, and latest `analysis_workspace_state_path`
120
+ - **Action**: synthesize user-action / lifecycle / state-machine / business-rule behavior, referencing (not rebuilding) upstream catalogs.
121
+ - **Output**: `behavior_logic.*`
122
+ - **Serial / Parallel**: serial within the module — runs after that module's Stage A gate passes.
123
+ - **Quality gate**: latest workspace state must not mark Stage A inputs stale; return-shape + output-file checks; every major UI/logic scope from the module brief has behavior coverage or an explicit reason for none.
124
+
125
+ ### Step 6 — Module representation
126
+
127
+ - **Executor**: Leader
128
+ - **Input**: verified node JSON/MD outputs for one `module_id`
129
+ - **Action**: integrate ONLY from verified outputs for that module. Write a module representation that covers both UI and logic when present: module purpose, UI surface, resources, architecture/ecosystem, data contracts/flows, behavior logic, dependencies, risks, gaps, evidence index, and readiness.
130
+ - **Output**: `module_representation.json`, `module_representation.md`
131
+ - **Serial / Parallel**: serial
132
+ - **Quality gate**: no unknowns hidden; every module representation points to its node artifacts and source evidence. Refresh workspace state after writing. Do not proceed to global integration until every scheduled module is represented or explicitly marked blocked/out of scope.
84
133
 
85
- ### Step 5Integrate: reconcile verified outputs
134
+ ### Step 7Global representation
86
135
 
87
136
  - **Executor**: Leader
88
- - **Input**: all verified node JSON/MD outputs
89
- - **Action**: integrate ONLY from verified outputs. Prefer evidence with exact source paths. Mark cross-node conflicts that affect architecture/data-flow/ecosystem/migration as `Needs confirmation`. Build a **coverage matrix** (screen/module → UI → architecture role → APIs/data sources resource usage data flows logic flows ecosystem constraints) and an **evidence index** (claim node output source paths confidence `verified|inferred|assumed|unknown`).
90
- - **Output**: reconciled coverage matrix + evidence index (in-memory, feeds Step 6)
137
+ - **Input**: all verified module representations
138
+ - **Action**: combine module representations into a total full-project global representation. Preserve module boundaries first, then synthesize cross-module architecture, navigation, data dependencies, shared resources, shared logic, platform constraints, conflicts, and global readiness. Do not read raw source to fill gaps at this stage; rerun the responsible module/node instead.
139
+ - **Output**: `global_representation.json`, `global_representation.md`
91
140
  - **Serial / Parallel**: serial
92
- - **Quality gate**: no unknowns hidden every unresolved item lands in SPEC risks/assumptions or `Needs confirmation`.
141
+ - **Quality gate**: latest workspace state must not mark required module representations stale; every global claim maps to a module representation and source-path evidence, or is marked `assumed`, `unknown`, or `blocked`.
93
142
 
94
- ### Step 6 — Final: write SPEC package + emit completion report
143
+ ### Step 8 — Final: write SPEC package + emit completion report
95
144
 
96
145
  - **Executor**: Leader
97
- - **Input**: coverage matrix + evidence index from Step 5
98
- - **Action**: write SPEC artifacts under `<output_dir>/SPEC`. **Exploration** mode → `prd.md`, `design.md`, `verification.md`. **Migration** mode → adds `plan.md`. SPEC must synthesize, not paste node summaries; every important claim maps to node output + source path or is marked assumption/gap. `design.md` sections include a Mermaid diagram, structured table, or evidence mapping; architecture/UI-navigation/data-flow/cross-module sections include diagrams when evidence exists.
146
+ - **Input**: `global_representation.json`, `global_representation.md`, module inventory, module representations, latest `analysis_workspace_state.json`
147
+ - **Action**: write SPEC artifacts under `<output_root>/SPEC`. **Exploration** mode → `prd.md`, `design.md`, `verification.md`. **Migration** mode → adds `plan.md`. SPEC must synthesize, not paste node summaries; every important claim maps to module/global representation evidence and source paths or is marked assumption/gap. `design.md` sections include a Mermaid diagram, structured table, or evidence mapping; presentation/navigation, project architecture, data-contract/flow, and cross-module sections include diagrams when evidence exists.
99
148
  - **Output**: SPEC files + the completion report below
100
149
 
101
150
  #### Final Report Format
@@ -106,15 +155,12 @@ graph TD
106
155
  "mode": "exploration | migration",
107
156
  "source_project_path": "...",
108
157
  "target_project_path": "... or null",
109
- "node_outputs": {
110
- "ui_understand": ["..."],
111
- "architecture_pattern": ["..."],
112
- "android_ecosystem": ["..."],
113
- "api_list": ["..."],
114
- "resource_understand": ["..."],
115
- "data_flow": ["..."],
116
- "logic_understand": ["..."]
117
- },
158
+ "output_root": "...",
159
+ "workspace_state": ["..."],
160
+ "module_inventory": ["..."],
161
+ "module_representations": ["..."],
162
+ "global_representation": ["..."],
163
+ "node_outputs_by_module": {},
118
164
  "spec_outputs": ["..."],
119
165
  "readiness": "ready | ready_with_assumptions | blocked",
120
166
  "blocking_gaps": []
@@ -124,9 +170,11 @@ graph TD
124
170
  ## Acceptance Criteria
125
171
 
126
172
  - All dispatched nodes returned outputs matching their role `## Output Schema` (no malformed returns); any `[ROLE MISSING]` is recorded per [bind.md](bind.md).
127
- - All required node artifacts exist and are non-empty; all required SPEC artifacts for the selected mode exist and are non-empty.
128
- - **Coverage check (B-pattern)**: every Stage A slice is accounted for — screens from `ui-understand` are represented in `design.md` or marked out of scope; APIs from `api-list` appear or are marked unknown; local/online resources from `resource-understand` appear or are marked unknown.
129
- - **Gate check (C-pattern)**: Stage B ran only after Stage A verification; Stage C ran only after Stage B verification; every kicked-back node is recorded.
130
- - Data-flow and logic-flow names align across `design.md`, `plan.md`, and `verification.md`.
173
+ - All required node artifacts exist and are non-empty; latest `analysis-workspace-state` has no stale required inputs; all required SPEC artifacts for the selected mode exist and are non-empty.
174
+ - **Path check**: every artifact path is under `output_root`; every node artifact is under `<output_root>/modules/<module_id>/node-results/<node_id>/`; SPEC is under `<output_root>/SPEC`.
175
+ - **Module-first check**: every scheduled module has a module brief, node outputs, and module representation before global representation is written.
176
+ - **Coverage check (B-pattern)**: every per-module Stage A slice is accounted for — screens/resources from `presentation-resource`, topology/platform constraints from `project-architecture`, and APIs/data flows from `data-contract-flow` appear in module/global representations or are marked out of scope/unknown.
177
+ - **Gate check (C-pattern)**: per-module behavior analysis ran only after that module's Stage A verification; every kicked-back node is recorded.
178
+ - Data-flow and behavior-flow names align across `design.md`, `plan.md`, and `verification.md`.
131
179
  - `verification.md` carries a readiness verdict (`ready | ready_with_assumptions | blocked`); if `blocked`, the final response lists blockers and exact missing evidence.
132
180
  - No artifact claims certainty for unknown or dynamic code paths.
@@ -41,4 +41,64 @@ The registry separated controller from nodes and even encoded the staged dispatc
41
41
 
42
42
  ## Team-vs-single delta
43
43
 
44
- The conversion preserves every source contract while adding: explicit pipeline + parallel + loop topology with verifiable gates, per-role anti-overlap boundaries that name siblings, self-contained pasteable personas (no re-derivation per dispatch across 20 nodes), resource/token/wall-clock budgets plus a `max_review_fix_cycles` bound, failure-routing rules, and concrete degraded modes for large monorepos and missing tooling. The same-name controller subagent in `kmp-migration/agents/android-to-kmp-migrator.md` is unchanged in behavior; its node table now points at `roles/<id>.md`.
44
+ The conversion preserves every source contract while adding: explicit pipeline + parallel + loop topology with verifiable gates, per-role anti-overlap boundaries that name siblings, self-contained pasteable personas (no re-derivation per dispatch across 20 nodes), resource/token/wall-clock budgets plus a `max_review_fix_cycles` bound, failure-routing rules, and concrete degraded modes for large monorepos and missing tooling. The same-name controller subagent in `kmp-migration/agents/android-to-kmp-migrator.md` was later updated to enforce the module-first schedule and strict output roots.
45
+
46
+ ## Module-First Refactor (0.3)
47
+
48
+ The second refactor added a module-first migration schedule and strict output paths. It initially kept the 20-role shape, then Phase 0.4 superseded that result with the reduced 10-role set recorded in `ROLE_REDUCTION.md`.
49
+
50
+ ### New schedule
51
+
52
+ 1. Lock `output_root = <output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator`.
53
+ 2. Write `<output_root>/run_manifest.json`.
54
+ 3. Write `<output_root>/module-index/migration_module_inventory.json` and `.md`.
55
+ 4. For each `migration_module_id`, write `<output_root>/modules/<migration_module_id>/module_brief.json`.
56
+ 5. Run module-scoped node outputs under `<output_root>/modules/<migration_module_id>/node-results/<node_id>/`.
57
+ 6. Run review/fix loops per module and owning node slice.
58
+ 7. Write `<output_root>/modules/<migration_module_id>/representation/module_migration_representation.json` and `.md`.
59
+ 8. Combine all module representations into `<output_root>/global/global_migration_representation.json` and `.md`.
60
+ 9. Write final `<output_root>/report/migration_report.json` and `.md`.
61
+ 10. Hand the final report to `kmp-test-validator`.
62
+
63
+ ### Contract changes
64
+
65
+ - Every module-scoped node now receives `migration_module_id`, `module_scope`, exact `output_dir`, and allowed target files/source sets when it may change files.
66
+ - Review mode remains read-only. Fix mode consumes explicit findings, `allowed_files`, `owning_node`, and `migration_module_id`; re-review is a fresh read-only invocation.
67
+ - Verification runs per module first. Global aggregation consumes module representations rather than loose node output lists.
68
+ - `migration-report` may return `ready_for_validation` only when every scheduled module representation and the global representation exists and is non-empty.
69
+
70
+ ### Path compatibility
71
+
72
+ The old default `~/.a2c_agents/migration/` is now only the base directory. The effective output root is always:
73
+
74
+ ```text
75
+ <output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator
76
+ ```
77
+
78
+ No controller or node should write durable migration artifacts directly under the base directory.
79
+
80
+ ## Role Reduction Refactor (0.4)
81
+
82
+ The third refactor reduces active migrator role definitions from 20 to 10. The full analysis lives in [ROLE_REDUCTION.md](ROLE_REDUCTION.md).
83
+
84
+ ### Old-to-new map
85
+
86
+ | Old role(s) | Active role |
87
+ |---|---|
88
+ | `migration-workspace-state` | `migration-workspace-state` |
89
+ | `legacy-spec-delta-review`, `target-project-understand`, `migration-alignment` | `migration-analysis-planning` |
90
+ | `dependency-resolution`, `platform-api-replacement` | `dependency-platform-gate` |
91
+ | `theme-design-system-mapping`, `resource-migration`, `navigation-migration` | `presentation-integration` |
92
+ | `state-model-mapping` plus API/data preparation expectations | `state-data-prep` |
93
+ | `ui-mockup-implementation` | `ui-implementation` |
94
+ | `dataflow-logic-implementation` | `logic-implementation` |
95
+ | `module-node-migration-review`, `module-node-migration-fix` | `module-node-review-fix` with `mode: review | fix` |
96
+ | `source-set-placement-guard`, `api-contract-parity`, `ui-render-fidelity-check`, `incremental-build-check` | `migration-verification` with stable `check_ids` |
97
+ | `prd-completion-check`, `migration-report` | `completion-report` with `mode: readiness | report` |
98
+
99
+ ### Safety preserved by modes
100
+
101
+ - Review and fix are in one role file but must run as separate invocations.
102
+ - Verification is consolidated but still read-only for source changes and uses explicit check IDs.
103
+ - Completion and report are consolidated but report mode is blocked until readiness mode and module/global representation gates pass.
104
+ - Build-config changes remain owned only by `dependency-platform-gate`.