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
@@ -5,6 +5,26 @@
5
5
  version: "0.1.0"
6
6
  id: template_flutter_rewrite
7
7
  name: Flutter Rewrite (Unified)
8
+ purpose: Govern a behavior-preserving Flutter v1 to v2 rewrite with evidence, review, and verification gates.
9
+ maturity: adopted
10
+ fit:
11
+ - Flutter module rewrites that must preserve v1 behavior.
12
+ - Dogfood-backed work needing behavior locks, diagnosis, fixes, and verification.
13
+ not_for:
14
+ - Feature redesign or product improvement during migration.
15
+ - Generic non-Flutter refactors without v1/v2 behavior equivalence constraints.
16
+ inputs:
17
+ - v1 source path
18
+ - v2 source path
19
+ - behavior documents
20
+ - diagnosis and progress evidence
21
+ outputs:
22
+ - governed rewrite workflow
23
+ - behavior lock artifacts
24
+ - verification and review evidence
25
+ lineage:
26
+ source: dogfood
27
+ reference: docs/archive/2026H1/references/flutter-rewrite-workflow-asset.md
8
28
  type: project
9
29
  namespace: frw
10
30
 
@@ -132,9 +152,11 @@ context_files:
132
152
  analysis_reviewer:
133
153
  - "docs/behavior/{{ARGUMENTS}}.md"
134
154
  - ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
155
+ - ".dna/specs/diagnosis-{{ARGUMENTS}}.contract.json"
135
156
  surgeon:
136
157
  - ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
137
158
  - ".dna/specs/diagnosis-{{ARGUMENTS}}.review.json"
159
+ - ".dna/specs/diagnosis-{{ARGUMENTS}}.contract.json"
138
160
  fix_reviewer:
139
161
  - "docs/behavior/{{ARGUMENTS}}.md"
140
162
  - ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
@@ -143,6 +165,8 @@ context_files:
143
165
  - ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
144
166
 
145
167
  verifier_policy:
168
+ allow_commands:
169
+ - "node -e \"const fs=require('node:fs'); const crypto=require('node:crypto'); const moduleName=process.env.ARGUMENTS || '$ARGUMENTS'; const path='.dna/specs/diagnosis-'+moduleName+'.contract.json'; const allowed=['BUG','UNIMPLEMENTED','INFRA','REMOVED','TEST_BUG']; const fail=(m)=>{throw new Error(m)}; const data=JSON.parse(fs.readFileSync(path,'utf8')); const same=(a,b)=>Array.isArray(a)&&a.length===b.length&&a.every((v,i)=>v===b[i]); if(data.contract_version!=='diagnosis-contract/v1')fail('contract_version'); if(!same(data.allowed_kinds,allowed))fail('allowed_kinds'); const observed=Array.isArray(data.observed_failures)?data.observed_failures:fail('observed_failures'); const work=Array.isArray(data.work_items)?data.work_items:fail('work_items'); if(observed.length===0)fail('empty_observed_failures'); if(work.length===0)fail('empty_work_items'); const ids=new Set(observed.map(x=>x&&x.id).filter(Boolean)); if(ids.size!==observed.length)fail('observed_failure_ids'); for(const f of observed){ if(!Array.isArray(f.evidence_paths)||f.evidence_paths.length===0)fail('observed_failure_evidence'); if(f.kind!==undefined)fail('observed_failure_kind_forbidden'); } const mapped=new Set(); for(const item of work){ if(!allowed.includes(item.kind))fail('invalid_kind'); if(item.kind==='PLACEHOLDER_CONTRACT')fail('placeholder_kind'); if(!Array.isArray(item.observed_failure_ids)||item.observed_failure_ids.length===0)fail('work_item_observed_failure_ids'); if(!Array.isArray(item.evidence_paths)||item.evidence_paths.length===0)fail('work_item_evidence'); for(const id of item.observed_failure_ids){ if(!ids.has(id))fail('unknown_observed_failure_id'); mapped.add(id); } } if(mapped.size!==ids.size)fail('unmapped_observed_failures'); const counts=data.baseline&&data.baseline.counts; if(!data.baseline||!data.baseline.source_path||!counts)fail('baseline'); const total=(counts.failed||0)+(counts.skipped||0)+(counts.hung||0); if(total!==observed.length)fail('baseline_count_mismatch'); const summary=data.summary_counts||{}; for(const kind of allowed){ if(!Number.isInteger(summary[kind])||summary[kind]!==work.filter(x=>x.kind===kind).length)fail('summary_count_'+kind); } const snap=data.contract_snapshot||{}; if(snap.observed_failure_count!==observed.length||snap.work_item_count!==work.length||!same(snap.allowed_kinds,allowed)||!snap.baseline_source_sha256||!snap.diagnosis_artifact_sha256)fail('contract_snapshot'); if(data.staleness&&data.staleness.is_stale===true)fail('stale_contract'); crypto.createHash('sha256').update(JSON.stringify(data)).digest('hex');\""
146
170
  allow_builtin_asserts:
147
171
  - clean_working_tree
148
172
 
@@ -235,6 +259,9 @@ roles:
235
259
  - "For each failing, skipped, and hung test: read test code + v1 impl + v2 impl"
236
260
  - "Classify each as BUG / UNIMPLEMENTED / INFRA / REMOVED / TEST_BUG (skipped tests are usually UNIMPLEMENTED)"
237
261
  - "Output diagnosis spec with v1 code snippets + v2 current state + evidence paths"
262
+ - "Also write .dna/specs/diagnosis-$ARGUMENTS.contract.json as the structured sidecar mapping baseline observed_failures to diagnosis work_items"
263
+ - "The sidecar allowed_kinds array must be exactly BUG, UNIMPLEMENTED, INFRA, REMOVED, TEST_BUG in that order; PLACEHOLDER_CONTRACT is never a kind"
264
+ - "A placeholder-contract symptom may appear only in observed_failures.symptom and must map to concrete TEST_BUG and/or UNIMPLEMENTED work_items with evidence"
238
265
  - "If reanalyzing after REQUEST_REANALYSIS, update every reviewer sections_to_fix item and report sections_updated"
239
266
  - "DO NOT include fix prescriptions, implementation order, call-site instructions, or Notes for Surgeon"
240
267
  - "DO NOT run tests. DO NOT edit app code. Analysis only."
@@ -250,9 +277,10 @@ roles:
250
277
  instructions:
251
278
  - "REQUIRED FIRST: Read all context files listed in SKILL.md"
252
279
  - "Verify analyzer spec: v1 references exist? Classifications sound?"
280
+ - "Independently validate .dna/specs/diagnosis-$ARGUMENTS.contract.json against the template sidecar contract; do not use Bash"
253
281
  - "Check missing: any failing test not covered?"
254
282
  - "Verify diagnosis remains evidence-only: no fix prescriptions, implementation order, call-site instructions, or Notes for Surgeon"
255
- - "Output a structured verdict block with verdict, artifact_reviewed, sections_to_fix, evidence_paths, confidence, summary, and updated_at"
283
+ - "Output a structured verdict block with contract_version, contract_valid, failure_reason, contract_artifact_reviewed, contract_snapshot, verdict, artifact_reviewed, sections_to_fix, evidence_paths, confidence, summary, and updated_at"
256
284
  - "Write the same structured verdict JSON to .dna/specs/diagnosis-$ARGUMENTS.review.json before finishing"
257
285
 
258
286
  fix_reviewer:
@@ -307,9 +335,12 @@ controllers:
307
335
  policy:
308
336
  diagnosis_reuse_criteria:
309
337
  - "$diagnosis_artifact_path exists"
338
+ - ".dna/specs/diagnosis-$ARGUMENTS.contract.json exists and passes the exact verifier_policy allow_commands node -e completion.command_success validator"
310
339
  - "$diagnosis_review_artifact_path exists and verdict is APPROVE"
340
+ - "$diagnosis_review_artifact_path contract_valid is true and contract_artifact_reviewed equals .dna/specs/diagnosis-$ARGUMENTS.contract.json"
311
341
  - "behavior doc is not newer than diagnosis spec"
312
342
  - "baseline artifact is not newer than diagnosis spec"
343
+ - "baseline artifact is not newer than diagnosis contract sidecar"
313
344
  - "user did not explicitly pass reanalyze or scope changed"
314
345
  - "progress JSON does not say diagnosis_invalid"
315
346
  progress_provenance_checks:
@@ -326,12 +357,14 @@ controllers:
326
357
  - "CONTINUE -> next fresh context fix round"
327
358
  - "REQUEST_CHANGES -> stop with the configured stop report"
328
359
  - "BLOCKED -> stop with the configured stop report"
360
+ - "DIAGNOSIS_CONTRACT_INVALID -> stop before fix with Verdict BLOCKED, failure_reason DIAGNOSIS_CONTRACT_INVALID, and progress diagnosis_invalid true"
329
361
  verdict_mapping:
330
362
  - "PASS / CONTINUE / REQUEST_CHANGES / BLOCKED mapping:"
331
363
  - "- PASS: success stop"
332
364
  - "- CONTINUE: start the next fresh context round"
333
365
  - "- REQUEST_CHANGES: stop, report reviewer/verifier requested changes"
334
366
  - "- BLOCKED: stop, report blocker"
367
+ - "- DIAGNOSIS_CONTRACT_INVALID: stop before fix, propagate diagnosis_invalid true in progress JSON, and require /dna-frw-diagnosis reanalysis"
335
368
  - "- MAX_ROUNDS: stop, report max rounds reached and next focus"
336
369
  stop_report:
337
370
  - "On REQUEST_CHANGES, BLOCKED, or MAX_ROUNDS, output exactly these Chinese sections:"
@@ -343,6 +376,7 @@ controllers:
343
376
  - "Do not infer module completion from raw test output."
344
377
  - "The controller must schedule only from $progress_artifact_path."
345
378
  - "Manual /dna-frw-diagnosis and /dna-frw-fix flows remain separate and available."
379
+ - "Manual /dna-frw-fix must run the same diagnosis contract preflight before edits and stop with DIAGNOSIS_CONTRACT_INVALID when the sidecar or independent review contract is invalid."
346
380
  - "Do not use the generic workflow policy block; branch only from the progress JSON verdict."
347
381
 
348
382
  workflows:
@@ -443,12 +477,33 @@ workflows:
443
477
  - Evidence paths for every classification
444
478
  - NO fix prescriptions, implementation order, call-site instructions, or "Notes for Surgeon"
445
479
  - NO running tests (analysis only)
446
- 6. If this is a reanalysis after REQUEST_REANALYSIS, read the reviewer verdict first, update every section listed in sections_to_fix plus the summary table, and report sections_updated in your final response. Reanalysis is not successful unless the spec artifact is rewritten.
480
+ 6. Write .dna/specs/diagnosis-$ARGUMENTS.contract.json with this sidecar contract:
481
+ - contract_version: "diagnosis-contract/v1"
482
+ - module: "$ARGUMENTS"
483
+ - diagnosis_artifact: ".dna/specs/diagnosis-$ARGUMENTS.md"
484
+ - baseline: { "source_path": "structured baseline path or explicit fallback file", "counts": { "failed": N, "skipped": N, "hung": N } }
485
+ - allowed_kinds: ["BUG", "UNIMPLEMENTED", "INFRA", "REMOVED", "TEST_BUG"] exactly, no extra values
486
+ - observed_failures: one entry per failing/skipped/hung test with id, test_name, symptom, evidence_paths, and no kind field
487
+ - work_items: one or more entries mapping observed_failure_ids to kind, evidence_paths, v1_evidence_paths, and v2_evidence_paths
488
+ - summary_counts: exact count of work_items by BUG / UNIMPLEMENTED / INFRA / REMOVED / TEST_BUG
489
+ - contract_snapshot: baseline_source_sha256, diagnosis_artifact_sha256, observed_failure_count, work_item_count, allowed_kinds
490
+ - staleness: source mtimes or hashes for behavior_doc, baseline, diagnosis_artifact, and is_stale false
491
+ 7. Contract rules:
492
+ - observed_failures must not be empty; work_items must not be empty.
493
+ - Every observed_failure id must be mapped by at least one work_item.
494
+ - Every work_item kind must be one of the five allowed kinds exactly.
495
+ - PLACEHOLDER_CONTRACT is forbidden as a kind. If a placeholder-contract symptom exists, keep it in observed_failures.symptom and map it to concrete TEST_BUG and/or UNIMPLEMENTED work_items with evidence.
496
+ - REMOVED may be diagnosed but must be marked manual/user-approved before any future fix can execute it.
497
+ - Mixed unknown kinds, missing evidence, count mismatches, missing/changed contract_snapshot, and stale baseline/diagnosis snapshots make the contract invalid.
498
+ 8. If this is a reanalysis after REQUEST_REANALYSIS or DIAGNOSIS_CONTRACT_INVALID, read the reviewer verdict first, update every section listed in sections_to_fix plus the summary table and contract sidecar, and report sections_updated in your final response. Reanalysis is not successful unless both the spec artifact and contract sidecar are rewritten.
447
499
  handoff:
448
500
  produces:
449
501
  - type: file
450
502
  path: ".dna/specs/diagnosis-$ARGUMENTS.md"
451
503
  description: "Diagnosis spec for module"
504
+ - type: file
505
+ path: ".dna/specs/diagnosis-$ARGUMENTS.contract.json"
506
+ description: "Structured diagnosis contract sidecar mapping baseline observed failures to work items"
452
507
 
453
508
  - id: review
454
509
  role: analysis_reviewer
@@ -464,10 +519,32 @@ workflows:
464
519
  3. Classifications reasonable? (INFRA not mistaken for BUG)
465
520
  4. Enough evidence detail for surgeon to act without adding fix prescriptions?
466
521
  5. Diagnosis remains evidence-only: no implementation order, call-site instructions, or "Notes for Surgeon"?
522
+ 6. .dna/specs/diagnosis-$ARGUMENTS.contract.json satisfies the structured sidecar contract:
523
+ - contract_version is "diagnosis-contract/v1"
524
+ - allowed_kinds is exactly ["BUG", "UNIMPLEMENTED", "INFRA", "REMOVED", "TEST_BUG"]
525
+ - observed_failures and work_items are non-empty and every observed_failure is mapped
526
+ - baseline counts equal observed_failures count
527
+ - summary_counts match work_items by kind
528
+ - every work_item has evidence_paths and only allowed kinds
529
+ - PLACEHOLDER_CONTRACT is rejected as a kind but placeholder-contract symptoms are allowed when mapped to TEST_BUG and/or UNIMPLEMENTED
530
+ - contract_snapshot includes diagnosis_artifact_sha256, baseline_source_sha256, observed_failure_count, work_item_count, and allowed_kinds
531
+ - staleness.is_stale is false; stale baseline/diagnosis/contract snapshots are invalid
532
+ - REMOVED work_items are reviewable diagnosis facts only and must not authorize automatic fix execution
467
533
 
468
534
  Output exactly one structured verdict block:
469
535
  ```json
470
536
  {
537
+ "contract_version": "diagnosis-contract-review/v1",
538
+ "contract_valid": true,
539
+ "failure_reason": "",
540
+ "contract_artifact_reviewed": ".dna/specs/diagnosis-$ARGUMENTS.contract.json",
541
+ "contract_snapshot": {
542
+ "baseline_source_sha256": "sha256 from contract sidecar",
543
+ "diagnosis_artifact_sha256": "sha256 from contract sidecar",
544
+ "observed_failure_count": 0,
545
+ "work_item_count": 0,
546
+ "allowed_kinds": ["BUG", "UNIMPLEMENTED", "INFRA", "REMOVED", "TEST_BUG"]
547
+ },
471
548
  "verdict": "APPROVE" | "REQUEST_REANALYSIS",
472
549
  "artifact_reviewed": ".dna/specs/diagnosis-$ARGUMENTS.md",
473
550
  "sections_to_fix": ["section ids or titles; empty when approved"],
@@ -481,16 +558,21 @@ workflows:
481
558
  Write the same verdict JSON to .dna/specs/diagnosis-$ARGUMENTS.review.json before finishing.
482
559
 
483
560
  APPROVE → diagnosis complete.
484
- REQUEST_REANALYSIS → sections_to_fix must be passed back to analyze. docs/behavior/blocked_items.md is historical context only and must not be treated as the current run verdict.
561
+ REQUEST_REANALYSIS → sections_to_fix must be passed back to analyze. If contract_valid is false, set failure_reason to DIAGNOSIS_CONTRACT_INVALID and include the exact invalid rule in sections_to_fix. docs/behavior/blocked_items.md is historical context only and must not be treated as the current run verdict.
562
+ completion:
563
+ - command_success: "node -e \"const fs=require('node:fs');const crypto=require('node:crypto');const path=require('node:path');const mod=process.env.ARGUMENTS||'$ARGUMENTS';const allowed=['BUG','UNIMPLEMENTED','INFRA','REMOVED','TEST_BUG'];const action=['BUG','UNIMPLEMENTED','INFRA','TEST_BUG'];const fail=m=>{throw new Error(m)};const same=(a,b)=>Array.isArray(a)&&a.length===b.length&&a.every((v,i)=>v===b[i]);const root=process.cwd();const inside=p=>{if(typeof p!=='string'||!p||path.isAbsolute(p))fail('path_invalid');const r=path.resolve(root,p);if(r!==root&&!r.startsWith(root+path.sep))fail('path_escape');return r};const readJson=p=>JSON.parse(fs.readFileSync(inside(p),'utf8'));if(!/^[A-Za-z0-9_-]+$/.test(mod))fail('module');const contractPath='.dna/specs/diagnosis-'+mod+'.contract.json';const reviewPath='.dna/specs/diagnosis-'+mod+'.review.json';const diagnosisPath='.dna/specs/diagnosis-'+mod+'.md';const data=readJson(contractPath);if(data.contract_version!=='diagnosis-contract/v1')fail('contract_version');if(data.module!==mod)fail('module_mismatch');if(data.diagnosis_artifact!==diagnosisPath)fail('diagnosis_artifact_path');if(!same(data.allowed_kinds,allowed))fail('allowed_kinds');const observed=Array.isArray(data.observed_failures)?data.observed_failures:fail('observed_failures');const work=Array.isArray(data.work_items)?data.work_items:fail('work_items');if(!observed.length)fail('empty_observed_failures');if(!work.length)fail('empty_work_items');const ids=new Set(observed.map(x=>x&&x.id).filter(Boolean));if(ids.size!==observed.length)fail('observed_failure_ids');const failureById=new Map();for(const f of observed){if(typeof f.test_name!=='string'||!f.test_name.trim())fail('observed_failure_test_name');if(typeof f.symptom!=='string'||!f.symptom.trim())fail('observed_failure_symptom');if(!Array.isArray(f.evidence_paths)||!f.evidence_paths.length)fail('observed_failure_evidence');for(const p of f.evidence_paths)inside(p);if(f.kind!==undefined)fail('observed_failure_kind_forbidden');failureById.set(f.id,f)}const mapped=new Set();for(const item of work){if(!allowed.includes(item.kind))fail('invalid_kind');if(item.kind==='PLACEHOLDER_CONTRACT')fail('placeholder_kind');if(!Array.isArray(item.observed_failure_ids)||!item.observed_failure_ids.length)fail('work_item_observed_failure_ids');if(!Array.isArray(item.evidence_paths)||!item.evidence_paths.length)fail('work_item_evidence');for(const p of item.evidence_paths)inside(p);if(action.includes(item.kind)){if(!Array.isArray(item.v1_evidence_paths)||!item.v1_evidence_paths.length)fail('work_item_v1_evidence');if(!Array.isArray(item.v2_evidence_paths)||!item.v2_evidence_paths.length)fail('work_item_v2_evidence');for(const p of item.v1_evidence_paths)inside(p);for(const p of item.v2_evidence_paths)inside(p)}for(const id of item.observed_failure_ids){const f=failureById.get(id);if(!f)fail('unknown_observed_failure_id');if(action.includes(item.kind)&&(!f.test_name||!String(f.test_name).trim()))fail('action_test_evidence');mapped.add(id)}}if(mapped.size!==ids.size)fail('unmapped_observed_failures');for(const f of observed.filter(x=>String(x.symptom).includes('PLACEHOLDER_CONTRACT'))){const kinds=new Set(work.filter(i=>i.observed_failure_ids.includes(f.id)).map(i=>i.kind));if(![...kinds].every(k=>k==='TEST_BUG'||k==='UNIMPLEMENTED')||kinds.size===0)fail('placeholder_mapping')}const counts=data.baseline&&data.baseline.counts;if(!data.baseline||data.baseline.source_path!=='.dna/baselines/'+mod+'.json'||!counts)fail('baseline');const total=(counts.failed||0)+(counts.skipped||0)+(counts.hung||0);if(total!==observed.length)fail('baseline_count_mismatch');const summary=data.summary_counts||{};for(const kind of allowed){if(!Number.isInteger(summary[kind])||summary[kind]!==work.filter(x=>x.kind===kind).length)fail('summary_count_'+kind)}const sha=p=>crypto.createHash('sha256').update(fs.readFileSync(inside(p))).digest('hex');const snap=data.contract_snapshot||{};if(snap.observed_failure_count!==observed.length||snap.work_item_count!==work.length||!same(snap.allowed_kinds,allowed))fail('contract_snapshot');if(snap.baseline_source_sha256!==sha(data.baseline.source_path))fail('baseline_sha256');if(snap.diagnosis_artifact_sha256!==sha(diagnosisPath))fail('diagnosis_sha256');if(!data.staleness||data.staleness.is_stale!==false)fail('stale_contract');const review=readJson(reviewPath);if(review.contract_version!=='diagnosis-contract-review/v1')fail('review_contract_version');if(review.contract_valid!==true)fail('review_contract_valid');if(review.verdict!=='APPROVE')fail('review_verdict');if(review.contract_artifact_reviewed!==contractPath)fail('review_contract_artifact_path');if(review.artifact_reviewed!==diagnosisPath)fail('review_artifact_path');if(JSON.stringify(review.contract_snapshot)!==JSON.stringify(snap))fail('review_contract_snapshot');if(!Array.isArray(review.evidence_paths)||!review.evidence_paths.length)fail('review_evidence_paths');for(const p of review.evidence_paths)inside(p);const cm=fs.statSync(inside(contractPath)).mtimeMs;const dm=fs.statSync(inside(diagnosisPath)).mtimeMs;const rm=fs.statSync(inside(reviewPath)).mtimeMs;if(rm<cm||rm<dm)fail('review_stale');\""
485
564
  handoff:
486
565
  consumes:
487
566
  - type: file
488
567
  path: ".dna/specs/diagnosis-$ARGUMENTS.md"
489
568
  description: "Diagnosis spec from analyzer"
569
+ - type: file
570
+ path: ".dna/specs/diagnosis-$ARGUMENTS.contract.json"
571
+ description: "Diagnosis contract sidecar from analyzer"
490
572
  produces:
491
573
  - type: file
492
574
  path: ".dna/specs/diagnosis-$ARGUMENTS.review.json"
493
- description: "Durable diagnosis review verdict (APPROVE or REQUEST_REANALYSIS)"
575
+ description: "Durable diagnosis review verdict with independent contract validation (APPROVE or REQUEST_REANALYSIS)"
494
576
  - type: summary
495
577
  required: false
496
578
  description: "Review verdict (APPROVE or REQUEST_REANALYSIS)"
@@ -508,6 +590,9 @@ workflows:
508
590
 
509
591
  Before editing, read .dna/specs/diagnosis-$ARGUMENTS.review.json.
510
592
  - If it is missing, invalid, or verdict is not APPROVE, stop immediately; do not edit.
593
+ - Also read .dna/specs/diagnosis-$ARGUMENTS.contract.json and perform the same preflight used by the diagnosis review completion validator before any Edit.
594
+ - If the sidecar is missing, invalid, stale, has unmapped observed_failures, bad counts, bad snapshot, unsupported kinds, or review contract_valid is not true, stop before edits with DIAGNOSIS_CONTRACT_INVALID.
595
+ - If stopping for DIAGNOSIS_CONTRACT_INVALID, write/update .dna/fix-progress/$ARGUMENTS.json with verdict BLOCKED, failure_reason DIAGNOSIS_CONTRACT_INVALID, diagnosis_invalid true, and evidence_paths naming the sidecar/review problem; also update the markdown progress artifact.
511
596
  - Manual fix invocations must obey this same gate.
512
597
  - If verdict is REQUEST_REANALYSIS, run diagnosis reanalysis first instead of fixing.
513
598
 
@@ -525,6 +610,7 @@ workflows:
525
610
 
526
611
  Otherwise process issues in priority order: INFRA → BUG → TEST_BUG → UNIMPLEMENTED.
527
612
  REMOVED is always skipped unless the user explicitly approved handling it.
613
+ REMOVED must never be auto-executed from diagnosis contract membership alone.
528
614
 
529
615
  For each issue:
530
616
  - BUG: read v1 file, edit v2 (use Riverpod per refactoring-workflow-v2.md)
@@ -545,6 +631,9 @@ workflows:
545
631
  - type: file
546
632
  path: ".dna/specs/diagnosis-$ARGUMENTS.md"
547
633
  description: "Diagnosis spec"
634
+ - type: file
635
+ path: ".dna/specs/diagnosis-$ARGUMENTS.contract.json"
636
+ description: "Validated diagnosis contract sidecar"
548
637
  - type: file
549
638
  path: ".dna/specs/diagnosis-$ARGUMENTS.review.json"
550
639
  description: "Approved diagnosis review gate"
@@ -643,6 +732,7 @@ workflows:
643
732
  - review REQUEST_CHANGES without safe actionable scope -> Verdict: BLOCKED, Failure reason: BLOCKED_BY_REVIEW.
644
733
  - 0 failed + remaining UNIMPLEMENTED skipped > 0 -> Verdict: CONTINUE, Module complete: no, Next Round Focus: next diagnosis-backed UNIMPLEMENTED test/evidence path.
645
734
  - progress contradicts diagnosis/test evidence -> Verdict: BLOCKED, Failure reason: PROGRESS_DIAGNOSIS_CONFLICT.
735
+ - diagnosis contract preflight failed -> Verdict: BLOCKED, Failure reason: DIAGNOSIS_CONTRACT_INVALID, diagnosis_invalid: true.
646
736
  - new red caused by current round -> Verdict: REQUEST_CHANGES.
647
737
  - new red appears to be newly exposed baseline gap AND remaining count decreases -> Verdict: CONTINUE.
648
738
  - ambiguous new red -> Verdict: BLOCKED, Failure reason: AMBIGUOUS_NEW_RED.
@@ -657,6 +747,7 @@ workflows:
657
747
  - Blocked: K tests skipped for TEST_BUG / INFRA / REMOVED / user-approved blocked reasons
658
748
  - Remaining: R tests still failing or diagnosis-backed UNIMPLEMENTED skipped
659
749
  - Remaining UNIMPLEMENTED skipped: U diagnosis-backed skipped tests still remaining
750
+ - Diagnosis invalid: true/false
660
751
  - Failure reason: why progress stopped, if any
661
752
  - Next round focus: the priority/classification/test file to continue with, if verdict is CONTINUE or REQUEST_CHANGES
662
753
  - Rollback decision: say whether the current round commit should be reverted or fixed forward, with one plain-language reason
@@ -692,6 +783,7 @@ workflows:
692
783
  "blocked_count": 0,
693
784
  "remaining_count": 0,
694
785
  "remaining_unimplemented_skipped_count": 0,
786
+ "diagnosis_invalid": false,
695
787
  "next_round_focus": "",
696
788
  "failure_reason": "",
697
789
  "last_fix_commit": null,
@@ -712,6 +804,7 @@ workflows:
712
804
  - actionability, scope, and risk are required and must mirror the review verdict when review is REQUEST_CHANGES; use none/none/none when review is APPROVE.
713
805
  - module_complete is a required boolean and must match the Markdown Module complete value.
714
806
  - fixed_count, new_red_count, blocked_count, remaining_count, and remaining_unimplemented_skipped_count are required non-negative integers.
807
+ - diagnosis_invalid is a required boolean; set true only when failure_reason is DIAGNOSIS_CONTRACT_INVALID.
715
808
  - next_round_focus is required and non-empty when verdict is CONTINUE or REQUEST_CHANGES; empty string is allowed when verdict is PASS.
716
809
  - failure_reason is required and non-empty when verdict is BLOCKED or REQUEST_CHANGES; empty string is allowed when verdict is PASS or CONTINUE. When review REQUEST_CHANGES is normalized to verdict CONTINUE, keep reviewer failure details in Review Issues To Address First instead of failure_reason.
717
810
  - last_fix_commit is the commit hash string if available, otherwise null.
@@ -737,6 +830,9 @@ workflows:
737
830
  - type: file
738
831
  path: ".dna/specs/diagnosis-$ARGUMENTS.md"
739
832
  description: "Diagnosis spec"
833
+ - type: file
834
+ path: ".dna/specs/diagnosis-$ARGUMENTS.contract.json"
835
+ description: "Diagnosis contract sidecar"
740
836
  produces:
741
837
  - type: file
742
838
  path: ".dna/fix-progress/$ARGUMENTS.md"
@@ -5,6 +5,25 @@
5
5
  version: "0.1.0"
6
6
  id: template_frontend_quality
7
7
  name: Frontend Quality Standards
8
+ purpose: Provide frontend implementation guardrails for accessibility, performance, design fidelity, and framework best practices.
9
+ maturity: draft
10
+ fit:
11
+ - React, Next.js, Vue, or similar frontend work needing a local quality baseline.
12
+ - UI implementation where accessibility, responsive layout, and performance must stay visible.
13
+ not_for:
14
+ - Replacing visual QA, Playwright checks, or design review evidence.
15
+ - Claiming Online runtime authority from browser UI.
16
+ inputs:
17
+ - UI route or component scope
18
+ - design and accessibility requirements
19
+ - framework and performance constraints
20
+ outputs:
21
+ - frontend quality guardrails
22
+ - accessibility and performance review notes
23
+ - design-fidelity checklist
24
+ lineage:
25
+ source: built-in frontend quality standards template
26
+ reference: src/templates/frontend-quality.dna.yaml
8
27
  type: project
9
28
  namespace: fe
10
29
 
@@ -5,6 +5,26 @@
5
5
  version: "0.1.0"
6
6
  id: template_full_pipeline
7
7
  name: Full Development Pipeline
8
+ purpose: Run a complete plan, implement, test, review, and release-note pipeline for feature work that needs staged evidence.
9
+ maturity: reviewed
10
+ fit:
11
+ - Product or engineering tasks that need design, implementation, verification, and review stages.
12
+ - Work where acceptance criteria and release notes must stay connected to code changes.
13
+ not_for:
14
+ - Tiny one-command fixes that do not need a full team workflow.
15
+ - Skipping tests or review because implementation appears complete.
16
+ inputs:
17
+ - requirement or task brief
18
+ - codebase context
19
+ - acceptance criteria and verification commands
20
+ outputs:
21
+ - design document
22
+ - implementation diff
23
+ - test evidence and review report
24
+ - release notes
25
+ lineage:
26
+ source: Superpowers-inspired plan/implement/test/review workflow shape
27
+ reference: src/templates/full-pipeline.dna.yaml
8
28
  type: project
9
29
  namespace: fp
10
30
 
@@ -0,0 +1,92 @@
1
+ import { type TemplateCatalogEntry } from "./catalog.js";
2
+ export type TemplateVisibility = "public" | "personal" | "internal_ready";
3
+ export type TemplateHarness = "claude_code" | "codex_cli";
4
+ export type TemplateEvidencePosture = "explicit_gap" | "example" | "dogfood";
5
+ export type TemplateAssetMaturity = "draft" | "reviewed" | "dogfood" | "internal_ready";
6
+ export type TemplateSyncSurface = "markdown_injection" | "compiled_ir" | "claude_mcp" | "claude_settings_hooks" | "claude_agents" | "claude_skills" | "workflow_scripts" | "codex_adapter";
7
+ export interface TemplateEvidenceExample {
8
+ label: string;
9
+ path: string;
10
+ kind: "doc" | "dogfood" | "reference";
11
+ description?: string;
12
+ }
13
+ export interface TemplateEvidenceGap {
14
+ status: "needs_local_evidence" | "covered_by_examples";
15
+ summary: string;
16
+ nextCommands: string[];
17
+ acceptanceCriteria: string[];
18
+ notEvidence: string[];
19
+ }
20
+ export interface TemplateAssetRelation {
21
+ relatedTemplate: string;
22
+ relation: "main_workflow" | "reusable_loop" | "followup_draft" | "companion_asset";
23
+ purpose: string;
24
+ preserves: string[];
25
+ nextCommands: string[];
26
+ notAllowedToImply: string[];
27
+ }
28
+ export interface TemplateMarketplaceMetadata {
29
+ visibility: TemplateVisibility;
30
+ purpose: string;
31
+ fit: string[];
32
+ inputs: string[];
33
+ outputs: string[];
34
+ assetRelations: TemplateAssetRelation[];
35
+ evidencePosture: TemplateEvidencePosture;
36
+ evidenceGap: TemplateEvidenceGap;
37
+ maturity: TemplateAssetMaturity;
38
+ lifecycleGuide: {
39
+ state: TemplateVisibility;
40
+ meaning: string;
41
+ availableNow: string[];
42
+ nextStep: string;
43
+ notAllowedToImply: string[];
44
+ };
45
+ supportedHarnesses: TemplateHarness[];
46
+ requiredDnaVersion: string;
47
+ syncSurfaces: TemplateSyncSurface[];
48
+ evidenceExamples: TemplateEvidenceExample[];
49
+ install: {
50
+ command: string;
51
+ syncCommands: string[];
52
+ };
53
+ review: {
54
+ inspectCommand: string;
55
+ adoptionCommand: string;
56
+ orgBindCommand: string;
57
+ orgReviewCommand: string;
58
+ rolloutCommand: string;
59
+ boundary: string;
60
+ };
61
+ }
62
+ export interface TemplateMarketplaceCatalogItem {
63
+ name: string;
64
+ displayName?: string;
65
+ namespace?: string;
66
+ version?: string;
67
+ source: TemplateCatalogEntry["source"];
68
+ contentHash: string;
69
+ keywords: readonly string[];
70
+ marketplace: TemplateMarketplaceMetadata;
71
+ }
72
+ export interface TemplateMarketplaceCatalog {
73
+ schema_version: "intentdna.template_marketplace_catalog.v1";
74
+ generated_at: string;
75
+ totals: {
76
+ templates: number;
77
+ public: number;
78
+ personal: number;
79
+ internal_ready: number;
80
+ claude_code: number;
81
+ codex_cli: number;
82
+ };
83
+ items: TemplateMarketplaceCatalogItem[];
84
+ boundaries: string[];
85
+ }
86
+ export declare function getTemplateMarketplaceMetadata(template: TemplateCatalogEntry, options?: {
87
+ content?: string;
88
+ }): Promise<TemplateMarketplaceMetadata>;
89
+ export declare function buildTemplateMarketplaceCatalog(options?: {
90
+ projectDir?: string;
91
+ generatedAt?: string;
92
+ }): Promise<TemplateMarketplaceCatalog>;