qfai 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +56 -36
  2. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  3. package/assets/defaults/workflows/run-owned-cleanup.yml +12 -0
  4. package/assets/init/.claude/settings.json +27 -9
  5. package/assets/init/.codex/hooks.json +20 -8
  6. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +5 -0
  7. package/assets/init/.qfai/assistant/agent/product-experience-architect.md +4 -0
  8. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +7 -0
  9. package/assets/init/.qfai/assistant/agent/requirements-analyst.md +8 -0
  10. package/assets/init/.qfai/assistant/rule/communication.md +18 -8
  11. package/assets/init/.qfai/assistant/rule/drift-protocol.md +58 -2
  12. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +6 -4
  13. package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +48 -0
  14. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +15 -25
  15. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +8 -8
  16. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +6 -1
  17. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +3 -3
  18. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +3 -7
  19. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +2 -4
  20. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +1 -6
  21. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +0 -16
  22. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +9 -3
  23. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +9 -1
  24. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +46 -0
  25. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +3 -0
  26. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +3 -3
  27. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +12 -6
  28. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +1 -265
  29. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +273 -0
  30. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +4 -3
  31. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +2 -3
  32. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +17 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +30 -17
  34. package/assets/init/.qfai/assistant/skill/qfai-run/references/evidence-delivery.md +322 -0
  35. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +47 -24
  36. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +218 -11
  37. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +4 -3
  38. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +14 -0
  39. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +4 -3
  40. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -0
  41. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +23 -5
  42. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +8 -0
  43. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +29 -4
  44. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +132 -4
  45. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +14 -2
  46. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +114 -0
  47. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +4 -29
  48. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +38 -1
  49. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/ui-contract.sample.yaml +52 -5
  50. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +3 -0
  51. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +29 -19
  52. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +5 -4
  53. package/assets/init/.qfai/assistant/skill/qfai-verify/references/context-load.md +9 -6
  54. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +72 -7
  55. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +35 -21
  56. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/config.toml +2 -4
  57. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/mcp-config.json +9 -5
  58. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/.mcp.json +1 -2
  59. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/config.toml +3 -3
  60. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/mcp-config.json +11 -8
  61. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/config.toml +1 -1
  62. package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/mcp-config.json +7 -3
  63. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +0 -4
  64. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +98 -8
  65. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +3 -2
  66. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +1 -0
  67. package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +2 -0
  68. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +1 -3
  69. package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +1 -1
  70. package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +7 -4
  71. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +4 -1
  72. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +2 -0
  73. package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +2 -2
  74. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +3 -3
  75. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +2 -2
  76. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +4 -3
  77. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +6 -3
  78. package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +4 -3
  79. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +6 -5
  80. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +1 -1
  81. package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +4 -3
  82. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +39 -5
  83. package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +22 -2
  84. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +18 -14
  85. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +4 -3
  86. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +4 -0
  87. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +1 -3
  88. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +11 -0
  89. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +2 -0
  90. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +10 -0
  91. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +30 -8
  92. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +5 -4
  93. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +33 -23
  94. package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +5 -3
  95. package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +2 -0
  96. package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +4 -0
  97. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +13 -4
  98. package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +8 -5
  99. package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +86 -0
  100. package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +2 -0
  101. package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +6 -3
  102. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +1 -0
  103. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +37 -9
  104. package/assets/init/.qfai/assistant/step/verify-external/STEP.md +5 -2
  105. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +7 -16
  106. package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +1 -0
  107. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +6 -4
  108. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +121 -30
  109. package/assets/init/root/.agents/rules/ai-readable-markdown.md +2 -2
  110. package/assets/init/root/.agents/rules/api-budget.md +187 -8
  111. package/assets/init/root/.agents/rules/documentation-clarity.md +162 -33
  112. package/assets/init/root/.agents/rules/minimal-implementation.md +3 -3
  113. package/assets/init/root/.agents/rules/reminders.json +27 -14
  114. package/assets/init/root/.agents/rules/session-feedback.md +136 -0
  115. package/assets/init/root/.agents/rules/temporary-files.md +33 -0
  116. package/assets/init/root/.agents/rules/user-questions.md +48 -37
  117. package/assets/init/root/.github/workflows/qfai-docs.yml +1 -1
  118. package/assets/init/root/AGENTS.md +23 -22
  119. package/assets/sandbox-templates/default-deny.yaml +9 -3
  120. package/assets/schemas/workflow/extraction.schema.json +85 -5
  121. package/assets/uix-rev/comparison-review.md +1 -1
  122. package/assets/uix-rev/contracts-review.md +1 -2
  123. package/dist/cli/index.cjs +6697 -8810
  124. package/dist/cli/index.cjs.map +1 -1
  125. package/dist/cli/index.mjs +6036 -8152
  126. package/dist/cli/index.mjs.map +1 -1
  127. package/dist/index.cjs +4947 -7746
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +18 -658
  130. package/dist/index.d.ts +18 -658
  131. package/dist/index.mjs +4866 -7640
  132. package/dist/index.mjs.map +1 -1
  133. package/package.json +4 -6
  134. package/assets/init/root/CLAUDE.md +0 -46
@@ -8,11 +8,6 @@ the 2.x validation and authoring workflow.
8
8
  ## Contents
9
9
 
10
10
  - Prepare
11
- - Place stories and rules
12
- - Retired configuration keys
13
- - Contract IDs
14
- - Business rules
15
- - Documents in their template's shape
16
11
  - Run the bundled steps
17
12
  - Write boundary
18
13
  - Resolve the reports
@@ -45,265 +40,6 @@ the 2.x validation and authoring workflow.
45
40
  Do not run `npx qfai init --force` to migrate. It can write beyond the migration
46
41
  scripts' allowed paths and replace local edits.
47
42
 
48
- ## Place stories and rules
49
-
50
- The AI writes `tmp/qfai-migration/plan.yaml` before running
51
- step 4. `plan.yaml` may be written before step 1, because only steps 4 and 7
52
- read it and a contract is named by the path it has in the contracts directory
53
- before step 3, which is also a key of `contract-map.json` once step 3 has run.
54
-
55
- The plan states the decisions the scripts cannot make. `flows` says which
56
- business flow holds each old story. `rules` says which existing contract
57
- enforces each old business rule, or that it enforces none. The optional
58
- `examples` list places an example whose criterion the test cases leave open.
59
- Flow order and story order determine the new IDs.
60
-
61
- - **`from`.** A `from` value identifies an old flow to continue; omit it for a
62
- new flow. It is the exact title of any H2 section of the old
63
- `_policies/04_Business-Flow.md`, and no other H2 of that file has the same
64
- title. For the unnamed opening flow, which is the text before the first
65
- `CHG-` heading or the whole file where it has none, use the reserved value
66
- `_policies/04_Business-Flow.md`. Several flows may continue the same section,
67
- and each takes that section's prose and diagram. If `from` is omitted, the
68
- script writes a template flow and reports that its diagram needs a person.
69
- - **`criteria`.** An old criterion belongs to the story its `Parent:` line
70
- names or, where it has none, to the story its row of the criteria catalog
71
- table names in the `US Ref`, `US-Refs` or `Maps To` column. Add `criteria`
72
- to a story only when the criterion has no such reference, the reference
73
- names several stories, or the two disagree.
74
- - **`contract`.** A contract path is relative to the configured contracts
75
- directory, lies under `cli/`, `api/`, `db/` or `ui/`, and names the contract
76
- file as it is before step 3 renames it. A Markdown file under `api/`, `db/`
77
- or `ui/` and a file under `design/` hold no contract, so a rule cannot be
78
- placed in one.
79
- - **`binds: none` and `retire`.** A rule with no contract takes one of these
80
- instead of `contract`. `binds: none` is allowed only where the rule's
81
- `Contract-Refs` cell is `-`. `retire` takes a reason. Step 7 removes such a
82
- rule from its `04_Business-Rules.md`, lists it under `## Operations` with
83
- its old ID and, for `retire`, the reason, and gives it no new ID.
84
- - **`examples`.** An entry names an old example ID and a `criterion`, one of
85
- the old criterion IDs that the `AC-Refs` of the test cases citing the example
86
- name. Step 4 places the example under that criterion's story, and its test
87
- cases enter the ID map, so that step 8 rewrites their annotations.
88
-
89
- ```yaml
90
- flows:
91
- - title: Place an order
92
- stories:
93
- - id: US-0001-0001
94
- criteria: [AC-0001-0001]
95
- examples:
96
- - id: EX-0001-0002
97
- criterion: AC-0001-0001
98
- rules:
99
- - id: BR-0006-0001
100
- contract: api/orders.yaml
101
- - id: BR-0006-0002
102
- binds: none
103
- - id: BR-0006-0003
104
- retire: The payment provider enforces this limit.
105
- ```
106
-
107
- Use IDs from the old files in this plan. Assign each old story, rule, example
108
- and criterion at most once. A `from` value that matches no old flow or matches
109
- several, an invalid plan, a duplicate assignment, an `examples` criterion that
110
- none of the citing test cases names, a rule with none or more than one of
111
- `contract`, `binds` and `retire`, or a contract path that is outside the four
112
- contract directories or names no contract stops step 4 before writing. Check
113
- the step-4 dry run before accepting its numbering. Step 4 writes
114
- `tmp/qfai-migration/id-map.json` once, and later steps use
115
- that map. Write the `examples` entries and the rule marks before step 4: once
116
- the map exists, an `examples` entry and a mark on a rule the map holds are
117
- refused. A mark on a rule step 4 left unplaced is still accepted while a spec
118
- pack is left. Place any other unplaced content in the new tree through `/qfai-sdd`. While the
119
- map exists and no spec pack is left, steps 4 and 7 read no plan, so a missing or
120
- rewritten `plan.yaml` stops nothing.
121
-
122
- ## Retired configuration keys
123
-
124
- Three keys of `qfai.config.yaml` no longer exist in 2.x. Each is handled by the
125
- step named here:
126
-
127
- | Key | What the migration does |
128
- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
129
- | `validation.traceability.scMustHaveTest` | Step 1 removes it and lists it under `## Operations` |
130
- | `validation.traceability.unknownContractIdSeverity` | Step 1 removes it and lists it under `## Operations` |
131
- | `prototyping.primarySpecId` | Step 3 replaces it with `prototyping.primaryUiContract` where exactly one UI contract is tied to that spec |
132
-
133
- Step 1 also removes a `validation.traceability` or `validation` mapping that
134
- the removal leaves empty. Steps 1 to 3 run although the configuration loader
135
- reports these keys. Steps 4 to 12 refuse with exit 2 before writing, naming the
136
- key, while `qfai.config.yaml` still holds one of the three. That refusal does
137
- not mean an earlier step has not run.
138
-
139
- A UI contract is tied to a spec when the contract IDs named by the
140
- `Contract-Refs` of that spec's business rules translate, through the contract
141
- map, to one UI contract. Step 3 lists the replacement under `## Operations`.
142
- Where `prototyping.primaryUiContract` is already set, step 3 removes the old key
143
- instead. Where no UI contract is tied, more than one is, or the spec pack is
144
- gone, step 3 leaves `prototyping.primarySpecId` and lists it under
145
- `## For a person` with its old value, and exits 3. Replace it by hand with
146
- `prototyping.primaryUiContract: UI-NNNN` naming the contract. Steps 4 to 12 then
147
- run.
148
-
149
- When a step cannot load `qfai.config.yaml` for any other reason, it exits 2
150
- before writing and prints on standard error the message of each configuration
151
- issue, one per line.
152
-
153
- ## Contract IDs
154
-
155
- Step 3 gives every contract file that has no 2.x contract ID one, and renames
156
- the file to match:
157
-
158
- | Old contract | Declares | New ID | New file |
159
- | -------------------------- | -------------- | -------- | -------------------------- |
160
- | `cli/orders.md` | nothing | CLI-0001 | `cli/cli-0001-orders.md` |
161
- | `api/api-0001-orders.yaml` | `CON-API-0001` | API-0002 | `api/api-0002-orders.yaml` |
162
- | `db/db-0001-orders.sql` | `CON-DB-0001` | DB-0003 | `db/db-0003-orders.sql` |
163
-
164
- - Numbers run across all contracts, in the order CLI, API, DB, UI, then by
165
- the old number, then by path. No two contracts share a number.
166
- - The new ID replaces the old one in the file's declaration: the H1 of a
167
- Markdown contract, as `# CLI-0001: <title>`, and the `QFAI-CONTRACT-ID` line
168
- of any other. The old IDs in `-- Depends on:` and `x-qfai-depends-on` become
169
- the new ones, and a YAML contract keeps its `x-qfai-depends-on` list on one
170
- line.
171
- - `contracts.md` becomes one index table listing every contract. The old
172
- index's other sections are reported for a person.
173
- - `tmp/qfai-migration/contract-map.json` records each old
174
- path and old ID with the new ones, and step 4 copies it into the ID map.
175
- - Step 7 writes the new IDs into rule statements, and step 8 changes a
176
- `QFAI:CON-API-0001` test annotation to `QFAI:API-0002`.
177
-
178
- Step 3 gives no ID to a file that is not a 2.x contract, and does not write it
179
- into the new tree:
180
-
181
- | Old file | Why it is not a contract |
182
- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
183
- | A Markdown file under `api/`, `db/` or `ui/` | Those directories hold OpenAPI YAML or JSON, SQL and UI YAML contracts |
184
- | Any file under `design/` | The directory no longer exists: the brand belongs in the root `DESIGN.md`, a screen in a `ui/` contract |
185
-
186
- Step 3 deletes each one, `design/` as one directory, and lists each file under
187
- `## For a person`. Rewrite what the file stated, from git history, in the form
188
- its row names.
189
-
190
- The old `design/prototype-handoff.yaml` is now
191
- `.qfai/prototype/final/handoff.json`, which `/qfai-prototyping` writes when
192
- the user confirms the prototype. The migration does not convert
193
- the old file into it.
194
-
195
- Step 3 also replaces every old `CON-*` ID that the contract map translates inside
196
- the contract files it writes, wherever it stands in the file, and lists none of
197
- them. It writes nothing outside those files. An old ID the map cannot translate,
198
- such as an ID no contract declared or that several declared, stays as written
199
- and is reported for a person with its file and line, as is a UI marker in
200
- application code.
201
-
202
- Step 3 groups its `## For a person` items under `### Content` and
203
- `### Identifiers`. `### Content` comes first and holds what a person rewrites
204
- or decides. `### Identifiers` holds an item that only pairs an old ID with its
205
- new one, such as a changed constraint ID. A group with no item is not printed.
206
-
207
- Step 3 writes a `routing:` override into `qfai.config.yaml` only for an entry
208
- of `agent-routing.yml` that differs from the installed default. It writes none
209
- for an entry equal to a default or to an entry a 1.x release shipped. Step 3
210
- lists each routing entry it does write under `## For a person`, with its name
211
- and a warning that a routing entry copied from a 1.x manifest hides the roles
212
- the 2.x skills declare.
213
-
214
- ## Business rules
215
-
216
- Rules are numbered per contract, `BR-<contract number>-NNNN` from `0001` in plan
217
- order: the first rule step 4 places in API-0006 is BR-0006-0001. Step 7 writes
218
- each rule into its contract in the form the contract's format takes:
219
-
220
- | Contract format | Where the rule goes |
221
- | --------------- | ----------------------------------------------------------------------- |
222
- | Markdown | A row of the `## Business rules` table: BR-ID, Statement and Examples |
223
- | YAML or JSON | An entry `{ id, statement, examples }` of the top-level `x-qfai-rules:` |
224
- | SQL | A `-- Rule BR-0006-0001: <statement>` line, then an `-- Examples:` line |
225
-
226
- A Markdown contract without a `## Business rules` section gets one as its last
227
- section. A rule's examples are the new IDs of the examples that cited it. A
228
- rule written as a heading section takes the value of its `Rule` field as its
229
- statement, and a SQL contract holds that statement on one line.
230
-
231
- ## Documents in their template's shape
232
-
233
- Each story-tree document the steps write takes the shape of its `qfai-sdd`
234
- template, which is the shape the document schema checks:
235
-
236
- | Documents | Step |
237
- | --------------------------------------------------------------------------------------- | ---- |
238
- | `decisions.md` and `open-questions.md` rows | 2 |
239
- | `objective.md`, `initiative.md`, `principle.md`, `glossary.md` and `constraint.md` | 3 |
240
- | `contracts.md` and `tech.md` | 3 |
241
- | Markdown contracts under `cli/` | 3 |
242
- | `business-flows.md`, `business-flow.md`, `user-stories.md` and each story's three files | 4 |
243
- | Examples turned from test cases | 5 |
244
-
245
- Content that does not fit that shape is listed under `## For a person`, and the
246
- step exits 3:
247
-
248
- - Step 3 leaves it out of the policy file, `tech.md` or CLI contract, and names the source
249
- file and, where one fits, the template section that takes the content once a
250
- person rewrites it. The source file is deleted, so the content is read from
251
- git history.
252
- - Step 3 also leaves as it is a policy file or `tech.md` that already exists
253
- and differs from what it would write.
254
- - A constraint row keeps only its ID, Constraint and Rationale. Step 3 lists
255
- an Impact column, whose content belongs to the contract or `tech.md` that
256
- owns it, and a row that names a file, a command or a rule ID, to be rewritten
257
- in plain words.
258
- - Step 3 numbers each constraint section from 01 in table order, and lists
259
- every ID that changed with the ID that replaces it.
260
- - Steps 4 and 5 write a story sentence or an example cell of another form as it
261
- stands, for a person to rewrite.
262
- - Step 4 lists every business flow, so that a person writes its alternate and
263
- exception paths.
264
-
265
- The steps do not write these into the new tree. Each stays in its old spec-pack
266
- file, which stays in the pack while any of its content is unplaced and is then
267
- deleted, kept in git history only:
268
-
269
- - a spec pack's scope and source provenance;
270
- - a story block's `Parent`, `Source` and `Flow` fields;
271
- - a criterion's `# Parent:` line, since its directory names the story;
272
- - a `Background:`, any scenario after a criterion's first named one, and a
273
- `Scenario Outline:`, each listed for a person.
274
-
275
- Step 3 writes no structure document. It routes the old `catalog/structure.md`
276
- section by section:
277
-
278
- | Old content | New home |
279
- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
280
- | An entrypoint with a smoke or skeleton command | A `- Skeleton:` line in `tech.md`'s Standard commands |
281
- | A layer row of an `## Architecture` or `## Architecture constraints` table of Layer, Responsibility and Depends on columns, naming no path | The `## Architecture` table of `tech.md` |
282
- | The `ui_paths:` globs of `## UI surface paths` | `uiux.surfacePaths` in `qfai.config.yaml`, if unset |
283
- | Anything else | `## For a person` |
284
-
285
- Step 3 writes the moved layers in the shape of the Architecture section: a
286
- `flowchart TD` with a node per layer and an edge per dependency, then the table
287
- with the rows ordered from the uppermost layer down. Where the rows cannot be
288
- ordered, because a layer depends on one that has no row or layers depend on each
289
- other, none of them moves: the section is listed under `## For a person` with
290
- the reason, and `tech.md` keeps the template's Architecture section.
291
-
292
- Step 3 writes each Markdown contract under `cli/` in the shape of the CLI
293
- contract template: its `# CLI-0001: <title>` heading, `## Ownership boundary`
294
- and a `## Business rules` table, and nothing else.
295
-
296
- - An old `## Ownership boundary` of one to three paragraphs that name no rule is
297
- kept as it stands.
298
- - Where the old contract has none, the section holds the template's placeholder,
299
- and the contract is listed for a person to write it.
300
- - The text before the first section, lines such as `Status:` or `Rule refs:`,
301
- and every other section are left out. Each is listed with the old file.
302
-
303
- Step 7 then writes the contract's rules into that table. A rule whose statement
304
- names another rule is written and listed for a person, because a CLI contract's
305
- rule cites only examples.
306
-
307
43
  ## Run the bundled steps
308
44
 
309
45
  For each row, run the script with `--dry-run`, read its operations, and then run
@@ -509,7 +245,7 @@ installed package's copy. A copy the project changed is replaced, an untracked
509
245
  file and an uncommitted edit included, and the replacement is listed under
510
246
  `## Operations`. A skill the package does not ship and
511
247
  `.qfai/assistant/skill.local/` are left alone. Step 11 also adds each missing
512
- host skill link and the `.qfai/run/` line of the managed `.gitignore` block. A
248
+ host skill link and brings the managed `.gitignore` block up to date. A
513
249
  path it cannot write is reported with the reason. It leaves `AGENTS.md` and
514
250
  `CLAUDE.md` as they are, a line an earlier `npx qfai init` wrote included.
515
251
 
@@ -0,0 +1,273 @@
1
+ # Place stories and write the documents
2
+
3
+ What the bundled steps need from a person before they place stories and
4
+ rules, and the shape of what steps 1 to 7 write: the plan, the retired
5
+ configuration keys, the contract numbers, the business rules and the story-tree
6
+ documents.
7
+
8
+ ## Contents
9
+
10
+ - Place stories and rules
11
+ - Retired configuration keys
12
+ - Contract IDs
13
+ - Business rules
14
+ - Documents in their template's shape
15
+
16
+ ## Place stories and rules
17
+
18
+ The AI writes `tmp/qfai-migration/plan.yaml` before running
19
+ step 4. `plan.yaml` may be written before step 1, because only steps 4 and 7
20
+ read it and a contract is named by the path it has in the contracts directory
21
+ before step 3, which is also a key of `contract-map.json` once step 3 has run.
22
+
23
+ The plan states the decisions the scripts cannot make. `flows` says which
24
+ business flow holds each old story. `rules` says which existing contract
25
+ enforces each old business rule, or that it enforces none. The optional
26
+ `examples` list places an example whose criterion the test cases leave open.
27
+ Flow order and story order determine the new IDs.
28
+
29
+ - **`from`.** A `from` value identifies an old flow to continue; omit it for a
30
+ new flow. It is the exact title of any H2 section of the old
31
+ `_policies/04_Business-Flow.md`, and no other H2 of that file has the same
32
+ title. For the unnamed opening flow, which is the text before the first
33
+ `CHG-` heading or the whole file where it has none, use the reserved value
34
+ `_policies/04_Business-Flow.md`. Several flows may continue the same section,
35
+ and each takes that section's prose and diagram. If `from` is omitted, the
36
+ script writes a template flow and reports that its diagram needs a person.
37
+ - **`criteria`.** An old criterion belongs to the story its `Parent:` line
38
+ names or, where it has none, to the story its row of the criteria catalog
39
+ table names in the `US Ref`, `US-Refs` or `Maps To` column. Add `criteria`
40
+ to a story only when the criterion has no such reference, the reference
41
+ names several stories, or the two disagree.
42
+ - **`contract`.** A contract path is relative to the configured contracts
43
+ directory, lies under `cli/`, `api/`, `db/` or `ui/`, and names the contract
44
+ file as it is before step 3 renames it. A Markdown file under `api/`, `db/`
45
+ or `ui/` and a file under `design/` hold no contract, so a rule cannot be
46
+ placed in one.
47
+ - **`binds: none` and `retire`.** A rule with no contract takes one of these
48
+ instead of `contract`. `binds: none` is allowed only where the rule's
49
+ `Contract-Refs` cell is `-`. `retire` takes a reason. Step 7 removes such a
50
+ rule from its `04_Business-Rules.md`, lists it under `## Operations` with
51
+ its old ID and, for `retire`, the reason, and gives it no new ID.
52
+ - **`examples`.** An entry names an old example ID and a `criterion`, one of
53
+ the old criterion IDs that the `AC-Refs` of the test cases citing the example
54
+ name. Step 4 places the example under that criterion's story, and its test
55
+ cases enter the ID map, so that step 8 rewrites their annotations.
56
+
57
+ ```yaml
58
+ flows:
59
+ - title: Place an order
60
+ stories:
61
+ - id: US-0001-0001
62
+ criteria: [AC-0001-0001]
63
+ examples:
64
+ - id: EX-0001-0002
65
+ criterion: AC-0001-0001
66
+ rules:
67
+ - id: BR-0006-0001
68
+ contract: api/orders.yaml
69
+ - id: BR-0006-0002
70
+ binds: none
71
+ - id: BR-0006-0003
72
+ retire: The payment provider enforces this limit.
73
+ ```
74
+
75
+ Use IDs from the old files in this plan. Assign each old story, rule, example
76
+ and criterion at most once. A `from` value that matches no old flow or matches
77
+ several, an invalid plan, a duplicate assignment, an `examples` criterion that
78
+ none of the citing test cases names, a rule with none or more than one of
79
+ `contract`, `binds` and `retire`, or a contract path that is outside the four
80
+ contract directories or names no contract stops step 4 before writing. Check
81
+ the step-4 dry run before accepting its numbering. Step 4 writes
82
+ `tmp/qfai-migration/id-map.json` once, and later steps use
83
+ that map. Write the `examples` entries and the rule marks before step 4: once
84
+ the map exists, an `examples` entry and a mark on a rule the map holds are
85
+ refused. A mark on a rule step 4 left unplaced is still accepted while a spec
86
+ pack is left. Place any other unplaced content in the new tree through `/qfai-sdd`. While the
87
+ map exists and no spec pack is left, steps 4 and 7 read no plan, so a missing or
88
+ rewritten `plan.yaml` stops nothing.
89
+
90
+ ## Retired configuration keys
91
+
92
+ Three keys of `qfai.config.yaml` no longer exist in 2.x. Each is handled by the
93
+ step named here:
94
+
95
+ | Key | What the migration does |
96
+ | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
97
+ | `validation.traceability.scMustHaveTest` | Step 1 removes it and lists it under `## Operations` |
98
+ | `validation.traceability.unknownContractIdSeverity` | Step 1 removes it and lists it under `## Operations` |
99
+ | `prototyping.primarySpecId` | Step 3 replaces it with `prototyping.primaryUiContract` where exactly one UI contract is tied to that spec |
100
+
101
+ Step 1 also removes a `validation.traceability` or `validation` mapping that
102
+ the removal leaves empty. Steps 1 to 3 run although the configuration loader
103
+ reports these keys. Steps 4 to 12 refuse with exit 2 before writing, naming the
104
+ key, while `qfai.config.yaml` still holds one of the three. That refusal does
105
+ not mean an earlier step has not run.
106
+
107
+ A UI contract is tied to a spec when the contract IDs named by the
108
+ `Contract-Refs` of that spec's business rules translate, through the contract
109
+ map, to one UI contract. Step 3 lists the replacement under `## Operations`.
110
+ Where `prototyping.primaryUiContract` is already set, step 3 removes the old key
111
+ instead. Where no UI contract is tied, more than one is, or the spec pack is
112
+ gone, step 3 leaves `prototyping.primarySpecId` and lists it under
113
+ `## For a person` with its old value, and exits 3. Replace it by hand with
114
+ `prototyping.primaryUiContract: UI-NNNN` naming the contract. Steps 4 to 12 then
115
+ run.
116
+
117
+ When a step cannot load `qfai.config.yaml` for any other reason, it exits 2
118
+ before writing and prints on standard error the message of each configuration
119
+ issue, one per line.
120
+
121
+ ## Contract IDs
122
+
123
+ Step 3 gives every contract file that has no 2.x contract ID one, and renames
124
+ the file to match:
125
+
126
+ | Old contract | Declares | New ID | New file |
127
+ | -------------------------- | -------------- | -------- | -------------------------- |
128
+ | `cli/orders.md` | nothing | CLI-0001 | `cli/cli-0001-orders.md` |
129
+ | `api/api-0001-orders.yaml` | `CON-API-0001` | API-0002 | `api/api-0002-orders.yaml` |
130
+ | `db/db-0001-orders.sql` | `CON-DB-0001` | DB-0003 | `db/db-0003-orders.sql` |
131
+
132
+ - Numbers run across all contracts, in the order CLI, API, DB, UI, then by
133
+ the old number, then by path. No two contracts share a number.
134
+ - The new ID replaces the old one in the file's declaration: the H1 of a
135
+ Markdown contract, as `# CLI-0001: <title>`, and the `QFAI-CONTRACT-ID` line
136
+ of any other. The old IDs in `-- Depends on:` and `x-qfai-depends-on` become
137
+ the new ones, and a YAML contract keeps its `x-qfai-depends-on` list on one
138
+ line.
139
+ - `contracts.md` becomes one index table listing every contract. The old
140
+ index's other sections are reported for a person.
141
+ - `tmp/qfai-migration/contract-map.json` records each old
142
+ path and old ID with the new ones, and step 4 copies it into the ID map.
143
+ - Step 7 writes the new IDs into rule statements, and step 8 changes a
144
+ `QFAI:CON-API-0001` test annotation to `QFAI:API-0002`.
145
+
146
+ Step 3 gives no ID to a file that is not a 2.x contract, and does not write it
147
+ into the new tree:
148
+
149
+ | Old file | Why it is not a contract |
150
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
151
+ | A Markdown file under `api/`, `db/` or `ui/` | Those directories hold OpenAPI YAML or JSON, SQL and UI YAML contracts |
152
+ | Any file under `design/` | The directory no longer exists: the brand belongs in the root `DESIGN.md`, a screen in a `ui/` contract |
153
+
154
+ Step 3 deletes each one, `design/` as one directory, and lists each file under
155
+ `## For a person`. Rewrite what the file stated, from git history, in the form
156
+ its row names.
157
+
158
+ The old `design/prototype-handoff.yaml` is now
159
+ `.qfai/prototype/final/handoff.json`, which `/qfai-prototyping` writes when
160
+ the user confirms the prototype. The migration does not convert
161
+ the old file into it.
162
+
163
+ Step 3 also replaces every old `CON-*` ID that the contract map translates inside
164
+ the contract files it writes, wherever it stands in the file, and lists none of
165
+ them. It writes nothing outside those files. An old ID the map cannot translate,
166
+ such as an ID no contract declared or that several declared, stays as written
167
+ and is reported for a person with its file and line, as is a UI marker in
168
+ application code.
169
+
170
+ Step 3 groups its `## For a person` items under `### Content` and
171
+ `### Identifiers`. `### Content` comes first and holds what a person rewrites
172
+ or decides. `### Identifiers` holds an item that only pairs an old ID with its
173
+ new one, such as a changed constraint ID. A group with no item is not printed.
174
+
175
+ Step 3 writes a `routing:` override into `qfai.config.yaml` only for an entry
176
+ of `agent-routing.yml` that differs from the installed default. It writes none
177
+ for an entry equal to a default or to an entry a 1.x release shipped. Step 3
178
+ lists each routing entry it does write under `## For a person`, with its name
179
+ and a warning that a routing entry copied from a 1.x manifest hides the roles
180
+ the 2.x skills declare.
181
+
182
+ ## Business rules
183
+
184
+ Rules are numbered per contract, `BR-<contract number>-NNNN` from `0001` in plan
185
+ order: the first rule step 4 places in API-0006 is BR-0006-0001. Step 7 writes
186
+ each rule into its contract in the form the contract's format takes:
187
+
188
+ | Contract format | Where the rule goes |
189
+ | --------------- | ----------------------------------------------------------------------- |
190
+ | Markdown | A row of the `## Business rules` table: BR-ID, Statement and Examples |
191
+ | YAML or JSON | An entry `{ id, statement, examples }` of the top-level `x-qfai-rules:` |
192
+ | SQL | A `-- Rule BR-0006-0001: <statement>` line, then an `-- Examples:` line |
193
+
194
+ A Markdown contract without a `## Business rules` section gets one as its last
195
+ section. A rule's examples are the new IDs of the examples that cited it. A
196
+ rule written as a heading section takes the value of its `Rule` field as its
197
+ statement, and a SQL contract holds that statement on one line.
198
+
199
+ ## Documents in their template's shape
200
+
201
+ Each story-tree document the steps write takes the shape of its `qfai-sdd`
202
+ template, which is the shape the document schema checks:
203
+
204
+ | Documents | Step |
205
+ | --------------------------------------------------------------------------------------- | ---- |
206
+ | `decisions.md` and `open-questions.md` rows | 2 |
207
+ | `objective.md`, `initiative.md`, `principle.md`, `glossary.md` and `constraint.md` | 3 |
208
+ | `contracts.md` and `tech.md` | 3 |
209
+ | Markdown contracts under `cli/` | 3 |
210
+ | `business-flows.md`, `business-flow.md`, `user-stories.md` and each story's three files | 4 |
211
+ | Examples turned from test cases | 5 |
212
+
213
+ Content that does not fit that shape is listed under `## For a person`, and the
214
+ step exits 3:
215
+
216
+ - Step 3 leaves it out of the policy file, `tech.md` or CLI contract, and names the source
217
+ file and, where one fits, the template section that takes the content once a
218
+ person rewrites it. The source file is deleted, so the content is read from
219
+ git history.
220
+ - Step 3 also leaves as it is a policy file or `tech.md` that already exists
221
+ and differs from what it would write.
222
+ - A constraint row keeps only its ID, Constraint and Rationale. Step 3 lists
223
+ an Impact column, whose content belongs to the contract or `tech.md` that
224
+ owns it, and a row that names a file, a command or a rule ID, to be rewritten
225
+ in plain words.
226
+ - Step 3 numbers each constraint section from 01 in table order, and lists
227
+ every ID that changed with the ID that replaces it.
228
+ - Steps 4 and 5 write a story sentence or an example cell of another form as it
229
+ stands, for a person to rewrite.
230
+ - Step 4 lists every business flow, so that a person writes its alternate and
231
+ exception paths.
232
+
233
+ The steps do not write these into the new tree. Each stays in its old spec-pack
234
+ file, which stays in the pack while any of its content is unplaced and is then
235
+ deleted, kept in git history only:
236
+
237
+ - a spec pack's scope and source provenance;
238
+ - a story block's `Parent`, `Source` and `Flow` fields;
239
+ - a criterion's `# Parent:` line, since its directory names the story;
240
+ - a `Background:`, any scenario after a criterion's first named one, and a
241
+ `Scenario Outline:`, each listed for a person.
242
+
243
+ Step 3 writes no structure document. It routes the old `catalog/structure.md`
244
+ section by section:
245
+
246
+ | Old content | New home |
247
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
248
+ | An entrypoint with a smoke or skeleton command | A `- Skeleton:` line in `tech.md`'s Standard commands |
249
+ | A layer row of an `## Architecture` or `## Architecture constraints` table of Layer, Responsibility and Depends on columns, naming no path | The `## Architecture` table of `tech.md` |
250
+ | The `ui_paths:` globs of `## UI surface paths` | `uiux.surfacePaths` in `qfai.config.yaml`, if unset |
251
+ | Anything else | `## For a person` |
252
+
253
+ Step 3 writes the moved layers in the shape of the Architecture section: a
254
+ `flowchart TD` with a node per layer and an edge per dependency, then the table
255
+ with the rows ordered from the uppermost layer down. Where the rows cannot be
256
+ ordered, because a layer depends on one that has no row or layers depend on each
257
+ other, none of them moves: the section is listed under `## For a person` with
258
+ the reason, and `tech.md` keeps the template's Architecture section.
259
+
260
+ Step 3 writes each Markdown contract under `cli/` in the shape of the CLI
261
+ contract template: its `# CLI-0001: <title>` heading, `## Ownership boundary`
262
+ and a `## Business rules` table, and nothing else.
263
+
264
+ - An old `## Ownership boundary` of one to three paragraphs that name no rule is
265
+ kept as it stands.
266
+ - Where the old contract has none, the section holds the template's placeholder,
267
+ and the contract is listed for a person to write it.
268
+ - The text before the first section, lines such as `Status:` or `Rule refs:`,
269
+ and every other section are left out. Each is listed with the old file.
270
+
271
+ Step 7 then writes the contract's rules into that table. A rule whose statement
272
+ names another rule is written and listed for a person, because a CLI contract's
273
+ rule cites only examples.
@@ -95,9 +95,10 @@ decide completion.
95
95
  The invocation completes when the user confirms the prototype and
96
96
  `prototyping-handoff` has written the handoff. A blocking finding the latest
97
97
  review still lists at that point is named in the final report. Report every
98
- decision a session adopted, as that step says. The report ends with a question
99
- listing the actions under Next, as `.agents/rules/user-questions.md` § 6 sets
100
- out. Under a no-question mode, list them in the report instead.
98
+ decision a session adopted, as that step says. Ask about the actions under Next
99
+ only when proceeding requires the user's answer, as
100
+ `.agents/rules/user-questions.md` § 6 sets out. A completion-only report needs
101
+ no question. Under a no-question mode, list any remaining actions instead.
101
102
 
102
103
  ## Next
103
104
 
@@ -7,7 +7,7 @@ and the user reads what it finds before confirming the prototype.
7
7
  The schema is **closed**: any key not listed below is rejected. The
8
8
  orchestrator checks each payload against it before writing it, and asks the
9
9
  reviewer again for one that does not conform before the prototype is put to
10
- the user. A near-miss (extra key, misspelled field, legacy flat key) fails the
10
+ the user. A near-miss (extra key, misspelled field) fails the
11
11
  whole file.
12
12
 
13
13
  ## Contents
@@ -99,8 +99,7 @@ These keys belong to the per-iteration summary, **not** to this payload.
99
99
  Writing any of them here breaks the closed schema:
100
100
 
101
101
  `iterIndex`, `reviewerId`, `proseCritique`, `pivotDirective`,
102
- `evidenceRefs`, and the retired flat `timeBudgetSoftWarning` string
103
- (use `softWarnings.timeBudget: boolean`).
102
+ and `evidenceRefs`.
104
103
 
105
104
  ## `sessionStatus` and the retry policy
106
105
 
@@ -168,7 +168,7 @@ count can support a finding, but cannot replace the live assessment.
168
168
  | 5 | No catalogued anti-pattern is present | `lap-*`, below |
169
169
  | 6 | Conformant, procured, restrained and consistent | below |
170
170
  | 7 | Every declared `primary_task` walks | below |
171
- | 8 | No text on the screen explains the interface | `.agents/rules/interface-clarity.md` |
171
+ | 8 | No text explains the interface, and the text shown is the contract's | `.agents/rules/interface-clarity.md` |
172
172
 
173
173
  Criteria 1 to 4 are the procurement ladder read as questions, so a screen
174
174
  cannot pass by a standard it was not built to.
@@ -214,6 +214,22 @@ Hint text survives only where a need was demonstrated, the control was
214
214
  improved first and the need remained, and it is one sentence at most. Longer
215
215
  means the question needs clarifying or splitting.
216
216
 
217
+ Compare the rendered text with the screen's UI contract in both directions. The
218
+ screen shows its `title`, the group headings of its `structure`, its labels and
219
+ the `supplements` it declares. A text shown that none of them declares is excess,
220
+ and a declared supplement that is not shown is an unmet need. The finding names
221
+ the screen, the task or state, the meaning that is duplicated or the need that is
222
+ unmet, and the text to remove or the control or structure to repair. Apply the
223
+ patterns of the section on copy that adds no meaning, which the loop step names; the
224
+ rest of the design anti-patterns list stays with the direction review.
225
+
226
+ A repair keeps what the task needs: a condition, cost, storage or transmission
227
+ destination, result, recovery step, the consequence of an action that cannot be
228
+ undone, and every label, accessible name, role and state. Moving that into a
229
+ tooltip or a placeholder is not a repair. After a repair, walk the task again at
230
+ the declared narrow and desktop widths, in the normal, empty, error, loading and
231
+ success states the screen has.
232
+
217
233
  The counts are contract-relative. A screen declaring one primary task and
218
234
  carrying forty controls is wrong; the same forty elsewhere may be right. The
219
235
  denominator is in the contract, so no global threshold has to be invented.