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
@@ -8,9 +8,21 @@
8
8
  # (you can opt out via `validation.testStrategy.forbidTestTodoStubs: false`
9
9
  # in qfai.config.yaml).
10
10
  #
11
- # Install step auto-detects the project's lockfile (pnpm / yarn /
12
- # npm) and runs the appropriate frozen-lockfile install. `npx qfai`
13
- # works with any Node package manager.
11
+ # What this file needs from your repository, and how it behaves when it does
12
+ # not get it:
13
+ #
14
+ # | Field | Value |
15
+ # | ----------------------------- | -------------------------------------------------------------------------------------------------------- |
16
+ # | Covered layer | specification and repository validation (`qfai validate`); it runs none of your own tests |
17
+ # | Runner selector | `vars.QFAI_CI_RUNNER`, default `ubuntu-latest` |
18
+ # | Wrong runner value | GitHub does not fail fast: an unknown label leaves the job queued indefinitely, never red |
19
+ # | `packageManager` precondition | a `pnpm-lock.yaml` needs `"packageManager": "pnpm@<version>"` in package.json, or this lane stops CLOSED |
20
+ # | Inert when | never inert; delete this file to opt out - `qfai init` will not recreate a file you removed |
21
+ # | Fail-open behaviour | no `.nvmrc` / `.node-version` in your tree: warning annotation, Node 20, and the lane continues |
22
+ # | Node support floor | the package declares `engines: ">=20.19.0"`; the fall-open Node 20 satisfies it |
23
+ # | Dependency install | follows your lockfile: pnpm / yarn Berry / yarn Classic / npm, else `npm install` |
24
+ #
25
+ # `.nvmrc` wins over `.node-version`; both are read before the fall-open.
14
26
 
15
27
  name: qfai validate
16
28
 
@@ -19,33 +31,299 @@ on:
19
31
  branches: [main, master]
20
32
  pull_request:
21
33
 
34
+ # One live run per ref: a superseded push or PR update cancels the older run.
35
+ concurrency:
36
+ group: ${{ github.workflow }}-${{ github.ref }}
37
+ cancel-in-progress: true
38
+
22
39
  jobs:
23
40
  validate:
24
41
  name: qfai validate (full profile, fail on error)
25
- runs-on: ubuntu-latest
42
+ runs-on: ${{ vars.QFAI_CI_RUNNER || 'ubuntu-latest' }}
43
+ # Least privilege: the job only checks out the repository and runs the
44
+ # validator; it writes nothing back to GitHub.
45
+ permissions:
46
+ contents: read
26
47
  timeout-minutes: 10
27
48
  steps:
28
- - uses: actions/checkout@v4
29
- - name: Set up pnpm (if project uses pnpm)
49
+ - name: Checkout via actions/checkout 4.4.0
50
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
51
+ with:
52
+ # Nothing in this job pushes back, so the token never needs to
53
+ # outlive the checkout step.
54
+ persist-credentials: false
55
+ - name: Resolve the package manager (pnpm route fails closed)
56
+ id: package-manager
57
+ shell: bash
58
+ run: |
59
+ # Package manager resolution, fail CLOSED. The pnpm setup action
60
+ # below is invoked with no `version:` input on purpose —
61
+ # overriding the version the adopter declared would be worse, e.g.
62
+ # forcing pnpm 9 on a pnpm 10 project — so
63
+ # `package.json#packageManager` is its only source. With that
64
+ # field missing the action stops with a resolution error naming
65
+ # neither the file nor the fix; we stop first and name both.
66
+ # Continuing without an install is not an option: the lane would
67
+ # report a validate result it never computed.
68
+ #
69
+ # Scoped to the pnpm route deliberately: Yarn Classic and npm ship
70
+ # with the runner and do resolve without the field, so stopping
71
+ # there would stop on a resolvable case.
72
+ if [ ! -f pnpm-lock.yaml ]; then
73
+ echo "qfai validate: no pnpm lockfile - no manifest-declared package manager required"
74
+ exit 0
75
+ fi
76
+ declared=""
77
+ if [ -f package.json ]; then
78
+ declared="$(node -e '
79
+ const { readFileSync } = require("node:fs");
80
+ let field = "";
81
+ try {
82
+ const parsed = JSON.parse(readFileSync("package.json", "utf8"));
83
+ if (
84
+ parsed !== null &&
85
+ typeof parsed === "object" &&
86
+ typeof parsed.packageManager === "string"
87
+ ) {
88
+ field = parsed.packageManager;
89
+ }
90
+ } catch {
91
+ field = "";
92
+ }
93
+ // The value is adopter input and this step echoes it, so every
94
+ // whitespace run collapses to one space: a `\n` (a legal JSON
95
+ // string escape) would otherwise start a new stdout line, and
96
+ // the runner reads `::`-leading lines as workflow commands - a
97
+ // fork PR could forge annotations against any file, mask
98
+ // output, or stop command processing for the rest of the step.
99
+ // Collapsing beats keeping the first line only: it also
100
+ // neutralises a lone `\r`, and it keeps the whole value
101
+ // visible in the log for diagnosis instead of silently
102
+ // truncating it.
103
+ process.stdout.write(field.trim().replace(/\s+/g, " "));
104
+ ')" || declared=""
105
+ fi
106
+ if [ -z "$declared" ]; then
107
+ echo '::error file=package.json::qfai validate: pnpm-lock.yaml is present but package.json does not resolve a "packageManager" string (the field is missing, is empty, is not a string, or package.json could not be read). Add "packageManager": "pnpm@<the pnpm version you use>" to package.json and commit it - the pnpm setup action reads the pnpm version from that field only, so this lane cannot install and must not report a validate result it did not compute.'
108
+ exit 1
109
+ fi
110
+ # Non-empty is not the same claim as resolvable. "yarn@4.9.2" and a
111
+ # bare "pnpm" both pass a presence test, and the setup action below
112
+ # then stops with an opaque resolution error naming neither the file
113
+ # nor the fix - which is the failure this guard exists to replace.
114
+ # So the pnpm route also checks the VALUE resolves to a pnpm version.
115
+ # Checked to the END of the value. `pnpm@[0-9]*` was not that check:
116
+ # a shell `*` is any string, not a repetition of digits, so
117
+ # `pnpm@9junk` matched on its first character and the opaque
118
+ # resolution error this guard exists to replace arrived one step
119
+ # later anyway. The shape required is `pnpm@` then MAJOR.MINOR.PATCH
120
+ # of digits, with corepack's optional `-<prerelease>` and `+<hash>`
121
+ # suffixes allowed but not required.
122
+ # The suffixes are VALIDATED, not stripped. Dropping everything from the
123
+ # first `-` or `+` and checking only what was left accepted
124
+ # `pnpm@9.12.3-`, `pnpm@9.12.3+` and `pnpm@9.12.3-foo_bar`: the core
125
+ # read as 9.12.3, this guard said `resolvable=yes`, and corepack then
126
+ # failed with the opaque resolution error the guard exists to replace.
127
+ # Corepack's own grammar is `<name>@<semver>` with an optional
128
+ # `+<algorithm>.<hex digest>` integrity suffix, so that is what is
129
+ # required here - whole value, one shape at a time.
130
+ version="${declared#pnpm@}"
131
+ resolvable=no
132
+ if [ "$version" != "$declared" ]; then
133
+ shape_ok=yes
134
+ body="$version"
135
+ case "$version" in
136
+ *+*)
137
+ body="${version%%+*}"
138
+ integrity="${version#*+}"
139
+ # `<algorithm>.<digest>`: an algorithm name, a dot, a hex digest.
140
+ # A bare `+`, a missing digest and a second `+` all fail — `+` is
141
+ # not a hex character, so the digest test rejects it too.
142
+ case "$integrity" in
143
+ *.*) ;;
144
+ *) shape_ok=no ;;
145
+ esac
146
+ # The algorithm is not guessed at from a fixed list, and it
147
+ # is not taken on shape alone either.
148
+ #
149
+ # A closed list of `sha1|sha224|sha256|sha384|sha512`
150
+ # refuses anything corepack accepts through
151
+ # `crypto.createHash` that is not on it - `sha3-256` is the
152
+ # obvious one - and refuses it with THIS guard's message,
153
+ # sending an adopter to fix a value that was already
154
+ # correct. But shape alone accepted
155
+ # `pnpm@9.12.3+garbage.deadbeef`: `garbage` is a run of
156
+ # letters, so this guard said the value was resolvable, and
157
+ # corepack then failed to hash with it - the opaque failure
158
+ # this precondition exists to replace, reached through the
159
+ # precondition.
160
+ #
161
+ # So the runner is asked. `crypto.getHashes()` is the set
162
+ # `crypto.createHash` accepts on THIS runner, which is the
163
+ # question that matters and the one a list in this file
164
+ # cannot answer.
165
+ algorithm="${integrity%%.*}"
166
+ case "$algorithm" in
167
+ ""|*[!0-9A-Za-z-]*) shape_ok=no ;;
168
+ *)
169
+ if ! node -e '
170
+ const { getHashes } = require("node:crypto");
171
+ const wanted = String(process.argv[1]).toLowerCase();
172
+ process.exit(
173
+ getHashes().some((name) => name.toLowerCase() === wanted)
174
+ ? 0
175
+ : 1,
176
+ );
177
+ ' "$algorithm" 2>/dev/null; then
178
+ shape_ok=no
179
+ fi
180
+ ;;
181
+ esac
182
+ case "${integrity#*.}" in
183
+ ""|*[!0-9a-fA-F]*) shape_ok=no ;;
184
+ esac
185
+ ;;
186
+ esac
187
+ case "$body" in
188
+ *-*)
189
+ core="${body%%-*}"
190
+ # A prerelease is dot-separated identifiers of alphanumerics and
191
+ # hyphens, none of them empty. `9.12.3-` has none at all.
192
+ case "${body#*-}" in
193
+ ""|.*|*.|*..*|*[!0-9A-Za-z.-]*) shape_ok=no ;;
194
+ esac
195
+ # And a NUMERIC identifier carries no leading zero, which SemVer
196
+ # forbids: `9.12.3-01` is not a version, and node-semver rejects
197
+ # it. An alphanumeric one may start with a zero (`0alpha`), so
198
+ # the two cases are separated rather than lumped together.
199
+ ids="${body#*-}"
200
+ while [ -n "$ids" ]; do
201
+ id="${ids%%.*}"
202
+ case "$id" in
203
+ "") shape_ok=no ;;
204
+ *[!0-9]*) ;;
205
+ 0) ;;
206
+ 0*) shape_ok=no ;;
207
+ esac
208
+ case "$ids" in
209
+ *.*) ids="${ids#*.}" ;;
210
+ *) ids="" ;;
211
+ esac
212
+ done
213
+ ;;
214
+ *) core="$body" ;;
215
+ esac
216
+ case "$core" in
217
+ ""|.*|*.|*[!0-9.]*|*.*.*.*) shape_ok=no ;;
218
+ [0-9]*.[0-9]*.[0-9]*) ;;
219
+ *) shape_ok=no ;;
220
+ esac
221
+ # MAJOR.MINOR.PATCH, each without a leading zero. The glob above is
222
+ # "digits and dots", not SemVer: `pnpm@9.12.03` and `pnpm@01.02.03`
223
+ # passed it, and neither is a version node-semver or corepack will
224
+ # resolve — so the guard said `resolvable` and the opaque downstream
225
+ # failure it exists to replace arrived one step later anyway. A
226
+ # dropped digit is an ordinary typo, which is exactly the case this
227
+ # guard is for.
228
+ rest="$core"
229
+ for _part in 1 2 3; do
230
+ part="${rest%%.*}"
231
+ case "$part" in
232
+ ""|*[!0-9]*) shape_ok=no ;;
233
+ 0) ;;
234
+ 0*) shape_ok=no ;;
235
+ esac
236
+ rest="${rest#*.}"
237
+ done
238
+ if [ "$shape_ok" = yes ]; then
239
+ resolvable=yes
240
+ fi
241
+ fi
242
+ if [ "$resolvable" != yes ]; then
243
+ printf '::error file=package.json::qfai validate: pnpm-lock.yaml is present but package.json "packageManager" is %s, which does not name a pnpm version. Set it to "pnpm@<the pnpm version you use>" and commit it - the pnpm setup action resolves the version from that field only, so this lane cannot install and must not report a validate result it did not compute.\n' "$declared"
244
+ exit 1
245
+ fi
246
+ echo "qfai validate: package manager ${declared} (from the package.json packageManager field)"
247
+ - name: Set up pnpm via pnpm/action-setup 4.4.0 (if project uses pnpm)
30
248
  if: ${{ hashFiles('pnpm-lock.yaml') != '' }}
31
- # pnpm/action-setup@v4 resolves the pnpm version from
32
- # `package.json#packageManager` when no `version:` input is
33
- # provided. Setting `version:` would override the consumer's
34
- # declared packageManager (e.g. forcing pnpm 9 on a pnpm 10
35
- # project), so we leave it unset and require the consumer to
36
- # declare `"packageManager": "pnpm@X.Y.Z"` in package.json —
37
- # the most common pnpm-on-CI baseline.
38
- uses: pnpm/action-setup@v4
39
- - uses: actions/setup-node@v4
249
+ # No `version:` input: the action reads it from
250
+ # `package.json#packageManager`, whose presence the step above has
251
+ # already established (see its comment for why it is required).
252
+ uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
253
+ - name: Resolve the Node version (adopter file wins, else fall open)
254
+ id: node-version
255
+ shell: bash
256
+ run: |
257
+ # Node version resolution, fail OPEN. An adopter version file
258
+ # wins in the order probed below; with none present we use the
259
+ # documented fallback and warn, so the lane continues.
260
+ #
261
+ # setup-node's `node-version-file:` input is deliberately NOT
262
+ # used: it fails the job outright for every adopter who has no
263
+ # such file, which would make this workflow unusable on a tree
264
+ # that simply never pinned a Node version.
265
+ fallback="20"
266
+ for candidate in .nvmrc .node-version; do
267
+ [ -f "$candidate" ] || continue
268
+ first_line=""
269
+ IFS= read -r first_line < "$candidate" || true
270
+ resolved="$(printf '%s' "$first_line" | tr -d '[:space:]')"
271
+ if [ -n "$resolved" ]; then
272
+ echo "qfai validate: Node ${resolved} (from ${candidate})"
273
+ echo "version=${resolved}" >> "$GITHUB_OUTPUT"
274
+ exit 0
275
+ fi
276
+ done
277
+ echo "::warning::qfai validate: no Node version file (.nvmrc or .node-version) found - using Node ${fallback} and continuing (fail open). Add one to pin the version this workflow uses."
278
+ echo "version=${fallback}" >> "$GITHUB_OUTPUT"
279
+ - name: Choose a package-manager cache setup-node can actually resolve
280
+ id: node-cache
281
+ shell: bash
282
+ run: |
283
+ # setup-node resolves a cache DIRECTORY by running the package manager, before this
284
+ # workflow has installed anything. Asking it for a cache it cannot resolve fails the
285
+ # step outright, which is why the choice is made here rather than in an expression.
286
+ #
287
+ # pnpm and npm are already available at this point: `pnpm/action-setup` runs above, and
288
+ # npm ships with every Node. Yarn does not. Corepack is not bundled from Node 25 on, and
289
+ # the Node this workflow runs is the adopter's own `.nvmrc` / `.node-version` — so on a
290
+ # runner with neither Yarn nor Corepack preinstalled, `cache: yarn` sent setup-node to
291
+ # `yarn cache dir` and the job stopped there, BEFORE the install step below could
292
+ # install Corepack and enable the shim. The lane failed at the one point it was built to
293
+ # fail open.
294
+ #
295
+ # So the Yarn cache is claimed only when Yarn answers now. Skipping it costs a warm
296
+ # cache and nothing else: the install step still provisions Corepack and installs, so
297
+ # the lane runs. A missing optimisation is not a missing verification.
298
+ if [ -f pnpm-lock.yaml ]; then
299
+ echo "cache=pnpm" >> "$GITHUB_OUTPUT"
300
+ elif [ -f yarn.lock ]; then
301
+ # The QUERY setup-node will make, not merely whether something called yarn is on
302
+ # PATH. A self-hosted runner can carry a stale Corepack shim, or a `yarn` that
303
+ # cannot resolve its own cache — `command -v` succeeds there and `yarn cache dir`
304
+ # does not, which is the case that still stopped the job. Asking the real question
305
+ # costs one subprocess and answers exactly what the cache needs.
306
+ if yarn cache dir > /dev/null 2>&1; then
307
+ echo "cache=yarn" >> "$GITHUB_OUTPUT"
308
+ else
309
+ echo "::warning::qfai validate: yarn is not on PATH yet, so the Yarn download cache is skipped for this run. The install step provisions Corepack and installs normally; preinstall Yarn or Corepack on this runner to get the cache back."
310
+ echo "cache=" >> "$GITHUB_OUTPUT"
311
+ fi
312
+ elif [ -f package-lock.json ]; then
313
+ echo "cache=npm" >> "$GITHUB_OUTPUT"
314
+ else
315
+ echo "cache=" >> "$GITHUB_OUTPUT"
316
+ fi
317
+ - name: Set up Node via actions/setup-node 4.4.0
318
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
40
319
  with:
41
- # Match the QFAI repo's CI baseline (Node 20 LTS) and the package
42
- # `engines: ">=18.0.0"`. Bump deliberately when QFAI raises its
43
- # supported floor.
44
- node-version: "20"
45
- # setup-node@v4's `cache:` accepts a single package-manager value.
46
- # Pick the one matching the consumer's lockfile (or leave unset
47
- # when none of the three is present). The conditional expression
48
- # short-circuits left-to-right.
320
+ # The version resolved by the step above: the adopter's own
321
+ # version file when they have one, else the documented fallback
322
+ # (Node 20, matching the package `engines: ">=20.19.0"` floor).
323
+ node-version: ${{ steps.node-version.outputs.version }}
324
+ # setup-node@v4's `cache:` accepts a single package-manager value, and the step above
325
+ # decides it — an expression cannot ask whether the package manager is on PATH, and
326
+ # asking for a cache setup-node cannot resolve fails the step outright.
49
327
  #
50
328
  # NOTE: `cache: yarn` is built around Yarn Classic (v1)'s
51
329
  # `yarn cache dir`. Yarn Berry (v2+) keeps deps under `.yarn/cache`
@@ -53,13 +331,38 @@ jobs:
53
331
  # step below still picks the correct flag (`--immutable` for
54
332
  # Berry, `--frozen-lockfile` for Classic) so functionality is
55
333
  # preserved either way.
56
- cache: ${{ hashFiles('pnpm-lock.yaml') != '' && 'pnpm' || (hashFiles('yarn.lock') != '' && 'yarn' || (hashFiles('package-lock.json') != '' && 'npm' || '')) }}
334
+ cache: ${{ steps.node-cache.outputs.cache }}
57
335
  - name: Install dependencies (lockfile-aware)
58
336
  shell: bash
59
337
  run: |
60
338
  if [ -f pnpm-lock.yaml ]; then
61
339
  pnpm install --frozen-lockfile
62
340
  elif [ -f yarn.lock ]; then
341
+ # Corepack is not bundled from Node 25 on, and the Node this workflow runs is the
342
+ # adopter's own `.nvmrc` / `.node-version`, which QFAI does not choose. Calling
343
+ # `corepack enable` unconditionally stopped the run at `command not found` before a
344
+ # single dependency was installed. Installed when absent, which is what this
345
+ # repository's own composite action does for the same reason.
346
+ if ! command -v corepack > /dev/null 2>&1; then
347
+ # Pinned rather than latest: an unpinned global install fetches whatever the
348
+ # registry calls latest at the moment the job runs, so the same commit installs a
349
+ # different corepack from one day to the next — and this is the step that
350
+ # bootstraps the toolchain everything after it depends on.
351
+ # The version AND the registry it comes from. `npm` resolves its registry from
352
+ # `NPM_CONFIG_REGISTRY` or from a project `.npmrc`, so a pinned version alone names
353
+ # WHAT to fetch and not WHERE from — and this package's bin runs on the very next
354
+ # line. `--registry` on the command line outranks both, and `--ignore-scripts` stops
355
+ # the package running during installation rather than when it is invoked.
356
+ #
357
+ # The own-CI copy of this fallback goes further: it downloads the tarball, compares
358
+ # its sha512 with a pinned integrity, and installs from the verified file. That is
359
+ # deliberately NOT done here. This lane runs in an ADOPTER's repository, where the
360
+ # enumerated set of programs a shipped lane may invoke is itself a reviewed
361
+ # contract — putting `curl` and `openssl` into it widens what every adopter's CI is
362
+ # allowed to run, to defend against a file that adopter owns and reviews. The flag
363
+ # closes the redirect; the download would import a capability instead.
364
+ npm install --global --ignore-scripts --registry https://registry.npmjs.org/ corepack@0.35.0
365
+ fi
63
366
  corepack enable
64
367
  # Yarn Berry (v2+) uses `--immutable`; Yarn Classic (v1) uses
65
368
  # `--frozen-lockfile`. Pick the right flag based on the
@@ -52,6 +52,12 @@ accessibility:
52
52
  motion: "respect-reduced-motion"
53
53
  ---
54
54
 
55
+ <!-- QFAI-SAMPLE-DESIGN-MD: this is the qfai sample brand, NOT your product's brand.
56
+ Replace the front-matter and the body below with this product's own brand SSOT
57
+ (`/qfai-discussion` emits the draft), then DELETE this comment. While this comment
58
+ is present `qfai validate` reports QFAI-DCON-034 and /qfai-sdd Phase 0 refuses to
59
+ freeze the file's sha256 as the project's brand contract. -->
60
+
55
61
  # Brand Philosophy
56
62
 
57
63
  Acme Ledger is a calm, confident financial comparison surface. The interface
@@ -18,17 +18,20 @@ validation:
18
18
  traceability:
19
19
  brMustHaveSc: true
20
20
  scMustHaveTest: true
21
- testFileGlobs:
22
- - tests/**/*.test.ts
23
- - tests/**/*.spec.ts
24
- - packages/*/tests/**/*.test.ts
25
- - packages/*/tests/**/*.spec.ts
26
- - src/**/*.test.ts
27
- - src/**/*.spec.ts
28
- - packages/*/src/**/*.test.ts
29
- - packages/*/src/**/*.spec.ts
30
- - features/**/*.feature
31
- - packages/*/features/**/*.feature
21
+ # Intentionally empty: this matches the in-code default and must be set to the
22
+ # repository's real test layout before the SC traceability gate means anything.
23
+ # Seeding a language-specific list here makes the gate silently pass on every
24
+ # other stack. Run /qfai-configure to populate it; `qfai validate` reports
25
+ # QFAI-TRACE-124 while this is unset or matches zero files.
26
+ #
27
+ # Examples:
28
+ # TypeScript: tests/**/*.test.ts, src/**/*.spec.ts
29
+ # Python: tests/**/test_*.py, tests/**/*_test.py
30
+ # Go: **/*_test.go
31
+ # Java/Kotlin: src/test/**/*.java, src/test/**/*.kt
32
+ # Rust: tests/**/*.rs
33
+ # Cucumber: features/**/*.feature
34
+ testFileGlobs: []
32
35
  testFileExcludeGlobs: []
33
36
  scNoTestSeverity: error
34
37
  orphanContractsPolicy: error
@@ -40,4 +43,4 @@ prototyping:
40
43
  packPath: .qfai/evidence/calibration.yaml
41
44
  execution:
42
45
  targetUrl: null
43
- browserTool: playwright-cli
46
+ browserTool: playwright