qfai 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +327 -55
  2. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  3. package/assets/defaults/workflows/change-tooling.yml +0 -4
  4. package/assets/defaults/workflows/run-owned-cleanup.yml +12 -0
  5. package/assets/init/.claude/settings.json +27 -9
  6. package/assets/init/.codex/hooks.json +20 -8
  7. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +5 -0
  8. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +14 -1
  9. package/assets/init/.qfai/assistant/agent/product-experience-architect.md +4 -0
  10. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +7 -0
  11. package/assets/init/.qfai/assistant/agent/qa-gatekeeper.md +29 -0
  12. package/assets/init/.qfai/assistant/agent/requirements-analyst.md +8 -0
  13. package/assets/init/.qfai/assistant/rule/communication.md +18 -8
  14. package/assets/init/.qfai/assistant/rule/constitution.md +5 -4
  15. package/assets/init/.qfai/assistant/rule/drift-protocol.md +72 -5
  16. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +72 -0
  17. package/assets/init/.qfai/assistant/rule/references/context-summary.md +30 -0
  18. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +42 -0
  19. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +23 -0
  20. package/assets/init/.qfai/assistant/rule/references/host-backstops.md +60 -0
  21. package/assets/init/.qfai/assistant/rule/references/placeholder-scan.md +25 -0
  22. package/assets/init/.qfai/assistant/rule/references/reviewer-findings.md +41 -0
  23. package/assets/init/.qfai/assistant/rule/references/reviewer-remit.md +35 -0
  24. package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +48 -0
  25. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +39 -162
  26. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +14 -145
  27. package/assets/init/.qfai/assistant/rule/stage-cost.md +1 -1
  28. package/assets/init/.qfai/assistant/rule/test-layers.md +42 -0
  29. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +6 -1
  30. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +11 -45
  31. package/assets/init/.qfai/assistant/skill/qfai-configure/references/principles.md +25 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +1 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +12 -9
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +2 -4
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/platform_baselines.md +11 -0
  36. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/review_audit_playbook.md +11 -0
  37. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +13 -42
  38. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +0 -16
  39. package/assets/init/.qfai/assistant/skill/qfai-grill/SKILL.md +1 -1
  40. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +16 -88
  41. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +58 -0
  42. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +42 -0
  43. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +17 -4
  44. package/assets/init/.qfai/assistant/skill/qfai-implement/references/credential-reuse.md +9 -0
  45. package/assets/init/.qfai/assistant/skill/qfai-implement/references/cross-spec-ownership.md +41 -0
  46. package/assets/init/.qfai/assistant/skill/qfai-implement/references/oracle-strength.md +6 -1
  47. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +9 -1
  48. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +47 -1
  49. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +4 -3
  50. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +4 -4
  51. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +16 -10
  52. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +10 -260
  53. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +273 -0
  54. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +5 -4
  55. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/design-md-spec.md +14 -5
  56. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +10 -0
  57. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +1 -1
  58. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +3 -4
  59. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +12 -5
  60. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +33 -4
  61. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +34 -36
  62. package/assets/init/.qfai/assistant/skill/qfai-run/references/evidence-delivery.md +322 -0
  63. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +67 -24
  64. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +246 -5
  65. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +29 -5
  66. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +43 -0
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +5 -4
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +10 -1
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +22 -9
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +41 -6
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +11 -5
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-brand-catalog.md +17 -2
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +10 -2
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +34 -9
  75. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +4 -4
  76. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  77. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +177 -7
  78. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +29 -5
  79. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +130 -1
  80. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +4 -30
  81. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +39 -2
  82. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/db-contract.sample.sql +2 -2
  83. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/ui-contract.sample.yaml +52 -5
  84. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/cli/cli-NNNN-title.md +2 -2
  85. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/03_contract/tech.md +1 -1
  86. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +7 -0
  87. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +30 -20
  88. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +6 -5
  89. package/assets/init/.qfai/assistant/skill/qfai-verify/references/context-load.md +9 -6
  90. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +92 -13
  91. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +37 -31
  92. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/config.toml +2 -4
  93. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/mcp-config.json +9 -5
  94. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/.mcp.json +1 -2
  95. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/config.toml +3 -3
  96. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/mcp-config.json +11 -8
  97. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/config.toml +1 -1
  98. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/mcp-config.json +7 -3
  99. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +17 -7
  100. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +126 -13
  101. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +3 -2
  102. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +1 -0
  103. package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +2 -0
  104. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +12 -4
  105. package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +1 -1
  106. package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +7 -4
  107. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +11 -1
  108. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +2 -0
  109. package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +2 -2
  110. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +3 -3
  111. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +2 -2
  112. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +4 -3
  113. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +6 -3
  114. package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +4 -3
  115. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +3 -3
  116. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +9 -6
  117. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +1 -1
  118. package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +4 -3
  119. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +42 -6
  120. package/assets/init/.qfai/assistant/step/implement-test-fix/STEP.md +2 -0
  121. package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +22 -2
  122. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +18 -14
  123. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +4 -3
  124. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +4 -0
  125. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +1 -3
  126. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +11 -0
  127. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +4 -0
  128. package/assets/init/.qfai/assistant/step/sdd-gate/STEP.md +4 -0
  129. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +10 -0
  130. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +37 -11
  131. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +5 -4
  132. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +33 -23
  133. package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +5 -3
  134. package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +2 -0
  135. package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +4 -0
  136. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +13 -4
  137. package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +8 -5
  138. package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +86 -0
  139. package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +2 -0
  140. package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +6 -3
  141. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +9 -5
  142. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +39 -6
  143. package/assets/init/.qfai/assistant/step/verify-external/STEP.md +5 -2
  144. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +10 -2
  145. package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +1 -0
  146. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +7 -5
  147. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +136 -28
  148. package/assets/init/.qfai/waivers.yml +1 -1
  149. package/assets/init/root/.agents/rules/ai-readable-markdown.md +98 -0
  150. package/assets/init/root/.agents/rules/api-budget.md +191 -13
  151. package/assets/init/root/.agents/rules/documentation-clarity.md +192 -35
  152. package/assets/init/root/.agents/rules/grilling.md +4 -4
  153. package/assets/init/root/.agents/rules/interface-clarity.md +5 -5
  154. package/assets/init/root/.agents/rules/minimal-implementation.md +11 -3
  155. package/assets/init/root/.agents/rules/reminders.json +27 -14
  156. package/assets/init/root/.agents/rules/session-feedback.md +136 -0
  157. package/assets/init/root/.agents/rules/temporary-files.md +47 -5
  158. package/assets/init/root/.agents/rules/untrusted-content.md +3 -3
  159. package/assets/init/root/.agents/rules/user-questions.md +74 -36
  160. package/assets/init/root/.gitattributes +9 -0
  161. package/assets/init/root/.github/workflows/qfai-docs.yml +44 -12
  162. package/assets/init/root/.github/workflows/qfai-tests.yml +58 -15
  163. package/assets/init/root/.github/workflows/qfai-validate.yml +49 -42
  164. package/assets/init/root/AGENTS.md +23 -21
  165. package/assets/mdschema/story/03_contract/tech.mdschema.yml +7 -3
  166. package/assets/sandbox-templates/default-deny.yaml +9 -5
  167. package/assets/schemas/workflow/extraction.schema.json +85 -5
  168. package/assets/schemas/workflow/plan.schema.json +9 -2
  169. package/assets/scripts/check-mdschema.mjs +172 -5
  170. package/assets/uix-rev/comparison-review.md +1 -1
  171. package/assets/uix-rev/contracts-review.md +1 -2
  172. package/dist/cli/index.cjs +6499 -7688
  173. package/dist/cli/index.cjs.map +1 -1
  174. package/dist/cli/index.mjs +6449 -7641
  175. package/dist/cli/index.mjs.map +1 -1
  176. package/dist/index.cjs +5548 -7823
  177. package/dist/index.cjs.map +1 -1
  178. package/dist/index.d.cts +40 -666
  179. package/dist/index.d.ts +40 -666
  180. package/dist/index.mjs +5397 -7648
  181. package/dist/index.mjs.map +1 -1
  182. package/docs/MIGRATION-2.0.0.md +1 -1
  183. package/package.json +5 -7
  184. package/assets/init/root/CLAUDE.md +0 -45
@@ -2,6 +2,16 @@
2
2
 
3
3
  Use this file when `/qfai-sdd` creates or updates `<paths.contractsDir>/**`. Write the concrete EX before its enforcing BR.
4
4
 
5
+ ## Contents
6
+
7
+ - Purpose
8
+ - Rules
9
+ - What validation checks in a `.sql` contract
10
+ - Cross-contract Reconciliation
11
+ - Executability
12
+ - Obligation realizability
13
+ - Review checklist
14
+
5
15
  ## Purpose
6
16
 
7
17
  Contracts are version-managed downstream execution truth and inputs:
@@ -11,10 +21,11 @@ Contracts are version-managed downstream execution truth and inputs:
11
21
  - `ui/`: UI contract YAML
12
22
 
13
23
  The brand SSOT is root `DESIGN.md` at the project root, and screens are `ui/`
14
- contracts. No other directory under `<paths.contractsDir>` holds a contract, and
15
- `QFAI-CONTRACT-034` reports a file in one. Evaluator axes are not a contract
16
- either: the review validation the QFAI CLI applies fixes them (restated in
17
- `.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md`).
24
+ contracts. A project's contracts live in those three directories. `cli/` holds
25
+ the command-surface contracts of the QFAI repository itself and is not a kind a
26
+ project adds. No other directory under `<paths.contractsDir>` holds a contract,
27
+ and `QFAI-CONTRACT-034` reports a file in one. Evaluator axes are not a contract
28
+ either: the review validation the QFAI CLI applies fixes them.
18
29
 
19
30
  Discussion UI/UX files are **non-normative** discovery / reference artifacts — not upstream SSOT (`.qfai/assistant/rule/drift-protocol.md#core-rule`). `/qfai-sdd` normalizes approved decisions into `<paths.contractsDir>/**`; downstream skills read contracts, not discussion UI/UX files. A contradiction between a pack and a contract is resolved in the contract, not by amending the pack.
20
31
 
@@ -42,20 +53,22 @@ Discussion UI/UX files are **non-normative** discovery / reference artifacts —
42
53
  not only where the attribute is written out — a framework that builds the
43
54
  attribute from a variable still writes the marker somewhere.
44
55
  - **Every entry under `screens` is a screen, once.** Each UI-bearing contract declares one full `UI-NNNN` ID and a nonempty `screens[]` list. Each screen has an ID and route, unique within its contract. The prototyping cycle covers all declared UI-bearing contract IDs; filenames do not select a legacy spec tier. `QFAI-CONTRACT-042` names malformed screen entries.
45
- - **A contract's ID comes from its directory.** `cli/` holds `CLI`
46
- contracts, `api/` `API`, `db/` `DB` and `ui/` `UI`. The ID is `<KIND>-NNNN`.
56
+ - **Every screen states the text it shows.** A screen declares `supplements` (`[]` when it shows none) and may declare `structure`. `QFAI-CONTRACT-043` names a key that is absent or malformed, `QFAI-CONTRACT-044` an id the screen does not declare, and `QFAI-CONTRACT-045` a text shown twice.
57
+ - **A contract's ID comes from its directory.** `api/` holds `API` contracts,
58
+ `db/` `DB` and `ui/` `UI`; the QFAI repository's own `cli/` holds `CLI`
59
+ contracts. The ID is `<KIND>-NNNN`.
47
60
  Its number is one more than the highest contract number of any kind, so
48
61
  `API-0002` and `DB-0002` cannot both exist. A number is never reused, even
49
62
  after its contract is removed.
50
63
  - **The file is named after the ID**: `<kind>-NNNN-<slug>.<ext>`, such as
51
- `api/api-0002-orders.yaml` or `cli/cli-0001-checkout.md`.
64
+ `api/api-0002-orders.yaml` or `db/db-0003-orders.sql`.
52
65
  - **The ID is declared once, in the file.** A Markdown contract declares it in
53
66
  its H1: `# CLI-0001: <title>`. A YAML or SQL contract declares it on a
54
67
  `QFAI-CONTRACT-ID: API-0002` comment line at the top. A Markdown file under
55
68
  `api/`, `db/` or `ui/` is not a contract, whatever its H1 says:
56
69
  `QFAI-CONTRACT-034` reports it, and no other check counts it.
57
70
  - **Rules are numbered after their contract.** A business rule's ID is
58
- `BR-<contract number>-NNNN`: `BR-0002-0001` is the first rule of `API-0002`.
71
+ `BR-<contract number>-NNNN`: `BR-0006-0001` is the first rule of `API-0006`.
59
72
  Only that contract declares it: under `x-qfai-rules` in YAML or JSON, on
60
73
  `-- Rule` and `-- Examples:` lines in SQL, and in the `## Business rules`
61
74
  table (`BR-ID`, `Statement`, `Examples`) of a Markdown contract.
@@ -120,12 +133,12 @@ The structural lane:
120
133
  | ------------------- | ----------------------------------------------------------------------------- | -------- |
121
134
  | `QFAI-CONTRACT-021` | an unterminated string, comment or dollar-quoted body, or unbalanced `(` | error |
122
135
  | `QFAI-DB-002` | one file creates the same object twice — only the last definition is in force | error |
136
+ | `QFAI-DB-001` | a dangerous statement (`DROP TABLE`, `TRUNCATE`, …) | warning |
123
137
 
124
138
  `QFAI-DB-002` covers tables, views, indexes, functions, procedures, types and
125
139
  domains. **Triggers are excluded**: a trigger name is unique per table, not per
126
140
  schema, so two same-named triggers on different tables are correct SQL and
127
141
  reporting them would be a false positive on valid input.
128
- | `QFAI-DB-001` | a dangerous statement (`DROP TABLE`, `TRUNCATE`, …) | warning |
129
142
 
130
143
  The statement splitter honours SQL quoting, so a `;` inside a literal, a
131
144
  comment, a `$$ … $$` body or parentheses does not end a statement.
@@ -9,6 +9,25 @@ default, not because the brand direction the discussion pack recorded asks for
9
9
  it. An instruction to avoid "a generic look" only swaps one default for another;
10
10
  naming the pattern is what works.
11
11
 
12
+ ## Contents
13
+
14
+ - Using the list
15
+ - Where the list stops
16
+ - Color and background
17
+ - Typography
18
+ - Iconography and imagery
19
+ - Surfaces
20
+ - Components
21
+ - Layout and composition
22
+ - Placement
23
+ - Motion and transitions
24
+ - Copy in the UI
25
+ - Copy that adds no meaning
26
+ - Information architecture and flow
27
+ - States and accessibility
28
+ - Implementation defaults
29
+ - Displacement
30
+
12
31
  ## Using the list
13
32
 
14
33
  - **Writing root `DESIGN.md`.** Read the list before choosing a value. A value
@@ -33,12 +52,13 @@ naming the pattern is what works.
33
52
  flow_ and _States and accessibility_ do, `interface-clarity.md` and the spec
34
53
  are the rules. The entry is the form a breach of them takes on a generated
35
54
  screen.
36
- - The reviewer inside the prototyping loop does not apply this list. Root
37
- `DESIGN.md` locks the brand values that reviewer sees
38
- (`.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md`), so
39
- a pattern is caught where the design direction is reviewed and where
40
- `DESIGN.md` is written. No entry here is a `lap-*` detection, and none blocks
41
- the loop.
55
+ - The reviewer inside the prototyping loop does not apply the sections about
56
+ identity. Root `DESIGN.md` locks the brand values that reviewer sees, so a
57
+ pattern there is caught where the design direction is reviewed and where
58
+ `DESIGN.md` is written. That reviewer does apply _Copy that adds no meaning_,
59
+ through the criterion on explanatory text, because those patterns are about
60
+ what the text tells the user, not about a brand. No entry here is a `lap-*`
61
+ detection.
42
62
 
43
63
  ## Color and background
44
64
 
@@ -252,6 +272,21 @@ naming the pattern is what works.
252
272
  - The screen shows technical detail nobody asked for, such as GPU status or
253
273
  average generation time.
254
274
 
275
+ ## Copy that adds no meaning
276
+
277
+ These patterns are judged against the screen's tasks and the `supplements` its UI
278
+ contract declares, in SDD, in implementation and in every surface review. A chosen
279
+ visual direction does not exempt them. A disclosure about demo data, cost, storage
280
+ or transmission that is true and shown where the user decides is not one of them:
281
+ judge where it sits and what it lets the user do, not the word.
282
+
283
+ - A second heading or a sentence repeats the main heading, an action label, a
284
+ state, or the content beside it.
285
+ - A condition the user already knows is explained again where it adds nothing to
286
+ the decision being made.
287
+ - Production copy carries a development instruction, implementation commentary,
288
+ or a demo note repeated on screen after screen.
289
+
255
290
  ## Information architecture and flow
256
291
 
257
292
  - Sections follow the stock order: hero, logos, three features, stats or
@@ -6,6 +6,13 @@ Applies only to a UI-bearing target — one whose classified surface set names
6
6
  `web`, `mobile`, `desktop` or `mixed`. A cli-only target has no root
7
7
  `DESIGN.md`.
8
8
 
9
+ ## Contents
10
+
11
+ - Where the answers come from
12
+ - Output mapping
13
+ - Taking the values from the theme
14
+ - When the file already exists
15
+
9
16
  ## Where the answers come from
10
17
 
11
18
  The interview is `/qfai-discussion`'s, and its record is the discussion pack
@@ -27,8 +34,7 @@ was translated. The competitor registry feeds brand and tokens; the component
27
34
  catalogue registry feeds screen structure, which is the contracts' business,
28
35
  not this file's.
29
36
 
30
- The questions behind those answers are in
31
- `../../qfai-discussion/references/design-dna-intake.md`.
37
+ The questions behind those answers are in the design DNA intake reference.
32
38
 
33
39
  ## Output mapping
34
40
 
@@ -47,7 +53,7 @@ three intent fields, so those come first.
47
53
  identities to avoid, not conventions.
48
54
  - Adopted reference points → the **Do** subsection of `# Brand Philosophy`.
49
55
  - Brand archetype → `brand.archetype`. Allowed values are the 8-archetype
50
- catalog in `design-md-brand-catalog.md`
56
+ catalog in the brand catalog
51
57
  (`minimal | bold | corporate | playful | organic | tech | elegant | casual`).
52
58
  Map the theme the pack records to the archetype that describes it; the
53
59
  Selection Guide's scoring is the fallback for a pack whose direction names
@@ -64,10 +70,10 @@ three intent fields, so those come first.
64
70
  - Visual decisions (color, typography, radius, shadow) → the `visual.*` token
65
71
  tree, **taken from the named theme's published values**. Schema and
66
72
  validation rules live in
67
- `.qfai/assistant/skill/qfai-prototyping/references/design-md-spec.md`.
73
+ the DESIGN.md specification.
68
74
 
69
75
  For the schema (12 colors, 3 fonts, 4 radii, 3 shadows, 8 archetypes), read
70
- `qfai-prototyping/references/design-md-spec.md` and start from the sample at
76
+ the DESIGN.md specification and start from the sample at
71
77
  `qfai-prototyping/templates/DESIGN.md.sample`.
72
78
 
73
79
  ## Taking the values from the theme
@@ -3,10 +3,25 @@
3
3
  Reference catalog of 8 canonical brand archetypes. The SDD design stage picks one to fill the
4
4
  required `brand.archetype` field of the root `DESIGN.md`; each archetype supplies
5
5
  `aesthetic_properties` that become the starting tokens, and
6
- `design-md-authoring.md#output-mapping` defines where each value is written.
6
+ the `Output mapping` section of the DESIGN.md authoring reference defines where
7
+ each value is written.
7
8
 
8
9
  ---
9
10
 
11
+ ## Contents
12
+
13
+ - Archetype: Minimal
14
+ - Archetype: Bold
15
+ - Archetype: Corporate
16
+ - Archetype: Playful
17
+ - Archetype: Organic
18
+ - Archetype: Tech
19
+ - Archetype: Elegant
20
+ - Archetype: Casual
21
+ - Patterns to avoid
22
+ - Typeface candidates
23
+ - Selection Guide
24
+
10
25
  ## Archetype: Minimal
11
26
 
12
27
  - representative_brand: Apple, Notion, Linear
@@ -91,7 +106,7 @@ required `brand.archetype` field of the root `DESIGN.md`; each archetype supplie
91
106
 
92
107
  ## Patterns to avoid
93
108
 
94
- `design-anti-patterns.md` lists the patterns that mark a design as generated,
109
+ The design anti-patterns reference lists the patterns that mark a design as generated,
95
110
  by aspect, and the substitutes a model falls back to once one is banned. Read it
96
111
  before turning an archetype's defaults into `DESIGN.md` values. A value that
97
112
  produces a listed pattern stays only where the recorded brand direction asks for
@@ -12,7 +12,7 @@ Use source-backed discussion requirements to write one connected, testable story
12
12
 
13
13
  1. Read the selected discussion pack's source registry, requirement index, open questions, decision record, and completed reviews. Each requirement must trace to a source ID. Record a missing source or unresolved product choice in `<paths.specsDir>/open-questions.md` and stop the dependent write.
14
14
  2. Reuse an existing policy, business flow, or story when it still expresses the requirement. Put a create, update, or retirement operation to the user, and record the approved one as a `Change request:` row of `<paths.specsDir>/decisions.md` naming the affected BF or US and `discussion-<id>#REQ-NNNN`.
15
- 3. Write broad intent in `01_policy/` as criteria, then each observable process in `02_business-flow/business-flow-NNNN/business-flow.md`. Keep each flow's story index and three-file story directories beneath it. Every file takes its template's shape exactly, as `spec-traceability-rules.md#document-shapes` sets out.
15
+ 3. Write broad intent in `01_policy/` as criteria, then each observable process in `02_business-flow/business-flow-NNNN/business-flow.md`. Keep each flow's story index and three-file story directories beneath it. Every file takes its template's shape exactly, as the `Document shapes` section of the spec traceability rules sets out.
16
16
  4. Write one observable outcome per AC, as one named Gherkin `Scenario:` under its ID comment. Give each AC at least one concrete EX, and give each EX exactly one AC reference. Include normal, failure, boundary, and authorization paths relevant to the requirement.
17
17
  5. Once the examples exist, write independently falsifiable BRs in the contracts that enforce them. Each BR cites at least one full EX ID; every EX has a BR. A shared BR is defined once, in the contract that enforces it, and no other contract cites it.
18
18
  6. Derive test obligations from the completed BF → US → AC → EX ← BR graph. The SDD skill records those obligations; `/qfai-implement` writes the acceptance tests.
@@ -25,7 +25,15 @@ Use source-backed discussion requirements to write one connected, testable story
25
25
  - An EX is one concrete input and expected result for exactly one AC. Split examples whose paths can pass or fail independently.
26
26
  - A BR is one independently falsifiable constraint. If removing a clause leaves another complete rule, split it.
27
27
 
28
- Allocate each ID as the highest ID of its kind in its defined scope plus one, counting retired IDs. Never reuse an ID. The scopes and widths are in `sdd-triage.md#id-allocation`.
28
+ A capacity-only sibling may represent the same actual actor goal within the
29
+ same BF when requested AC or EX additions exceed the source story's remaining
30
+ capacity. Prefer preserving published cases and IDs, and place only new,
31
+ cohesive incoming cases under their own covering change request. Confirm
32
+ retired-inclusive capacity and the owning approval before writing; this
33
+ exception invents no new product outcome and grants no future creation or move
34
+ permission.
35
+
36
+ Allocate each ID as the highest ID of its kind in its defined scope plus one, counting retired IDs. Never reuse an ID. The scopes and widths are in the `ID allocation` section of the triage reference.
29
37
 
30
38
  ## Ambiguity
31
39
 
@@ -1,17 +1,42 @@
1
1
  # SDD Execution Playbook
2
2
 
3
- Use this sequence for /qfai-sdd. The shipped templates under ../templates/spec/ define each file's shape, and spec-traceability-rules.md#document-shapes states what a template cannot show.
3
+ Use this sequence for /qfai-sdd. The shipped templates under ../templates/spec/ define each file's shape, and the `Document shapes` section of the spec traceability rules states what a template cannot show.
4
4
 
5
5
  ## Stage 0: source inventory
6
6
 
7
- 1. Run npx qfai sdd preflight and read its selectedInputPath and source. Respect an explicitly selected discussion pack, including one older than the newest pack.
8
- 2. Read the selected pack, completed reviews that target it, explicit user requirements, and the existing story tree. A pack is reference and provenance material. Disposition its applicable review advice in the SDD report, a decision row, or an open question. A pack discrepancy does not itself block SDD.
9
- 3. Stop if there is no usable input source. Stop on an unresolved product decision that cannot safely be inferred; record the question in open-questions.md.
10
- 4. If no discussion pack exists and an imported specification does, run npx qfai sdd preflight --import <path> with that file, which selects it as the source. An explicit user requirement is used as it is and named in the SDD report. Do not manufacture a discussion pack.
7
+ 1. Use the launcher established by
8
+ `.qfai/assistant/rule/shared-skill-operating-baseline.md#canonical-qfai-launcher-mandatory`.
9
+ Record its resolved package path and version in the SDD report. Check that
10
+ the installed Stage 0 instructions support the procedure being used.
11
+ 2. Run `npx qfai sdd preflight` and read its `selectedInputPath` and `source`.
12
+ Respect an explicitly selected discussion pack, including one older than the
13
+ newest pack.
14
+ 3. Read the selected pack, completed reviews that target it, explicit user
15
+ requirements, and the existing story tree. A pack is reference and provenance
16
+ material. Disposition its applicable review advice in the SDD report, a decision
17
+ row, or an open question. A pack discrepancy does not itself block SDD. For
18
+ the current request, read the existing purpose in
19
+ `<paths.specsDir>/01_policy/objective.md` and inspect related flows and stories.
20
+ 4. A missing discussion pack does not mean that specifications are missing. If
21
+ an existing readable specification is authoritative for this request, run
22
+ `npx qfai sdd preflight --import <path>` with that file. The fallback does
23
+ not replace a selected pack or bypass unsafe pack names, unreadable files,
24
+ invalid active pointers, config errors, or a mismatched tool.
25
+ 5. Use an explicit user requirement as supplied and name it in the SDD report.
26
+ Do not invent an import file from conversation. Without a file, CLI preflight
27
+ can remain blocked while SDD assesses that explicit requirement.
28
+ 6. Use `/qfai-discussion` only when no usable source exists; stop SDD until one
29
+ is available. Stop on an unresolved product decision that cannot safely be
30
+ inferred; record the question in `open-questions.md`. Do not manufacture or
31
+ regenerate a past discussion pack, or regenerate the existing purpose,
32
+ merely to clear preflight.
33
+ 7. Import-lite readiness identifies the input source. It does not establish
34
+ complete requirements or a validation PASS. Keep the existing purpose and
35
+ current request while updating only affected flow and story content.
11
36
 
12
37
  ## Stage 1: triage and decisions
13
38
 
14
- Follow sdd-triage.md. Classify each requirement against existing policy, flow, story, example, and contract content.
39
+ Follow the triage reference. Classify each requirement against existing policy, flow, story, example, and contract content.
15
40
  Identify every affected flow. Put each approval-required operation to the user through the shared user-question
16
41
  protocol before a dependent write, and append its change request row to decisions.md once approved; record unresolved
17
42
  questions in open-questions.md. In --auto, ask nothing and stop dependent work. A declined change request is appended at REJECTED.
@@ -22,7 +47,7 @@ questions in open-questions.md. In --auto, ask nothing and stop dependent work.
22
47
  A constraint is a limit in plain words; its ID is its place in its section, so removing a row renumbers the rows after it.
23
48
  A layer boundary is a row of tech.md `## Architecture`, written from the technical decisions the pack records and, in an existing codebase, its module layout and import directions: what each layer does and the layers below it that it may import from.
24
49
  A layer is a group of modules whose dependencies point one way: down. The section draws the layers as one `flowchart TD`, then lists them in the table from the uppermost down, and the two name the same layers and edges.
25
- Implementation places new code by that table and reviewers judge a change against it, as spec-traceability-rules.md#architecture states.
50
+ Implementation places new code by that table and reviewers judge a change against it, as the `Architecture` section of the spec traceability rules states.
26
51
  2. Write 02_business-flow/business-flows.md and the affected business-flow-NNNN/business-flow.md files. Each flow's `## Flow` section is exactly one Mermaid flowchart or sequenceDiagram.
27
52
  3. Allocate BF and US IDs from the highest existing ID in their scopes, counting retired IDs named in decisions rows. Add rows to the flow and story indexes.
28
53
 
@@ -37,12 +62,12 @@ questions in open-questions.md. In --auto, ask nothing and stop dependent work.
37
62
 
38
63
  1. Write the 03_contract/ view and each contract file from its paired template or contract-specific template. tech.md holds the stack, the runtime dependencies and, in its Standard commands section, the only quality-gate command definitions. It holds no BR.
39
64
  2. Put each BR inside the contract that enforces it, numbered `BR-<contract number>-NNNN`. Cite at least one EX already written. Every EX is cited by at least one BR. A shared rule has one authoritative definition, and no other contract cites it.
40
- 3. Give each new contract the next contract number, declare its `<KIND>-NNNN` ID, name the file `<kind>-NNNN-<slug>.<ext>`, and add its row to contracts.md in the same change. Reconcile API and DB fields, state transitions, errors, and persisted attributes. Run the executable DB contract checks required by contract-artifact-rules.md.
65
+ 3. Give each new contract the next contract number, declare its `<KIND>-NNNN` ID, name the file `<kind>-NNNN-<slug>.<ext>`, and add its row to contracts.md in the same change. Reconcile API and DB fields, state transitions, errors, and persisted attributes. Run the executable DB contract checks required by the contract artifact rules.
41
66
  4. For a visual UI surface, the root DESIGN.md is written and validated by .qfai/assistant/step/common-design-md/STEP.md. A CLI-only surface does not require one.
42
67
 
43
68
  ## Concrete-abstract cycle
44
69
 
45
- When Stage 4 wrote or changed a BR Statement or Examples cell, run the cycle in concrete-abstract-cycle.md before the gate: a sub-agent that wrote none of the BRs raises findings against the tree, the session agent decides them, the adopted changes are applied, and the affected BRs are rewritten. At most two cycles run.
70
+ When Stage 4 wrote or changed a BR Statement or Examples cell, run the concrete-abstract cycle before the gate: a sub-agent that wrote none of the BRs raises findings against the tree, the session agent decides them, the adopted changes are applied, and the affected BRs are rewritten. At most two cycles run.
46
71
 
47
72
  ## Stage 5: gate, review, and completion
48
73
 
@@ -1,6 +1,6 @@
1
1
  # SDD Phase Checklists
2
2
 
3
- Use these checkpoints with the ordered stages in sdd-execution-playbook.md. A checked item requires evidence in the story tree or the SDD report.
3
+ Use these checkpoints with the ordered stages of the SDD steps. A checked item requires evidence in the story tree or the SDD report.
4
4
 
5
5
  ## Source and triage
6
6
 
@@ -14,7 +14,7 @@ Use these checkpoints with the ordered stages in sdd-execution-playbook.md. A ch
14
14
 
15
15
  ## Policy and business flow
16
16
 
17
- - Files in 01_policy/ and 02_business-flow/ were copied from paired templates and hold their headings and nothing else, as spec-traceability-rules.md#document-shapes sets out. No section records history.
17
+ - Files in 01_policy/ and 02_business-flow/ were copied from paired templates and hold their headings and nothing else, as the `Document shapes` section of the spec traceability rules sets out. No section records history.
18
18
  - Objective, initiative, principle, and tech state each fact in one place. Gate commands occur only in tech.md Standard commands.
19
19
  - Every affected business-flow.md has exactly one Mermaid flowchart or sequenceDiagram in `## Flow`, and at least one alternate or exception path.
20
20
  - business-flows.md and user-stories.md index actual flows and stories with their assigned BF and US IDs and the titles in their H1s after the ID, word for word.
@@ -37,12 +37,12 @@ The one example a diagnosed missing test needs is appended by the implement stag
37
37
  - No contract names an implementation file.
38
38
  - Every written contract file has a contracts.md index row in the same change, with the columns `ID`, `Title`, `File`, `Depends On`, `Reconciled With` and `Purpose`.
39
39
  - Contract state, errors, and persisted attributes can realize the AC and EX outcomes, including required joins.
40
- - Changed DB contracts were applied to a scratch database and their declared write paths exercised as contract-artifact-rules.md requires. Record the command and result under Contract executability in the SDD repdence.
40
+ - Changed DB contracts were applied to a scratch database and their declared write paths exercised as the contract artifact rules require. Record the command and result under Contract executability in the SDD repdence.
41
41
  - UI contracts follow the product's own root `DESIGN.md`; the sample design was not adopted.
42
42
 
43
43
  ## Concrete-abstract cycle
44
44
 
45
- Follow concrete-abstract-cycle.md.
45
+ Follow the cycle the `sdd-cycle` step sets out.
46
46
 
47
47
  - A cycle ran when this invocation wrote or changed a BR Statement or Examples cell, and did not run otherwise or in an append stage.
48
48
  - The finder is a sub-agent that wrote none of the BRs it read. The session agent decided each finding that is not critical.
@@ -8,7 +8,7 @@ The gate checks the story-tree files against their shipped templates, the docume
8
8
  - Quality-gate commands occur only in the Standard commands section of <paths.contractsDir>/tech.md. Other files point there.
9
9
  - 02_business-flow/business-flows.md indexes real BF directories. Each business-flow.md has exactly one Mermaid flowchart or sequenceDiagram, in `## Flow`.
10
10
  - Each story directory holds exactly 01_User-story.md, 02_Acceptance-Criteria.md, and 03_Example.md.
11
- - The story tree was written from its paired templates under ../templates/spec/ and holds no heading, section, content kind or history they do not show, as spec-traceability-rules.md#document-shapes sets out.
11
+ - The story tree was written from its paired templates under ../templates/spec/ and holds no heading, section, content kind or history they do not show, as the `Document shapes` section of the spec traceability rules sets out.
12
12
  - decisions.md and open-questions.md have four cells per row: ID, Content, Approach, Status. Existing rows changed only in Status.
13
13
  - Each change the user approved, retirement included, has its `Change request:` decision row recording who approved it, when, and the option chosen. No row records a decision the agent took. Unanswered critical decisions have open-question rows and prevent completion.
14
14
 
@@ -22,7 +22,7 @@ The gate checks the story-tree files against their shipped templates, the docume
22
22
  - Every contract file written has a contracts.md row from the same change.
23
23
  - Every persisted attribute and state named by an AC, EX, or BR is realizable by its contract directly or through a stated join.
24
24
  - Paired API and DB contracts agree on terminal states and error outcomes.
25
- - Each changed DB contract was applied to a scratch database and its declared write paths were exercised as contract-artifact-rules.md requires. The result appears under Contract executability in the SDD repdence.
25
+ - Each changed DB contract was applied to a scratch database and its declared write paths were exercised as the contract artifact rules require. The result appears under Contract executability in the SDD repdence.
26
26
  - UI work uses a product-owned DESIGN.md that parses and validates; a sample design is not adopted.
27
27
 
28
28
  ## Flow validation
@@ -2,6 +2,17 @@
2
2
 
3
3
  Triage selects the smallest story-tree change that answers each incoming requirement. The source may be the discussion pack selected by preflight, an imported specification, or the user's explicit requirement. Treat the pack as reference material and resolve a conflict in an SDD-owned artifact.
4
4
 
5
+ ## Contents
6
+
7
+ - Inputs
8
+ - Operation choice
9
+ - Decision and question rows
10
+ - Published decision prefix recovery
11
+ - Approval and no-question mode
12
+ - Retiring an EX, AC or BR
13
+ - ID allocation
14
+ - Completion of triage
15
+
5
16
  ## Inputs
6
17
 
7
18
  - The selected source and its requirement IDs, if present.
@@ -14,7 +25,7 @@ Read the flow and story indexes plus concrete files. A subject match alone is in
14
25
  ## Operation choice
15
26
 
16
27
  Choose one primary operation for each affected BF or US. UPDATE is the default when the existing item keeps its identity
17
- and purpose. Its sub-operation is APPEND, MODIFY, or REMOVE. CREATE is used when no existing item represents the new
28
+ and purpose. Its sub-operation is written UPDATE:APPEND, UPDATE:MODIFY, or UPDATE:REMOVE. CREATE is used when no existing item represents the new
18
29
  outcome. DELETE, SPLIT, MERGE, and SUPERSEDE change identity or scope and require explicit approval. UPDATE:REMOVE also
19
30
  requires approval. A supporting contract update is named in the same decision's Approach or in a linked row; it is not a
20
31
  second fictional flow.
@@ -23,7 +34,8 @@ Inspect the impact cascade: policy → BF → US → AC → EX → enforcing con
23
34
 
24
35
  ## Decision and question rows
25
36
 
26
- Use <paths.specsDir>/decisions.md and <paths.specsDir>/open-questions.md, each with exactly ID, Content, Approach, Status. Append a row; later only Status may change. Do not edit the first three cells or remove the row. Use the next highest ID in the table plus one. A retired item still reserves its BF or US ID.
37
+ Use <paths.specsDir>/decisions.md and <paths.specsDir>/open-questions.md, each with exactly ID, Content, Approach, Status. Append a row; later only Status may change, including to `PARTLY SUPERSEDED (by DEC-NNNN)` when a later row narrows a decision without replacing it.
38
+ Do not edit the first three cells or remove the row, except for explicit branch-added decision renumbering under ID allocation below or the bounded published decision prefix recovery below. Inherited rows retain those cells. Use the next highest ID in the table plus one. A retired item still reserves its BF or US ID.
27
39
 
28
40
  decisions.md records only what the user decided: each change request the user approved or declined,
29
41
  and each critical decision the user made. A row is appended once the user has decided what it records.
@@ -47,9 +59,48 @@ whose Content opens Unadjudicated:, at TODO until decided. A justified test exce
47
59
  decision Content with Test exception:, names the exact BF, AC, or EX it exempts, and puts the reason
48
60
  in Approach. It takes effect only at DONE; it never exempts descendant items.
49
61
 
62
+ A test annotation may remain pending only when authority to change the
63
+ specification covers that state and the test deferral is approved. Record the
64
+ specification change in its own `Change request:` row. Record the deferral as a
65
+ `Test exception:` decision naming the exact AC at DONE. Its Approach states
66
+ the reason, untested scope, owner, next decision date and condition for restoring
67
+ the annotation.
68
+
69
+ DONE establishes the exception decision; it does not mean test completion.
70
+ The existing info finding names the exempted AC and its decision without
71
+ claiming test execution or coverage. The exception never exempts descendant EX
72
+ obligations or authorizes changes to EX or BR scope. Do not silently substitute
73
+ an EX or prose rewrite for an approved specification change. Use the next
74
+ decision date for manual review; there is no automatic expiry and no automatic
75
+ warning.
76
+
77
+ When specification changes are forbidden or either authority is missing, first
78
+ append an `Unadjudicated:` OQ at TODO. Name the affected IDs, expected versus
79
+ actual behavior, implementation-change evidence, owner and required permission.
80
+ Stop dependent AC, EX and BR edits; independent authorized work may continue.
81
+
82
+ ## Published decision prefix recovery
83
+
84
+ When an approved request names a published malformed decision added by the
85
+ branch, read `.qfai/assistant/rule/drift-protocol.md#published-decision-prefix-recovery`.
86
+ That rule defines the source, byte boundaries, exact prefix and stop conditions.
87
+ Approval of the generic protocol alone authorizes no target; append a separate
88
+ new target-specific recovery change request using `templates/change-request.md`.
89
+
90
+ Record the fixed base and unique common ancestor, absence of the target in both,
91
+ the published source commit's ancestry, raw Approach digests and the exact
92
+ approved prefix. Immediately before writing, recheck the unique current row,
93
+ its original ID, Content and Status, and its old digest. Preserve every original
94
+ Approach byte as the suffix and leave every other row unchanged. Recheck the
95
+ existing form and validation; status or supersession clears no malformed form.
96
+ Record actual results, including any stopped recovery, without claiming an
97
+ automatic repair. Inherited records and open-question rows remain excluded.
98
+ Rollback follows the recorded new-digest check and restores the original form
99
+ failure; it never resets, amends or force pushes.
100
+
50
101
  ## Approval and no-question mode
51
102
 
52
- Use the shared user-question protocol for CREATE, DELETE, SPLIT, MERGE, SUPERSEDE, and UPDATE:REMOVE. Present the target and rationale. Do not self-approve.
103
+ Use the shared user-question protocol for CREATE, DELETE, SPLIT, MERGE, SUPERSEDE, and UPDATE:REMOVE. Present the target and rationale. Do not self-approve. A request from the user in the session that names the operation and its effect is the approval, and no second question is asked.
53
104
  In --auto, ask no question: append one `open-questions.md` row per pending operation naming it and its target, at TODO with its Content opening Unadjudicated:; stop before the dependent writes, and report every pending operation with its target as open.
54
105
  Approval-free changes may proceed only if they do not depend on a pending operation.
55
106
 
@@ -60,23 +111,142 @@ Clarifications follow the constitution's question budget. Approval questions are
60
111
  A story-tree or contract file changes only on the user's approval:
61
112
 
62
113
  1. Show the user the files the stage would change and the proposed change, and
63
- change nothing until the user answers.
114
+ change nothing until the user answers. A request from the user in the
115
+ session that names the change and its effect is that answer: the stage lists
116
+ the files in its announcement, asks no second question, and records the
117
+ request as the option chosen.
64
118
  2. On approval, write the change and append one `decisions.md` row whose Content
65
119
  opens `Change request:` and names every story-tree and contract file it
66
120
  changed, and `decisions.md` when it appended any other row. Its Approach
67
121
  records who approved it, when, and the label of the option chosen.
68
122
  3. Move the row to DONE once every change it names is written.
69
123
 
70
- A row present before the stage started keeps its ID, Content and Approach.
124
+ A row present before the stage started keeps its ID, Content and Approach, except for explicit branch-added decision renumbering under ID allocation below or published decision prefix recovery above. Inherited rows keep those cells without exception.
71
125
  Only a row this stage appended changes its Status.
72
126
 
127
+ ## Retiring an EX, AC or BR
128
+
129
+ A retirement touches every place the ID is written. Do all of them in one change:
130
+
131
+ 1. Get the user's approval of the UPDATE:REMOVE and append its `Change request:` decision row, whose Content names every retired ID.
132
+ 2. Delete the EX row from 03_Example.md, the AC scenario from 02_Acceptance-Criteria.md, or the BR row from its contract.
133
+ 3. Remove a retired EX from the Examples cell of every BR that cites it. A BR left with no example gets another example or is retired in the same row.
134
+ 4. Remove each QFAI:EX annotation of a retired EX from the tests, or point it at the example the test now proves.
135
+ 5. An AC left with no example gets one or is retired in the same row.
136
+ 6. Retiring an AC also retires each EX whose AC-Ref names it, or moves that EX to another AC of the story by changing its AC-Ref, then applies steps 3 and 4 to each EX retired. Remove each QFAI:AC annotation of the retired AC from the tests, or point it at the AC the test now proves.
137
+ 7. Never reuse a retired ID. The decision row keeps it counted.
138
+
139
+ `npx qfai validate` reports what steps 3 to 6 left behind: a BR citing an unknown example (`QFAI-STORY-005`), a test annotation naming an undeclared ID (`QFAI-STORY-008`), and an AC with no example or an EX with an invalid AC-Ref (`QFAI-STORY-004`).
140
+
73
141
  ## ID allocation
74
142
 
75
- Read all IDs of the kind in the relevant scope, including IDs named by retirement rows. The next ID is the highest plus one. BF spans the project. US is inside its BF. AC and EX are inside their US.
143
+ Read all IDs of the kind in the relevant scope, including IDs named by retirement rows. The next ID is the highest plus one. A project that also counts the IDs its open pull requests add takes the highest across the tree and those pull requests, so a gap above the tree's own highest is allowed. BF spans the project. US is inside its BF. AC and EX are inside their US.
76
144
  A contract number spans every contract kind, and a BR is numbered inside its contract. DEC and OQ each span their table.
77
145
  Empty numeric scopes begin at 0001, and AC/EX tails begin at 01. Do not reuse an ID because its file was removed or a row was rejected.
78
146
 
79
- A move to another BF changes the story's US ID and all child AC and EX IDs. Record the old IDs as retired, allocate new IDs in the destination scope, and update every citation before the move is complete.
147
+ ### Capacity before writing
148
+
149
+ AC and EX tails stay two digits, from 01 through 99. Before writing a planned
150
+ batch, report each affected kind and story, its high-water number H (0 when
151
+ empty), remaining capacity 99-H and the number of requested additions. Count
152
+ valid IDs in the tree and decisions, including retired IDs, plus observed
153
+ published parallel heads and known reservations under the project's existing
154
+ method. Name the fixed observation and what it did not cover. A snapshot
155
+ reserves nothing and cannot cover unpublished concurrent work.
156
+
157
+ If requested additions exceed 99-H, stop before any partial allocation or
158
+ invalid declaration. Never fill gaps, reuse retired IDs or emit tail 100.
159
+ An empty scope has capacity 99. H = 98 allows one addition at tail 99, not two;
160
+ a retired 99 still exhausts the scope. Recheck newly published claims or
161
+ collisions before publication.
162
+
163
+ ### Capacity partition
164
+
165
+ Only additions exceeding an actual AC or EX scope's remaining 99-H qualify for
166
+ a capacity-only story partition. Record the source story, affected kind, H,
167
+ remainder and requested count first. Prefer leaving every published case and ID
168
+ in place and putting a cohesive incoming group in a capacity-checked sibling
169
+ under the same BF and actual actor goal. An in-force owning change request must
170
+ explicitly approve this partition and its affected paths before writing.
171
+
172
+ State the sibling's truthful cohesive scope and settle each criterion's owner;
173
+ do not invent a new product outcome, duplicate an obligation or weaken it.
174
+ A different actor, goal, flow or intended behavior needs its existing owning
175
+ approval path. Additions that fit the original scope do not qualify. Missing
176
+ authority, insufficient destination capacity or no truthful partition stops
177
+ the dependent write. This prospective split places new overflow cases; moving
178
+ an existing case also needs the complete map below. These instructions approve
179
+ no future specific creation, move or split.
180
+
181
+ ### Actual moves and incoming collisions
182
+
183
+ Before an approved actual AC/EX move or incoming collision repair, make a
184
+ complete one-to-one map of:
185
+
186
+ - the fixed source commit and declaration path;
187
+ - each original BF/US/AC/EX identity and its case meaning;
188
+ - destination story, AC/EX IDs and paths;
189
+ - every affected active BR citation and counted adjacent test declaration;
190
+ - unaffected cases and the input, expected outcome and executable assertion
191
+ each mapped case preserves.
192
+
193
+ Check both scopes' retired-inclusive capacity. Each destination EX needs one
194
+ existing destination AC; each AC needs an EX. Preserve every moved EX's
195
+ owning BR link and counted test obligation. An ID change alone proves no
196
+ coverage. Retire old moved IDs in a new approved record and never refill them.
197
+ Inherited published DEC ID, Content and Approach cells and their old-ID
198
+ references remain historical and unchanged; update only approved active
199
+ references.
200
+
201
+ Keep unaffected published cases and IDs. Identify same-number branch cases by
202
+ fixed provenance and meaning, and change only the provably incoming item,
203
+ without blanket replacement. Unknown ownership, ambiguous collisions,
204
+ uncovered declarations, missing counted test links, changed assertions or an
205
+ incomplete map stops the move without a completion claim. This is a manual
206
+ approval and mapping procedure, not a relocation executor or mapping schema.
207
+
208
+ Two branches can take the same next ID. When a merge leaves one ID on two items:
209
+
210
+ 1. The merge target's item keeps the ID. Renumber the incoming item, the one the merge brings in.
211
+ 2. Give it the next ID of its scope.
212
+ A renumbered BF or US takes its child IDs and its directory names with it, as a move to another BF does below.
213
+ 3. Change every citation belonging to the incoming item in the same commit.
214
+ For a decision, leave inherited references unchanged.
215
+ 4. State the old ID, the new ID and the renamed record's subject or path in the commit message.
216
+ A citation of the old ID elsewhere is then told apart from the item that kept it.
217
+
218
+ A `decisions.md` or `open-questions.md` row already on the target keeps its ID, Content and Approach.
219
+ A row the incoming branch added takes the next ID of its table.
220
+ An ID that two merged records already share is not renumbered:
221
+ ask the user for a change request row that states which record each citation meant.
222
+
223
+ For a unique decision added by the incoming branch, repair its ID before merging:
224
+
225
+ ```text
226
+ qfai sdd renumber-decision --from <old-DEC-ID> --to <new-DEC-ID> --base <local-ref>
227
+ ```
228
+
229
+ The explicit base and HEAD must resolve locally and have one common ancestor
230
+ that declares no source row. The base may already use that ID; the current
231
+ tree must declare it only once. Choose an unused destination above both story trees'
232
+ highest decision number, retired IDs included, within the four-digit grammar.
233
+ The command reserves no number and chooses no final number automatically.
234
+
235
+ Read the preview's fixed SHAs, IDs, relative paths and replacement lines or
236
+ counts. It writes nothing and dumps no original lines or full files. Each
237
+ invocation builds its own plan. Run with `--apply` to recheck that invocation's
238
+ fixed refs and original bytes before writing; changed refs after a preview can
239
+ produce a different plan. Preflight-only
240
+ `--format`, `--fail-on`, `--import` and `--assume` are not accepted here.
241
+ Only provably branch-added exact references change. Inherited references stay
242
+ fixed; ambiguous ownership, dirty or linked candidates, unsupported text or
243
+ failed reads stop the whole plan before writing. Unrelated links and dirty
244
+ files are not candidates. Apply rechecks original bytes before each write.
245
+ Rollback restores a changed file only if its bytes still match this invocation's
246
+ replacement, preserving concurrent changes and naming any unrestored path.
247
+ These checks guarantee neither atomic concurrency nor power-loss safety.
248
+
249
+ A move to another BF changes the story's US ID and all child AC and EX IDs. It follows the existing approval path, not the same-BF capacity exception. Apply the complete map above to approved active citations and retire old IDs in a new approved record; inherited DEC cells and their historical references stay unchanged.
80
250
 
81
251
  ## Completion of triage
82
252