@code-migration/wow-migrator 0.1.3 → 0.1.5

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 (60) hide show
  1. package/package.json +1 -1
  2. package/skills/android-project-analyst/SKILL.md +69 -46
  3. package/skills/android-project-analyst/bind.md +10 -5
  4. package/skills/android-project-analyst/dependencies.yaml +66 -10
  5. package/skills/android-project-analyst/output-contract.md +357 -0
  6. package/skills/android-project-analyst/roles/analysis-workspace-state.md +25 -8
  7. package/skills/android-project-analyst/roles/behavior-logic.md +6 -2
  8. package/skills/android-project-analyst/roles/data-contract-flow.md +5 -1
  9. package/skills/android-project-analyst/roles/presentation-resource.md +5 -1
  10. package/skills/android-project-analyst/roles/project-architecture.md +5 -1
  11. package/skills/android-project-analyst/workflow.md +75 -29
  12. package/skills/android-to-kmp-migrator/SKILL.md +62 -142
  13. package/skills/android-to-kmp-migrator/bind.md +29 -67
  14. package/skills/android-to-kmp-migrator/dependencies.yaml +72 -11
  15. package/skills/android-to-kmp-migrator/output-contract.md +318 -0
  16. package/skills/android-to-kmp-migrator/roles/completion-report.md +3 -1
  17. package/skills/android-to-kmp-migrator/roles/global-migration-phase.md +87 -0
  18. package/skills/android-to-kmp-migrator/roles/migration-planning-gate.md +75 -0
  19. package/skills/android-to-kmp-migrator/roles/migration-prep.md +75 -0
  20. package/skills/android-to-kmp-migrator/roles/migration-verification.md +44 -26
  21. package/skills/android-to-kmp-migrator/roles/migration-workspace-state.md +16 -8
  22. package/skills/android-to-kmp-migrator/roles/module-implementation.md +82 -0
  23. package/skills/android-to-kmp-migrator/roles/target-project-assistant.md +104 -0
  24. package/skills/android-to-kmp-migrator/workflow.md +85 -224
  25. package/skills/kmp-test-validator/SKILL.md +52 -85
  26. package/skills/kmp-test-validator/bind.md +30 -56
  27. package/skills/kmp-test-validator/dependencies.yaml +101 -9
  28. package/skills/kmp-test-validator/output-contract.md +166 -0
  29. package/skills/kmp-test-validator/roles/validation-business-testing.md +83 -0
  30. package/skills/kmp-test-validator/roles/validation-code-gate.md +116 -0
  31. package/skills/kmp-test-validator/roles/validation-fidelity-gate.md +118 -0
  32. package/skills/kmp-test-validator/roles/validation-report.md +23 -14
  33. package/skills/kmp-test-validator/roles/validation-workspace-state.md +5 -2
  34. package/skills/kmp-test-validator/workflow.md +60 -115
  35. package/skills/migration-task-adapter/SKILL.md +64 -93
  36. package/skills/migration-task-adapter/bind.md +27 -91
  37. package/skills/migration-task-adapter/dependencies.yaml +21 -10
  38. package/skills/migration-task-adapter/output-contract.md +276 -0
  39. package/skills/migration-task-adapter/roles/adapter-report.md +73 -0
  40. package/skills/migration-task-adapter/roles/adapter-workspace-state.md +73 -0
  41. package/skills/migration-task-adapter/roles/task-route-orchestrator.md +106 -0
  42. package/skills/migration-task-adapter/workflow.md +76 -142
  43. package/skills/android-project-analyst/MIGRATION.md +0 -67
  44. package/skills/android-to-kmp-migrator/MIGRATION.md +0 -129
  45. package/skills/android-to-kmp-migrator/roles/dependency-platform-gate.md +0 -68
  46. package/skills/android-to-kmp-migrator/roles/logic-implementation.md +0 -71
  47. package/skills/android-to-kmp-migrator/roles/migration-analysis-planning.md +0 -70
  48. package/skills/android-to-kmp-migrator/roles/presentation-integration.md +0 -70
  49. package/skills/android-to-kmp-migrator/roles/state-data-prep.md +0 -68
  50. package/skills/android-to-kmp-migrator/roles/ui-implementation.md +0 -69
  51. package/skills/kmp-test-validator/MIGRATION.md +0 -84
  52. package/skills/kmp-test-validator/roles/validation-intake-fidelity.md +0 -72
  53. package/skills/kmp-test-validator/roles/validation-plan-gate.md +0 -72
  54. package/skills/kmp-test-validator/roles/validation-remediation.md +0 -117
  55. package/skills/kmp-test-validator/roles/validation-test-runner.md +0 -67
  56. package/skills/migration-task-adapter/MIGRATION.md +0 -49
  57. package/skills/migration-task-adapter/roles/task-reporter.md +0 -134
  58. package/skills/migration-task-adapter/roles/task-understanding-router.md +0 -139
  59. package/skills/migration-task-adapter/roles/workflow-orchestrator.md +0 -145
  60. package/skills/migration-task-adapter/roles/workspace-state-discipline-inspector.md +0 -198
@@ -4,79 +4,41 @@
4
4
 
5
5
  | Item | Limit | Reason |
6
6
  |---|---|---|
7
- | `max_parallel_teammates` | 2 | Matches the reduced per-module fan-out (`presentation-integration` + `state-data-prep`). Other stages are serial or mode-gated. |
8
- | `total_wall_clock_budget` | 90 min per feature module batch | Upper bound for one module-first migration batch including inventory, per-module planning, prep, UI, logic, review/fix, verification, representations, and report. |
9
- | `total_token_budget` | 1.2M tokens per batch | Budget across 10 reduced roles + Leader integration + review/fix iterations + representation synthesis. |
10
- | `per_node_token_budget` | 140k tokens | Consolidated roles carry broader context; implementation and completion/report modes may use the upper end. |
11
- | `max_review_fix_cycles` | 3 per slice | Max `review → fix → re-review` iterations for one module/node scope before escalating the slice as `blocked` to the controller/user. |
12
- | `incremental_build_runs` | 1 per Verify pass | One smallest-trustworthy build/check per verification pass; reruns only after a routed fix. |
13
- | `workspace_state_refreshes` | after every major stage | Required so per-module finish rates, plan-vs-code gaps, and rerun hooks stay current before downstream consumption. |
7
+ | `max_parallel_teammates` | 1 | Serial pipeline per module |
8
+ | `total_wall_clock_budget` | 90 min per module batch | Module-first migration schedule |
9
+ | `total_token_budget` | 1.2M tokens per batch | Leader + role dispatches per module |
10
+ | `per_node_token_budget` | 160k tokens | Planning-gate, prep, module-implementation carry broader context |
11
+ | `max_review_fix_cycles` | 3 per slice | Before `blocked` escalation |
14
12
 
15
- ## Behavioral Constraints
16
-
17
- Team-level rules — distinct from each role's own `## Boundary`.
18
-
19
- - **Leader-as-orchestrator only**: the Leader (`android-to-kmp-migrator` controller) verifies the trigger, builds the shared brief, dispatches reduced roles in dependency order, verifies outputs, routes reruns, and invokes `kmp-test-validator`. The Leader does NOT implement migration code, fix findings, or substitute any node's work.
20
- - **Strict output root**: the Leader must lock `output_root = <output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator` before any migration node dispatch. All node outputs, module representations, global representation, report artifacts, logs, and ledgers must be under this root.
21
- - **Module-first schedule**: the Leader must write `module-index/migration_module_inventory.*`, then process each `migration_module_id` through planning, dependency/platform, prep, review/fix, UI, review/fix, logic, review/fix, verification, readiness, and module representation before global aggregation.
22
- - **Per-node exact paths**: module-scoped nodes receive `output_dir = <output_root>/modules/<migration_module_id>/node-results/<node_id>`. Global-only outputs use `<output_root>/global/...`; final reports use `<output_root>/report/...`.
23
- - **Role-output content discipline**: required artifacts must contain the content owned by their role, not just the correct filename. For example, `migration_analysis_planning.*` must contain source-to-target planning evidence, `dependency_platform_gate.*` must contain dependency/platform decisions, `presentation_integration.*` must contain token/resource/navigation prep, `state_data_prep.*` must contain state/model/API prep, `ui_implementation.*` must contain UI implementation evidence, `logic_implementation.*` must contain behavior/data/API implementation evidence, `migration_verification.*` must contain check results, and `migration_report.*` must contain validation handoff evidence.
24
- - **Hard dependency order (C-pattern)**: `migration-analysis-planning` precedes `dependency-platform-gate`, which precedes prep and implementation. `ui-implementation` precedes `logic-implementation`. A downstream node references upstream node outputs by path and must NOT rebuild or overwrite upstream artifacts.
25
- - **Mandatory review→fix→re-review loop**: after any node changes files, `module-node-review-fix` runs in `mode: review`; on `needs_fix`, it runs in `mode: fix` inside `allowed_files`, then a fresh `mode: review` invocation is mandatory. No downstream gate consumes a slice whose latest review is not `approved`.
26
- - **Dependency gate authority**: only `dependency-platform-gate` may justify a build-config change; target build configuration is read-only to every other role. No role adds dependencies, root Gradle/settings files, or wrappers.
27
- - **Single-project invariant**: migrated code stays inside one KMP target project; no migrated sub-module becomes a standalone project. Android-only APIs never enter `commonMain`.
28
- - **No placeholder completion**: no implementation node may return `completed` with TODO/FIXME/stub/sample-only-data in production paths as its deliverable.
29
- - **Failure routing, not mediation**: when a verification node fails or nodes disagree, the Leader routes the failure verbatim to the responsible node (recorded in the workspace-state ledger, `rerun_hooks`, and completion/readiness artifacts); it does not silently reconcile or average.
30
- - **Progress ledger discipline**: `migration-workspace-state` is refreshed after inventory, planning, dependency/platform, prep fan-out, every review/fix loop, UI implementation, logic implementation, verification, readiness, module representation, global representation, and report. The ledger must track per-module `module_progress`, `finish_rate`, `plan_code_gaps`, changed-file ownership, stale outputs, rerun hooks, blockers, and next actions.
31
- - **Stale-artifact discipline**: any output whose upstream changed afterward is marked stale in `migration-workspace-state` and must be re-run before consumption.
32
- - **Plan-vs-code gap discipline**: if the workspace ledger reports planned work without code evidence, unplanned target changes, missing review, missing verification, stale plan/source evidence, or a failed verification route, the Leader must follow the emitted rerun hook before advancing the module.
33
- - **Validation boundary**: only `completion-report` in `mode: readiness` issues readiness, only `completion-report` in `mode: report` assembles the validation handoff, and only `kmp-test-validator` validates. SPEC guides migration, but raw Legacy Android source wins when evidence conflicts.
34
- - **Representation gate**: every scheduled module must have `module_migration_representation.json` and `.md`. `completion-report` in `mode: report` cannot return `ready_for_validation` until every scheduled module representation plus `global_migration_representation.json` and `.md` exists and is non-empty.
13
+ ## Build Boundary
35
14
 
36
- ## Failure Handling
15
+ - Migrator: `syntax_check`, static checks, restoration parity only.
16
+ - **Forbidden**: `incremental_build` in migrator.
17
+ - **kmp-test-validator**: full compile/build/test at package **V0**.
37
18
 
38
- ### (a) Teammate failure
19
+ ## Behavioral Constraints
39
20
 
40
- | Failure mode | Response |
41
- |---|---|
42
- | Node timeout | Retry once with the same contract. On 2nd timeout, mark the slice `[ROLE MISSING — node timed out]` in the workspace ledger and `prd_completion_check`; downstream nodes that hard-require it return `blocked`. |
43
- | Malformed output (does not match role `## Output Schema` / shared return, files missing/empty, or artifact content does not match the role duty) | Re-dispatch once with the schema and role-owned output content inlined plus a "previous output was malformed/missing/out-of-duty" preamble. On 2nd failure, mark `[ROLE MISSING malformed output]`. |
44
- | Node returns `needs_rerun` / `blocked` (missing or stale upstream input) | Refresh/re-run the named upstream node first, then re-dispatch this node. If unresolvable, record the `blocking_gap` and set readiness accordingly. |
45
- | Review→fix loop does not converge in `max_review_fix_cycles` | Escalate the slice as `blocked` with the unresolved `must_fix` findings to the controller/user; do not force-approve. |
46
- | `migration-verification` returns `failed` for any check ID | Route each failure to its reduced `route_to_node`, re-run that node, re-enter the review/fix loop, then re-run the failed check IDs. |
47
- | `migration-workspace-state` reports blocking `plan_code_gaps` | Follow the corresponding `rerun_hooks` before downstream consumption. Missing or stale plans route to `migration-analysis-planning`; unplanned/missing code routes to the owner implementation/prep node; missing review routes to `module-node-review-fix`; missing or failed verification routes to `migration-verification` or its `route_to_node`. |
48
- | `migration-workspace-state` reports low or unknown `finish_rate` due to missing plan evidence | Block implementation progress until planning outputs and planned work units are refreshed. Do not compute completion from changed files alone. |
49
- | Node attempts to rebuild another node's artifact or edit outside scope | Reject as out-of-scope; re-dispatch with the role `## Boundary > Forbidden` restated. |
21
+ - **Role schedule**: dispatch only role IDs listed in [SKILL.md](SKILL.md).
22
+ - **Mode discipline**:
23
+ - `module-implementation`: `ui` then `logic` separate invocations
24
+ - `global-migration-phase`: `integrate` (edits) then `align` (read-only)separate invocations
25
+ - `module-node-review-fix`: `review` then optional `fix` then fresh `review`
26
+ - **TPA monopoly**: all target Q&A through `target-project-assistant`.
27
+ - **Analyst P6 gate**: required before dispatch.
28
+ - **Output contract**: [output-contract.md](output-contract.md) paths only.
29
+ - **Handoff gates**: persist **M0**–**M6**, **V0** in workspace ledger.
50
30
 
51
- ### (b) Input over-scale degradation
31
+ ## Failure Handling
52
32
 
53
- | Trigger condition | Degraded mode |
33
+ | Failure | Response |
54
34
  |---|---|
55
- | Whole-project migration on a large monorepo (e.g., > ~30 feature modules or > ~3000 in-scope source files) | Warn the user; split into `migration_module_id` batches in `migration_module_inventory.*`; process batches without changing `output_root`. |
56
- | `total_token_budget` projected to overflow before verification | Complete the analysis chain + dependency gate + current slice, checkpoint via `migration-workspace-state`, and continue in a follow-up run; mark uncovered scope explicitly. |
57
- | No trustworthy incremental build command from target understanding/planning evidence | `migration-verification` returns `blocked` for `check_id: incremental_build`; rely on completed static verification checks and surface the build gap to `completion-report` (does not auto-pass). |
58
- | `jetbrains` MCP unavailable or pointing at the wrong project | Continue on file-system evidence and the target Gradle wrapper; record the MCP gap in the workspace ledger and affected node outputs. |
59
-
60
- ### Escalation rules
61
-
62
- - If 50%+ of dispatched nodes in a stage return `[ROLE MISSING]`, the run is **FAILED** — emit a partial migration report with a `FAILED: insufficient node coverage` header, readiness `blocked`, and the missing-evidence list.
63
- - If `total_wall_clock_budget` is exceeded, halt in-flight nodes, checkpoint via `migration-workspace-state`, emit whatever verified outputs exist, and tag the report `INCOMPLETE: budget exceeded`.
64
- - If `total_token_budget` is exceeded mid-run, halt new dispatches, let in-flight nodes finish, checkpoint, and emit a partial report tagged `INCOMPLETE: token budget exceeded`.
65
-
66
- ## Required Path Contract
67
-
68
- The controller must pass these values to nodes and reject any output outside the declared path:
35
+ | Unknown or invalid role ID | Reject; use role from `SKILL.md` registry |
36
+ | `ui` and `logic` combined | Reject invocation |
37
+ | `integrate` and `align` combined | Reject invocation |
38
+ | Verification restoration failed | Rerun `module-implementation` or `migration-prep`; no completion record |
39
+ | Align omissions | Rerun `rerun_modules` or `global-migration-phase integrate` |
40
+ | Build requested in migrator | Block; route to kmp-test-validator |
69
41
 
70
- ```json
71
- {
72
- "output_root": "<output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator",
73
- "module_index_dir": "<output_root>/module-index",
74
- "module_root": "<output_root>/modules/<migration_module_id>",
75
- "node_result_dir": "<module_root>/node-results/<node_id>",
76
- "module_representation_dir": "<module_root>/representation",
77
- "global_dir": "<output_root>/global",
78
- "report_dir": "<output_root>/report"
79
- }
80
- ```
42
+ ## Dependencies
81
43
 
82
- Each reduced role boundary is justified in `ROLE_REDUCTION.md`. Do not dispatch superseded old role IDs, alias old paths, or write compatibility copies outside this schedule.
44
+ Pre-flight reads [dependencies.yaml](dependencies.yaml): `rg`, `git`, `curl`, optional `jetbrains` MCP. Record per-role `used_by` in manifest.
@@ -1,21 +1,82 @@
1
- # dependencies.yaml — Swarm Skill startup dependency check
1
+ # dependencies.yaml — Swarm Skill startup dependency check (android-to-kmp-migrator)
2
2
  #
3
- # Leader reads this file in SKILL.md Workflow Step 0 (pre-flight) and reports missing items.
4
- # Populated from Stage 2 auto-matching (local CLI scan): rg, git, curl found locally; the target
5
- # project's own Gradle wrapper drives builds (migration-verification selects a documented/discovered
6
- # command and returns blocked rather than inventing one). All entries are required: false — the team
7
- # degrades gracefully (built-in Grep/Read substitute for rg; resource downloads become resource_gaps
8
- # without curl; build check returns blocked without a trustworthy command).
3
+ # Leader reads this in Workflow Step 0 and records results in run_manifest.json
4
+ # dependency_preflight. All CLI entries are required: false.
5
+ # Android Studio MCP is optional auxiliary evidence for the KMP target — it never
6
+ # replaces durable node artifacts or upstream android-project-analyst package P6 inputs.
7
+ # Full KMP project compile/build is NOT a migrator dependency; kmp-test-validator owns that at package V0.
9
8
 
10
- skills: [] # Stage 2 auto-matching confirmed no local domain-specific skill matches for any role.
9
+ skills: [] # No local domain-specific skill packages required for active roles.
10
+
11
+ # Read-only upstream inputs (not MCP — verified at Step 1)
12
+ upstream_inputs:
13
+ - source: android-project-analyst
14
+ handoff_package: P6
15
+ required: true
16
+ purpose: |
17
+ Legacy understanding via analyst artifacts only: modules_index.json,
18
+ migration_assembly_basis.json, cross_module_* globals, module representations,
19
+ SPEC (prd/design/plan/verification). Migrator does not re-run full legacy analysis.
20
+
21
+ optional_mcp:
22
+ - server: jetbrains
23
+ required: false
24
+ used_by:
25
+ - Leader
26
+ - target-project-assistant
27
+ - migration-planning-gate
28
+ - migration-prep
29
+ - module-implementation
30
+ - global-migration-phase
31
+ - migration-verification
32
+ purpose: |
33
+ Optional indexed KMP target-project context from Android Studio / JetBrains IDE.
34
+ Typical tools: get_project_modules, get_project_dependencies, get_repositories,
35
+ find_files_by_glob, search_in_files_by_regex, get_symbol_info, get_file_problems.
36
+ Always pass projectPath = kmp_target_project_path (target project open in IDE).
37
+ Supports target layout survey, anchor-path discovery, reuse inventory, symbol ownership,
38
+ and integration glue placement. Legacy Android evidence comes from analyst P6 artifacts
39
+ and file-system reads — not from re-surveying legacy via MCP unless explicitly scoped.
40
+ MCP output is supporting evidence only; node JSON artifacts still require target source paths.
11
41
 
12
42
  tools:
13
43
  - name: rg
14
44
  required: false
15
- purpose: Fast source search across the Legacy and target projects for every node; built-in Grep/Read substitute if unavailable.
45
+ used_by:
46
+ - target-project-assistant
47
+ - migration-planning-gate
48
+ - migration-prep
49
+ - module-implementation
50
+ - module-node-review-fix
51
+ - global-migration-phase
52
+ - migration-verification
53
+ - completion-report
54
+ purpose: Fast search across Legacy source (read-only) and KMP target project. Built-in Grep/Read substitute if unavailable.
16
55
  - name: git
17
56
  required: false
18
- purpose: Inspect changed-file sets, diffs, timestamps, and ownership evidence for review, verification, workspace-state progress tracking, plan-vs-code gap detection, and stale-output routing.
57
+ used_by:
58
+ - migration-workspace-state
59
+ - module-node-review-fix
60
+ - migration-verification
61
+ - completion-report
62
+ purpose: Changed-file sets, diffs, timestamps, and ownership evidence for ledger, review/fix, verification, and plan-vs-code gaps.
19
63
  - name: curl
20
64
  required: false
21
- purpose: Used by presentation-integration to fetch concrete online resource URLs when alignment requires local copies; without it those resources are recorded as resource_gaps.
65
+ used_by:
66
+ - migration-prep
67
+ purpose: Fetch concrete online resource URLs for the presentation section of migration-prep; without curl, record resource_gaps.
68
+
69
+ # Target Gradle wrapper: path discovery reference only during migrator.
70
+ # migration-verification MUST NOT invoke assemble/test; kmp-test-validator uses the wrapper at V0.
71
+
72
+ degraded_modes:
73
+ - trigger: analyst P6 not ready
74
+ effect: blocked — do not dispatch migration nodes; repair upstream analyst handoff first
75
+ - trigger: rg missing
76
+ effect: Use built-in Grep/Read; record in run_manifest dependency_preflight
77
+ - trigger: git missing
78
+ effect: migration-workspace-state uses artifact timestamps only; stale detection less precise
79
+ - trigger: curl missing
80
+ effect: migration-prep records resource_gaps for remote media URLs
81
+ - trigger: jetbrains MCP missing or wrong open project
82
+ effect: TPA and planning-gate use file-system target evidence only; record MCP gap in migration_report or alignment_report
@@ -0,0 +1,318 @@
1
+ # Output Contract: File Recording System, Upstream Inputs, And Downstream Trigger Gates
2
+
3
+ This document is the **canonical path and content contract** for `android-to-kmp-migrator`. Downstream handlers (`kmp-test-validator`, `migration-task-adapter`) **MUST treat missing, empty, out-of-path, stale, or schema-invalid artifacts as hard blockers** — they do not infer from chat summaries.
4
+
5
+ The Leader and every node MUST read this file before writing artifacts. When `SKILL.md` or `workflow.md` diverge, **this file wins on paths, filenames, upstream inputs, and trigger gates**.
6
+
7
+ ## Upstream Input Contract (android-project-analyst)
8
+
9
+ Migration starts only when analyst handoff package **`P6`** (see `android-project-analyst/output-contract.md`) is ready. Required upstream paths (read-only inputs):
10
+
11
+ | Upstream artifact | Purpose for migrator |
12
+ |---|---|
13
+ | `analyst_output_root/run_manifest.json` | Source path, mode, analyst `handoff_package` |
14
+ | `analyst_output_root/module-index/modules_index.json` | Legacy `module_id` → folder/dimension paths |
15
+ | `analyst_output_root/module-index/module_inventory.json` | Module schedule, scopes, `depends_on` |
16
+ | `analyst_output_root/global/migration_assembly_basis.json` | Module assembly order, integration checkpoints |
17
+ | `analyst_output_root/global/cross_module_architecture.json` | Inter-module topology for global integration |
18
+ | `analyst_output_root/global/cross_module_data_logic.json` | Cross-module data/control links |
19
+ | `analyst_output_root/global/global_representation.json` | Full-project legacy synthesis |
20
+ | `analyst_output_root/SPEC/prd.md`, `design.md`, `plan.md`, `verification.md` | Product/design/plan baseline |
21
+
22
+ Per legacy `module_id`, migrator may consume:
23
+
24
+ - `modules/<module_id>/representation/module_representation.json`
25
+ - `modules/<module_id>/dimension_index.json`
26
+ - dimension JSON artifacts under `node-results/<dimension>/`
27
+
28
+ Record all resolved upstream paths in `run_manifest.json` → `upstream_analyst_artifacts`.
29
+
30
+ **Fail closed**: if analyst `handoff_gates.P6.ready` is false or paths are missing, migrator returns `blocked` — do not start module dispatch.
31
+
32
+ ---
33
+
34
+ ## Migration Output Root Layout
35
+
36
+ ```text
37
+ output_root = <output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator
38
+
39
+ <output_root>/
40
+ ├── run_manifest.json
41
+ ├── upstream-index/
42
+ │ └── upstream_analyst_index.json # resolved analyst paths + P6 gate snapshot
43
+ ├── module-index/
44
+ │ ├── migration_module_inventory.json
45
+ │ ├── migration_module_inventory.md
46
+ │ └── modules_migration_index.json # migration_module_id → paths + legacy module_id map
47
+ ├── global/
48
+ │ ├── node-results/
49
+ │ │ ├── migration-workspace-state/
50
+ │ │ │ ├── migration_workspace_state.json
51
+ │ │ │ └── migration_workspace_state.md
52
+ │ │ ├── target-project-assistant/
53
+ │ │ │ ├── target_project_assistant.json
54
+ │ │ │ ├── target_project_assistant.md
55
+ │ │ │ ├── target_alignment_revision.json
56
+ │ │ │ └── target_alignment_revision.md
57
+ │ │ └── global-migration-phase/
58
+ │ │ ├── integrate/
59
+ │ │ │ ├── global_system_integration.json
60
+ │ │ │ └── global_system_integration.md
61
+ │ │ └── align/
62
+ │ │ ├── post_integration_alignment.json
63
+ │ │ └── post_integration_alignment.md
64
+ │ ├── global_migration_representation.json
65
+ │ └── global_migration_representation.md
66
+ ├── modules/
67
+ │ └── <migration_module_id>/
68
+ │ ├── module_brief.json
69
+ │ ├── node-results/
70
+ │ │ ├── migration-workspace-state/ # per-module ledger slice
71
+ │ │ ├── target-project-assistant/ # per-module anchors (mode module_anchors)
72
+ │ │ ├── migration-planning-gate/
73
+ │ │ │ ├── migration_planning_gate.json
74
+ │ │ │ └── migration_planning_gate.md
75
+ │ │ ├── migration-prep/
76
+ │ │ │ ├── migration_prep.json
77
+ │ │ │ └── migration_prep.md
78
+ │ │ ├── module-implementation/
79
+ │ │ │ ├── ui/
80
+ │ │ │ │ ├── module_implementation_ui.json
81
+ │ │ │ │ └── module_implementation_ui.md
82
+ │ │ │ └── logic/
83
+ │ │ │ ├── module_implementation_logic.json
84
+ │ │ │ └── module_implementation_logic.md
85
+ │ │ ├── module-node-review-fix/
86
+ │ │ ├── migration-verification/
87
+ │ │ └── completion-report/
88
+ │ └── representation/
89
+ │ ├── module_migration_representation.json
90
+ │ ├── module_migration_representation.md
91
+ │ └── module_completion_record.json
92
+ └── report/
93
+ ├── alignment_report.json
94
+ ├── alignment_report.md
95
+ ├── migration_report.json
96
+ └── migration_report.md
97
+ ```
98
+
99
+ ### Path Variables
100
+
101
+ | Variable | Resolved path |
102
+ |---|---|
103
+ | `output_root` | `<output_dir or ~/.a2c_agents/migration>/android-to-kmp-migrator` |
104
+ | `upstream_index_dir` | `<output_root>/upstream-index` |
105
+ | `module_index_dir` | `<output_root>/module-index` |
106
+ | `module_root` | `<output_root>/modules/<migration_module_id>` |
107
+ | `node_result_dir` | `<module_root>/node-results/<node_id>` |
108
+ | `module_representation_dir` | `<module_root>/representation` |
109
+ | `global_dir` | `<output_root>/global` |
110
+ | `report_dir` | `<output_root>/report` |
111
+
112
+ ### Build Boundary (mandatory)
113
+
114
+ - **Migrator verification** runs **syntax/code structure checks** and **UI/logic restoration checks** against upstream analyst evidence. It does **NOT** compile or build the entire KMP project.
115
+ - **`incremental_build` is forbidden** in `migration-verification` during migrator runs.
116
+ - **Full compile/build/preview/behavioral tests** are delegated to **`kmp-test-validator`** after `migration_report.*` handoff package **`V0`** is ready.
117
+
118
+ ---
119
+
120
+ ## Write Order (Leader Schedule)
121
+
122
+ | Step | Gate | Required artifacts before next step |
123
+ |---|---|---|
124
+ | `MG0` | Run lock | `run_manifest.json`, `upstream-index/upstream_analyst_index.json` |
125
+ | `MG1` | Workspace init | global `migration_workspace_state.*` |
126
+ | `MG2` | Migration index | `migration_module_inventory.*`, `modules_migration_index.json`, per-module `module_brief.json` |
127
+ | `MG3` | Target baseline | global `target-project-assistant/*` (`mode: global_baseline`) + `target_alignment_revision.*` |
128
+ | `MG4` | Per-module anchors | per-module `target-project-assistant/target_module_anchors.json` |
129
+ | `MG5` | Per-module plan+gate | `migration-planning-gate/migration_planning_gate.*` |
130
+ | `MG6`–`MG10` | Per-module impl | prep → review/fix → module-implementation `ui` → review/fix → `logic` → review/fix |
131
+ | `MG11` | Module verify | `migration_verification.*` (no full build) + `module_completion_record.json` |
132
+ | `MG12` | Module rep | `module_migration_representation.*` |
133
+ | `MG13` | All modules done | every scheduled module passes `MG11`–`MG12` |
134
+ | `MG14` | Global integrate | `global-migration-phase/integrate/global_system_integration.*` |
135
+ | `MG15` | Global align | `global-migration-phase/align/post_integration_alignment.*`, `report/alignment_report.*` (read-only) |
136
+ | `MG16` | Global rep + report | `global_migration_representation.*`, `migration_report.*` |
137
+ | `MG17` | Validator handoff | invoke `kmp-test-validator` |
138
+
139
+ ---
140
+
141
+ ## Handoff Packages (Downstream Trigger Conditions)
142
+
143
+ ### Package `M0` — Migration run identity
144
+
145
+ | Required paths |
146
+ |---|
147
+ | `run_manifest.json` |
148
+ | `upstream-index/upstream_analyst_index.json` |
149
+ | global `migration_workspace_state.json` |
150
+
151
+ ### Package `M1` — Migration module routing
152
+
153
+ | Required paths |
154
+ |---|
155
+ | `migration_module_inventory.json` |
156
+ | `modules_migration_index.json` |
157
+
158
+ ### Package `M2` — Target alignment ready
159
+
160
+ | Required paths |
161
+ |---|
162
+ | Package `M1` |
163
+ | `global/node-results/target-project-assistant/target_alignment_revision.json` |
164
+ | per scheduled module: `node-results/target-project-assistant/target_module_anchors.json` |
165
+
166
+ ### Package `M3` — Module implementation complete (per `migration_module_id`)
167
+
168
+ | Required paths |
169
+ |---|
170
+ | Package `M2` for this module |
171
+ | `migration-planning-gate/migration_planning_gate.json` |
172
+ | `migration-prep/migration_prep.json` |
173
+ | `module-implementation/ui/module_implementation_ui.json`, `module-implementation/logic/module_implementation_logic.json` + approved reviews |
174
+ | `migration_verification.json` with all required `check_ids` passed |
175
+ | `module_completion_record.json` with `ui_restoration` and `logic_restoration` passed |
176
+
177
+ ### Package `M4` — All modules migrated
178
+
179
+ | Required paths |
180
+ |---|
181
+ | Package `M3` for every `migration_module_id` in `assembly_order` |
182
+ | all `module_migration_representation.json` files |
183
+
184
+ ### Package `M5` — Global system integrated
185
+
186
+ | Required paths |
187
+ |---|
188
+ | Package `M4` |
189
+ | `global/node-results/global-migration-phase/integrate/global_system_integration.json` |
190
+ | `global_migration_representation.json` |
191
+
192
+ ### Package `M6` — Post-integration alignment passed
193
+
194
+ | Required paths |
195
+ |---|
196
+ | Package `M5` |
197
+ | `global/node-results/global-migration-phase/align/post_integration_alignment.json` with `alignment_verdict: passed \| passed_with_assumptions` |
198
+ | `report/alignment_report.json` |
199
+
200
+ ### Package `V0` — kmp-test-validator entry (downstream)
201
+
202
+ | Required paths |
203
+ |---|
204
+ | Package `M6` |
205
+ | `report/migration_report.json` |
206
+ | `global_migration_representation.json` |
207
+ | analyst `SPEC/*` paths recorded in `run_manifest.json` |
208
+
209
+ **Fail closed**: `kmp-test-validator` MUST NOT start when `V0` is false. It owns full project build, preview, and behavioral tests.
210
+
211
+ ---
212
+
213
+ ## Key Artifact Content Requirements
214
+
215
+ ### `upstream_analyst_index.json`
216
+
217
+ ```json
218
+ {
219
+ "analyst_output_root": "",
220
+ "analyst_handoff_package": "P6",
221
+ "analyst_handoff_ready": true,
222
+ "modules_index_path": "",
223
+ "migration_assembly_basis_path": "",
224
+ "cross_module_architecture_path": "",
225
+ "cross_module_data_logic_path": "",
226
+ "global_representation_path": "",
227
+ "spec_paths": {},
228
+ "legacy_module_map": [{ "legacy_module_id": "", "migration_module_id": "" }]
229
+ }
230
+ ```
231
+
232
+ ### `modules_migration_index.json`
233
+
234
+ Machine lookup: `migration_module_id` → `legacy_module_id`, `module_output_root`, `upstream_module_representation_path`, `target_anchor_paths`, `completion_status`.
235
+
236
+ ### `target_alignment_revision.json` (Target-Project-Assistant)
237
+
238
+ `target_project_layout`, `reusable_components[]`, `anchor_points[]` (legacy scope → target path), `revised_alignment[]`, `integration_constraints[]`, `consultation_log[]`.
239
+
240
+ ### `target_module_anchors.json` (per module)
241
+
242
+ `migration_module_id`, `legacy_module_id`, `target_paths[]`, `anchor_points[]`, `reuse_decisions[]`, `alignment_revision_refs[]`.
243
+
244
+ ### `module_completion_record.json`
245
+
246
+ ```json
247
+ {
248
+ "migration_module_id": "",
249
+ "legacy_module_id": "",
250
+ "completion_status": "completed | needs_rerun | blocked",
251
+ "verification_ref": "",
252
+ "ui_restoration": { "status": "passed | failed", "gaps": [] },
253
+ "logic_restoration": { "status": "passed | failed", "gaps": [] },
254
+ "upstream_match": { "module_representation_path": "", "matched_claims": [], "missing_claims": [] },
255
+ "rerun_required": false,
256
+ "evidence_paths": []
257
+ }
258
+ ```
259
+
260
+ ### `migration_verification.json` — required `check_ids` (migrator only)
261
+
262
+ - `source_set` — files in allowed source sets
263
+ - `syntax_check` — Kotlin/syntax validity on changed files (static; no full project compile)
264
+ - `api_contract` — API/model shape vs planning + analyst data contracts
265
+ - `ui_render` — static UI surface check (Compose structure/resources; no full render pipeline build)
266
+ - `ui_restoration` — migrated UI coverage vs upstream `presentation_resource` + module representation
267
+ - `logic_restoration` — migrated logic coverage vs upstream `behavior_logic` + module representation
268
+
269
+ **Forbidden**: `incremental_build`, `full_project_compile`, `gradle_assemble`.
270
+
271
+ ### `global_system_integration.json`
272
+
273
+ `assembly_order`, `ui_transition_edges[]`, `control_logic_handoffs[]`, `data_call_edges[]`, `shared_contracts_applied[]`, `integration_changed_files[]`, evidence paths from analyst cross-module globals.
274
+
275
+ ### `post_integration_alignment.json` (analysis only — no target edits)
276
+
277
+ `alignment_verdict`, `module_alignment_results[]`, `global_alignment_results`, `omissions[]`, `poor_restoration[]`, `rerun_modules[]`, `comparison_evidence[]` (analyst path vs target path pairs).
278
+
279
+ ### `migration_planning_gate.json`
280
+
281
+ Combined `planning` (spec deltas, source-to-target map, tasks) and `dependency_platform` (capability map, platform boundaries) sections. Status `ready_for_implementation` when both complete.
282
+
283
+ ### `migration_prep.json`
284
+
285
+ Combined `presentation` (tokens, resources, routes) and `state_data` (state/models/API expectations) sections.
286
+
287
+ ### `module_implementation_ui.json` / `module_implementation_logic.json`
288
+
289
+ UI mode and logic mode outputs under `module-implementation/ui/` and `module-implementation/logic/` respectively.
290
+
291
+ ### `alignment_report.json`
292
+
293
+ Human/agent-readable synthesis of align mode; routes reruns to `migration_module_id` or `global-migration-phase integrate`.
294
+
295
+ ---
296
+
297
+ ## Leader Obligations
298
+
299
+ 1. Verify analyst package `P6` before `MG0` completes.
300
+ 2. Dispatch `target-project-assistant` for all target-project questions; other roles MUST reference TPA artifacts instead of re-analyzing target ad hoc.
301
+ 3. Write `module_completion_record.json` after each module passes `migration-verification`.
302
+ 4. Run `global-migration-phase` `integrate` only after package `M4`.
303
+ 5. Run `global-migration-phase` `align` only after integrate; **no code changes** in align mode.
304
+ 6. Dispatch only role IDs listed in [SKILL.md](SKILL.md).
305
+ 7. Set `handoff_gates` (`M0`–`M6`, `V0`) in workspace ledger and `migration_report.json`.
306
+ 8. Invoke `kmp-test-validator` only when `V0` is true.
307
+
308
+ ## Invalid Artifact Handling
309
+
310
+ | Condition | Action |
311
+ |---|---|
312
+ | Missing path | `blocked`, `reason: missing` |
313
+ | Empty file | `blocked`, `reason: empty` |
314
+ | Out of `output_root` | `blocked`, `reason: out_of_path` |
315
+ | Stale per workspace ledger | `needs_rerun`, name owner |
316
+ | `module_completion_record` failed | Re-enter module loop from routed node |
317
+ | `post_integration_alignment` omissions | Rerun listed modules or `global-migration-phase integrate` |
318
+ | Full build requested during migrator | Reject — route to `kmp-test-validator` |
@@ -24,6 +24,8 @@ Forbidden:
24
24
  - Do not fix implementation gaps.
25
25
  - Do not mark validation passed.
26
26
  - Do not run report mode when module/global representations are missing.
27
+ - Do not run report mode when package `M6` is false (`global-migration-phase align` / `alignment_report` missing or failed).
28
+ - Do not mark `ready_for_validation` when `handoff_gates.V0` is false.
27
29
 
28
30
  Mandatory:
29
31
  - Validate `mode`, `migration_module_id`, module/global representation paths, workspace state, and exact `output_dir`.
@@ -57,7 +59,7 @@ Shared return shape applies.
57
59
 
58
60
  - `completion_readiness.json`: machine-routable readiness artifact containing requirement coverage, migration invariants, module/global representation references when applicable, verification/review status, validation inputs readiness, rerun requests, and blockers.
59
61
  - `completion_readiness.md`: agent-readable readiness handoff containing coverage tables, invariant checks, incomplete markers, rerun routing, blockers, and whether representation/report gates may proceed.
60
- - `migration_report.json`: machine-routable final migration handoff containing migration scope, source/target paths, output root, module representations, global representation, changed files by role, source-to-target summary, coverage summary, validation inputs, limitations, manual steps, and blockers.
62
+ - `migration_report.json`: machine-routable final migration handoff containing migration scope, source/target paths, analyst_output_root, upstream_analyst_index, `handoff_gates` (`M0`–`M6`, `V0`), `handoff_package: V0`, module representations, global representation, `alignment_report` path, `global_system_integration` path, changed files by role, coverage summary, validation inputs for kmp-test-validator, `validation_deferred_to: kmp-test-validator`, limitations, blockers.
61
63
  - `migration_report.md`: agent-readable final migration report for `kmp-test-validator` and follow-up agents, preserving exact artifact paths, changed-file ownership, validation handoff context, limitations, and blockers.
62
64
 
63
65
  ## Inline Persona for Teammate
@@ -0,0 +1,87 @@
1
+ # Role: Global Migration Phase
2
+
3
+ ## Identity
4
+
5
+ > *"After all modules complete, I integrate the system then audit alignment — integrate edits, align read-only."*
6
+
7
+ You are the `global-migration-phase` node subagent. You merge **global system integration** and **post-integration alignment** with strict modes.
8
+
9
+ ## Modes
10
+
11
+ | Mode | When | May edit target? | Output |
12
+ |---|---|---|---|
13
+ | `integrate` | Package `M4` true | Yes — integration glue only | `global_system_integration.json` / `.md` |
14
+ | `align` | After `integrate` completes | **No** — analysis only | `post_integration_alignment.json` / `.md` + `report/alignment_report.*` |
15
+
16
+ ## Success Criteria
17
+
18
+ **Integrate mode**:
19
+ - Wire `ui_transition_edges`, `control_logic_handoffs`, `data_call_edges` from analyst cross-module globals.
20
+ - `integration_changed_files` limited to glue; route module gaps via `rerun_requests`.
21
+
22
+ **Align mode**:
23
+ - True comparison: analyst artifacts vs migrated target; `alignment_verdict` explicit.
24
+ - `rerun_modules[]` and `rerun_global_integration` when omissions found.
25
+ - Write `alignment_report.*` under `report_dir`.
26
+
27
+ ## Boundary
28
+
29
+ **Forbidden**:
30
+ - Do not combine `integrate` and `align` in one invocation.
31
+ - Align mode: no target or legacy edits, no full project build.
32
+ - Integrate mode: no full module reimplementation; no alignment comparison.
33
+
34
+ **Mandatory**:
35
+ - Integrate: `output_dir = <global_dir>/node-results/global-migration-phase/integrate`
36
+ - Align: primary output under `<global_dir>/node-results/global-migration-phase/align`; alignment report under `report_dir`
37
+
38
+ ## Output Schema (integrate)
39
+
40
+ ```json
41
+ {
42
+ "status": "completed | needs_rerun | blocked",
43
+ "node": "global-migration-phase",
44
+ "mode": "integrate",
45
+ "migration_module_id": "global",
46
+ "ui_transition_edges": [],
47
+ "control_logic_handoffs": [],
48
+ "data_call_edges": [],
49
+ "integration_changed_files": [],
50
+ "blocking_gaps": []
51
+ }
52
+ ```
53
+
54
+ ## Output Schema (align)
55
+
56
+ ```json
57
+ {
58
+ "status": "completed | needs_rerun | blocked",
59
+ "node": "global-migration-phase",
60
+ "mode": "align",
61
+ "alignment_verdict": "passed | passed_with_assumptions | failed",
62
+ "module_alignment_results": [],
63
+ "global_alignment_results": {},
64
+ "rerun_modules": [],
65
+ "rerun_global_integration": false,
66
+ "comparison_evidence": [],
67
+ "blocking_gaps": []
68
+ }
69
+ ```
70
+
71
+ ## Inline Persona for Teammate
72
+
73
+ ```text
74
+ ROLE: global-migration-phase node. Modes: integrate | align. NEVER combine.
75
+
76
+ INTEGRATE: wire cross-module UI transitions, control logic, data calls. Edit glue files only.
77
+ ALIGN: compare analyst vs migrated target. NO edits. Write alignment_report under report_dir.
78
+
79
+ INPUTS: mode, analyst globals, module representations, module_completion_records,
80
+ target_alignment_revision, kmp_target_project_path, global_system_integration (align mode), output_dir, report_dir.
81
+
82
+ OUTPUTS:
83
+ - integrate: global_system_integration.json/.md under .../global-migration-phase/integrate/
84
+ - align: post_integration_alignment.json/.md under .../align/ + alignment_report.json/.md under report/
85
+
86
+ Do NOT run full project build.
87
+ ```