@code-migration/wow-migrator 0.2.1 → 0.2.4

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 (23) hide show
  1. package/package.json +1 -1
  2. package/skills/android-to-kmp-migrator/SKILL.md +32 -6
  3. package/skills/android-to-kmp-migrator/bind.md +15 -0
  4. package/skills/android-to-kmp-migrator/output-contract.md +61 -12
  5. package/skills/android-to-kmp-migrator/references/kmp-expert.md +260 -0
  6. package/skills/android-to-kmp-migrator/references/kmp-mvi-flowredux.md +344 -0
  7. package/skills/android-to-kmp-migrator/references/kmp-mvvm.md +328 -0
  8. package/skills/android-to-kmp-migrator/roles/completion-report.md +2 -1
  9. package/skills/android-to-kmp-migrator/roles/global-migration-phase.md +7 -2
  10. package/skills/android-to-kmp-migrator/roles/migration-planning-gate.md +7 -2
  11. package/skills/android-to-kmp-migrator/roles/migration-prep.md +12 -2
  12. package/skills/android-to-kmp-migrator/roles/migration-verification.md +5 -3
  13. package/skills/android-to-kmp-migrator/roles/module-implementation.md +20 -2
  14. package/skills/android-to-kmp-migrator/roles/module-node-review-fix.md +19 -3
  15. package/skills/android-to-kmp-migrator/roles/target-project-assistant.md +10 -1
  16. package/skills/android-to-kmp-migrator/workflow.md +23 -2
  17. package/skills/kmp-test-validator/SKILL.md +3 -3
  18. package/skills/kmp-test-validator/bind.md +3 -2
  19. package/skills/kmp-test-validator/dependencies.yaml +15 -2
  20. package/skills/kmp-test-validator/output-contract.md +92 -8
  21. package/skills/kmp-test-validator/roles/validation-code-gate.md +53 -7
  22. package/skills/kmp-test-validator/roles/validation-workspace-state.md +7 -2
  23. package/skills/kmp-test-validator/workflow.md +3 -1
@@ -49,7 +49,7 @@ You are the `global-migration-phase` node subagent. Your job is **target KMP pro
49
49
  - Integrate mode: no edits outside `kmp_target_project_path` or outside approved integration glue paths from TPA `integration_constraints`.
50
50
 
51
51
  **Mandatory**:
52
- - Integrate: validate `kmp_target_project_path`, package `M4`, all module representations, analyst cross-module globals, and `target_alignment_revision.json` before editing.
52
+ - Integrate: validate `kmp_target_project_path`, `design_mode` + `architecture_reference_path`, package `M4`, all module representations, analyst cross-module globals, and `target_alignment_revision.json` before editing. Cross-module glue, DI, and entry wiring MUST follow the run's `design_mode` (default `mvi`: state-machine wiring per `references/kmp-mvi-flowredux.md`; `mvvm`: `ViewModel`/Koin wiring per `references/kmp-mvvm.md`) and `references/kmp-expert.md` base KMP conventions — shared glue/nav/DI in `commonMain`, platform entry wrappers in `androidMain`/`iosMain`, `expect`/`actual` for platform launch hooks.
53
53
  - Integrate: `output_dir = <global_dir>/node-results/global-migration-phase/integrate`
54
54
  - Align: primary output under `<global_dir>/node-results/global-migration-phase/align`; alignment report under `report_dir`
55
55
  - Include `mode` and `kmp_target_project_path` in JSON return payload.
@@ -190,6 +190,11 @@ Read-only verification after integrate. For each Legacy Android entry in analyst
190
190
  ```text
191
191
  ROLE: global-migration-phase node in android-to-kmp-migrator. Modes: integrate | align. NEVER combine.
192
192
 
193
+ DESIGN MODE: glue/DI/entry wiring follows design_mode (default mvi → references/kmp-mvi-flowredux.md
194
+ state-machine wiring; mvvm → references/kmp-mvvm.md ViewModel/Koin wiring) and references/kmp-expert.md
195
+ base KMP conventions (shared glue/nav/DI in commonMain, platform entry wrappers + expect/actual launch
196
+ hooks in androidMain/iosMain). Do NOT mix patterns.
197
+
193
198
  INTEGRATE — EDIT THE TARGET KMP PROJECT:
194
199
  - Wire cross-module UI transitions, control logic handoffs, and data calls inside kmp_target_project_path.
195
200
  - Wire entry points: Android launcher/Application/root nav/deep links → KMP app shell (entry_point_wiring[]).
@@ -208,7 +213,7 @@ CONTROL:
208
213
  analyst cross-module globals, target_alignment_revision before editing.
209
214
  - Align: consume global_system_integration output; inspect target files without modifying them.
210
215
 
211
- INPUTS: mode, kmp_target_project_path, analyst cross_module_architecture_path,
216
+ INPUTS: mode, design_mode, architecture_reference_path, kmp_target_project_path, analyst cross_module_architecture_path,
212
217
  cross_module_data_logic_path, module_migration_representation paths,
213
218
  presentation_resource entry_points paths (per module + launcher module),
214
219
  target_alignment_revision_path (entry_point_anchors[]), global_system_integration path (align mode),
@@ -9,7 +9,7 @@ You are the `migration-planning-gate` node subagent. You merge **migration analy
9
9
  ## Success Criteria
10
10
 
11
11
  - `migration_planning_gate.json` and `migration_planning_gate.md` written under `output_dir`.
12
- - **Planning section**: SPEC/raw-source deltas, source-to-target map (from TPA anchors), reuse inventory, ordered `implementation_tasks`.
12
+ - **Planning section**: SPEC/raw-source deltas, source-to-target map (from TPA anchors), reuse inventory, ordered `implementation_tasks`. The source-to-target map and tasks MUST follow the run's `design_mode` (default `mvi`) layout from `architecture_reference_path` — `mvi` (`references/kmp-mvi-flowredux.md`): `model/` (sealed `State`/`Action`), `statemachine/` (`FlowReduxStateMachineFactory`), `domain/`; `mvvm` (`references/kmp-mvvm.md`): `presentation/` (`ViewModel` + `UiState`), `domain/`, `data/`. Both modes target a KMP project per `references/kmp-expert.md` base conventions — map source to KMP source sets (`commonMain` first, `androidMain`/`iosMain` only for platform actuals) and the 2026 `shared` + `*App` module layout.
13
13
  - **Dependency/platform section**: capability map, minimal-change dependency decisions, platform boundaries, `ready_for_implementation` or `blocked`.
14
14
  - No feature UI/logic implementation; build-config changes only when gate justifies them.
15
15
 
@@ -17,6 +17,7 @@ You are the `migration-planning-gate` node subagent. You merge **migration analy
17
17
 
18
18
  **Forbidden**:
19
19
  - Do not re-survey target project (consume `target-project-assistant` artifacts only).
20
+ - Do not edit target KMP source files — planning routes edits to `migration-prep` and `module-implementation`.
20
21
  - Do not implement UI, repositories, or business logic.
21
22
  - Do not add dependencies for convenience.
22
23
 
@@ -63,9 +64,13 @@ See [output-contract.md](../output-contract.md). Artifact basename: `migration_p
63
64
  ROLE: migration-planning-gate node. Merge planning + dependency/platform gate in ONE invocation.
64
65
 
65
66
  PLANNING: SPEC deltas, source-to-target map from TPA anchors, ordered tasks. No target re-survey.
67
+ Layout follows design_mode (default mvi): mvi → model/statemachine/domain (references/kmp-mvi-flowredux.md);
68
+ mvvm → presentation(ViewModel+UiState)/domain/data (references/kmp-mvvm.md).
69
+ Both target a KMP project per references/kmp-expert.md base conventions: prefer commonMain, drop to
70
+ androidMain/iosMain only for platform actuals, follow the shared + *App module layout.
66
71
  GATE: capability map, minimal-change deps, platform boundaries. ready_for_implementation or blocked.
67
72
 
68
- INPUTS: migration_module_id, module_scope, module_brief_path, target_module_anchors_path,
73
+ INPUTS: design_mode, architecture_reference_path, migration_module_id, module_scope, module_brief_path, target_module_anchors_path,
69
74
  target_alignment_revision_path, upstream module_representation, SPEC paths, target path,
70
75
  allowed_files, allowed_source_sets, output_dir.
71
76
 
@@ -10,20 +10,26 @@ You are the `migration-prep` node subagent. You merge **presentation integration
10
10
 
11
11
  - `migration_prep.json` and `migration_prep.md` written under `output_dir`.
12
12
  - **Presentation section**: token mappings, resource mapping, route mapping, UI handoff, presentation gaps.
13
- - **State/data section**: state mappings, model mappings, API contract expectations, logic handoff.
13
+ - **State/data section**: state mappings, model mappings, API contract expectations, logic handoff. State holder expectations MUST follow the run's `design_mode` (default `mvi`): `mvi` → sealed `State`/`Action` + state-machine handoff (`references/kmp-mvi-flowredux.md`); `mvvm` → immutable `UiState` + `ViewModel` event-method handoff (`references/kmp-mvvm.md`). All scaffold and contracts target a KMP project per `references/kmp-expert.md` base conventions — place shared tokens/resources/models/routes in `commonMain`, reserve `androidMain`/`iosMain` for platform actuals, and prefer the multiplatform stack (Ktor, kotlinx-serialization, kotlinx-datetime) over Android-only types.
14
14
  - Changed files recorded; cross-module impacts noted.
15
15
  - No full UI layouts or repository/API behavior.
16
16
 
17
+ ## Target KMP Edit Mandate (optional scaffold)
18
+
19
+ When planning allows prep-time file changes, you MAY create or update target scaffold files (theme tokens, shared resources, route stubs, model shells) under `kmp_target_project_path` and `allowed_files`. Record every path in `changed_files[]`. Full screens and business logic belong in `module-implementation`.
20
+
17
21
  ## Boundary
18
22
 
19
23
  **Forbidden**:
20
24
  - Do not implement visible UI screens or business logic.
21
25
  - Do not add dependencies or create standalone modules.
22
26
  - Do not invent missing assets or API fields.
27
+ - Do not edit Legacy Android source.
23
28
 
24
29
  **Mandatory**:
25
30
  - Validate `migration_planning_gate` output, analyst presentation/data/behavior evidence, TPA anchors.
26
31
  - Use `output_dir = <output_root>/modules/<migration_module_id>/node-results/migration-prep`.
32
+ - When `changed_files[]` is non-empty, every path MUST resolve under `kmp_target_project_path`; file-changing prep requires review before `module-implementation`.
27
33
  - `curl` optional for online resource fetch; gaps recorded when unavailable.
28
34
 
29
35
  ## Output Schema
@@ -65,8 +71,12 @@ ROLE: migration-prep node. Merge presentation + state/data prep in ONE invocatio
65
71
 
66
72
  PRESENTATION: tokens, resources, media, routes, UI handoff.
67
73
  STATE/DATA: state holders, models, mappers, API expectations, logic handoff.
74
+ State holder shape follows design_mode (default mvi): mvi → sealed State/Action + state machine
75
+ (references/kmp-mvi-flowredux.md); mvvm → UiState + ViewModel methods (references/kmp-mvvm.md).
76
+ Target is a KMP project per references/kmp-expert.md: scaffold in commonMain, platform actuals only in
77
+ androidMain/iosMain, prefer the multiplatform library stack over Android-only types.
68
78
 
69
- INPUTS: migration_module_id, migration_planning_gate_path, analyst dimension paths,
79
+ INPUTS: design_mode, architecture_reference_path, migration_module_id, migration_planning_gate_path, analyst dimension paths,
70
80
  target path, allowed_files, output_dir.
71
81
 
72
82
  OUTPUTS: migration_prep.json, migration_prep.md
@@ -8,6 +8,7 @@ You are the `migration-verification` node subagent. You verify one `migration_mo
8
8
 
9
9
  ## Required Check IDs (migrator only)
10
10
 
11
+ - `target_files_exist`
11
12
  - `source_set`
12
13
  - `syntax_check`
13
14
  - `api_contract`
@@ -29,6 +30,7 @@ If a dispatch contract includes forbidden check ids, return `blocked` and cite [
29
30
  - Every required `check_id` has `passed | failed | blocked`.
30
31
  - `ui_restoration` and `logic_restoration` cite upstream analyst paths and list gaps explicitly.
31
32
  - `syntax_check` validates changed Kotlin/files statically without assembling the whole project.
33
+ - `target_files_exist` confirms every aggregated module `changed_files[]` path exists on disk under `kmp_target_project_path`.
32
34
  - Failures route to owning roles per `SKILL.md`; Leader writes `module_completion_record.json` only when all checks pass.
33
35
 
34
36
  ## Boundary
@@ -56,7 +58,7 @@ If a dispatch contract includes forbidden check ids, return `blocked` and cite [
56
58
  "upstream_module_representation_path": "",
57
59
  "check_results": [
58
60
  {
59
- "check_id": "source_set | syntax_check | api_contract | ui_render | ui_restoration | logic_restoration",
61
+ "check_id": "target_files_exist | source_set | syntax_check | api_contract | ui_render | ui_restoration | logic_restoration",
60
62
  "status": "passed | failed | blocked",
61
63
  "evidence": [],
62
64
  "failures": [],
@@ -86,8 +88,8 @@ Write only under `output_dir = <output_root>/modules/<migration_module_id>/node-
86
88
  ```text
87
89
  ROLE: migration-verification node.
88
90
 
89
- Run module-scoped checks ONLY: source_set, syntax_check, api_contract, ui_render,
90
- ui_restoration, logic_restoration. Compare UI/logic to upstream analyst module_representation.
91
+ Run module-scoped checks ONLY: target_files_exist, source_set, syntax_check, api_contract,
92
+ ui_render, ui_restoration, logic_restoration. Compare UI/logic to upstream analyst module_representation.
91
93
 
92
94
  DO NOT run incremental_build or full project compile — kmp-test-validator owns that.
93
95
 
@@ -25,6 +25,17 @@ You merge **UI implementation** and **logic implementation** with strict modes.
25
25
 
26
26
  **Gate**: `logic` mode MUST NOT run until latest UI review is `approved`.
27
27
 
28
+ ## Design Mode (architecture pattern)
29
+
30
+ The run's `design_mode` (default `mvi`) is supplied by the Leader together with `architecture_reference_path`. You MUST implement to that pattern; do not mix patterns.
31
+
32
+ | `design_mode` | Reference | Shape you produce |
33
+ |---|---|---|
34
+ | `mvi` **(default)** | `references/kmp-mvi-flowredux.md` | Sealed `State`/`Action`, `FlowReduxStateMachineFactory`, `dispatch()` from UI, unidirectional flow |
35
+ | `mvvm` | `references/kmp-mvvm.md` | `ViewModel` exposing immutable `UiState` as `StateFlow`, public event methods, `collectAsStateWithLifecycle()` |
36
+
37
+ Both modes follow `references/kmp-expert.md` for base KMP/CMP conventions. If `design_mode` or `architecture_reference_path` is missing from the dispatch, return `blocked` — do not guess the pattern.
38
+
28
39
  ## Success Criteria
29
40
 
30
41
  **UI mode**:
@@ -54,7 +65,7 @@ You merge **UI implementation** and **logic implementation** with strict modes.
54
65
  - Do not run full project compile/build — static edits only; build is `kmp-test-validator`.
55
66
 
56
67
  **Mandatory**:
57
- - Validate `kmp_target_project_path`, planning-gate `ready_for_implementation`, prep outputs, `target_module_anchors.json`, `allowed_files`, source sets, and workspace state before editing.
68
+ - Validate `kmp_target_project_path`, `design_mode` + `architecture_reference_path`, planning-gate `ready_for_implementation`, prep outputs, `target_module_anchors.json`, `allowed_files`, source sets, and workspace state before editing.
58
69
  - Map each implementation task to a target path from planning/TPA before writing code.
59
70
  - Include `mode`, `kmp_target_project_path`, and `changed_files` in JSON return payload.
60
71
  - Write migration evidence artifacts under `output_dir`; write **implementation code** under `kmp_target_project_path`.
@@ -70,6 +81,8 @@ You merge **UI implementation** and **logic implementation** with strict modes.
70
81
  "legacy_module_id": "",
71
82
  "module_scope": {},
72
83
  "kmp_target_project_path": "",
84
+ "design_mode": "mvi | mvvm",
85
+ "architecture_reference_path": "",
73
86
  "output_root": "",
74
87
  "output_dir": "",
75
88
  "target_edit_summary": {
@@ -127,6 +140,11 @@ ROLE: module-implementation node in android-to-kmp-migrator. Modes: ui | logic.
127
140
  YOU IMPLEMENT IN THE TARGET KMP PROJECT. Edit/create KMP files under kmp_target_project_path.
128
141
  Legacy Android and analyst artifacts are read-only evidence. Do NOT edit Legacy Android.
129
142
 
143
+ DESIGN MODE: follow design_mode (default mvi). mvi → references/kmp-mvi-flowredux.md
144
+ (sealed State/Action + FlowReduxStateMachineFactory + dispatch); mvvm → references/kmp-mvvm.md
145
+ (ViewModel + immutable UiState StateFlow + public event methods). Both follow references/kmp-expert.md.
146
+ Do NOT mix patterns. If design_mode/architecture_reference_path missing, return blocked.
147
+
130
148
  UI MODE:
131
149
  - Port visible UI from upstream presentation evidence into target Compose/resources/navigation.
132
150
  - changed_files = every target file you created or modified.
@@ -143,7 +161,7 @@ CONTROL:
143
161
  - Map each task to a target path from planning source_to_target_map / TPA anchors first.
144
162
  - If anchor or allowed_files is missing, return blocked — do not guess target paths.
145
163
 
146
- INPUTS: mode, migration_module_id, legacy_module_id, kmp_target_project_path,
164
+ INPUTS: mode, design_mode, architecture_reference_path, migration_module_id, legacy_module_id, kmp_target_project_path,
147
165
  migration_planning_gate_path, migration_prep_path, target_module_anchors_path,
148
166
  upstream module_representation + presentation_resource/behavior_logic paths (read-only),
149
167
  prior module_implementation_ui output (logic mode), allowed_files, output_dir.
@@ -11,12 +11,23 @@ You are the `module-node-review-fix` node subagent. You consolidate review and f
11
11
  - `mode: review`: read-only review of one module/node slice.
12
12
  - `mode: fix`: scoped edit of explicit `must_fix` findings from one review report.
13
13
 
14
+ ## Design Mode (architecture pattern)
15
+
16
+ The run's `design_mode` (default `mvi`) and `architecture_reference_path` are supplied by the Leader. Both modes MUST judge/repair code against that pattern:
17
+
18
+ - `mvi` → `references/kmp-mvi-flowredux.md` (sealed `State`/`Action`, `FlowReduxStateMachineFactory`, `dispatch`).
19
+ - `mvvm` → `references/kmp-mvvm.md` (`ViewModel` + immutable `UiState` `StateFlow` + public event methods).
20
+
21
+ Both modes also judge code against `references/kmp-expert.md` base KMP/CMP conventions — correct source-set placement (`commonMain` vs `androidMain`/`iosMain`), `expect`/`actual` usage, no Android-only APIs leaked into `commonMain`, and multiplatform-stack choices.
22
+
23
+ Flag architecture drift (wrong pattern vs `design_mode`) or base-KMP violations as `must_fix` findings in review; in fix mode, conform to the references. Do not introduce the other pattern.
24
+
14
25
  ## Success Criteria
15
26
 
16
27
  - Review mode writes `module_node_review.json` and `module_node_review.md`.
17
28
  - Fix mode writes `module_node_fix.json` and `module_node_fix.md`.
18
29
  - Review mode edits no files.
19
- - Fix mode edits only `allowed_files`, sets `requires_re_review: true`, and never self-approves.
30
+ - Fix mode edits only `allowed_files` under `kmp_target_project_path`, sets `requires_re_review: true`, records `changed_files[]`, and never self-approves.
20
31
 
21
32
  ## Boundary
22
33
 
@@ -68,10 +79,15 @@ Shared return shape applies.
68
79
  ROLE: module-node-review-fix node.
69
80
 
70
81
  Respect mode strictly.
71
- Review mode: read-only; verify one owning node slice for contract, scope, parity, source-set, target convention, dependency discipline, and handoff readiness.
82
+ Review mode: read-only; verify one owning node slice for contract, scope, parity, source-set, target convention, design_mode architecture conformance, dependency discipline, and handoff readiness.
72
83
  Fix mode: consume one review report; fix only assigned must_fix findings inside allowed_files; set requires_re_review=true.
73
84
 
74
- INPUTS: mode, migration_module_id, module_scope, owning_node, owning_node_output_path, changed_files, review_report_path for fix mode, allowed_files, workspace state, output_dir.
85
+ DESIGN MODE: judge/repair against design_mode (default mvi). mvi references/kmp-mvi-flowredux.md;
86
+ mvvm → references/kmp-mvvm.md. Also enforce references/kmp-expert.md base KMP conventions (source-set
87
+ placement, expect/actual, no android.* in commonMain). Wrong-pattern or base-KMP violations are must_fix.
88
+ Never introduce the other pattern.
89
+
90
+ INPUTS: mode, design_mode, architecture_reference_path, migration_module_id, module_scope, owning_node, owning_node_output_path, changed_files, review_report_path for fix mode, allowed_files, workspace state, output_dir.
75
91
 
76
92
  OUTPUTS:
77
93
  - review mode: module_node_review.json/md (read-only reviewed files, findings, approval/needs-fix decision, blockers)
@@ -20,6 +20,8 @@ You are the `target-project-assistant` node subagent. You understand the existin
20
20
  - `target_alignment_revision.json` exists after `global_baseline` with anchor points, `entry_point_anchors[]`, and revised alignment rows.
21
21
  - Per-module `target_module_anchors.json` maps legacy evidence to resolvable target paths.
22
22
  - `consult` responses reference prior alignment revision version and list affected anchor ids.
23
+ - `target_project_layout` notes the target's existing presentation pattern and whether it matches the run's `design_mode` (default `mvi`); a mismatch is surfaced in `integration_constraints[]` for the Leader, not silently resolved.
24
+ - `target_project_layout` is read against `references/kmp-expert.md` base KMP conventions — record the target's source-set hierarchy (`commonMain` / `androidMain` / `iosMain`), `shared` + `*App` module shape, and multiplatform stack so anchors resolve to the correct KMP source set; flag deviations from the base layout in `integration_constraints[]`.
23
25
  - No target code edits (read-only analysis).
24
26
 
25
27
  ## Boundary
@@ -106,7 +108,14 @@ You own target KMP understanding and alignment revision. Modes:
106
108
 
107
109
  You do NOT edit target code or run full builds. Other roles MUST use your artifacts.
108
110
 
109
- INPUTS: kmp_target_project_path, analyst_output_root, upstream_analyst_index_path, modules_index_path,
111
+ DESIGN MODE: detect the target's existing presentation pattern and compare to design_mode (default mvi:
112
+ references/kmp-mvi-flowredux.md; mvvm: references/kmp-mvvm.md). Record the match/mismatch in
113
+ integration_constraints[] — do not resolve it yourself.
114
+ KMP BASE: read the target against references/kmp-expert.md — capture source-set hierarchy
115
+ (commonMain/androidMain/iosMain), shared + *App module shape, and stack so anchors resolve to the right
116
+ source set; flag base-layout deviations in integration_constraints[].
117
+
118
+ INPUTS: design_mode, architecture_reference_path, kmp_target_project_path, analyst_output_root, upstream_analyst_index_path, modules_index_path,
110
119
  migration_assembly_basis_path, cross_module_architecture_path, cross_module_data_logic_path,
111
120
  legacy module_representation paths, migration_module_id, mode, output_dir.
112
121
 
@@ -10,6 +10,16 @@ See [output-contract.md](output-contract.md) and active role IDs in [SKILL.md](S
10
10
  | Migration | `android-to-kmp-migrator` | **M0**–**V0** | Runs only after P6 verified; ends with `migration_report.*` and **V0** ready. |
11
11
  | Post-migration | `kmp-test-validator` | **V0** | MUST be invoked after migrator completes **V0** (MG17). Do not end the migration workflow without validator dispatch. |
12
12
 
13
+ ## Target KMP Edit Flow
14
+
15
+ After analyst **P6** understanding (read-only), the migrator **edits** `kmp_target_project_path`:
16
+
17
+ 1. **Per module**: `migration-prep` (optional scaffold) → `module-implementation` `ui` → `logic` (required target edits) → review/fix remediation as needed.
18
+ 2. **Global**: `global-migration-phase` `integrate` edits cross-module glue and entry-point wiring.
19
+ 3. **Align** is read-only verification — reruns integrate or module implementation when target edits are missing or wrong.
20
+
21
+ Planning and TPA artifacts route edits; they do not replace implementation.
22
+
13
23
  ## Overview
14
24
 
15
25
  ```mermaid
@@ -49,10 +59,19 @@ graph TD
49
59
  ## Step 0 — Pre-flight
50
60
 
51
61
  - **Executor**: Leader
52
- - **Input**: [dependencies.yaml](dependencies.yaml) — `tools[]` (`rg`, `git`, `curl`), `optional_mcp.jetbrains`, `upstream_inputs` analyst **P6**
53
- - **Output**: `run_manifest.json` → `dependency_preflight` (CLI status, MCP availability, P6 readiness pointer)
62
+ - **Input**: [dependencies.yaml](dependencies.yaml) — `tools[]` (`rg`, `git`, `curl`), `optional_mcp.jetbrains`, `upstream_inputs` analyst **P6**; the **user input / migration request**
63
+ - **Output**: `run_manifest.json` → `dependency_preflight` (CLI status, MCP availability, P6 readiness pointer) and `design_mode` (architecture pattern decision)
54
64
  - **Gate**: missing CLI tools → degraded modes per dependencies.yaml; `android-project-analyst` **P6** not ready → **blocked** — invoke analyst first, do not dispatch migrator nodes
55
65
 
66
+ ### Step 0a — Identify design mode (default MVI)
67
+
68
+ - Scan the **user input** for an explicit or implied presentation architecture:
69
+ - **`mvvm`** signals: "MVVM", shared `ViewModel`, `StateFlow` / `uiState`, `viewModelScope`, `collectAsStateWithLifecycle`, KMP-ObservableViewModel, SKIE → `references/kmp-mvvm.md`
70
+ - **`mvi`** signals: "MVI", FlowRedux, state machine, reducer, intent, unidirectional, sealed `State`/`Action`, `dispatch`, `inState`, `onEnter` → `references/kmp-mvi-flowredux.md`
71
+ - **No clear signal → default `mvi`.**
72
+ - Record `design_mode: { value: "mvi | mvvm", source: "user_input | default", signals: [], architecture_reference_path: "" }` in `run_manifest.json`.
73
+ - Freeze `design_mode` for the run; pass `design_mode` + `architecture_reference_path` into every architecture-producing dispatch (planning-gate, prep, module-implementation, module-node-review-fix, global-migration-phase) and to TPA for target-pattern detection.
74
+
56
75
  ## Step 1 — Upstream + output root
57
76
 
58
77
  - Verify analyst package **P6**; write `upstream_analyst_index.json`.
@@ -115,6 +134,8 @@ Any target question → TPA `mode: consult` (append `consultation_log`).
115
134
  ## Acceptance Criteria
116
135
 
117
136
  - `android-project-analyst` **P6** verified before any migrator module dispatch.
137
+ - `design_mode` identified from user input at Step 0 (default `mvi`) and recorded in `run_manifest.json`; architecture-producing dispatches carry `design_mode` + `architecture_reference_path`.
138
+ - Target KMP files created or updated under `kmp_target_project_path` for every module requiring implementation; `target_changed_files[]` aggregated in `migration_report.json`.
118
139
  - `kmp-test-validator` invoked after **V0** — mandatory MG17 step.
119
140
  - Dispatch only role IDs from `SKILL.md`.
120
141
  - Mode rules: `ui` before `logic`; `integrate` before `align`; `review`/`fix` separate.
@@ -48,7 +48,7 @@ The team is a **serial pipeline with two controller loops**: code-gate fix remed
48
48
  0. **Pre-flight** — [dependencies.yaml](dependencies.yaml); verify migrator `V0`; lock output root.
49
49
  1. **Workspace state** — ledger + `handoff_gates`.
50
50
  2. **Fidelity gate `trust`** — migration trigger + pre-build fidelity (`VG1`).
51
- 3. **Code gate `build`** — three-scenario compile + build/preview (`VG2`); on failure → code gate `fix` → rerun `build` (max 3 cycles).
51
+ 3. **Code gate `build`** — three-scenario compile + build/preview (`VG2`); on failure → code gate `fix` (lookup bug-fix knowledge, then fix) → rerun `build` (max 3 cycles); persist verified compile-error experiences after `VG2` pass.
52
52
  4. **Fidelity gate `restoreability`** — post-build restoreability (`VG3`); migrator supplement loop (max 3) when required.
53
53
  5. **Business testing** — optional behavioral / Figma submodules when user inputs exist (`VG4`).
54
54
  6. **Final report** — `validation-report` (`VG5`).
@@ -91,7 +91,7 @@ See [output-contract.md](output-contract.md) for full layout. No validator artif
91
91
  | Leader | `run_manifest.json`, `upstream_migration_index.json` | V0 verification, dependency preflight |
92
92
  | `validation-workspace-state` | `validation_workspace_state.*` | `handoff_gates` VG0–VG5, cycle counts |
93
93
  | `validation-fidelity-gate` | `trust/validation_fidelity_trust.*`, `restoreability/validation_restoreability_audit.*` | Pre-build trust or post-build restoreability per mode |
94
- | `validation-code-gate` | `build/validation_code_build.*`, `fix/<cycle>/validation_code_fix.*`, code-gate logs | Compile scenario + build/preview (build mode) or target KMP edits + `changed_files` + reruns (fix mode) |
94
+ | `validation-code-gate` | `build/validation_code_build.*`, `fix/<cycle>/validation_code_fix.*`, `knowledge/compile_error_knowledge.*`, `knowledge/entries/<entry_id>/bug_fix_experience.*`, code-gate logs | Compile scenario + build/preview (build mode); target KMP edits + knowledge lookup/candidates (fix mode); verified bug-fix experiences (after `VG2` pass) |
95
95
  | `validation-business-testing` | `validation_business_testing.*`, logs | Submodule outcomes or explicit skip |
96
96
  | `validation-report` | `kmp_validation_report.*` | Evidence-backed final verdict |
97
97
 
@@ -116,5 +116,5 @@ See [output-contract.md](output-contract.md) for full layout. No validator artif
116
116
  - Dispatch only role IDs listed in this registry.
117
117
  - Only `validation-code-gate` mode `fix` edits target production code.
118
118
  - Fidelity-gate modes are read-only; restoreability routes gaps to migrator supplement.
119
- - Code-gate `build` uses three compile scenarios only; `fix` uses error DB when configured.
119
+ - Code-gate `build` uses three compile scenarios only; `fix` reuses `code-gate/knowledge/` bug-fix experiences when fingerprints match, then optional external error DB, then `model_inference`.
120
120
  - Business-testing submodules require user inputs; skipped is not pass-by-omission.
@@ -20,7 +20,7 @@
20
20
  - **Read-only fidelity**: `validation-fidelity-gate` never runs commands or edits code.
21
21
  - **Single production editor**: only `validation-code-gate` mode `fix` edits target production code.
22
22
  - **Three compile scenarios**: `user_specified` → `global_tool_search` → `default_gradle_kmp`.
23
- - **Two fix knowledge paths**: `error_knowledge_path` when configured; else `model_inference`.
23
+ - **Compile error knowledge loop**: fix mode looks up `code-gate/knowledge/compile_error_knowledge.json` first, then optional `error_knowledge_path`, then `model_inference`; verified fixes persist under `knowledge/entries/` after `VG2` pass.
24
24
  - **Restoreability-preserving fixes**: no delete/stub of migrated behavior; missing modules → migrator supplement.
25
25
  - **Optional business testing**: submodules require user inputs; skip is not pass-by-omission.
26
26
  - **Report-only verdict**: only `validation-report` issues `passed | failed | blocked`.
@@ -41,7 +41,8 @@
41
41
  | Trigger | Effect |
42
42
  |---|---|
43
43
  | Migrator V0 not ready | `blocked` |
44
- | No `error_knowledge_path` | Fix uses `model_inference` only |
44
+ | No local knowledge index yet | Leader initializes empty `compile_error_knowledge.json` |
45
+ | No knowledge match and no `error_knowledge_path` | Fix uses `model_inference` |
45
46
  | No test cases or Figma refs | `VG4` skipped explicitly |
46
47
  | Preview unsupported | Build only; preview `skipped` with reason |
47
48
  | jetbrains / Figma MCP unavailable | Gradle + filesystem; record gap |
@@ -26,12 +26,23 @@ upstream_inputs:
26
26
  migration_assembly_basis, module representations for fidelity and restoreability.
27
27
 
28
28
  optional_inputs:
29
+ - name: compile_error_knowledge_path
30
+ required: false
31
+ default: <output_root>/code-gate/knowledge/compile_error_knowledge.json
32
+ used_by:
33
+ - validation-code-gate
34
+ mode: fix
35
+ purpose: |
36
+ Run-local bug-fix experience index. Fix mode looks up matching compile errors here first;
37
+ verified fixes are persisted under code-gate/knowledge/entries/ after VG2 pass.
29
38
  - name: error_knowledge_path
30
39
  required: false
31
40
  used_by:
32
41
  - validation-code-gate
33
42
  mode: fix
34
- purpose: Compilation error DB; code-gate fix mode uses error_database lookup before model_inference.
43
+ purpose: |
44
+ Optional external/shared compilation error DB. Used after local compile_error_knowledge lookup;
45
+ does not replace run-local knowledge persistence.
35
46
  - name: user_provided_commands
36
47
  required: false
37
48
  used_by:
@@ -89,8 +100,10 @@ tools:
89
100
  degraded_modes:
90
101
  - trigger: migrator V0 not ready
91
102
  effect: blocked
103
+ - trigger: compile_error_knowledge_path missing
104
+ effect: Leader initializes empty code-gate/knowledge/compile_error_knowledge.json on first fix dispatch
92
105
  - trigger: error_knowledge_path missing
93
- effect: code-gate fix uses model_inference only
106
+ effect: code-gate fix uses local knowledge + model_inference only
94
107
  - trigger: no validation_requirements and no figma_refs
95
108
  effect: VG4 skipped — not auto-pass
96
109
  - trigger: rg missing
@@ -46,10 +46,17 @@ output_root = <output_dir or ~/.a2c_agents/validation>/kmp-test-validator
46
46
  │ ├── build/
47
47
  │ │ ├── validation_code_build.json
48
48
  │ │ └── validation_code_build.md
49
- └── fix/
50
- └── <cycle_id>/
51
- ├── validation_code_fix.json
52
- └── validation_code_fix.md
49
+ ├── fix/
50
+ └── <cycle_id>/
51
+ ├── validation_code_fix.json
52
+ └── validation_code_fix.md
53
+ │ └── knowledge/
54
+ │ ├── compile_error_knowledge.json
55
+ │ ├── compile_error_knowledge.md
56
+ │ └── entries/
57
+ │ └── <entry_id>/
58
+ │ ├── bug_fix_experience.json
59
+ │ └── bug_fix_experience.md
53
60
  ├── business-testing/
54
61
  │ ├── validation_business_testing.json
55
62
  │ └── validation_business_testing.md
@@ -72,6 +79,8 @@ output_root = <output_dir or ~/.a2c_agents/validation>/kmp-test-validator
72
79
  | `code_gate_dir` | `<output_root>/code-gate` |
73
80
  | `code_build_dir` | `<code_gate_dir>/build` |
74
81
  | `code_fix_dir` | `<code_gate_dir>/fix` |
82
+ | `code_gate_knowledge_dir` | `<code_gate_dir>/knowledge` |
83
+ | `knowledge_entries_dir` | `<code_gate_knowledge_dir>/entries` |
75
84
  | `business_testing_dir` | `<output_root>/business-testing` |
76
85
 
77
86
  ### Role Ownership (mandatory)
@@ -92,7 +101,7 @@ output_root = <output_dir or ~/.a2c_agents/validation>/kmp-test-validator
92
101
  1. Verify `V0`; write `run_manifest.json`, `upstream_migration_index.json`.
93
102
  2. `validation-workspace-state` — initialize; refresh after each group.
94
103
  3. `validation-fidelity-gate` mode `trust` → `VG1`.
95
- 4. `validation-code-gate` mode `build` → `VG2`; on failure → mode `fix` → rerun `build` (max 3 fix cycles).
104
+ 4. `validation-code-gate` mode `build` → `VG2`; on failure → mode `fix` (lookup `compile_error_knowledge.*` and optional `error_knowledge_path`) → rerun `build` (max 3 fix cycles); on `VG2` pass after a fix cycle, persist verified bug-fix experiences under `code-gate/knowledge/entries/`.
96
105
  5. `validation-fidelity-gate` mode `restoreability` → `VG3`; on `needs_migrator_supplement` → migrator supplement (max 3) → refresh upstream → rerun affected stages.
97
106
  6. `validation-business-testing` when user inputs exist → `VG4` or explicit skip.
98
107
  7. On business failures → code-gate mode `fix` → rerun `build` and/or business-testing.
@@ -127,10 +136,84 @@ Migration trigger evidence, `fidelity_gaps`, `test_trust_blockers`, normalized v
127
136
 
128
137
  ### `validation_code_fix.json` (mode `fix`)
129
138
 
130
- `kmp_target_project_path`, `fix_knowledge_source`: `error_database | model_inference`, `target_edit_summary`, `changed_files[]` listing every target KMP path created or modified to resolve build/preview failures, `restoreability_impact` per change. `required_reruns`: `["validation-code-gate:build", ...]`. Fix mode is the **only** validator role that edits target production code.
139
+ `kmp_target_project_path`, `fix_knowledge_source`: `prior_experience | error_database | model_inference`, `knowledge_lookup`, `referenced_entry_ids[]`, `knowledge_candidates[]`, `target_edit_summary`, `changed_files[]` listing every target KMP path created or modified to resolve build/preview failures, `restoreability_impact` per change. `required_reruns`: `["validation-code-gate:build", ...]`. Fix mode is the **only** validator role that edits target production code.
131
140
 
132
141
  **Forbidden fix patterns**: delete/stub migrated behavior solely to pass compile; route missing modules to migrator supplement.
133
142
 
143
+ ### Compile error knowledge store (`code-gate/knowledge/`)
144
+
145
+ The validator maintains a durable bug-fix experience ledger for compile/preview failures. Reuse it before inventing new fixes.
146
+
147
+ | Path | Owner | When written | Purpose |
148
+ |---|---|---|---|
149
+ | `compile_error_knowledge.json` | `validation-code-gate` | init empty; update after verified fix | Machine index: fingerprints → `entry_id`, hit counts, last match |
150
+ | `compile_error_knowledge.md` | `validation-code-gate` | with index updates | Agent-readable lookup table |
151
+ | `entries/<entry_id>/bug_fix_experience.json` | `validation-code-gate` | after `VG2` pass confirms fix cycle | Verified error signature + solution steps + changed files |
152
+ | `entries/<entry_id>/bug_fix_experience.md` | `validation-code-gate` | with entry JSON | Agent-readable bug-fix experience card |
153
+
154
+ **Lookup order (fix mode, before editing target code)**:
155
+
156
+ 1. `code-gate/knowledge/compile_error_knowledge.json` — match `message_fingerprint`, `error_code`, `file_pattern`, `symbol_pattern`.
157
+ 2. Optional external `error_knowledge_path` — same signature matching when configured.
158
+ 3. `model_inference` — only when no prior experience matches.
159
+
160
+ **Persist rule**: write or update `entries/<entry_id>/` only after the fix cycle is **verified** by a subsequent code-gate `build` pass (`VG2`). Unverified fixes stay in `validation_code_fix.json` → `knowledge_candidates[]` only.
161
+
162
+ #### `compile_error_knowledge.json` index shape
163
+
164
+ ```json
165
+ {
166
+ "knowledge_root": "",
167
+ "external_error_knowledge_path": "",
168
+ "entry_count": 0,
169
+ "entries": [
170
+ {
171
+ "entry_id": "ce-<slug>",
172
+ "message_fingerprint": "",
173
+ "error_code": "",
174
+ "compiler": "kotlin | gradle | compose",
175
+ "verified": true,
176
+ "hit_count": 0,
177
+ "last_matched_at": "",
178
+ "entry_path": "entries/<entry_id>/bug_fix_experience.json"
179
+ }
180
+ ]
181
+ }
182
+ ```
183
+
184
+ #### `bug_fix_experience.json` entry shape
185
+
186
+ ```json
187
+ {
188
+ "entry_id": "ce-<slug>",
189
+ "error_signature": {
190
+ "compiler": "kotlin | gradle | compose",
191
+ "error_code": "",
192
+ "normalized_message": "",
193
+ "message_fingerprint": "",
194
+ "file_pattern": "",
195
+ "symbol_pattern": ""
196
+ },
197
+ "root_error_excerpt": "",
198
+ "build_log_ref": "",
199
+ "failure_id": "",
200
+ "fix_summary": "",
201
+ "solution_steps": [],
202
+ "target_files_changed": [],
203
+ "changed_files_snapshot": [],
204
+ "fix_knowledge_source": "prior_experience | error_database | model_inference",
205
+ "referenced_entry_ids": [],
206
+ "verified_by": "validation-code-gate:build",
207
+ "verification_cycle_id": "",
208
+ "fix_cycle_id": "",
209
+ "created_at": "",
210
+ "hit_count": 0,
211
+ "last_matched_at": ""
212
+ }
213
+ ```
214
+
215
+ **Same-error reuse**: when a routed failure matches an existing fingerprint, fix mode MUST set `fix_knowledge_source: prior_experience`, populate `referenced_entry_ids`, apply the recorded `solution_steps` when still valid, and increment `hit_count` in the index after successful verification.
216
+
134
217
  ### `validation_restoreability_audit.json` (mode `restoreability`)
135
218
 
136
219
  `migrator_supplement_request` when new migration work required. Controller invokes `android-to-kmp-migrator` — not code-gate `fix`.
@@ -153,8 +236,9 @@ Migration trigger evidence, `fidelity_gaps`, `test_trust_blockers`, normalized v
153
236
  1. Dispatch only role IDs listed in [SKILL.md](SKILL.md).
154
237
  2. Run fidelity-gate `trust` before code-gate `build`; `restoreability` only after `VG2`.
155
238
  3. Route compile failures to code-gate `fix`; route missing modules to migrator supplement.
156
- 4. Enable business-testing submodules only with user prerequisites.
157
- 5. Maintain `handoff_gates` in workspace ledger and final report.
239
+ 4. Initialize `code-gate/knowledge/compile_error_knowledge.json` when missing; persist verified bug-fix experiences after `VG2` pass.
240
+ 5. Enable business-testing submodules only with user prerequisites.
241
+ 6. Maintain `handoff_gates` in workspace ledger and final report.
158
242
 
159
243
  ## Invalid Artifact Handling
160
244