qfai 1.9.2 → 1.10.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 (136) hide show
  1. package/README.md +67 -6
  2. package/assets/init/.qfai/assistant/README.md +27 -0
  3. package/assets/init/.qfai/assistant/agents/acceptance-test-engineer.md +1 -0
  4. package/assets/init/.qfai/assistant/agents/backend-engineer.md +1 -0
  5. package/assets/init/.qfai/assistant/agents/completion-reviewer.md +29 -2
  6. package/assets/init/.qfai/assistant/agents/delivery-planner.md +17 -0
  7. package/assets/init/.qfai/assistant/agents/frontend-engineer.md +1 -0
  8. package/assets/init/.qfai/assistant/agents/implementation-reviewer.md +17 -0
  9. package/assets/init/.qfai/assistant/agents/orchestrator.md +2 -2
  10. package/assets/init/.qfai/assistant/agents/qa-gatekeeper.md +183 -5
  11. package/assets/init/.qfai/assistant/agents/test-design-analyst.md +22 -3
  12. package/assets/init/.qfai/assistant/catalog/cli-ux-guidelines.md +2 -2
  13. package/assets/init/.qfai/assistant/catalog/spec_required_files.json +2 -1
  14. package/assets/init/.qfai/assistant/catalog/test-layers-ci-lanes.md +60 -0
  15. package/assets/init/.qfai/assistant/catalog/test-layers.md +430 -13
  16. package/assets/init/.qfai/assistant/catalog/worklog-entry.schema.md +165 -0
  17. package/assets/init/.qfai/assistant/constitution/communication.md +1 -1
  18. package/assets/init/.qfai/assistant/constitution/constitution.md +1 -1
  19. package/assets/init/.qfai/assistant/constitution/drift-protocol.md +359 -10
  20. package/assets/init/.qfai/assistant/constitution/quality.md +35 -5
  21. package/assets/init/.qfai/assistant/constitution/requirements-decomposition.md +37 -0
  22. package/assets/init/.qfai/assistant/constitution/shared-skill-delegation-baseline.md +419 -8
  23. package/assets/init/.qfai/assistant/constitution/shared-skill-operating-baseline.md +122 -5
  24. package/assets/init/.qfai/assistant/constitution/workflow.md +53 -7
  25. package/assets/init/.qfai/assistant/manifest/agent-catalog.yml +439 -946
  26. package/assets/init/.qfai/assistant/manifest/agent-routing.yml +116 -4
  27. package/assets/init/.qfai/assistant/manifest/review-profiles.yml +9 -0
  28. package/assets/init/.qfai/assistant/process/migrations/v1.4.27-atdd-alignment.md +1 -1
  29. package/assets/init/.qfai/assistant/skills/qfai-atdd/SKILL.md +150 -53
  30. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/credential-reuse.md +146 -0
  31. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/red-provenance.md +456 -0
  32. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/review-fix-rounds.md +128 -0
  33. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/scaffolding.md +29 -0
  34. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/shared-test-artifacts.md +96 -0
  35. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/stale-manifest.md +34 -0
  36. package/assets/init/.qfai/assistant/skills/qfai-atdd/references/test-case-depth-checklist.md +52 -5
  37. package/assets/init/.qfai/assistant/skills/qfai-configure/SKILL.md +16 -8
  38. package/assets/init/.qfai/assistant/skills/qfai-discussion/SKILL.md +8 -4
  39. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/design-md-brand-catalog.md +2 -2
  40. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/discussion-completion-matrix.md +17 -7
  41. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/rcp_footer.md +10 -4
  42. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/review-cycle-playbook.md +5 -1
  43. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui-bearing-playbook.md +4 -4
  44. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/review_audit_playbook.md +1 -1
  45. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux/trend_scan_playbook.md +1 -1
  46. package/assets/init/.qfai/assistant/skills/qfai-discussion/references/ui_ux_best_practices.md +17 -7
  47. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/01_Context.md +1 -1
  48. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/02_Inception-Deck.md +1 -1
  49. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/03_Story-Workshop.md +11 -3
  50. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/05_Scope.md +5 -2
  51. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/07_NFR.md +1 -1
  52. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/09_Constraints.md +7 -4
  53. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/10_Policy.md +1 -1
  54. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/11_OQ-Register.md +1 -1
  55. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/12_OQ-Resolution-Log.md +1 -1
  56. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/14_Review-Request.md +14 -7
  57. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/99_delta.md +1 -1
  58. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/Rxx_reviewer.md +16 -7
  59. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/review_request.md +9 -6
  60. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/review/summary.json +2 -0
  61. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/40_screen_contracts.md +3 -2
  62. package/assets/init/.qfai/assistant/skills/qfai-discussion/templates/uiux/50_review_input_bundle.md +4 -2
  63. package/assets/init/.qfai/assistant/skills/qfai-implement/SKILL.md +252 -130
  64. package/assets/init/.qfai/assistant/skills/qfai-implement/references/change-request-reset.md +93 -0
  65. package/assets/init/.qfai/assistant/skills/qfai-implement/references/checkpoint-verification.md +210 -0
  66. package/assets/init/.qfai/assistant/skills/qfai-implement/references/cross-spec-ownership.md +73 -0
  67. package/assets/init/.qfai/assistant/skills/qfai-implement/references/evidence-revision.md +291 -0
  68. package/assets/init/.qfai/assistant/skills/qfai-implement/references/execution-ledger.md +389 -0
  69. package/assets/init/.qfai/assistant/skills/qfai-implement/references/final-checklist.md +28 -0
  70. package/assets/init/.qfai/assistant/skills/qfai-implement/references/finding-classification.md +49 -0
  71. package/assets/init/.qfai/assistant/skills/qfai-implement/references/ledger-preconditions.md +55 -0
  72. package/assets/init/.qfai/assistant/skills/qfai-implement/references/oracle-strength.md +81 -0
  73. package/assets/init/.qfai/assistant/skills/qfai-implement/references/parallelization-policy.md +235 -0
  74. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-admissibility.md +91 -0
  75. package/assets/init/.qfai/assistant/skills/qfai-implement/references/red-not-observable.md +112 -0
  76. package/assets/init/.qfai/assistant/skills/qfai-implement/references/relevant-test-suite.md +87 -0
  77. package/assets/init/.qfai/assistant/skills/qfai-implement/references/review-artifact-layout.md +44 -0
  78. package/assets/init/.qfai/assistant/skills/qfai-implement/references/round-evidence.md +118 -0
  79. package/assets/init/.qfai/assistant/skills/qfai-implement/references/selector-granularity.md +24 -0
  80. package/assets/init/.qfai/assistant/skills/qfai-implement/references/upstream-artifact-ordering.md +33 -0
  81. package/assets/init/.qfai/assistant/skills/qfai-implement/references/volume-policy.md +149 -0
  82. package/assets/init/.qfai/assistant/skills/qfai-prototyping/SKILL.md +35 -18
  83. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/evidence-requirements.md +1 -1
  84. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/generator-prompt.md +106 -7
  85. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/handoff.md +40 -11
  86. package/assets/init/.qfai/assistant/skills/qfai-prototyping/references/iteration-loop.md +48 -1
  87. package/assets/init/.qfai/assistant/skills/qfai-prototyping/templates/DESIGN.md.sample +6 -0
  88. package/assets/init/.qfai/assistant/skills/qfai-sdd/SKILL.md +87 -22
  89. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/contract-artifact-rules.md +148 -0
  90. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/rcp_footer.md +10 -4
  91. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/review-cycle-playbook.md +5 -1
  92. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-execution-playbook.md +4 -2
  93. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-phase-checklists.md +18 -0
  94. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-quality-gate.md +44 -3
  95. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/sdd-triage.md +60 -7
  96. package/assets/init/.qfai/assistant/skills/qfai-sdd/references/spec-traceability-rules.md +171 -6
  97. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/change-request.md +125 -0
  98. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/contracts/db-contract.sample.sql +6 -0
  99. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/evidence/sdd-spec.md +92 -0
  100. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/01_Objective.md +27 -0
  101. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/02_Initiative.md +30 -0
  102. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/05_Contracts.md +16 -6
  103. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/06_Glossary.md +19 -0
  104. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/07_Constraints.md +25 -0
  105. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/08_Decisions.md +22 -2
  106. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/_policies/11_Slice-Policy.md +37 -10
  107. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/02_User-stories.md +20 -0
  108. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/03_Acceptance-Criteria.md +19 -0
  109. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/04_Business-Rules.md +32 -3
  110. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/06_Test-Cases.md +56 -0
  111. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/07_Decisions.md +29 -2
  112. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/10_Plan.md +41 -0
  113. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/16_Traceability-ledger.md +58 -0
  114. package/assets/init/.qfai/assistant/skills/qfai-sdd/templates/specs/spec/tdd/test-list.md +56 -0
  115. package/assets/init/.qfai/assistant/skills/qfai-verify/SKILL.md +57 -102
  116. package/assets/init/.qfai/assistant/skills/qfai-verify/references/articles.md +24 -0
  117. package/assets/init/.qfai/assistant/skills/qfai-verify/references/context-load.md +22 -0
  118. package/assets/init/.qfai/assistant/skills/qfai-verify/references/verify-output-contract.md +48 -0
  119. package/assets/init/.qfai/assistant/skills/qfai-verify/templates/verify-evidence.md +48 -0
  120. package/assets/init/.qfai/assistant/skills/web-research/SKILL.md +25 -7
  121. package/assets/init/.qfai/waivers.yml +11 -5
  122. package/assets/init/root/.github/workflows/qfai-tests.yml +318 -0
  123. package/assets/init/root/.github/workflows/qfai-validate.yml +327 -24
  124. package/assets/init/root/DESIGN.md +6 -0
  125. package/assets/init/root/qfai.config.yaml +15 -12
  126. package/dist/cli/index.cjs +20646 -13620
  127. package/dist/cli/index.cjs.map +1 -1
  128. package/dist/cli/index.mjs +22101 -15061
  129. package/dist/cli/index.mjs.map +1 -1
  130. package/dist/index.cjs +13954 -8829
  131. package/dist/index.cjs.map +1 -1
  132. package/dist/index.d.cts +423 -14
  133. package/dist/index.d.ts +423 -14
  134. package/dist/index.mjs +9330 -4224
  135. package/dist/index.mjs.map +1 -1
  136. package/package.json +22 -19
@@ -0,0 +1,118 @@
1
+ # Round Evidence
2
+
3
+ Per-round fields of the `qfai-implement` evidence contract. The skill's
4
+ `### Per-item evidence contract` section carries the summary.
5
+
6
+ ## Round block
7
+
8
+ One block per RED/GREEN cycle. Round 1 is the original cycle; each blocking
9
+ reviewer `REVISE` that requires new production behaviour adds a round.
10
+
11
+ - `Round N: Revision` — the state this round's observations were made
12
+ against (`evidence-revision.md`)
13
+ - `Round N: RED revision` — the tree that round's RED was observed on, and
14
+ `Round N: RED test hash` with its manifest. Each round's RED is taken on its
15
+ own tree, so holding one of each for the row meant a second round either
16
+ overwrote the first pair's address or inherited it — neither of which any
17
+ reader can audit
18
+ - `Round N: RED command` — the exact command executed to observe failure
19
+ - `Round N: RED result` — the failure output (result completeness is
20
+ best-effort; truncated output is acceptable)
21
+ - `Round N: Satisfied-by` / `Falsifiability command` / `Falsifiability result`
22
+ — **in place of the RED pair** on a `falsifiability` row. It is that row's
23
+ RED observation, so it sits where the RED pair sits and takes the same prefix;
24
+ writing it unprefixed left the completion gate unable to find the round it
25
+ belongs to
26
+ - `Round N: GREEN command` — the exact command executed to observe success
27
+ - `Round N: GREEN result` — the success output
28
+ - `Round N: reviewer verdict` — the verdict that closed the round (`PASS`, or
29
+ `REVISE` plus the finding, and which rework path it took). Absent on round 1
30
+ when no review has run yet.
31
+
32
+ ## What opens a round
33
+
34
+ Round 1 is the original RED/GREEN cycle. Each blocking reviewer `REVISE` that
35
+ requires new production behaviour adds a round. A `REVISE` that needs none
36
+ (naming, duplication, comments) opens no round and is verified by a refreshed
37
+ `Refactor verify` pair instead. Rounds are numbered and repeatable, not appended
38
+ as free prose.
39
+
40
+ Every field in a round block carries the `Round N:` prefix, and **this list
41
+ is the whole of it** — `Revision`, the RED pair (or the falsifiability trio in
42
+ its place), the GREEN pair, the reviewer verdict. Row-level fields are not round
43
+ fields and take no prefix: `TDD-ID`, the obligation reference, `Test file`,
44
+ `Selector`, `Layer`, and the refactor-verify pair. `RED revision`,
45
+ `RED test hash` and `Falsifiability revision` were on that list until a
46
+ second round showed they describe a round's RED, not the row's.
47
+
48
+ ## Single-round items
49
+
50
+ A single-round item satisfies the contract with `Round 1: ...` and no
51
+ reviewer-verdict line, which is the same content the previous one-pair
52
+ contract required. Nothing existing becomes non-conformant.
53
+
54
+ ## Where the rounds happen
55
+
56
+ An item at `review-fix` may re-enter the RED/GREEN cycle as many times as the
57
+ rework needs. Each pass is its own round block.
58
+
59
+ **The row's `Status` stays `review-fix` throughout.** The RED/GREEN passes are
60
+ work, not ledger states here: `review-fix -> red` and `review-fix -> green` are
61
+ not allowed transitions, and writing either would be the backward transition
62
+ the lifecycle forbids. `review-fix -> refactor` is the only status change the
63
+ rework produces; the rounds themselves are recorded in `Evidence`.
64
+
65
+ ## A `REVISE` that needs no new production behaviour
66
+
67
+ `implementation-reviewer` frequently returns `REVISE` for naming, duplication
68
+ or a comment — rework that changes no observable behaviour. There is no new
69
+ failing test to write, so opening a round would mean inventing a RED phase for
70
+ a change that has none. That rework takes the second path:
71
+
72
+ 1. The status contract is unchanged: the row still moves
73
+ `refactor -> review-fix` and back.
74
+ 2. **No round is opened.** Round blocks record RED/GREEN cycles; a
75
+ behaviour-preserving change has none.
76
+ 3. Make the change, re-run the item's tests, and refresh
77
+ `Refactor verify command` / `Refactor verify result`. That refreshed pair is
78
+ the evidence the change kept GREEN, and it must be fresh — the pre-rework
79
+ pair is stale evidence.
80
+ 4. Record the trigger and the path taken on the current round's
81
+ `Round N: reviewer verdict` line, then return to `refactor` and re-submit.
82
+
83
+ Which path applies is decided by the finding, not by the reviewer: a `REVISE`
84
+ that requires new production behaviour opens round N+1 even when it came from
85
+ `implementation-reviewer`.
86
+
87
+ ## Who the rework goes back to
88
+
89
+ Returning to `refactor` re-submits the item to **every routed blocking reviewer
90
+ whose verdict the rework could invalidate** — always the reviewer that opened
91
+ the round, plus any reviewer that already returned `PASS` on artifacts the
92
+ rework changed. A `PASS` recorded against the pre-rework test or production
93
+ code is stale evidence: it does not count towards "After all routed blocking
94
+ reviewers return PASS" and must be re-earned before the item may reach `done`.
95
+
96
+ ## Resuming a `review-fix` item
97
+
98
+ A `review-fix` row can outlive the session that created it — the operator
99
+ interrupts, or the run ends between the `REVISE` and the rework. On the next
100
+ start, `review-fix` rows are selected **before** any `todo` row (Required
101
+ Process, Phase: Red, step 1), so an interrupted rework is always resumed
102
+ rather than stranded behind newer items.
103
+
104
+ Resuming a `review-fix` row:
105
+
106
+ 1. Read the round blocks already in the item's evidence and take the highest
107
+ `Round N`; the reviewer verdict on that round names the finding to fix.
108
+ 2. Pick the path the finding calls for: open round `N + 1` and run the
109
+ RED/GREEN cycle when the fix needs new production behaviour, or take the
110
+ behaviour-preserving path above when it does not.
111
+ 3. Return the row to `refactor` and re-submit per **Who the rework goes back
112
+ to** above.
113
+
114
+ A `review-fix` row must already have a `Test file` — it reached `refactor`
115
+ before the `REVISE`. `validateTddList` checks the file exists for
116
+ `review-fix` exactly as it does for `green`, `refactor` and `done`, so a
117
+ rework row that lost its test file is reported (`TDDLIST_TEST_FILE_MISSING`)
118
+ instead of being accepted as a valid ledger state.
@@ -0,0 +1,24 @@
1
+ # Selector Granularity
2
+
3
+ `Selector` is **not** restricted to a single test function. A row may legally own several, written as
4
+ a comma-separated list or a glob — but only when they observe the **same** boundary from different
5
+ angles: `test_rejects_expired_token_via_header, test_rejects_expired_token_via_cookie`, or
6
+ `test_rejects_expired_token_*`. Two different rejection reasons (`expired_token` and
7
+ `wrong_audience`) are two boundaries and therefore two rows. What is restricted is what a row may
8
+ _conflate_:
9
+
10
+ - **One independently observable boundary per row.** Multiple selector entries are for covering that
11
+ one boundary from more than one angle, never for packing several boundaries behind one `TDD-ID`.
12
+ RED is still observed **per selector entry**, not once per row — each entry needs its own "watch it
13
+ fail for the expected reason" observation, and each entry's failure reason is recorded separately
14
+ in Evidence.
15
+ - **A matrix-shaped `TC-*` must be decomposed before RED begins.** A `TC-*` that enumerates many
16
+ rejection reasons, a status-code matrix, or several independent state transitions is split across
17
+ multiple TDD rows — one falsifying oracle per row — rather than accumulated behind one selector.
18
+ The splitting rule: **one row per independently observable boundary**. Rows that decompose the
19
+ same `TC-*` all carry that `TC-*` in `TC-Refs`; `TC-Refs` is many-to-many with `TDD-ID`.
20
+ - A selector that accumulates unrelated boundaries **invalidates the RED observation** — see the Red
21
+ phase below.
22
+ - **Precedence, when the two rules seem to disagree:** the row-splitting rule wins. If you cannot
23
+ name the single boundary that every selector entry on a row observes, the row is carrying more
24
+ than one and must be split.
@@ -0,0 +1,33 @@
1
+ # Upstream Artifact Ordering
2
+
3
+ What to do when a row's own test asserts over the **content** of an artifact this skill may not write
4
+ — a decision record in `07_Decisions.md`, a contract, another spec file.
5
+
6
+ ## The row is not implementable here, and all three moves lose
7
+
8
+ 1. **Write the artifact.** Forbidden: `07_Decisions.md` and `09_delta.md` are upstream SSOT this skill
9
+ may not patch, and writing spec artifacts other than this skill's own ledger belongs to `/qfai-sdd`.
10
+ 2. **Leave the row at `todo` and say nothing.** Correct by the letter, and it strands the row on an
11
+ artifact only another skill can produce, with no mechanism that summons that skill. A later reader
12
+ sees a row waiting on nothing in particular and waits with it.
13
+ 3. **Weaken the assertion** so it no longer needs the artifact. Forbidden, and it discards the
14
+ obligation the row exists to carry.
15
+
16
+ None of the three is a good outcome, which is why the situation is a defect in the arrangement rather
17
+ than a decision for the agent that meets it.
18
+
19
+ ## What to do instead
20
+
21
+ Stop at the row. Raise a Change Request naming the artifact and the rows that read it, and let
22
+ `/qfai-sdd` produce it. The row stays where it is until that lands — the Change Request is the
23
+ mechanism that summons the other skill, which is the thing option 2 above is missing.
24
+
25
+ Record the artifact's absence as the reason, not the calendar. A row whose recorded anomaly says
26
+ "waiting" tells the next reader to wait; a row that names the missing artifact tells them what to go
27
+ and get.
28
+
29
+ ## The constraint that prevents it
30
+
31
+ `/qfai-sdd` carries the other half: a test case whose assertion reads an upstream artifact's content
32
+ must not be written before that artifact exists. This file is what to do when you meet a row written
33
+ before that constraint was in force.
@@ -0,0 +1,149 @@
1
+ # Volume Policy
2
+
3
+ ## Why this exists
4
+
5
+ The per-item ceremony in `SKILL.md` is written for a ledger of tens of rows. At
6
+ the volume `/qfai-sdd` and `/qfai-atdd` routinely produce it is arithmetically
7
+ unfinishable, and an unfinishable process is abandoned wholesale — taking the
8
+ RED/GREEN evidence and the drift discipline with it. Scaling the ceremony is
9
+ what keeps those intact; dropping a gate is not on the table.
10
+
11
+ The per-item ceremony below is written for a ledger of tens of rows. At the
12
+ volume `/qfai-sdd` and `/qfai-atdd` routinely produce it is arithmetically
13
+ unfinishable, and an unfinishable process is abandoned wholesale — taking the
14
+ RED/GREEN evidence and drift discipline with it. Scale the ceremony instead.
15
+
16
+ ## Risk tier (derive per row)
17
+
18
+ Derive the tier from the ledger row's `Layer`, what the item touches, and what
19
+ it would cost to get wrong:
20
+
21
+ | Tier | Row shape | Ceremony |
22
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
23
+ | **T1 — standard** | Pure decision logic; unit/component layer; touches no infrastructure, no public API surface, no UI; not critical below | `qa-gatekeeper` confirms RED/GREEN once per coherent group instead of once per row. Reviews are batched the same way (below). |
24
+ | **T2 — elevated** | Touches infrastructure, a public API surface, a contract (`CON-*`), or persisted schema — **or** is critical (below) | Full per-item ceremony: per-row `qa-gatekeeper` RED and GREEN turns, per-row `completion-reviewer` and `implementation-reviewer`. |
25
+ | **T3 — surface** | Changes UI behavior or rendered output | T2 plus `product-surface-reviewer`. |
26
+
27
+ Record the tier in the row's `Evidence` cell alongside the RED/GREEN commands.
28
+ A row with no recorded tier is treated as **T2**.
29
+
30
+ ### Criticality outranks connectedness
31
+
32
+ Tiering is not only about what the code is wired to. A row is **T2 regardless of
33
+ layer**, even as pure unit-level logic touching nothing else, when it implements:
34
+
35
+ - an authorization or authentication decision (permission checks, role/scope
36
+ evaluation, token or session validity);
37
+ - cryptographic verification (signature, MAC, hash comparison, nonce or replay
38
+ checks, key selection);
39
+ - money or accounting arithmetic (pricing, billing, tax, interest, currency
40
+ conversion, ledger balancing);
41
+ - data-integrity or safety-critical logic (irreversible mutation and deletion
42
+ rules, quota and rate limits, PII redaction or retention, consent
43
+ enforcement, idempotency keys).
44
+
45
+ Cheap to connect is not the same as cheap to get wrong. When it is arguable
46
+ whether a row is critical, it is critical.
47
+
48
+ ### Routing is unchanged
49
+
50
+ The tier scales **how often** a gate runs, never **whether** it runs.
51
+ `agent-routing.yml` keeps `qa-gatekeeper`, `completion-reviewer` and
52
+ `implementation-reviewer` all **mandatory** for `qfai-implement`; T1 only
53
+ changes the submitted unit from one row to one coherent group. Every row is
54
+ still covered by a live turn from each of those agents, and a group that has
55
+ not been confirmed leaves all of its members short of the 11-point gate.
56
+
57
+ Note the asymmetry, because "all routed blocking reviewers pass" alone is not
58
+ the item gate: `blocking_agents` lists only `qa-gatekeeper` and
59
+ `completion-reviewer`. `implementation-reviewer` is mandatory but not in that
60
+ list, and a `REVISE` from it still blocks `done` — item 8 of the 11-point gate
61
+ requires its PASS independently of the routing list. Read the 11-point gate as
62
+ the authority for an item transition; `blocking_agents` governs phase
63
+ progression, not the ledger write.
64
+
65
+ ## Batched review
66
+
67
+ For T1 rows, run **one** `completion-reviewer` pass and **one**
68
+ `implementation-reviewer` pass per _coherent group_ — a set of items that share
69
+ a BR or an AC — instead of one pass per item. The group is the review unit:
70
+
71
+ - record the group's member `TDD-ID`s as a single block in the evidence file;
72
+ - a `REVISE` on the group blocks every member until it is resolved;
73
+ - a group must not mix tiers; a T2 or T3 row is always reviewed alone.
74
+
75
+ ### Group formation (states and transitions)
76
+
77
+ Batching adds **no** status value. It adds exactly **one** lifecycle edge, the
78
+ `refactor -> red` QA rejection recovery in `SKILL.md`, because confirming
79
+ RED/GREEN after the row has left `red` is only meaningful if a rejected row can
80
+ redo it. A T1 row whose refactor verify is GREEN sits in `refactor` — that is
81
+ the review-ready state — and waits there for its group. Members still move
82
+ `refactor -> done`, only together.
83
+
84
+ - **Open** the group when the first T1 row of a BR/AC reaches `refactor`.
85
+ - **Fill** it by continuing to process that BR/AC's remaining rows one item at
86
+ a time. The one-item-at-a-time constraint is about the Red/Green cycle: at
87
+ most one row is in `red` or `green` at any moment. A row parked in `refactor`
88
+ is an in-flight member of the **open** group, not an abandoned item, so
89
+ parking is not a violation of that constraint.
90
+ - **Close** the group — this is the review-start condition — at whichever comes
91
+ first: every member has reached `refactor`; the next `todo` row belongs to a
92
+ different BR/AC; the ledger has no `todo` rows left. A group never spans a
93
+ spec, so finishing a ledger also closes the open group.
94
+ - **Review** on close: one `qa-gatekeeper` turn over the members' recorded
95
+ RED/GREEN evidence, one `completion-reviewer` pass, one
96
+ `implementation-reviewer` pass. On `REVISE` no member goes `done`; where the
97
+ faulted member goes depends on what was faulted:
98
+ - `completion-reviewer` / `implementation-reviewer` `REVISE`, or a
99
+ `qa-gatekeeper` `REVISE` about how the evidence was **written** — fix in
100
+ place; the member stays in `refactor` and the refactor verify re-runs.
101
+ - `qa-gatekeeper` `REVISE` rejecting the **cycle** (the RED never failed, or
102
+ failed for the wrong reason) — that member takes the `refactor -> red` QA
103
+ rejection recovery, cites the verdict in `Evidence`, and re-runs its
104
+ micro-cycle. The group stays open and is reviewed again on close. Leaving it
105
+ in `refactor` instead would strand it: forward-only means it could never
106
+ redo the RED the gatekeeper rejected.
107
+ - **Checkpoint, then the ledger write.** Reviews passing is not the last gate:
108
+ `SKILL.md` Refactor step 5 and item 11 of the 11-point gate both require
109
+ checkpoint verification to pass **before** a row becomes `done`. Run it once
110
+ for the group after the three reviews return PASS, and only then transition
111
+ every member `refactor -> done` in the same ledger write. A failing checkpoint
112
+ leaves the whole group in `refactor` — no member goes `done` on a regression
113
+ the checkpoint would have caught.
114
+ - A group left open when the run ends is a completion prohibition: rows still in
115
+ `refactor` already block spec-level completion.
116
+
117
+ ## Multi-spec queue
118
+
119
+ Auto-discovery may accept **several** specs and process them **one spec at a
120
+ time**, in the order the user confirms. This is a queue, not parallelism: the
121
+ one-spec-at-a-time and one-item-at-a-time constraints are unchanged. It removes
122
+ the "invoke the skill eight times by hand" tax without touching the parallelism
123
+ question.
124
+
125
+ ### Advancing the queue
126
+
127
+ The queue is only a queue if the skill walks it. Record the confirmed order
128
+ once, then after each ledger:
129
+
130
+ 1. Close the spec normally — report its result, and satisfy the spec completion
131
+ conditions or report the blockers. `exception` rows do not stop the queue;
132
+ they are reported with their DR-IDs and carried into the final summary.
133
+ 2. Look at the remaining queue. **Empty -> exit.** Otherwise announce the next
134
+ `spec-id`, load its `test-list.md`, and restart at Phase: Red.
135
+ 3. "Report and exit" in CRITICAL CONSTRAINTS applies per ledger, not per run: a
136
+ ledger whose rows are all `done` yields "nothing to do" **for that spec** and
137
+ the queue advances past it rather than ending the run.
138
+ 4. Exit only after the last queued spec, with a summary naming every processed
139
+ spec and its outcome.
140
+
141
+ A queue entry is never skipped silently: a spec that cannot be started (missing
142
+ ledger, unresolved Change Request) is reported as blocked and the queue moves
143
+ on to the next entry.
144
+
145
+ ## Cost visibility
146
+
147
+ Before starting, state the implied cost: rows × gate cycles at the derived
148
+ tiers. If the ledger exceeds ~50 rows, surface that number to the user before
149
+ processing begins, and offer T1 batching explicitly.
@@ -38,7 +38,7 @@ One final prototype satisfying the spec under a locked brand identity, with all
38
38
  - `references/design-md-spec.md` — DESIGN.md front-matter schema and
39
39
  validation rules
40
40
  - `templates/DESIGN.md.sample` — reference content shipped at the
41
- consuming-project root by `qfai init`
41
+ consuming-project root by `npx qfai init`
42
42
 
43
43
  ## Required Contracts
44
44
 
@@ -60,13 +60,13 @@ current `DESIGN.md` hash does not match the lock.
60
60
  strict `surface_type: ui-bearing` frontmatter + matching
61
61
  `.qfai/contracts/ui/<spec-id>*.yaml`, with legacy title-marker and
62
62
  `qfai.config.yaml` `prototyping` pinning folded in. Run
63
- `qfai doctor --profile prototyping` to surface the resolved value.
63
+ `npx qfai doctor --profile prototyping` to surface the resolved value.
64
64
  Zero UI-bearing specs at cycle 0 is a deterministic no-op exit `0`.
65
65
  Confirm each resolved spec has a supported `surface`.
66
66
  - Confirm root `DESIGN.md` and `.qfai/contracts/design/DESIGN.md.lock.yaml`
67
67
  both exist; confirm `.qfai/contracts/ui/*.yaml` exists.
68
- - Run `qfai prototyping preflight --target-url <url>` (alias for
69
- `qfai doctor --profile prototyping`) — verifies DESIGN.md parses and
68
+ - Run `npx qfai prototyping preflight --target-url <url>` (alias for
69
+ `npx qfai doctor --profile prototyping`) — verifies DESIGN.md parses and
70
70
  matches the lock sha256.
71
71
 
72
72
  ### Step 2-B — Verify Environment Preconditions
@@ -74,13 +74,14 @@ current `DESIGN.md` hash does not match the lock.
74
74
  - Confirm a capture route exists for each declared screen.
75
75
  - Canonical launcher: `npx --no-install playwright` or
76
76
  `node_modules/.bin/playwright` when PATH reachability is uncertain.
77
- - Legacy fallback (deprecation window only, emits
78
- `D-DEPRECATED-PROBE` and will be removed in a future minor release):
79
- `npx --no-install playwright-cli` or `node_modules/.bin/playwright-cli`.
77
+ - `playwright-cli` was the legacy fallback. Its deprecation window closed:
78
+ `browserTool: "playwright-cli"` is now rejected by config load and
79
+ `D-DEPRECATED-PROBE` reports `error`. Install `playwright`
80
+ (`npm i -D playwright`) rather than reaching for it.
80
81
 
81
82
  ### Step 2-B.1 — Opt-in iterate flags
82
83
 
83
- Three flags extend `qfai prototyping iterate`; all default OFF so the
84
+ Three flags extend `npx qfai prototyping iterate`; all default OFF so the
84
85
  prior invocation pattern is byte-equivalent when no flag is passed:
85
86
 
86
87
  - `--capture` — enable PNG / HTML capture per screen each cycle via
@@ -90,7 +91,13 @@ prior invocation pattern is byte-equivalent when no flag is passed:
90
91
  - `--auto-serve` — start an in-process `node:http` server rooted at
91
92
  the prototype tree for the cycle. SIGINT teardown <= 2 s;
92
93
  EADDRINUSE on a foreign owner exits 2 (no foreign-process kill).
93
- Use when no external dev server is running.
94
+ Use when no external dev server is running. Routing is SPA-style:
95
+ a document request (GET/HEAD with `text/html` in `Accept`) that
96
+ matches no file on disk is served `index.html`, so client-side and
97
+ parameterized contract routes (`/overview`,
98
+ `/pairs/:instrument`) resolve instead of 404-ing. Sub-resource
99
+ requests (`.css`, `.png`, `fetch()`) still 404 when genuinely
100
+ missing, and the path-traversal 403 guard runs first.
94
101
  - `--check-convergence` — read-only peek of `prototyping.json`.
95
102
  Exits `0` when converged (`stopReason === "axes-exceptional"` with
96
103
  `acceptedIterationIndex` set), exits `2` otherwise. No writes,
@@ -100,9 +107,9 @@ prior invocation pattern is byte-equivalent when no flag is passed:
100
107
 
101
108
  | Step | Actor | Action | Output |
102
109
  | ----- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
103
- | C0 | product-experience-architect | `qfai prototyping iterate --cycle 0 --target-url <url>`. CLI computes `sha256(DESIGN.md)`; lock match enforced. Generator reads contracts + `references/generator-prompt.md` + DESIGN.md tokens and writes `.qfai/prototypes/iter-00/index.html`. Capture + review → `iter-00/review.json`. Append entry; commit `prototyping: iter-00`. | iter-00, prototyping.json#designMdSha256 |
104
- | C1..9 | (a) devops, (b) reviewer, (c) orchestrator, (d) generator | (a) playwright-cli writes `iter-NN/<screen>.{png,html}`; (b) reviewer writes `iter-NN/review.json` per `references/reviewer-prompt.md` (4 UX axes ordinal, 200..500 word critique, `layoutAntiPatternsDetected[]`, `designMdViolations[]`, `pivotDirective`); (c) update `prototyping.json#iterations[]` + `progress.md`, commit `prototyping: iter-NN`; (d) `qfai prototyping iterate --cycle <n+1>` decides exit. After C9 do NOT call `--cycle 10` — the CLI rejects out-of-range cycles. See the "Cycle 9 budget exhaustion" subsection below for recovery. | iter-NN, exit ∈ {0, 64, 65, 66, 2} |
105
- | H | orchestrator | Mirror latest to `.qfai/prototypes/final/index.html`. Per `references/handoff.md`: write `design-system.yaml` (deterministic DESIGN.md token mirror, no HTML extraction) + `prototype-handoff.yaml`. Run `qfai validate --profile prototyping --fail-on error` (produces `validate.json` with `counts.error === 0`), then `/qfai-verify` (produces `verify.json` with `status === "PASS"`), then `qfai prototyping certify` — certify requires both gate files to be present and passing before it will seal the certificate. | DONE |
110
+ | C0 | product-experience-architect | `npx qfai prototyping iterate --cycle 0 --target-url <url>`. CLI computes `sha256(DESIGN.md)`; lock match enforced. Generator reads contracts + `references/generator-prompt.md` + DESIGN.md tokens and writes `.qfai/prototypes/iter-00/index.html`. Capture + review → `iter-00/review.json`. Append entry; commit `prototyping: iter-00`. | iter-00, prototyping.json#designMdSha256 |
111
+ | C1..9 | (a) devops, (b) reviewer, (c) orchestrator, (d) generator | (a) playwright writes `iter-NN/<screen>.{png,html}`; (b) reviewer writes `iter-NN/review.json` per `references/reviewer-prompt.md` (4 UX axes ordinal, 200..500 word critique, `layoutAntiPatternsDetected[]`, `designMdViolations[]`, `pivotDirective`); (c) update `prototyping.json#iterations[]` + `progress.md`, commit `prototyping: iter-NN`; (d) `npx qfai prototyping iterate --cycle <n+1>` decides exit. After C9 do NOT call `--cycle 10` — the CLI rejects out-of-range cycles. See the "Cycle 9 budget exhaustion" subsection below for recovery. | iter-NN, exit ∈ {0, 64, 65, 66, 2} |
112
+ | H | orchestrator | Mirror latest to `.qfai/prototypes/final/index.html`. Per `references/handoff.md`: write `design-system.yaml` (deterministic DESIGN.md token mirror, no HTML extraction) + `prototype-handoff.yaml`. Run `npx qfai validate --profile prototyping --fail-on error` (produces `validate.json` with `counts.error === 0`), then `/qfai-verify` (produces `verify.json` with `status === "PASS"`), then `npx qfai prototyping certify` — certify requires both gate files to be present and passing before it will seal the certificate. | DONE |
106
113
 
107
114
  **Exit codes**: `0` continue (read `pivotDirective`); `64` convergence (4
108
115
  axes `exceptional` AND `layoutAntiPatternsDetected` empty AND
@@ -117,7 +124,7 @@ covers `frozenSurfaceUnion` / `frozenLicenseCatalog` drift on cycle ≥ 1).
117
124
 
118
125
  ### License-verify hard-stop (exit 66)
119
126
 
120
- `qfai prototyping iterate` exits `66` when an `imageSources[]` entry on
127
+ `npx qfai prototyping iterate` exits `66` when an `imageSources[]` entry on
121
128
  `prototyping.json` violates the cycle-0 frozen license catalog. The
122
129
  verifier rejects five distinct error codes:
123
130
 
@@ -142,18 +149,28 @@ Recovery path (no in-loop retry — the verifier is fail-closed):
142
149
 
143
150
  If convergence is not reached at iter-09, certify rejects the run; H
144
151
  handoff artifacts and `validate` / `/qfai-verify` can still execute for
145
- inspection, but `qfai prototyping certify --check` will exit non-zero
152
+ inspection, but `npx qfai prototyping certify --check` will exit non-zero
146
153
  and prevent DONE.
147
154
 
148
- Use `qfai prototyping iterate --cycle 9 --check-convergence` for a
155
+ Use `npx qfai prototyping iterate --cycle 9 --check-convergence` for a
149
156
  read-only peek of `prototyping.json` before refreezing: exit `0`
150
157
  confirms convergence (no recovery needed), exit `2` confirms the run
151
158
  did not converge. Recovery: review `DESIGN.md`, the pivot strategy
152
159
  in `references/reviewer-prompt.md`, and the latest `review.json`
153
- findings, then re-run `qfai prototyping iterate --cycle 0
160
+ findings, then re-run `npx qfai prototyping iterate --cycle 0
154
161
  --target-url <url>` to refreeze. Do not seal a certificate against
155
162
  an unconverged iter-09.
156
163
 
164
+ ### Continuing or resetting a converged loop
165
+
166
+ Only `stopReason: "axes-exceptional"` + `acceptedIterationIndex` seals a loop; `iterate --cycle N`
167
+ then refuses with exit `2` past the accepted index, writing nothing. `license-verify-fail` /
168
+ `input-error` do NOT seal — fix the cause and re-run the same cycle.
169
+ `max-iterations` does not seal either, but iter-09 still stops every `--cycle N >= 1` at exit `65`.
170
+ Recovery for both is the cycle-0 reset; re-running the accepted cycle is reported by the convergence
171
+ gate (exit `64`) and writes nothing, so it is a state read, not a rerun. The reset command, the
172
+ `--force` requirement and the `certify` alternative are in `references/iteration-loop.md#sealed-loop`.
173
+
157
174
  ## Evaluator Inputs (Mandatory)
158
175
 
159
176
  - Screenshot evidence path: `.qfai/evidence/prototyping/iter-NN/<screen>.png`
@@ -171,7 +188,7 @@ an unconverged iter-09.
171
188
  - Token-only colors / fonts / radii / shadows — non-DESIGN.md hex /
172
189
  rgb / rgba / hsl / font / radius / shadow values land in
173
190
  `designMdViolations[]` and block exit 64.
174
- - DONE only when `qfai prototyping certify --check` returns 0.
191
+ - DONE only when `npx qfai prototyping certify --check` returns 0.
175
192
  - No `mode / round / polish / branch / concept-fit` artifacts.
176
193
 
177
194
  ## Delegation Scope Table
@@ -192,7 +209,7 @@ an unconverged iter-09.
192
209
  ## Completion
193
210
 
194
211
  DONE = `completion-certificate.json` exists AND
195
- `qfai prototyping certify --check` returns 0 AND `/qfai-verify` returns
212
+ `npx qfai prototyping certify --check` returns 0 AND `/qfai-verify` returns
196
213
  PASS.
197
214
 
198
215
  Follow `.qfai/assistant/constitution/shared-skill-operating-baseline.md#gate-failure-autorepair-protocol` for validate, doctor, and quality-gate failures.
@@ -3,7 +3,7 @@
3
3
  Prototyping evidence files MUST include a `taskFidelity` section so the
4
4
  `QFAI-CRIT-009` gate passes. Below is the required keyword set and
5
5
  the canonical markdown shape consumed by the validator and the
6
- `qfai prototyping iterate --capture` template emitter.
6
+ `npx qfai prototyping iterate --capture` template emitter.
7
7
 
8
8
  ## Required keywords
9
9
 
@@ -92,10 +92,20 @@ forms caught:
92
92
 
93
93
  - Inline `border-radius: 12px` / `border-radius: 0.5rem`.
94
94
  - Tailwind arbitrary `rounded-[13px]`, `rounded-[0.5rem]`.
95
- - Tailwind scale aliases (`rounded`, `rounded-sm`, `rounded-md`,
96
- `rounded-lg`, `rounded-xl`, `rounded-2xl`, `rounded-3xl`,
97
- `rounded-full`, `rounded-none`) — all resolve to Tailwind defaults,
98
- not `DESIGN.md` tokens.
95
+ - Tailwind scale aliases with **no** `DESIGN.md.visual.radius` key of
96
+ the same name: bare `rounded` (Tailwind's `DEFAULT`), `rounded-xl`,
97
+ `rounded-2xl`, `rounded-3xl`, `rounded-none`. These resolve to
98
+ Tailwind defaults, not `DESIGN.md` tokens.
99
+ - `rounded-sm` / `rounded-md` / `rounded-lg` / `rounded-full` are
100
+ **allowed only in an iter whose own envelope re-binds that name**.
101
+ The schema's `visual.radius` keys are exactly `sm|md|lg|full`, and
102
+ the mandatory `theme.extend.borderRadius` injection re-binds those
103
+ four names to the `DESIGN.md` tokens — but the gate verifies that in
104
+ the iter's html rather than assuming it. An iter that omits the
105
+ envelope, drops a key from the `borderRadius` map, or binds it to a
106
+ different value renders Tailwind's default, and the alias is flagged
107
+ exactly as before. Same for the side/corner prefixes
108
+ (`rounded-t-md`, `rounded-tl-lg`, …).
99
109
 
100
110
  ### 4. box-shadow literal ban (including rgba color slot)
101
111
 
@@ -105,9 +115,23 @@ Authored forms caught:
105
115
 
106
116
  - Inline `box-shadow: 0 1px 2px rgba(15,23,42,0.05)`.
107
117
  - Tailwind arbitrary `shadow-[0_4px_6px_rgba(0,0,0,0.1)]`.
108
- - Tailwind scale aliases (`shadow`, `shadow-sm`, `shadow-md`,
109
- `shadow-lg`, `shadow-xl`, `shadow-2xl`, `shadow-inner`,
110
- `shadow-none`, `drop-shadow-*`).
118
+ - Tailwind scale aliases with **no** `DESIGN.md.visual.shadow` key of
119
+ the same name: bare `shadow` (Tailwind's `DEFAULT`), `shadow-xl`,
120
+ `shadow-2xl`, `shadow-inner`, `shadow-none`.
121
+ - Every `drop-shadow-<alias>` form, including `drop-shadow-sm|md|lg` —
122
+ the alias resolves through `theme.dropShadow`, which the mandatory
123
+ envelope does not inject, so it renders a Tailwind default no matter
124
+ what `visual.shadow` declares. The arbitrary form
125
+ `drop-shadow-[...]` carries its own literal and is judged like any
126
+ other arbitrary value: compliant when the literal is one of the
127
+ `visual.shadow` tokens, drift otherwise.
128
+ - `shadow-sm` / `shadow-md` / `shadow-lg` are **allowed only in an iter
129
+ whose own envelope re-binds that name**. The schema's `visual.shadow`
130
+ keys are exactly `sm|md|lg`, and the mandatory
131
+ `theme.extend.boxShadow` injection re-binds those three names to the
132
+ `DESIGN.md` tokens — but the gate verifies that in the iter's html
133
+ rather than assuming it, so an iter with a missing, incomplete, or
134
+ overwritten `boxShadow` map still has its aliases flagged.
111
135
 
112
136
  ### Safelisted CSS-wide keywords
113
137
 
@@ -151,6 +175,81 @@ The generator MUST express every styled surface as one of:
151
175
  - One self-contained HTML file; embedded CSS / JS minimal.
152
176
  - All declared spec screens reachable; loading / empty / error /
153
177
  success states representable.
178
+ - The compliance gate reports **one finding per distinct offending value**, not
179
+ one per occurrence: a single drifting token repeated across N screens is one
180
+ entry in `designMdViolations[]`. Fix the value once and the finding clears —
181
+ do not expect the count to track the number of places it appears.
182
+
183
+ ## Output layout — two trees, two shapes
184
+
185
+ There are two directory trees and they are NOT interchangeable. The
186
+ generator writes to exactly one of them.
187
+
188
+ | Tree | Shape | Written by | Read by |
189
+ | ------------------------------------- | -------------------------------------------------------- | ---------------------------------------- | ----------------------------------------------- |
190
+ | `.qfai/prototypes/iter-NN/` | one `index.html` | **the generator** (you) | `--auto-serve`, the operator, `/qfai-implement` |
191
+ | `.qfai/evidence/prototyping/iter-NN/` | `<screenId>.html` + `.png`, one pair per declared screen | `npx qfai prototyping iterate --capture` | `npx qfai prototyping certify`, the reviewer |
192
+
193
+ **The generator never writes the evidence tree.** The `--capture` step
194
+ performs the fan-out: it drives a browser to each declared screen's
195
+ contract `route`, and writes one HTML snapshot plus one screenshot per
196
+ screen into `.qfai/evidence/prototyping/iter-NN/`. `certify` reads only
197
+ that tree and hard-fails with "missing HTML for N declared screen(s)"
198
+ when a declared screen has no snapshot there.
199
+
200
+ ### N declared screens, one file
201
+
202
+ A spec declaring N screens is satisfied by **one** `index.html`
203
+ containing N client-side routes — not N files. Each declared screen
204
+ must be reachable at its own contract `route`, so the capture step can
205
+ navigate to it and snapshot it independently. This is what "all
206
+ declared spec screens reachable" above means operationally.
207
+
208
+ **Which routing shapes the capture step can actually reach.** Capture
209
+ navigates to `new URL(<contract route>, <target url>)` and treats any
210
+ HTTP status >= 400 as a failed screen, writing no evidence. What the
211
+ target server does with that URL therefore decides the routing shape:
212
+
213
+ - `--auto-serve` starts the built-in static file server. It resolves
214
+ every non-root URL to a real file under the served directory and
215
+ returns 404 when there is none — it has no SPA fallback. With it,
216
+ declare **hash routes** (`/#/settings`): the browser never sends the
217
+ fragment, so the server always serves `index.html` and the shell
218
+ routes client-side.
219
+ - **Path routes** (`/settings`) and any `history.pushState` shell need
220
+ a server that rewrites unknown paths to `index.html`. Run one
221
+ yourself and pass `--target-url`; they will 404 under `--auto-serve`.
222
+ - Per-screen files (`--emit-skeletons`, below) are a third option, but
223
+ only if the contract `route` names the file: `--emit-skeletons` writes
224
+ `<screenId>.html`, and the static server resolves a URL to a literal
225
+ path — it does not append `.html`, so a `/settings` route 404s while
226
+ `/settings.html` serves. `htmlSourceCopy` does not help here: it runs
227
+ after the capture has already navigated successfully, so it cannot
228
+ rescue a route the server could not resolve.
229
+
230
+ Pick the routing shape to match the server you will capture against,
231
+ and keep the contract `route` values consistent with it.
232
+
233
+ Opt-in **seed aid**, not an alternative output shape:
234
+ `npx qfai prototyping iterate --emit-skeletons` (cycle 0 only) writes one
235
+ placeholder `.qfai/prototypes/iter-00/<screenId>.html` per declared
236
+ screen, and the `htmlSourceCopy` capture option likewise operates on
237
+ per-screen files. Neither writes an `index.html`.
238
+
239
+ An accepted iteration must still carry `iter-NN/index.html`: Handoff
240
+ below copies it to `.qfai/prototypes/final/index.html`, and without it
241
+ `/qfai-implement` has nothing to read. So consolidate the skeletons into
242
+ the single-file envelope before the loop converges — including when a
243
+ cycle-0 skeleton set scores well enough that cycle 1 would otherwise
244
+ accept it as it stands. If you keep the per-screen files because your
245
+ capture routing needs them, author `index.html` alongside them so the
246
+ accepted iteration carries both.
247
+
248
+ ### Handoff
249
+
250
+ `.qfai/prototypes/final/index.html` is a copy of the accepted
251
+ `iter-NN/index.html` and is the deliverable `/qfai-implement` reads.
252
+ It is not a certify input; certify never opens the `prototypes/` tree.
154
253
 
155
254
  ## Cycle 0 (seed)
156
255