qfai 2.2.0 → 2.2.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 (117) hide show
  1. package/README.md +46 -6
  2. package/assets/defaults/workflows/bump-dependency.yml +4 -1
  3. package/assets/defaults/workflows/decide-design.yml +5 -1
  4. package/assets/defaults/workflows/rename-concept.yml +30 -0
  5. package/assets/defaults/workflows/resolve-conflicts.yml +14 -0
  6. package/assets/defaults/workflows/retire-feature.yml +26 -0
  7. package/assets/defaults/workflows/run-release.yml +12 -0
  8. package/assets/init/.claude/settings.json +11 -11
  9. package/assets/init/.codex/hooks.json +9 -9
  10. package/assets/init/.qfai/assistant/agent/backend-engineer.md +1 -1
  11. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +1 -1
  12. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +5 -0
  13. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +8 -3
  14. package/assets/init/.qfai/assistant/rule/constitution.md +5 -3
  15. package/assets/init/.qfai/assistant/rule/drift-protocol.md +18 -0
  16. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +1 -1
  17. package/assets/init/.qfai/assistant/rule/review-convergence.md +9 -3
  18. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +11 -2
  19. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +6 -4
  20. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +2 -1
  21. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +5 -2
  22. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +15 -2
  23. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +17 -0
  24. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/trend_scan_playbook.md +3 -1
  25. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/01_Context.md +4 -1
  26. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/04_Sources.md +5 -1
  27. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +4 -1
  28. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +2 -2
  29. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +10 -0
  30. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +35 -0
  31. package/assets/init/.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md +445 -0
  32. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +2 -2
  33. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +10 -9
  34. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +33 -2
  35. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +77 -2
  36. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +12 -3
  37. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +3 -1
  38. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +31 -5
  39. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +17 -17
  40. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +194 -129
  41. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +29 -14
  42. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +46 -22
  43. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +2 -0
  44. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +7 -4
  45. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -1
  46. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -1
  47. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +2 -2
  48. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +1 -1
  49. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +1 -0
  50. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +1 -1
  51. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +83 -6
  52. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +1 -1
  53. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +23 -5
  54. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +1 -1
  55. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions/page-NNNN.md +6 -0
  56. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +9 -0
  57. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/open-questions.md +13 -0
  58. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +15 -9
  59. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +1 -1
  60. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +11 -8
  61. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +15 -2
  62. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +48 -11
  63. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +11 -3
  64. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +12 -0
  65. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +18 -2
  66. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +4 -0
  67. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +3 -0
  68. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +4 -0
  69. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +31 -7
  70. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +12 -3
  71. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +35 -6
  72. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +25 -5
  73. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +26 -0
  74. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +28 -5
  75. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +20 -5
  76. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +70 -6
  77. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +39 -6
  78. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +12 -3
  79. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +56 -6
  80. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +5 -0
  81. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +8 -0
  82. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +9 -4
  83. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +22 -1
  84. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +48 -12
  85. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +7 -2
  86. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +6 -0
  87. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +76 -3
  88. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +35 -10
  89. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +65 -7
  90. package/assets/init/root/.agents/rules/api-budget.md +8 -3
  91. package/assets/init/root/.agents/rules/graph-exploration.md +18 -4
  92. package/assets/init/root/.agents/rules/reminders.json +20 -28
  93. package/assets/init/root/.agents/rules/user-questions.md +21 -11
  94. package/assets/init/root/.gitattributes +2 -0
  95. package/assets/init/root/AGENTS.md +1 -1
  96. package/assets/mdschema/manifest.yml +3 -0
  97. package/assets/mdschema/story/03_contract/tech.mdschema.yml +1 -1
  98. package/assets/mdschema/story/decisions/page-NNNN.mdschema.yml +32 -0
  99. package/assets/mdschema/story/decisions.mdschema.yml +12 -0
  100. package/assets/schemas/workflow/extraction.schema.json +94 -2
  101. package/assets/schemas/workflow/plan.schema.json +34 -1
  102. package/assets/scripts/check-mdschema.mjs +434 -45
  103. package/dist/cli/index.cjs +4930 -2264
  104. package/dist/cli/index.cjs.map +1 -1
  105. package/dist/cli/index.mjs +4690 -2016
  106. package/dist/cli/index.mjs.map +1 -1
  107. package/dist/graph/cli.cjs.map +1 -1
  108. package/dist/graph/cli.mjs.map +1 -1
  109. package/dist/graph/hook.cjs.map +1 -1
  110. package/dist/graph/hook.mjs.map +1 -1
  111. package/dist/index.cjs +3338 -1830
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +59 -3
  114. package/dist/index.d.ts +59 -3
  115. package/dist/index.mjs +3154 -1649
  116. package/dist/index.mjs.map +1 -1
  117. package/package.json +1 -1
@@ -17,7 +17,8 @@ agent does: wording, a typo, a code comment, prose in a document.
17
17
  ## Non-goals
18
18
 
19
19
  - A behaviour change of any size. That is another route's work.
20
- - A story-tree file, a contract, or a row of `decisions.md` or `open-questions.md`.
20
+ - A story-tree file, a contract, or a row of `decisions.md` or `open-questions.md`,
21
+ except as [Resolving conflicts](#resolving-conflicts) allows.
21
22
  - A file outside the write scope the request or the work order gives.
22
23
 
23
24
  ## Never a maintenance edit
@@ -28,7 +29,7 @@ as [A semantic effect](#a-semantic-effect) says:
28
29
  - dependency updates;
29
30
  - workflow and CI files;
30
31
  - authorization conditions and environment settings;
31
- - SQL and generated files;
32
+ - SQL, generated files and lockfiles;
32
33
  - a command a README states as the way to do something;
33
34
  - QFAI's own skills, steps and rules.
34
35
 
@@ -38,6 +39,61 @@ A procedure's actions, required values, commands and order govern what a person
38
39
  does. Changing any of them has a semantic effect, even when only Markdown
39
40
  changes.
40
41
 
42
+ ## Resolving conflicts
43
+
44
+ In the `resolve-conflicts` route, the step merges the named base into the
45
+ branch and keeps every record's meaning. `verify-commit` concludes the merge.
46
+
47
+ 1. Fetch the base (`git fetch`), then on a clean tree, before the merge,
48
+ renumber every `decisions.md` row the branch added, from the lowest one
49
+ whose ID the fetched base now declares upward, lowest first, by the
50
+ `npx qfai sdd renumber-decision` procedure in
51
+ `.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md` (two branches
52
+ taking the same ID), and commit after each run. The union merge of
53
+ `decisions.md` duplicates a colliding ID without a conflict, so this runs
54
+ first. When a merge has already stopped with conflicts, run
55
+ `git merge --abort`, renumber, and merge again.
56
+ 2. Start or resume the merge with `git merge --no-commit <base>`.
57
+ 3. Resolve each conflict. The base's item keeps its ID; never rename it. An
58
+ item the branch added whose ID collides takes the next free ID of its scope,
59
+ with every citation of it. Every other edit only keeps what one side already
60
+ had: what each side added to a conflicting block.
61
+
62
+ Stop before the edit, as [A semantic effect](#a-semantic-effect) says, on any
63
+ of these:
64
+
65
+ - Content neither side had is a semantic effect.
66
+ - When both sides changed the same record, keeping both is a semantic effect:
67
+ stop.
68
+ - An ID that two records already share on one history before this merge,
69
+ carried in by an earlier merge, is a semantic effect: stop.
70
+ - A conflict in code, or in a file listed under
71
+ [Never a maintenance edit](#never-a-maintenance-edit), such as a generated
72
+ file or a lockfile, stops: its owner route resolves or regenerates it.
73
+ - A conflict in a pin or digest file, or in a file with an owner marker or a
74
+ CODEOWNERS entry, stops.
75
+ - After the merge, check each union-merged register, such as `decisions.md`,
76
+ for an ID declared twice. A duplicate is a semantic effect: stop.
77
+
78
+ ### Several branches
79
+
80
+ When the user names several branches to take one base into, each branch is its
81
+ own run of this route, one branch at a time, with every rule above.
82
+
83
+ - Take the base in by merge, never by rebase. Never force-push a branch.
84
+ - On a stop, abort that branch's merge with `git merge --abort`, or keep each
85
+ branch in its own worktree, report the branch at its commit before the merge,
86
+ and go on with the next branch.
87
+ - The verify block repairs no failure on such a branch: a failing gate undoes
88
+ the merge and holds the branch.
89
+ - The route pushes nothing. A push the user's instruction names is planned
90
+ after the run as an order. A branch with a failed or UNRUN gate is not
91
+ pushed. A gate DELEGATED to CI may be pushed under the user's push
92
+ instruction once every gate that runs locally has passed, and the branch is
93
+ not merged until that CI check is green.
94
+ - Report each branch's result: merged locally, pushed, stopped on the named
95
+ file and hunk, or held by the named gate.
96
+
41
97
  ## Reads
42
98
 
43
99
  - The write scope the request or the work order gives.
@@ -51,7 +107,8 @@ itself.
51
107
 
52
108
  1. Read the write scope. Edit nothing outside it.
53
109
  2. Before editing, judge whether each planned edit has a semantic effect: a
54
- changed command, value, identifier, condition or rule. If one has, stop before
110
+ changed command, value, identifier, condition or rule, except a renumber
111
+ [Resolving conflicts](#resolving-conflicts) allows. If one has, stop before
55
112
  editing as [A semantic effect](#a-semantic-effect) says. Do not make the edit.
56
113
  3. Make the edit.
57
114
  4. Run the applicable lint and link checks over the changed files through
@@ -68,12 +125,12 @@ so the run is `blocked`, naming the finding and the owner skill to invoke by nam
68
125
  The session report records:
69
126
 
70
127
  - the semantic effect, affected paths and the review or command that found it;
71
- - that nothing was edited and the `edit-text` run binds no flow;
128
+ - that nothing was edited and this run binds no flow;
72
129
  - the owner skill to invoke by name: `qfai-implement` for code or configuration,
73
130
  or `qfai-sdd` for a story or contract;
74
131
  - the authorized owner route needed before work can resume.
75
132
 
76
- Do not treat a stage of the `edit-text` plan as the owner of this repair.
133
+ Do not treat a stage of this route's plan as the owner of this repair.
77
134
 
78
135
  ## Passes when
79
136
 
@@ -92,10 +149,17 @@ edit changes none. Any other entry under
92
149
  - The no-behaviour-change judgement, with its reason.
93
150
  - The independent review's verdict and who gave it.
94
151
  - The lint and link checks run, and their results.
152
+ - In the `resolve-conflicts` route: the base, each renumber as old → new, and
153
+ the combined diff of each resolved path, taken with `git diff` before it is
154
+ staged, and `git diff` of every path the renumbers touched. Every added line
155
+ is inside one side's text, except the ID changes that list names.
95
156
 
96
157
  ## Gate
97
158
 
98
159
  The diff stays inside the write scope, the no-behaviour-change judgement names
99
160
  its reason, and every check run over the changed files exited 0. The review that
100
161
  follows (`implementation-reviewer`) confirms the diff changes no behaviour; the
101
- reviewer is never the agent that made the edit.
162
+ reviewer is never the agent that made the edit. In the `resolve-conflicts`
163
+ route, that review runs as `common-review-cycle` says: a resolution that
164
+ touches no story-tree file, contract or register row gets no reviewer. The
165
+ combined diff passes the added-line check before `verify-commit` commits.
@@ -18,6 +18,8 @@ settles, by talking, the questions that do not need a prototype to answer.
18
18
  - The specs in the story tree, the UI contracts in scope (see [Scope](#scope))
19
19
  and root `DESIGN.md`.
20
20
  - `.qfai/prototype/grilling.md`, where an earlier run left one.
21
+ - `.qfai/prototype/final/index.html` and `final/handoff.json`, when the request
22
+ scopes the run (see [Run scope](#run-scope)).
21
23
 
22
24
  ## Writes
23
25
 
@@ -48,8 +50,34 @@ Inside an `npx qfai workflow` run the work order narrows that set:
48
50
 
49
51
  A standalone invocation still resolves every UI-bearing UI contract.
50
52
 
51
- The scope floor is unchanged: which UI contracts the loop covers is decided by
52
- their declared IDs and screens, and no session narrows it.
53
+ The scope floor is unchanged, and no session narrows it: its single home is
54
+ `.qfai/assistant/rule/constitution.md` Article VII § Prototyping exception
55
+ (scope floor).
56
+
57
+ ### Run scope
58
+
59
+ A run can rebuild part of a prototype the user already confirmed. The record's
60
+ optional `## Run scope` section names what the run changes, one entry per
61
+ line: a screen as `<ui-contract-id>/<screen>`, or a shared component by its
62
+ repository path or by the `item` that `final/handoff.json` `procurement`
63
+ names for it. Take the entries from the request, settle them in the session,
64
+ and write them afresh each run: a `## Run scope` an earlier run left does not
65
+ carry over.
66
+
67
+ The run covers the whole product, and the session report says so, when:
68
+
69
+ - the record has no `## Run scope`, or an empty one;
70
+ - `.qfai/prototype/final/index.html` is missing, or `final/handoff.json` is
71
+ missing or lacks `finalArtifact` or `procurement`, as the restyle short
72
+ form does;
73
+ - the run is a `restyle` loop.
74
+
75
+ Write no `## Run scope` in any of these cases.
76
+
77
+ Check the earlier `final/` against every declared screen outside the scope: it
78
+ needs a route in `final/index.html` and a `procurement` row. Add each screen
79
+ that lacks either to the scope; when the scope would then hold every screen,
80
+ run the whole product instead.
53
81
 
54
82
  ## What is grilled, and what is prototyped
55
83
 
@@ -97,8 +125,9 @@ user's behalf — with more evidence than before, and still not the user's answe
97
125
  that re-opens a frozen requirement produces an answer that drifts from it.
98
126
  What is left is what the session is for.
99
127
  3. Run the session. **It is delegated** (`.agents/rules/grilling.md` § Two
100
- kinds of session): a griller interviews the agents that generate and review
101
- the prototype, and each decision that is not critical takes its
128
+ kinds of session). The orchestrator starts the griller, never a stage
129
+ worker. The griller interviews the agents that generate and review the
130
+ prototype, and each decision that is not critical takes its
102
131
  recommendation. `DESIGN.md` is frozen from the discussion stage's answers, so
103
132
  a question of taste or purpose it already answers is adopted from it. One it
104
133
  leaves open is product intent, which is critical, and goes to the user.
@@ -119,7 +148,8 @@ and name it.
119
148
  **The session's answers are written down, and the loop reads them.** They go to
120
149
  `.qfai/prototype/grilling.md`, under `## Session` for the decisions
121
150
  — an adopted one names the agent that recommended it and why it was taken —
122
- and `## Escalated` for a critical decision the user has yet to settle. The
151
+ and `## Escalated` for a critical decision the user has yet to settle, plus
152
+ `## Run scope` when the run is scoped (see [Run scope](#run-scope)). The
123
153
  generator and the reviewer both take that file as an input — named in
124
154
  `prototyping-loop`'s `## Evaluator Inputs (Mandatory)` and in the generator's
125
155
  contract set — because a decision the loop cannot read is one it will
@@ -169,4 +199,7 @@ this gate's subject — those are what the loop exists to make answerable, and
169
199
  they are open by design until the user has something to react to.
170
200
 
171
201
  Otherwise the step passes when `.qfai/prototype/grilling.md` exists
172
- with both sections and every row carries a `Scope`.
202
+ with both sections and every row carries a `Scope`. Every `## Run scope`
203
+ entry names a declared screen, or a component (by existing path or
204
+ `procurement` item) that at least one screen in `final/index.html` renders.
205
+ Any other entry stops the run before the first iteration, naming it.
@@ -18,22 +18,30 @@ Runs only after the user confirmed the prototype in `prototyping-loop`.
18
18
  - `.qfai/assistant/skill/qfai-prototyping/references/handoff.md` — the handoff
19
19
  fields.
20
20
  - `.qfai/prototype/grilling.md`, for the completion report.
21
+ - `.qfai/prototype/progress.md`, for `iterationKind` and any `runScope`.
22
+ - In a scoped run, the `final/index.html` and `final/handoff.json` an earlier
23
+ run confirmed, which the merge keeps outside the scope.
21
24
 
22
25
  ## Writes
23
26
 
24
27
  - `.qfai/prototype/final/index.html` — a copy, not a symlink, of the confirmed
25
- iteration.
28
+ iteration, or in a scoped run its in-scope parts merged in, except in a
29
+ `restyle` loop.
26
30
  - `.qfai/prototype/final/handoff.json`, a CLI-HANDOFF record.
27
31
 
28
32
  ## Procedure
29
33
 
30
34
  1. Copy the confirmed iteration to `.qfai/prototype/final/index.html`.
35
+ In a `restyle` loop, copy nothing: the iteration is the live app. In a
36
+ scoped run, replace only the in-scope parts and keep the rest, as the
37
+ handoff reference's Scoped handoff says.
31
38
  2. Write `.qfai/prototype/final/handoff.json` per the handoff reference.
32
39
  3. Write the completion report.
33
40
 
34
41
  ## Gate
35
42
 
36
- The step passes when both files exist. Only `npx qfai validate --profile
43
+ The step passes when both files exist,
44
+ or, in a `restyle` loop, when `handoff.json` exists. Only `npx qfai validate --profile
37
45
  saas-package` checks the handoff record; nothing certifies the prototype.
38
46
 
39
47
  The completion report names:
@@ -41,6 +49,7 @@ The completion report names:
41
49
  - every blocking finding, layout anti-pattern and `DESIGN.md` violation the
42
50
  latest review still lists;
43
51
  - every decision a session adopted, from the `## Session` rows of
44
- `.qfai/prototype/grilling.md`, with why each was taken.
52
+ `.qfai/prototype/grilling.md`, with why each was taken;
53
+ - in a scoped run, the scope the user confirmed.
45
54
 
46
55
  It does not wait for an answer.
@@ -22,7 +22,8 @@ answer. No command, score or check decides that the loop is done.
22
22
 
23
23
  ## Writes
24
24
 
25
- - `.qfai/prototype/iter-NN/index.html` (the generator).
25
+ - `.qfai/prototype/iter-NN/index.html` (the generator), and in a `restyle`
26
+ loop the project's stylesheet and motion files it restyles.
26
27
  - `.qfai/prototype/iter-NN/review.json` and
27
28
  `iter-NN/<ui-contract-id>/<screen>.review.json` (the reviewer).
28
29
  - `.qfai/prototype/progress.md` (the orchestrator).
@@ -50,7 +51,8 @@ Generation and review use two distinct sub-agent identities. The reviewer
50
51
  operates Playwright during the assessment and returns its review payloads;
51
52
  it has no write access, so the orchestrator writes them. There is
52
53
  no fixed capture identity: a screenshot is taken by whoever needs it. The build
53
- owner is separate from this identity rule.
54
+ owner is separate from this identity rule. The orchestrator starts every role
55
+ in the table below, the generator included, and never a stage worker.
54
56
 
55
57
  | Work | Allowed Role |
56
58
  | --------------------------------------------- | ------------------------------------ |
@@ -65,6 +67,51 @@ the loop does not stop at it. Report an
65
67
  assignment that gives generation and review to one identity before either
66
68
  runs.
67
69
 
70
+ ## Iteration kind
71
+
72
+ Record `iterationKind` in `progress.md` beside `targetIterations` and the
73
+ other planning fields. The kind comes from the request, as preflight took it:
74
+ `prototype`, the default, or `restyle` when the request changes only the
75
+ styles and motion of screens the project already runs, keeping their screens,
76
+ fields and behaviour. A `restyle` iteration is the live app restyled in place.
77
+ The generator edits the project's stylesheet and motion entry points and
78
+ writes `iter-NN/index.html` as a list of the live routes in scope, one link
79
+ per declared screen. Each link carries the route's absolute URL and the setup
80
+ it needs, such as a login or seed data. The live app is already running at
81
+ preflight, and the build owner keeps it running, so each link answers and the
82
+ reviewer drives those routes directly.
83
+
84
+ A restyle's edits are product code. The route's implement stage carries them:
85
+ there they are change-noted, gated, tested and committed. So a restyle needs a
86
+ scope that includes the implement stage. A request extracted with the
87
+ qualifier `restyle` is planned with only such scopes.
88
+
89
+ If the route's scope has no implement stage, stop and ask the user to re-plan
90
+ before iteration 00.
91
+
92
+ ## Run scope
93
+
94
+ Each run records `runScope` in `progress.md` afresh, beside `iterationKind`,
95
+ before its first iteration, overwriting any earlier one. When `grilling.md`
96
+ has a non-empty `## Run scope`, it holds three lists: the in-scope screens, the in-scope
97
+ components, and the render-check screens, each the other screen that renders
98
+ an in-scope component, named `<ui-contract-id>/<screen>` with that component.
99
+ Find them in the `final/handoff.json` `procurement` rows and in
100
+ `final/index.html`. Otherwise `runScope` is recorded as absent.
101
+
102
+ The run's first iteration is the first one after that record. It treats no
103
+ earlier run's review or confirmation as its prior review or the user's last
104
+ answer: those start with this run.
105
+
106
+ - The run's first iteration starts from a copy of `final/index.html`. Each
107
+ later one builds on the previous iteration, whose out-of-scope parts are
108
+ still `final/`'s. Either way only the in-scope screens and components change,
109
+ and a `pivot` applies only inside the scope.
110
+ - The reviewer reviews the in-scope screens in full and, on a render-check
111
+ screen, only that the component renders there. No other screen is opened.
112
+
113
+ With `runScope` absent, every screen is in scope and nothing here applies.
114
+
68
115
  ## Procedure
69
116
 
70
117
  Run these for iteration `NN`: the next index after the iterations already
@@ -72,9 +119,11 @@ under `.qfai/prototype/`, or `00` when there are none.
72
119
 
73
120
  1. **Generator** (product-experience-architect). Reads the contracts,
74
121
  `.qfai/prototype/grilling.md`, the generator prompt, the `DESIGN.md` tokens
75
- and, from the second iteration on, the latest reviews and the user's last
76
- answer. It starts from the primary UI contract preflight resolved: the one
77
- the request names, else `prototyping.primaryUiContract`. Writes
122
+ and, from the run's second iteration on, this run's latest reviews and the
123
+ user's last answer. In a scoped run it also reads `runScope` in `progress.md` and
124
+ `.qfai/prototype/final/index.html`, every iteration. It starts from the
125
+ primary UI contract preflight resolved: the one the request names, else
126
+ `prototyping.primaryUiContract`. Writes
78
127
  `.qfai/prototype/iter-NN/index.html`.
79
128
  2. **Build** (devops-ci-engineer). Serves `.qfai/prototype/` at the URL
80
129
  preflight checked, starting the server on the first iteration and keeping it
@@ -139,7 +188,8 @@ confirmation.
139
188
 
140
189
  - The live prototype, opened in the reviewer's own Playwright session.
141
190
  - Root `DESIGN.md` (read-only), `axisDefs`, `previousScore` and
142
- `designSystemChecklist`.
191
+ `designSystemChecklist`. `previousScore` and the prior reviews come from
192
+ this run's own iterations; the run's first iteration has none.
143
193
  - The prior `review.json` files and `progress.md`.
144
194
  - The layout anti-pattern registry the package ships.
145
195
  - `.qfai/prototype/grilling.md` — what the prototype is for, what counts as
@@ -42,6 +42,11 @@ Nothing. The CLI checks are read-only.
42
42
  - Confirm a dev server or a static file server can serve
43
43
  `.qfai/prototype/` at the URL passed to
44
44
  `npx qfai doctor --profile prototyping --target-url <url>`.
45
+ - Take the iteration kind from the request: `restyle` when it changes only
46
+ the styles and motion of screens the project already runs.
47
+ - For a `restyle` request, the live app must already be running. Also run
48
+ `npx qfai doctor --profile prototyping --target-url <url>` against the live
49
+ app's URL, so the running app answers before the first iteration.
45
50
  - Doctor sends one `GET` to exactly the URL it is given, without following a
46
51
  redirect, and waits 3 seconds. A status from 200 to 399 passes; a 404 or any
47
52
  other status fails the check, and so does no answer. It probes that one URL,
@@ -63,6 +63,10 @@ states.
63
63
  attributes, and run the executable DB contract checks
64
64
  `contract-artifact-rules.md` requires. Record the command and result under
65
65
  Contract executability in the SDD report.
66
+ 7. Where a decision replaced a claim, such as an input, a threshold or a
67
+ count, search the whole story tree and the contracts for the old claim
68
+ before finishing. List each hit in the stage report, with what it now
69
+ says or why it stays.
66
70
 
67
71
  ## UI contracts
68
72
 
@@ -112,3 +116,7 @@ Read first: the triage decisions, the examples `sdd-story` wrote or kept, and th
112
116
  contracts whose rules cite them. The step passes when the change writes no BR
113
117
  and changes no contract or `contracts.md` row. The pass names the contracts it
114
118
  read.
119
+
120
+ A pass is refused while an example `sdd-story` wrote or kept is cited by no
121
+ BR, an example this run added included: that example is owed a rule, which
122
+ this step writes.
@@ -19,10 +19,11 @@ rules against their examples. Follow
19
19
  the Examples cell of a BR. No cycle runs when it changed none, even if an AC
20
20
  or EX changed, or in an append stage.
21
21
  - **Finder.** A sub-agent that wrote none of those BRs reads them, the EXs they
22
- cite and the EXs this invocation wrote or changed. It raises findings of five
23
- kinds: a case the rule implies that no example states, a redundant example,
24
- an example no rule explains, a rule its examples do not support, and a flow,
25
- story or criterion split the rules show to be wrong.
22
+ cite and the EXs this invocation wrote or changed. The orchestrator starts
23
+ it, never a stage worker. It raises findings of five kinds: a case the rule
24
+ implies that no example states, a redundant example, an example no rule
25
+ explains, a rule its examples do not support, and a flow, story or criterion
26
+ split the rules show to be wrong.
26
27
  - **Deciding.** The session agent decides each finding that is not critical. A
27
28
  finding resting on product intent nothing written states goes to the user.
28
29
  - **Scope.** A proposed EX must be implied by an existing BR, an existing AC or
@@ -45,3 +46,7 @@ rules against their examples. Follow
45
46
  Read first: what `sdd-contract` wrote in this stage. The step passes when
46
47
  `sdd-contract` wrote or changed no BR Statement and no Examples cell, which is
47
48
  when no cycle runs. The pass names the contracts it read.
49
+
50
+ A step whose first cycle adopted a finding is not a pass. It ends only after
51
+ the second cycle has run, and the review treats a missing second cycle as a
52
+ failure.
@@ -31,6 +31,8 @@ Stage 3 of the story tree: stories and examples.
31
31
  - Each affected `user-story-NNNN-NNNN/` with exactly `01_User-story.md`,
32
32
  `02_Acceptance-Criteria.md`, and `03_Example.md`, from their paired templates.
33
33
  Do not create another document inside a story directory.
34
+ - The `// QFAI:EX-NNNN-NNNN-NN` annotation line that maps an example to an
35
+ existing test, as procedure item 9 states, and nothing else in a test file.
34
36
 
35
37
  Write only what the user approved, as
36
38
  `.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md#a-change-to-the-story-tree`
@@ -60,13 +62,32 @@ states.
60
62
  4. Give each EX exactly one existing AC in its `AC-Ref` cell, and give each AC
61
63
  at least one EX. `Input` and `Expected` hold plain values, not Gherkin
62
64
  steps.
65
+ For each EX added, name in the stage report the contract rule that will
66
+ cite it, or the contract that needs a new rule for it. `sdd-contract`
67
+ writes the rule.
63
68
  5. Preserve normal outcomes and meaningful failure boundaries.
64
69
  6. Follow `.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md`
65
70
  and `.qfai/assistant/rule/test-layers.md` when deriving the later BF/E2E,
66
71
  AC/API or Integration, and EX/other test obligations. Do not author
67
- acceptance tests in this step.
72
+ acceptance tests in this step. Item 9's annotation line is not test
73
+ authoring.
68
74
  7. Retire a story by removing its directory under the change request that names
69
75
  it, and never recycle its IDs.
76
+ 8. Where a decision replaced a claim, such as an input, a threshold or a
77
+ count, search the whole story tree and the contracts for the old claim
78
+ before finishing. List each hit in the stage report, with what it now
79
+ says or why it stays. A hit in a contract is left to `sdd-contract`,
80
+ which reports it.
81
+ 9. Where an existing assertion already proves an example this step added or
82
+ renumbered, add that example's `// QFAI:EX-NNNN-NNNN-NN` line to the test's
83
+ annotation lines, directly before the test declaration it marks, in a
84
+ selected non-E2E test file. Replace an old ID only on the test that proves
85
+ the renumbered example, the incoming item a merge collision renumbered; a
86
+ test of the item that kept the ID keeps its annotation. This is
87
+ specification metadata, not a test repair: change no assertion body, add or
88
+ remove no case, and keep the case count.
89
+ List each annotated test in the stage report. An example no existing
90
+ assertion proves stays unannotated for the implementation stage.
70
91
 
71
92
  ## Passes when
72
93
 
@@ -22,7 +22,7 @@ changes, and record that decision before anything depends on it.
22
22
  - `.qfai/assistant/rule/change-classification.md`, the classification
23
23
  authority.
24
24
  - The existing story tree: `01_policy/`, `02_business-flow/`, `03_contract/`,
25
- `decisions.md` and `open-questions.md` under `<paths.specsDir>`.
25
+ `decisions.md`, every page it lists in order, and `open-questions.md` under `<paths.specsDir>`; read decision pages before the root tail.
26
26
 
27
27
  ## Scope of the request
28
28
 
@@ -66,6 +66,13 @@ descendants when it still represents the requirement. Create a flow or story
66
66
  only when the existing tree cannot represent it. Trace impact through BF → US →
67
67
  AC → EX and every enforcing contract.
68
68
 
69
+ Read the complete decision register using the Decision pages rules in the triage
70
+ reference before allocating IDs or relying on an in-force decision. Append new
71
+ rows only to the root table. Listed pages preserve the same row identity and
72
+ Status permissions; an unreadable or incomplete register stops this stage.
73
+ No automatic rotation is permitted. A physical relocation requires a separately
74
+ adopted execution change request and reviewed raw-byte receipt.
75
+
69
76
  Record in `<paths.specsDir>/decisions.md` only what the user decided: each
70
77
  change request the user approved or declined, and each critical decision the
71
78
  user made. Record unresolved
@@ -77,9 +84,16 @@ Content begins `Change request:` and names the
77
84
  affected repository-relative paths; its Approach names the operation, the affected BF or US,
78
85
  its source as `discussion-<id>#REQ-NNNN` when that source exists, and who
79
86
  approved it, when, and the option chosen. A declined change request is appended at
80
- REJECTED, recording who declined it and when. A decision the agent took
87
+ REJECTED, recording who declined it and when. When a later decision replaces a
88
+ row, change that row's Status to `SUPERSEDED (by DEC-NNNN)`, naming the later
89
+ row, or to `PARTLY SUPERSEDED (by DEC-NNNN)` when it replaces only part of it.
90
+ When a decision answers an open question, change that row's Status to
91
+ `DONE (by DEC-NNNN)`; when a decision makes what the row states wrong before the
92
+ question is answered, change it to `SUPERSEDED (by DEC-NNNN)` and append a new
93
+ row for the question that remains. Either names the decision row.
94
+ A decision the agent took
81
95
  appends no row. Do not write a second decision-record
82
- directory or a retired story file.
96
+ directory or a retired story file. Listed pages are members of the same register, not a second decision home.
83
97
 
84
98
  For a published malformed branch-added decision, follow
85
99
  `.qfai/assistant/rule/drift-protocol.md#published-decision-prefix-recovery`
@@ -176,21 +190,43 @@ this step took it or the operator answered it.
176
190
  ## ID allocation
177
191
 
178
192
  Allocate each new ID from the highest ID of its kind in scope plus one,
179
- including retired IDs named in decisions rows. A project that also counts the
180
- IDs its open pull requests add takes the highest across the tree and those pull
181
- requests, so a gap above the tree's own highest is allowed. BF scope is project-wide; US
193
+ including retired IDs named in decisions rows. BF scope is project-wide; US
182
194
  scope is its BF; AC and EX scope is their US; a contract number's scope is every
183
195
  contract of every kind; BR scope is its contract, whose number the BR carries
184
- (`BR-0006-0001` belongs to `API-0006`); DEC and OQ scope is their own table.
185
- Empty scopes begin at `0001`, or `01` for AC and EX tails. This is a reading
186
- rule over the tree, not a new command.
196
+ (`BR-0006-0001` belongs to `API-0006`); DEC scope is the complete ordered register; OQ scope is its own table.
197
+ Empty scopes begin at `0001`, or `01` for AC and EX tails. Take each new ID from
198
+ `npx qfai sdd next-id <kind> [<parent-ID>] --base <local-ref>` with a fetched
199
+ base: it prints the number after the highest of the working tree and the base.
200
+
201
+ Parallel branches pick the same next ID unless each reads the others first:
202
+
203
+ 1. Before taking an ID, fetch the base. Where a forge CLI is available, list the
204
+ open pull requests once per session through its REST API, for example
205
+ `gh api repos/{owner}/{repo}/pulls?state=open`, and reuse that listing for
206
+ every ID the session takes. Fetch each one's head ref, such as
207
+ `refs/pull/<n>/head`, so a pull request from a fork is read too, and read
208
+ the IDs it adds from `git diff <base>...<head>`. Take the highest across the
209
+ base, the working tree and those heads, plus one. Without a forge CLI, read
210
+ the base alone.
211
+ 2. When merging the base into the branch, check each ID the branch adds against
212
+ the fetched base. The base's item keeps its ID; the branch renumbers its own
213
+ item and every reference to it, then runs the gates again.
214
+ - A DEC or OQ row: check before the merge, and renumber a DEC row with
215
+ `npx qfai sdd renumber-decision` as the triage reference's ID allocation
216
+ section says, or an OQ row and its references by hand. The union merge of `decisions.md` and `open-questions.md`
217
+ would duplicate a colliding ID without a conflict.
218
+ - Any other ID: check after the merge.
219
+ 3. Keep the change-request row last in `decisions.md`, so the rows the branch
220
+ added stay in ascending order at the end of the register, where the
221
+ merge-time renumbering works from the lowest colliding one upward.
187
222
 
188
223
  ## Pre-draft grilling
189
224
 
190
225
  Before this step's first mutation, run the checkpoint for `Triage and records`
191
- in `.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md`. Put
192
- each critical decision it holds to the user, and list each decision it adopted
193
- in the final report. Each later design-writing step runs its own checkpoint the
226
+ in `.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md`. The
227
+ orchestrator starts the griller, never a stage worker. Put each critical
228
+ decision it holds to the user, and list each decision it adopted in the final
229
+ report. Each later design-writing step runs its own checkpoint the
194
230
  same way.
195
231
 
196
232
  ## A change to the story tree
@@ -66,6 +66,11 @@ Any other route closes here.
66
66
  - No file git tracks. Name any ignored record's location in the stage
67
67
  report, separately from tracked changes.
68
68
  - The stage report states the outcome and each follow-up's goal and reason.
69
+ When the release change is produced outside this run (by a release workflow
70
+ or bot), the stage report records the release approval with what was
71
+ approved, who approved it, when, and the chosen option's label, and lists
72
+ the row as a pending follow-up; the next change that touches `decisions.md`
73
+ appends its row.
69
74
  For a re-route, retain the plan's branch outcome, the selected route and
70
75
  the request extraction in the session handoff. A re-route does not close
71
76
  the request.
@@ -79,5 +84,5 @@ triage step. The report never says a tracked change is done. The `cleaned`
79
84
  outcome confirms only the temporary cleanup's completed gate.
80
85
 
81
86
  Outside triage steps, the only tracked-file changes allowed are the records
82
- the route's discussion stage names and the required approval row that
83
- `qfai-run` writes in `decisions.md` before `triage-handoff` runs.
87
+ the route's discussion stage names and the approval row, if any, that
88
+ `qfai-run` writes in `decisions.md` under its step 7 before `triage-handoff` runs.
@@ -40,6 +40,12 @@ operation and records what happened.
40
40
  Run none of the operation here: no push, publication, tag or change to an
41
41
  account.
42
42
 
43
+ A user who delegates the release to the agent while this step waits gives a
44
+ new instruction, and the handoff has no result to record. Quote the
45
+ instruction word for word with its source, do not report `handed-off`, and
46
+ list the delegated release as the follow-up for the closing step, which closes
47
+ the request as `deferred`, so it is planned again as a request of its own.
48
+
43
49
  ## What it writes
44
50
 
45
51
  - No file git tracks.