intentdna 1.7.5 → 1.8.1

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 (154) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/LICENSE +201 -0
  4. package/README.md +143 -194
  5. package/dist/assets/candidates.d.ts +124 -0
  6. package/dist/assets/candidates.js +1249 -0
  7. package/dist/assets/catalog.d.ts +101 -0
  8. package/dist/assets/catalog.js +311 -0
  9. package/dist/assets/evidence.d.ts +93 -0
  10. package/dist/assets/evidence.js +391 -0
  11. package/dist/assets/index.d.ts +4 -0
  12. package/dist/assets/index.js +4 -0
  13. package/dist/assets/metadata.d.ts +19 -0
  14. package/dist/assets/metadata.js +227 -0
  15. package/dist/cli/commands/assets.d.ts +65 -0
  16. package/dist/cli/commands/assets.js +2871 -0
  17. package/dist/cli/commands/auth.d.ts +322 -0
  18. package/dist/cli/commands/auth.js +1592 -0
  19. package/dist/cli/commands/cloud-auth-guidance.d.ts +2 -0
  20. package/dist/cli/commands/cloud-auth-guidance.js +4 -0
  21. package/dist/cli/commands/cloud.d.ts +1359 -0
  22. package/dist/cli/commands/cloud.js +8364 -0
  23. package/dist/cli/commands/evolve.js +18 -2
  24. package/dist/cli/commands/generate.js +25 -2
  25. package/dist/cli/commands/guard.d.ts +1 -1
  26. package/dist/cli/commands/guard.js +1 -1
  27. package/dist/cli/commands/guide.d.ts +15 -0
  28. package/dist/cli/commands/guide.js +1747 -0
  29. package/dist/cli/commands/init.d.ts +12 -0
  30. package/dist/cli/commands/init.js +95 -60
  31. package/dist/cli/commands/org.d.ts +16 -0
  32. package/dist/cli/commands/org.js +2393 -0
  33. package/dist/cli/commands/release.d.ts +59 -0
  34. package/dist/cli/commands/release.js +716 -0
  35. package/dist/cli/commands/report.d.ts +82 -0
  36. package/dist/cli/commands/report.js +1516 -0
  37. package/dist/cli/commands/run.d.ts +8 -1
  38. package/dist/cli/commands/run.js +129 -57
  39. package/dist/cli/commands/sync.d.ts +8 -1
  40. package/dist/cli/commands/sync.js +436 -141
  41. package/dist/cli/commands/templates.d.ts +64 -0
  42. package/dist/cli/commands/templates.js +2151 -1
  43. package/dist/cli/commands/workflow.d.ts +26 -0
  44. package/dist/cli/commands/workflow.js +3053 -0
  45. package/dist/cli/index.js +703 -36
  46. package/dist/compiler/cascade.js +4 -9
  47. package/dist/compiler/compile.js +1 -0
  48. package/dist/governance/evidence-capture-attribution.d.ts +12 -0
  49. package/dist/governance/evidence-capture-attribution.js +46 -0
  50. package/dist/governance/index.d.ts +2 -0
  51. package/dist/governance/index.js +1 -0
  52. package/dist/hooks/cli.d.ts +9 -0
  53. package/dist/hooks/cli.js +170 -411
  54. package/dist/hooks/enforce.d.ts +1 -0
  55. package/dist/hooks/protocol.d.ts +1 -1
  56. package/dist/hooks/protocol.js +1 -1
  57. package/dist/hooks/state.d.ts +41 -0
  58. package/dist/hooks/state.js +126 -2
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.js +3 -0
  61. package/dist/mcp/tools-state.js +2 -0
  62. package/dist/organization/index.d.ts +121 -0
  63. package/dist/organization/index.js +413 -0
  64. package/dist/runtime/claude-sync-target.d.ts +49 -0
  65. package/dist/runtime/claude-sync-target.js +280 -0
  66. package/dist/runtime/codex-adapter.d.ts +254 -0
  67. package/dist/runtime/codex-adapter.js +1204 -0
  68. package/dist/runtime/codex-sync-target.d.ts +33 -0
  69. package/dist/runtime/codex-sync-target.js +241 -0
  70. package/dist/runtime/index.d.ts +8 -0
  71. package/dist/runtime/index.js +4 -0
  72. package/dist/runtime/output-artifact-registry.d.ts +1 -1
  73. package/dist/runtime/output-artifact-registry.js +2 -0
  74. package/dist/runtime/settings-adapter.d.ts +1 -1
  75. package/dist/runtime/settings-adapter.js +1 -1
  76. package/dist/runtime/skill-adapter.d.ts +5 -1
  77. package/dist/runtime/skill-adapter.js +164 -39
  78. package/dist/runtime/sync-artifact-registry.d.ts +99 -0
  79. package/dist/runtime/sync-artifact-registry.js +194 -0
  80. package/dist/runtime/sync-target-plan.d.ts +45 -0
  81. package/dist/runtime/sync-target-plan.js +19 -0
  82. package/dist/runtime/verifier.d.ts +51 -0
  83. package/dist/runtime/verifier.js +462 -0
  84. package/dist/schema/controller-registry.d.ts +8 -1
  85. package/dist/schema/controller-registry.js +8 -0
  86. package/dist/schema/types.d.ts +35 -23
  87. package/dist/schema/types.js +10 -1
  88. package/dist/schema/validate.js +22 -22
  89. package/dist/schema/validators/controllers.js +38 -20
  90. package/dist/schema/workflow-authoring-contract.d.ts +29 -0
  91. package/dist/schema/workflow-authoring-contract.js +109 -0
  92. package/dist/schema/yaml-parser.js +18 -0
  93. package/dist/templates/api-backend.dna.yaml +19 -0
  94. package/dist/templates/brainstorming-first.dna.yaml +19 -0
  95. package/dist/templates/code-cleanup.dna.yaml +19 -0
  96. package/dist/templates/code-review-pipeline.dna.yaml +18 -0
  97. package/dist/templates/documentation-writer.dna.yaml +19 -0
  98. package/dist/templates/flutter-behavior-lock.dna.yaml +19 -0
  99. package/dist/templates/flutter-refactoring-rescue.dna.yaml +19 -0
  100. package/dist/templates/flutter-rewrite-diagnosis-review.dna.yaml +210 -0
  101. package/dist/templates/flutter-rewrite-fix-review-loop.dna.yaml +260 -0
  102. package/dist/templates/flutter-rewrite-new.dna.yaml +506 -0
  103. package/dist/templates/flutter-rewrite.dna.yaml +100 -4
  104. package/dist/templates/frontend-quality.dna.yaml +19 -0
  105. package/dist/templates/full-pipeline.dna.yaml +20 -0
  106. package/dist/templates/marketplace.d.ts +92 -0
  107. package/dist/templates/marketplace.js +502 -0
  108. package/dist/templates/metadata.d.ts +25 -0
  109. package/dist/templates/metadata.js +136 -3
  110. package/dist/templates/mobile-dev.dna.yaml +19 -0
  111. package/dist/templates/multi-agent-handoff-coordination.dna.yaml +156 -0
  112. package/dist/templates/multi-perspective-review.dna.yaml +19 -0
  113. package/dist/templates/persistent-executor.dna.yaml +19 -0
  114. package/dist/templates/qa-loop.dna.yaml +18 -0
  115. package/dist/templates/release-evidence-gate.dna.yaml +131 -0
  116. package/dist/templates/requirements-gate.dna.yaml +19 -0
  117. package/dist/templates/research-orchestration.dna.yaml +19 -0
  118. package/dist/templates/root-cause-analysis.dna.yaml +19 -0
  119. package/dist/templates/safe-refactoring.dna.yaml +321 -0
  120. package/dist/templates/secure-dev.dna.yaml +19 -0
  121. package/dist/templates/subagent-parallel.dna.yaml +19 -0
  122. package/dist/templates/systematic-debugging.dna.yaml +19 -0
  123. package/dist/templates/tdd-strict.dna.yaml +19 -0
  124. package/dist/templates/ui-visual-regression-qa.dna.yaml +133 -0
  125. package/dist/templates/workflow-author.dna.yaml +302 -0
  126. package/dist/templates/workflow-blocked-scope-triage.dna.yaml +242 -0
  127. package/dist/templates/workflow-completion-audit.dna.yaml +254 -0
  128. package/dist/templates/workflow-cross-boundary-resource-approval.dna.yaml +249 -0
  129. package/dist/templates/workflow-evidence-review.dna.yaml +198 -0
  130. package/dist/templates/workflow-module-inventory.dna.yaml +257 -0
  131. package/dist/templates/workflow-runtime-smoke-review.dna.yaml +252 -0
  132. package/dist/templates/workflow-verification-command-routing.dna.yaml +278 -0
  133. package/dist/workflow/authoring-packet.d.ts +67 -0
  134. package/dist/workflow/authoring-packet.js +218 -0
  135. package/dist/workflow/draft.d.ts +159 -0
  136. package/dist/workflow/draft.js +800 -0
  137. package/dist/workflow/index.d.ts +3 -0
  138. package/dist/workflow/index.js +3 -0
  139. package/dist/workflow/suggestion-review.d.ts +65 -0
  140. package/dist/workflow/suggestion-review.js +245 -0
  141. package/package.json +1 -1
  142. package/spec/README.md +15 -48
  143. package/spec/codex-adapter-contract.md +176 -0
  144. package/spec/sync-target-plan.md +158 -0
  145. package/spec/workflow-capability-ir.md +153 -0
  146. package/spec/agent-dispatch-fix.md +0 -116
  147. package/spec/control-plane-convergence-handoff-2026-04-24.md +0 -432
  148. package/spec/flutter-rewrite-template-optimization.md +0 -301
  149. package/spec/foundation-hardening.md +0 -178
  150. package/spec/hooks-infra-harness-hardening.md +0 -741
  151. package/spec/multi-config.md +0 -172
  152. package/spec/parallel-isolation.md +0 -268
  153. package/spec/template-version-namespace-fix.md +0 -653
  154. package/spec/workflow-pipeline.md +0 -101
@@ -0,0 +1,506 @@
1
+ # flutter-rewrite-new: Flutter rewrite with workflow-infra governance stages
2
+ # Purpose: demonstrate the next template shape after workflow capability foundation.
3
+ # Keeps Flutter-specific migration knowledge, but moves execution into explicit
4
+ # intent, boundary, baseline, diagnosis, rewrite, equivalence, review, evidence gates.
5
+
6
+ version: "0.1.0"
7
+ id: template_flutter_rewrite_new
8
+ name: Flutter Rewrite New
9
+ purpose: Demonstrate the governed Flutter rewrite workflow shape with explicit intent, boundary, baseline, diagnosis, rewrite, equivalence, review, and evidence gates.
10
+ maturity: draft
11
+ fit:
12
+ - Designing or reviewing the next generation Flutter rewrite workflow shape.
13
+ - Migration work that needs explicit stage boundaries before adopting the full dogfood-proven asset.
14
+ not_for:
15
+ - Replacing the adopted flutter-rewrite asset without review.
16
+ - Feature redesigns or runtime execution outside local dna sync.
17
+ inputs:
18
+ - target module or feature slug
19
+ - v1 source root
20
+ - v2 Flutter package root
21
+ - behavior and evidence directories
22
+ outputs:
23
+ - governed rewrite stage plan
24
+ - baseline, diagnosis, rewrite, equivalence, and review evidence
25
+ - adoption review material
26
+ lineage:
27
+ source: workflow-infra governance template shape
28
+ reference: src/templates/flutter-rewrite.dna.yaml
29
+ type: project
30
+ namespace: frwn
31
+
32
+ cascade:
33
+ inherits: ["species:default"]
34
+ priority: 100
35
+
36
+ variables:
37
+ module:
38
+ description: "Target module or feature slug"
39
+ default: "$ARGUMENTS"
40
+ v1_path:
41
+ description: "v1 source root used as behavior truth"
42
+ default: "common/lib"
43
+ v2_path:
44
+ description: "v2 Flutter package root"
45
+ default: "v2/packages"
46
+ behavior_docs:
47
+ description: "Behavior contract output directory"
48
+ default: "docs/behavior"
49
+ test_path:
50
+ description: "Behavior test output directory"
51
+ default: "test/behavior"
52
+ evidence_dir:
53
+ description: "Rewrite governance evidence directory"
54
+ default: ".dna/rewrite/{{module}}"
55
+ test_command:
56
+ description: "Command that verifies the target module"
57
+ default: "flutter test"
58
+ target_scope:
59
+ description: "Allowed write scope for the rewrite step"
60
+ default: "v2/**"
61
+
62
+ genes:
63
+ v1_behavior_truth:
64
+ description: v1 source is the behavior truth for rewrite decisions.
65
+ codons:
66
+ - type: attract
67
+ target: read_v1_source_before_changing
68
+ - type: attract
69
+ target: cite_v1_evidence
70
+ - type: repel
71
+ target: guess_api_signature
72
+ - type: threshold
73
+ condition: "v1_reference_missing == false"
74
+ action: block
75
+
76
+ workflow_gates_before_code:
77
+ description: Rewrite cannot begin until intent, boundary, and baseline are recorded.
78
+ codons:
79
+ - type: attract
80
+ target: intent_lock
81
+ - type: attract
82
+ target: boundary_freeze
83
+ - type: attract
84
+ target: baseline_characterization
85
+ - type: repel
86
+ target: direct_edit_without_evidence
87
+ - type: threshold
88
+ condition: "prewrite_evidence_complete == true"
89
+ action: block
90
+
91
+ equivalence_over_improvement:
92
+ description: The rewrite preserves v1 behavior rather than improving product behavior.
93
+ codons:
94
+ - type: attract
95
+ target: logic_equivalence_validation
96
+ - type: attract
97
+ target: same_inputs_same_outputs
98
+ - type: repel
99
+ target: opportunistic_improvement
100
+ - type: threshold
101
+ condition: "behavior_delta_approved == true"
102
+ action: escalate
103
+
104
+ small_bounded_rounds:
105
+ description: Each rewrite round stays small, scoped, and reviewable.
106
+ codons:
107
+ - type: attract
108
+ target: single_module_focus
109
+ - type: attract
110
+ target: targeted_tests_per_round
111
+ - type: repel
112
+ target: cross_module_rewrite
113
+ - type: threshold
114
+ condition: "files_changed_per_round <= 5"
115
+ action: escalate
116
+
117
+ evidence_before_completion:
118
+ description: Completion requires reviewable evidence, not a prose claim.
119
+ codons:
120
+ - type: attract
121
+ target: evidence_package
122
+ - type: attract
123
+ target: runtime_decision_evidence
124
+ - type: repel
125
+ target: claim_without_test_output
126
+
127
+ contexts: {}
128
+
129
+ context_files:
130
+ mandatory:
131
+ - CLAUDE.md
132
+ - docs/refactoring-workflow-v2.md
133
+ - v2/docs/PROVIDER_DESIGN.md
134
+ - v2/docs/memory/flutter_architecture_guide.md
135
+ per_role:
136
+ intent_mapper:
137
+ - "{{behavior_docs}}/{{module}}.md"
138
+ boundary_guard:
139
+ - "{{behavior_docs}}/{{module}}.md"
140
+ baseline_tester:
141
+ - "{{behavior_docs}}/{{module}}.md"
142
+ diagnosis_analyst:
143
+ - "{{evidence_dir}}/intent.md"
144
+ - "{{evidence_dir}}/boundary.md"
145
+ - "{{evidence_dir}}/baseline.log"
146
+ rewrite_surgeon:
147
+ - "{{evidence_dir}}/intent.md"
148
+ - "{{evidence_dir}}/boundary.md"
149
+ - "{{evidence_dir}}/diagnosis.md"
150
+ equivalence_verifier:
151
+ - "{{evidence_dir}}/baseline.log"
152
+ - "{{evidence_dir}}/diagnosis.md"
153
+ rewrite_reviewer:
154
+ - "{{evidence_dir}}/intent.md"
155
+ - "{{evidence_dir}}/boundary.md"
156
+ - "{{evidence_dir}}/equivalence.md"
157
+
158
+ verifier_policy:
159
+ allow_builtin_asserts:
160
+ - clean_working_tree
161
+ - no_test_regression
162
+
163
+ roles:
164
+ intent_mapper:
165
+ description: Locks module intent, v1 truth, success criteria, and explicit non-goals.
166
+ tool_permissions:
167
+ allow: [Read, Grep, Glob, Write]
168
+ deny: [Edit, Bash, NotebookEdit]
169
+ scope:
170
+ read: ["**/*"]
171
+ write: ["{{evidence_dir}}/**"]
172
+ instructions:
173
+ - "Read the behavior doc and v1 source references before writing intent."
174
+ - "Define exact module scope, success criteria, and explicit non-goals."
175
+ - "Do not edit implementation or tests."
176
+
177
+ boundary_guard:
178
+ description: Freezes allowed paths, forbidden areas, tool policy, and escalation triggers.
179
+ tool_permissions:
180
+ allow: [Read, Grep, Glob, Write]
181
+ deny: [Edit, Bash, NotebookEdit]
182
+ scope:
183
+ read: ["**/*"]
184
+ write: ["{{evidence_dir}}/**"]
185
+ instructions:
186
+ - "Record allowed write paths and forbidden source areas."
187
+ - "Treat cross-module rewrites or unbounded scope as blockers."
188
+ - "Do not edit implementation or tests."
189
+
190
+ baseline_tester:
191
+ description: Captures baseline test behavior before rewrite.
192
+ tool_permissions:
193
+ allow: [Read, Grep, Glob, Bash, Write]
194
+ deny: [Edit, NotebookEdit]
195
+ scope:
196
+ read: ["**/*"]
197
+ write: ["{{evidence_dir}}/**"]
198
+ instructions:
199
+ - "Run the declared test command before edits."
200
+ - "Record pass/fail/skip/hung counts and known failures."
201
+ - "Do not change code to make baseline pass."
202
+
203
+ diagnosis_analyst:
204
+ description: Classifies gaps using v1 behavior evidence without prescribing implementation.
205
+ tool_permissions:
206
+ allow: [Read, Grep, Glob, Write]
207
+ deny: [Edit, Bash, NotebookEdit]
208
+ scope:
209
+ read: ["**/*"]
210
+ write: ["{{evidence_dir}}/**"]
211
+ instructions:
212
+ - "For each failing, skipped, or missing behavior, read test code, v1 source, and v2 current state."
213
+ - "Classify as BUG, UNIMPLEMENTED, INFRA, TEST_BUG, or REMOVED."
214
+ - "Write evidence and classification only; do not include fix prescriptions."
215
+
216
+ rewrite_surgeon:
217
+ description: Performs the smallest behavior-preserving v2 rewrite inside the frozen boundary.
218
+ tool_permissions:
219
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
220
+ scope:
221
+ read: ["**/*"]
222
+ write: ["{{target_scope}}", "{{test_path}}/**"]
223
+ instructions:
224
+ - "Read intent, boundary, approved diagnosis, and v1 source before any edit."
225
+ - "Apply the smallest behavior-preserving rewrite for this module."
226
+ - "Use v2 architecture conventions, but do not change product behavior."
227
+ - "Run targeted tests after material changes."
228
+ - "Stop if the required change exceeds the frozen boundary."
229
+
230
+ equivalence_verifier:
231
+ description: Compares baseline and post-rewrite behavior and records equivalence evidence.
232
+ tool_permissions:
233
+ allow: [Read, Grep, Glob, Bash, Write]
234
+ deny: [Edit, NotebookEdit]
235
+ scope:
236
+ read: ["**/*"]
237
+ write: ["{{evidence_dir}}/**"]
238
+ instructions:
239
+ - "Run the declared test command after rewrite."
240
+ - "Compare current results with baseline and diagnosis classifications."
241
+ - "Mark unproven equivalence as a blocker."
242
+
243
+ rewrite_reviewer:
244
+ description: Reviews diff, evidence, and risk before final approval.
245
+ tool_permissions:
246
+ allow: [Read, Grep, Glob, Bash, Write]
247
+ deny: [Edit, NotebookEdit]
248
+ scope:
249
+ read: ["**/*"]
250
+ write: ["{{evidence_dir}}/**"]
251
+ instructions:
252
+ - "Review final diff against intent, boundary, diagnosis, and equivalence evidence."
253
+ - "Reject scope creep, fake tests, unrelated refactors, or unapproved behavior deltas."
254
+ - "Write final evidence package with verdict and residual risks."
255
+
256
+ workflows:
257
+ rewrite-governed:
258
+ name: Governed Flutter Rewrite
259
+ description: "Intent-locked Flutter rewrite workflow: freeze scope, capture baseline, diagnose, rewrite, prove equivalence, and package evidence."
260
+ consumes:
261
+ - type: state
262
+ name: module_rewrite_request
263
+ required: true
264
+ description: Target module and rewrite goal.
265
+ produces:
266
+ - type: file
267
+ path: "{{evidence_dir}}/evidence.md"
268
+ description: Final rewrite evidence package.
269
+ default_isolation: worktree
270
+ retry_policy:
271
+ max_retries: 1
272
+ retry_from: equivalence_verify
273
+ backoff: none
274
+ steps:
275
+ - id: intent_lock
276
+ role: intent_mapper
277
+ description: Lock module intent, v1 truth, success criteria, and non-goals.
278
+ enforce:
279
+ read_only: true
280
+ additional_write_paths: ["{{evidence_dir}}/**"]
281
+ handoff:
282
+ produces:
283
+ - type: file
284
+ path: "{{evidence_dir}}/intent.md"
285
+ description: Locked module intent and equivalence criteria.
286
+ completion:
287
+ - file_contains: { path: "{{evidence_dir}}/intent.md", pattern: "Equivalence criteria" }
288
+ checkpoints:
289
+ - assert: clean_working_tree
290
+ action: warn
291
+ message: "Record any pre-existing dirty state before rewrite."
292
+ prompt: |
293
+ Lock rewrite intent for module {{module}} before implementation.
294
+ Write {{evidence_dir}}/intent.md with:
295
+ - Module and exact target scope
296
+ - v1 truth references under {{v1_path}}
297
+ - v2 target paths under {{v2_path}}
298
+ - Explicit non-goals
299
+ - Equivalence criteria
300
+ - Allowed behavior deltas, if any
301
+
302
+ - id: boundary_freeze
303
+ role: boundary_guard
304
+ depends_on: [intent_lock]
305
+ description: Freeze allowed write paths, forbidden areas, tool policy, and escalation triggers.
306
+ enforce:
307
+ read_only: true
308
+ additional_write_paths: ["{{evidence_dir}}/**"]
309
+ handoff:
310
+ consumes:
311
+ - type: file
312
+ path: "{{evidence_dir}}/intent.md"
313
+ from: intent_lock
314
+ description: Locked intent.
315
+ produces:
316
+ - type: file
317
+ path: "{{evidence_dir}}/boundary.md"
318
+ description: Frozen rewrite boundary.
319
+ completion:
320
+ - file_contains: { path: "{{evidence_dir}}/boundary.md", pattern: "Allowed writes" }
321
+ prompt: |
322
+ Freeze rewrite boundary for module {{module}}.
323
+ Write {{evidence_dir}}/boundary.md with:
324
+ - Allowed writes: {{target_scope}}, {{test_path}}/**
325
+ - Forbidden areas
326
+ - Required context files
327
+ - Required checks: {{test_command}}
328
+ - Escalation triggers
329
+
330
+ - id: baseline_characterization
331
+ role: baseline_tester
332
+ depends_on: [boundary_freeze]
333
+ description: Capture baseline behavior before rewrite.
334
+ handoff:
335
+ consumes:
336
+ - type: file
337
+ path: "{{evidence_dir}}/boundary.md"
338
+ from: boundary_freeze
339
+ description: Frozen boundary.
340
+ produces:
341
+ - type: test_result
342
+ path: "{{evidence_dir}}/baseline.log"
343
+ description: Baseline test output before rewrite.
344
+ completion:
345
+ - file_not_empty: "{{evidence_dir}}/baseline.log"
346
+ checkpoints:
347
+ - assert: no_test_regression
348
+ command: "{{test_command}}"
349
+ action: warn
350
+ message: "Baseline command should run before rewrite; known failures must be recorded."
351
+ prompt: |
352
+ Capture baseline behavior for module {{module}} before code edits.
353
+ Run: {{test_command}}
354
+ Save output or concise transcript to {{evidence_dir}}/baseline.log.
355
+ Record known failures, skipped tests, and any command that cannot run.
356
+
357
+ - id: diagnosis
358
+ role: diagnosis_analyst
359
+ depends_on: [baseline_characterization]
360
+ description: Classify failures and missing behavior using v1 evidence.
361
+ enforce:
362
+ read_only: true
363
+ additional_write_paths: ["{{evidence_dir}}/**"]
364
+ handoff:
365
+ consumes:
366
+ - type: file
367
+ path: "{{evidence_dir}}/intent.md"
368
+ from: intent_lock
369
+ description: Locked intent.
370
+ - type: test_result
371
+ path: "{{evidence_dir}}/baseline.log"
372
+ from: baseline_characterization
373
+ description: Baseline output.
374
+ produces:
375
+ - type: file
376
+ path: "{{evidence_dir}}/diagnosis.md"
377
+ description: Evidence-only diagnosis classification.
378
+ completion:
379
+ - file_contains: { path: "{{evidence_dir}}/diagnosis.md", pattern: "Classification" }
380
+ prompt: |
381
+ Diagnose module {{module}} without editing code.
382
+ Write {{evidence_dir}}/diagnosis.md with:
383
+ - Classification table: BUG / UNIMPLEMENTED / INFRA / TEST_BUG / REMOVED
384
+ - v1 evidence path and snippet reference for each item
385
+ - v2 current state path for each item
386
+ - Baseline evidence reference
387
+ Do not include implementation order, prescriptions, or surgeon notes.
388
+
389
+ - id: rewrite
390
+ role: rewrite_surgeon
391
+ depends_on: [diagnosis]
392
+ description: Rewrite inside the frozen boundary while preserving behavior.
393
+ isolation: worktree
394
+ enforce:
395
+ additional_write_paths: ["{{target_scope}}", "{{test_path}}/**"]
396
+ handoff:
397
+ consumes:
398
+ - type: file
399
+ path: "{{evidence_dir}}/intent.md"
400
+ from: intent_lock
401
+ description: Locked intent.
402
+ - type: file
403
+ path: "{{evidence_dir}}/boundary.md"
404
+ from: boundary_freeze
405
+ description: Frozen boundary.
406
+ - type: file
407
+ path: "{{evidence_dir}}/diagnosis.md"
408
+ from: diagnosis
409
+ description: Diagnosis classification.
410
+ produces:
411
+ - type: summary
412
+ name: rewrite_summary
413
+ description: Summary of behavior-preserving rewrite changes.
414
+ checkpoints:
415
+ - assert: no_test_regression
416
+ command: "{{test_command}}"
417
+ action: warn
418
+ message: "Rewrite should keep the declared verification path non-regressing."
419
+ prompt: |
420
+ Rewrite module {{module}} inside the frozen boundary only.
421
+ Before editing, read {{evidence_dir}}/intent.md, boundary.md, diagnosis.md, and the relevant v1 source.
422
+ Preserve behavior exactly unless the intent file explicitly approves a delta.
423
+ Use v2 Flutter architecture conventions.
424
+ Run targeted checks after material changes.
425
+ Produce a concise rewrite_summary with files changed, diagnosis items addressed, and commands run.
426
+
427
+ - id: equivalence_verify
428
+ role: equivalence_verifier
429
+ depends_on: [rewrite]
430
+ description: Prove rewritten behavior is equivalent to v1 and baseline expectations.
431
+ handoff:
432
+ consumes:
433
+ - type: test_result
434
+ path: "{{evidence_dir}}/baseline.log"
435
+ from: baseline_characterization
436
+ description: Baseline output.
437
+ - type: summary
438
+ name: rewrite_summary
439
+ from: rewrite
440
+ description: Rewrite summary.
441
+ produces:
442
+ - type: test_result
443
+ path: "{{evidence_dir}}/equivalence.log"
444
+ description: Post-rewrite verification output.
445
+ - type: file
446
+ path: "{{evidence_dir}}/equivalence.md"
447
+ description: Equivalence verdict.
448
+ completion:
449
+ - file_contains: { path: "{{evidence_dir}}/equivalence.md", pattern: "Equivalent: yes" }
450
+ checkpoints:
451
+ - assert: no_test_regression
452
+ command: "{{test_command}}"
453
+ message: "Equivalence validation must pass or record a blocker before review."
454
+ prompt: |
455
+ Verify module {{module}} after rewrite.
456
+ Run: {{test_command}}
457
+ Save output to {{evidence_dir}}/equivalence.log.
458
+ Write {{evidence_dir}}/equivalence.md with:
459
+ - Equivalent: yes/no
460
+ - Baseline comparison
461
+ - v1 behavior evidence covered
462
+ - Remaining unimplemented / skipped / blocked behavior
463
+ - Any unverified behavior or residual risk
464
+
465
+ - id: review
466
+ role: rewrite_reviewer
467
+ depends_on: [equivalence_verify]
468
+ description: Review final diff and package evidence.
469
+ enforce:
470
+ read_only: true
471
+ additional_write_paths: ["{{evidence_dir}}/**"]
472
+ handoff:
473
+ consumes:
474
+ - type: file
475
+ path: "{{evidence_dir}}/intent.md"
476
+ from: intent_lock
477
+ description: Locked intent.
478
+ - type: file
479
+ path: "{{evidence_dir}}/boundary.md"
480
+ from: boundary_freeze
481
+ description: Frozen boundary.
482
+ - type: file
483
+ path: "{{evidence_dir}}/diagnosis.md"
484
+ from: diagnosis
485
+ description: Diagnosis.
486
+ - type: file
487
+ path: "{{evidence_dir}}/equivalence.md"
488
+ from: equivalence_verify
489
+ description: Equivalence verdict.
490
+ produces:
491
+ - type: file
492
+ path: "{{evidence_dir}}/evidence.md"
493
+ description: Final rewrite evidence package.
494
+ completion:
495
+ - file_contains: { path: "{{evidence_dir}}/evidence.md", pattern: "Verdict: APPROVE" }
496
+ prompt: |
497
+ Review module {{module}} rewrite evidence.
498
+ Write {{evidence_dir}}/evidence.md with:
499
+ - Intent summary
500
+ - Boundary summary
501
+ - Diagnosis items addressed
502
+ - Test/equivalence evidence
503
+ - RuntimeDecisionEvent or diagnostic evidence refs when available
504
+ - Unsupported or partial harness capability gaps
505
+ - Residual risks
506
+ - Verdict: APPROVE or REQUEST_CHANGES