peaks-loop 4.1.4 → 4.1.6

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 (294) hide show
  1. package/.claude-plugin/marketplace.json +7 -2
  2. package/CHANGELOG.md +148 -0
  3. package/README-en.md +47 -183
  4. package/README.md +24 -188
  5. package/dist/cli/cli-helpers.d.ts +20 -0
  6. package/dist/cli/cli-helpers.js +34 -0
  7. package/dist/cli/commands/_register.js +2 -0
  8. package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
  9. package/dist/cli/commands/best-practice-scan-command.js +35 -20
  10. package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
  11. package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
  12. package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
  13. package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
  14. package/dist/cli/commands/code-commands.d.ts +6 -4
  15. package/dist/cli/commands/code-commands.js +6 -4
  16. package/dist/cli/commands/code-gate-command.d.ts +5 -5
  17. package/dist/cli/commands/code-gate-command.js +49 -9
  18. package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
  19. package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
  20. package/dist/cli/commands/core/memory-extract-command.js +10 -5
  21. package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
  22. package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
  23. package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
  24. package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
  25. package/dist/cli/commands/dispatch-command-spec.js +1 -1
  26. package/dist/cli/commands/dispatch-commands.js +12 -5
  27. package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
  28. package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
  29. package/dist/cli/commands/dispatch-preflight.js +46 -0
  30. package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
  31. package/dist/cli/commands/dispatch-prompt-composition.d.ts +7 -1
  32. package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
  33. package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
  34. package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
  35. package/dist/cli/commands/doc-commands.js +1 -1
  36. package/dist/cli/commands/feedback-commands-helpers.js +1 -1
  37. package/dist/cli/commands/final-review-prepare-command.js +22 -1
  38. package/dist/cli/commands/gate-commands-enforce.js +3 -3
  39. package/dist/cli/commands/hook-handle.js +41 -20
  40. package/dist/cli/commands/lint-commands.js +3 -1
  41. package/dist/cli/commands/loop-eval-capture-index.js +2 -4
  42. package/dist/cli/commands/openspec-command-shared.js +2 -2
  43. package/dist/cli/commands/perf-audit-commands.js +15 -5
  44. package/dist/cli/commands/project-commands.js +9 -6
  45. package/dist/cli/commands/race-commands.d.ts +15 -0
  46. package/dist/cli/commands/race-commands.js +65 -0
  47. package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
  48. package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
  49. package/dist/cli/commands/request-command-options.d.ts +8 -0
  50. package/dist/cli/commands/request-commands.js +2 -0
  51. package/dist/cli/commands/request-init-command.js +67 -12
  52. package/dist/cli/commands/{vm-status-command.d.ts → request-retag-command.d.ts} +1 -1
  53. package/dist/cli/commands/request-retag-command.js +50 -0
  54. package/dist/cli/commands/request-show-command.d.ts +8 -0
  55. package/dist/cli/commands/request-show-command.js +14 -1
  56. package/dist/cli/commands/request-transition-command.js +12 -4
  57. package/dist/cli/commands/request-transition-failures.d.ts +14 -0
  58. package/dist/cli/commands/request-transition-failures.js +76 -7
  59. package/dist/cli/commands/request-transition-preflight.js +1 -1
  60. package/dist/cli/commands/scan-scope-commands.js +2 -2
  61. package/dist/cli/commands/security-audit-commands.js +26 -6
  62. package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
  63. package/dist/cli/commands/verdict-aggregate-command.js +2 -1
  64. package/dist/cli/commands/workflow-gate-commands.js +4 -4
  65. package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
  66. package/dist/cli/program.js +0 -2
  67. package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
  68. package/dist/services/artifacts/artifact-contract-block.js +231 -0
  69. package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
  70. package/dist/services/artifacts/artifact-prerequisites.js +65 -135
  71. package/dist/services/artifacts/artifact-templates.d.ts +1 -1
  72. package/dist/services/artifacts/artifact-templates.js +17 -10
  73. package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
  74. package/dist/services/artifacts/prerequisite-checks.js +198 -0
  75. package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
  76. package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
  77. package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
  78. package/dist/services/artifacts/rd-transition-gates.js +71 -0
  79. package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
  80. package/dist/services/artifacts/request-artifact-metadata.js +44 -0
  81. package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
  82. package/dist/services/artifacts/request-artifact-service.js +43 -69
  83. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +21 -1
  84. package/dist/services/artifacts/request-artifact-state-helpers.js +34 -8
  85. package/dist/services/artifacts/request-retag-service.d.ts +68 -0
  86. package/dist/services/artifacts/request-retag-service.js +125 -0
  87. package/dist/services/artifacts/request-state-order.d.ts +38 -0
  88. package/dist/services/artifacts/request-state-order.js +99 -0
  89. package/dist/services/artifacts/request-type-demand.d.ts +44 -0
  90. package/dist/services/artifacts/request-type-demand.js +71 -0
  91. package/dist/services/audit/audit-goal-service.d.ts +7 -0
  92. package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
  93. package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
  94. package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
  95. package/dist/services/audit/enforcers/code-ban.js +21 -1
  96. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
  97. package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
  98. package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
  99. package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
  100. package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
  101. package/dist/services/audit-independent/handoff-readers.js +81 -0
  102. package/dist/services/audit-independent/index.d.ts +6 -1
  103. package/dist/services/audit-independent/index.js +6 -1
  104. package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
  105. package/dist/services/audit-independent/judged-declaration-build.js +73 -0
  106. package/dist/services/audit-independent/judged-declaration-check.d.ts +80 -0
  107. package/dist/services/audit-independent/judged-declaration-check.js +216 -0
  108. package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
  109. package/dist/services/audit-independent/judged-declaration.js +218 -0
  110. package/dist/services/audit-independent/perf-audit-service.js +12 -14
  111. package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
  112. package/dist/services/audit-independent/security-audit-artifact.js +90 -0
  113. package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
  114. package/dist/services/audit-independent/security-audit-service.js +34 -178
  115. package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
  116. package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
  117. package/dist/services/context/build-dispatch-system-prompt.d.ts +8 -12
  118. package/dist/services/context/build-dispatch-system-prompt.js +18 -18
  119. package/dist/services/context/collector.js +5 -1
  120. package/dist/services/context/post-compact-reinjection.js +1 -1
  121. package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
  122. package/dist/services/dispatch/active-dispatch-index.js +118 -0
  123. package/dist/services/dispatch/batch-counter.js +1 -2
  124. package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
  125. package/dist/services/dispatch/dispatch-record-writer.js +58 -100
  126. package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
  127. package/dist/services/dispatch/karpathy-block.d.ts +55 -0
  128. package/dist/services/dispatch/karpathy-block.js +101 -0
  129. package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
  130. package/dist/services/dispatch/ledger-reaper.js +131 -0
  131. package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
  132. package/dist/services/dispatch/test-tool-detection.js +12 -1
  133. package/dist/services/evidence/evidence-generator.js +23 -12
  134. package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
  135. package/dist/services/feedback/feedback-promotion-service.js +30 -35
  136. package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
  137. package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
  138. package/dist/services/feedback/promotion-artifact-missing.js +63 -0
  139. package/dist/services/final-review/final-review-contract.d.ts +95 -4
  140. package/dist/services/final-review/final-review-contract.js +64 -0
  141. package/dist/services/final-review/final-review-delivery.d.ts +13 -0
  142. package/dist/services/final-review/final-review-delivery.js +26 -12
  143. package/dist/services/final-review/final-review-evidence-collect.js +8 -53
  144. package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
  145. package/dist/services/final-review/final-review-evidence-records.js +67 -0
  146. package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
  147. package/dist/services/final-review/final-review-evidence-sources.js +28 -4
  148. package/dist/services/final-review/final-review-prompt.js +19 -6
  149. package/dist/services/final-review/final-review-runner.js +5 -0
  150. package/dist/services/final-review/final-review-service.d.ts +2 -2
  151. package/dist/services/final-review/index.d.ts +1 -1
  152. package/dist/services/final-review/pre-post-diff.d.ts +2 -75
  153. package/dist/services/final-review/pre-post-diff.js +60 -59
  154. package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
  155. package/dist/services/hooks/pre-tool-code-gate.js +21 -2
  156. package/dist/services/hooks/worktree-authorization-gate.js +6 -31
  157. package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
  158. package/dist/services/hooks/worktree-refusal-messages.js +102 -0
  159. package/dist/services/lint/eslint-runner-support.d.ts +1 -1
  160. package/dist/services/lint/eslint-runner-support.js +2 -1
  161. package/dist/services/lint/eslint-runner-types.d.ts +8 -0
  162. package/dist/services/lint/eslint-runner.js +17 -4
  163. package/dist/services/llm/anthropic-runner.js +24 -7
  164. package/dist/services/loop/loop-observability.d.ts +39 -0
  165. package/dist/services/loop/loop-observability.js +55 -0
  166. package/dist/services/loop/monotonic-guard.js +6 -9
  167. package/dist/services/loop/monotonic-runner.js +8 -7
  168. package/dist/services/loop/run-driver.js +18 -22
  169. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
  170. package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
  171. package/dist/services/memory/project-memory-service/index.d.ts +2 -2
  172. package/dist/services/memory/project-memory-service/index.js +1 -1
  173. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
  174. package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
  175. package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
  176. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
  177. package/dist/services/memory/project-memory-service/types.d.ts +32 -0
  178. package/dist/services/observability/observability-service.d.ts +7 -0
  179. package/dist/services/observability/observability-service.js +2 -1
  180. package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
  181. package/dist/services/openspec/coverage-evidence-reader.js +8 -8
  182. package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
  183. package/dist/services/openspec/openspec-archive-service.js +6 -6
  184. package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
  185. package/dist/services/prd/gate-evidence-derivation.js +4 -3
  186. package/dist/services/qa/bdd-test-style-verifier.js +22 -8
  187. package/dist/services/race/gate2-evaluator.d.ts +58 -0
  188. package/dist/services/race/gate2-evaluator.js +111 -0
  189. package/dist/services/race/gate2-policy.d.ts +17 -0
  190. package/dist/services/race/gate2-policy.js +31 -0
  191. package/dist/services/race/lane-phase.d.ts +19 -0
  192. package/dist/services/race/lane-phase.js +113 -0
  193. package/dist/services/race/pilot-gate-store.d.ts +67 -0
  194. package/dist/services/race/pilot-gate-store.js +227 -0
  195. package/dist/services/scan/file-size-baseline.d.ts +33 -0
  196. package/dist/services/scan/file-size-baseline.js +173 -0
  197. package/dist/services/scan/file-size-scan.d.ts +35 -3
  198. package/dist/services/scan/file-size-scan.js +63 -42
  199. package/dist/services/scan/type-corroboration.d.ts +32 -0
  200. package/dist/services/scan/type-corroboration.js +51 -0
  201. package/dist/services/scan/type-sanity-service.d.ts +14 -0
  202. package/dist/services/scan/type-sanity-service.js +23 -22
  203. package/dist/services/security/safe-settings-path.d.ts +5 -0
  204. package/dist/services/security/safe-settings-path.js +64 -8
  205. package/dist/services/skill/resume-detector.js +11 -11
  206. package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
  207. package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
  208. package/dist/services/skills/hooks-settings-service.d.ts +1 -1
  209. package/dist/services/skills/hooks-settings-service.js +1 -1
  210. package/dist/services/skills/presence-lease-order.d.ts +13 -0
  211. package/dist/services/skills/presence-lease-order.js +24 -0
  212. package/dist/services/skills/skill-conformance-service.js +1 -0
  213. package/dist/services/skills/skill-statusline-service.js +4 -7
  214. package/dist/services/slice/slice-check-service.js +8 -8
  215. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
  216. package/dist/services/workflow/pipeline-verify-gate-support.js +34 -39
  217. package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
  218. package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
  219. package/dist/services/workflow/pipeline-verify-service.js +27 -28
  220. package/dist/services/workflow/request-type-resolution.d.ts +99 -0
  221. package/dist/services/workflow/request-type-resolution.js +130 -0
  222. package/dist/services/workflow/workflow-skip-service.d.ts +1 -20
  223. package/dist/services/workflow/workflow-skip-service.js +22 -25
  224. package/dist/services/workflow/workflow-state-store.d.ts +9 -0
  225. package/dist/services/workflow/workflow-state-store.js +26 -1
  226. package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
  227. package/dist/services/workspace/claude-settings-retirements.js +112 -0
  228. package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
  229. package/dist/services/workspace/claude-settings-template-merge.js +33 -53
  230. package/dist/services/workspace/claude-settings-template.d.ts +62 -12
  231. package/dist/services/workspace/claude-settings-template.js +58 -58
  232. package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
  233. package/dist/services/workspace/reconcile-service.js +0 -1
  234. package/dist/shared/incrementing-number.d.ts +33 -2
  235. package/dist/shared/incrementing-number.js +72 -3
  236. package/package.json +5 -7
  237. package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
  238. package/skills/bee/peaks-prd/SKILL.md +4 -3
  239. package/skills/bee/peaks-qa/SKILL.md +1 -1
  240. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
  241. package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
  242. package/skills/bee/peaks-rd/SKILL.md +2 -2
  243. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
  244. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
  245. package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
  246. package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
  247. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
  248. package/skills/bee/peaks-reviewer/SKILL.md +1 -1
  249. package/skills/bee/peaks-sc/SKILL.md +1 -1
  250. package/skills/bee/peaks-security-audit/SKILL.md +10 -2
  251. package/skills/bee/peaks-txt/SKILL.md +4 -3
  252. package/skills/bee/peaks-ui/SKILL.md +3 -3
  253. package/skills/peaks-audit/SKILL.md +29 -1
  254. package/skills/peaks-code/SKILL.md +37 -17
  255. package/skills/peaks-code/references/fast-lane-norm.md +42 -0
  256. package/skills/peaks-code/references/fast-mode.md +3 -2
  257. package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
  258. package/skills/peaks-code/references/micro-cycle.md +3 -3
  259. package/skills/peaks-code/references/resume-detection.md +1 -1
  260. package/skills/peaks-code/references/runbook.md +12 -6
  261. package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
  262. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  263. package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
  264. package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
  265. package/skills/peaks-code/references/worktree-governance.md +4 -4
  266. package/skills/peaks-content/SKILL.md +1 -1
  267. package/skills/peaks-doctor/SKILL.md +1 -1
  268. package/skills/peaks-final-review/SKILL.md +31 -11
  269. package/skills/peaks-ide/SKILL.md +1 -1
  270. package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
  271. package/skills/peaks-race-code/SKILL.md +185 -0
  272. package/skills/peaks-resume/SKILL.md +1 -1
  273. package/skills/peaks-slice-decompose/SKILL.md +1 -1
  274. package/skills/peaks-solo/SKILL.md +1 -1
  275. package/skills/peaks-sop/SKILL.md +1 -1
  276. package/skills/peaks-status/SKILL.md +1 -1
  277. package/skills/peaks-test/SKILL.md +7 -4
  278. package/dist/cli/commands/vm-command-shared.d.ts +0 -23
  279. package/dist/cli/commands/vm-command-shared.js +0 -23
  280. package/dist/cli/commands/vm-commands.d.ts +0 -3
  281. package/dist/cli/commands/vm-commands.js +0 -45
  282. package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
  283. package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
  284. package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
  285. package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
  286. package/dist/cli/commands/vm-release-command.d.ts +0 -5
  287. package/dist/cli/commands/vm-release-command.js +0 -101
  288. package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
  289. package/dist/cli/commands/vm-spawn-command.js +0 -177
  290. package/dist/cli/commands/vm-status-command.js +0 -50
  291. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
  292. package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
  293. package/dist/services/vm/vm-lease.d.ts +0 -40
  294. package/dist/services/vm/vm-lease.js +0 -160
@@ -0,0 +1,24 @@
1
+ // Shared ordering for a peaks session's presence leases.
2
+ //
3
+ // Lives on its own because the three readers that need it — the resolver, the
4
+ // statusline projection, and the per-caller legacy read — sit in three modules
5
+ // and none of them owns the other. They used to order the same lease set three
6
+ // ways (two by heartbeat alone, one with a tie-break), so they could name
7
+ // different leases as "who is driving".
8
+ /**
9
+ * Most recent lease first: `lastHeartbeat` desc, `startedAt` desc as the
10
+ * tie-break.
11
+ *
12
+ * The tie-break is not decorative. Nothing refreshes the on-disk heartbeat
13
+ * today — no caller runs `setPresenceLease` on a cadence — so `lastHeartbeat`
14
+ * frequently equals `startedAt`, and two leases written in the same millisecond
15
+ * tie on heartbeat alone. That tie then falls through to `Array.prototype.sort`
16
+ * stability, i.e. `readdirSync` order, which is the input this ordering exists
17
+ * to stop depending on.
18
+ */
19
+ export function comparePresenceLeases(a, b) {
20
+ const byHeartbeat = (b.lastHeartbeat ?? '').localeCompare(a.lastHeartbeat ?? '');
21
+ if (byHeartbeat !== 0)
22
+ return byHeartbeat;
23
+ return (b.startedAt ?? '').localeCompare(a.startedAt ?? '');
24
+ }
@@ -29,6 +29,7 @@ const SKILL_NAMES = [
29
29
  'peaks-qa',
30
30
  'peaks-sc',
31
31
  'peaks-code',
32
+ 'peaks-race-code',
32
33
  'peaks-resume',
33
34
  'peaks-status',
34
35
  'peaks-test',
@@ -1,6 +1,7 @@
1
1
  import { findProjectRoot } from '../config/config-safety.js';
2
2
  import { getSessionIdCanonical } from '../session/session-manager.js';
3
3
  import { resolveActiveSkillForCaller } from '../audit/enforcers/active-skill-resolver.js';
4
+ import { comparePresenceLeases } from './presence-lease-order.js';
4
5
  import { listPresenceLeases } from './presence-lease-service.js';
5
6
  import { read24hOverlay, readActiveLeaf, readCompactState, resolveCallerId, resolveCwdFromStdin } from './skill-statusline-model.js';
6
7
  export { parseStatusLineStdin, read24hOverlay } from './skill-statusline-model.js';
@@ -101,13 +102,9 @@ function readPresenceReadOnly(projectRoot, callerId) {
101
102
  if (inFlight.length === 0) {
102
103
  return { presence: null, invalid: false };
103
104
  }
104
- // Most recent wins — sort by `lastHeartbeat` desc, fall back to `startedAt`.
105
- const sorted = inFlight.slice().sort((a, b) => {
106
- const hb = b.lastHeartbeat.localeCompare(a.lastHeartbeat);
107
- if (hb !== 0)
108
- return hb;
109
- return b.startedAt.localeCompare(a.startedAt);
110
- });
105
+ // Most recent wins, through the shared comparator so every reader of one
106
+ // lease set names the same lease.
107
+ const sorted = inFlight.slice().sort(comparePresenceLeases);
111
108
  const latest = sorted[0];
112
109
  if (latest === undefined || typeof latest.skill !== 'string' || latest.skill.length === 0) {
113
110
  return { presence: null, invalid: false };
@@ -243,22 +243,22 @@ async function runUnitTests(projectRoot, runTests) {
243
243
  }
244
244
  };
245
245
  }
246
- // carry the rid now. Candidate order is canonical-first, then the
247
- // back-compat tiers — the same order `artifact-prerequisites.ts` resolves
248
- // in, so this boundary gate and the transition gate agree on which file is
249
- // a slice's evidence. `<rid>` is substituted at probe time.
246
+ // Candidate order is canonical-first, then the back-compat tiers, mirroring
247
+ // `artifact-prerequisites.ts` (v2.12.0 moved security + perf to audit skills).
250
248
  const REVIEW_FILES = [
251
249
  {
252
250
  name: 'code-review',
253
251
  paths: ['rd/code-review-<rid>.md', 'rd/code-review.md'],
254
252
  label: 'code-review'
255
253
  },
256
- // v2.12.0 collapse: security + perf moved to standalone audit skills.
257
- // OR the v2.11.x legacy path during the 1-minor-release back-compat
258
- // window (v2.13.0 hard-deletes the legacy paths — see CHANGELOG [2.12.0]).
259
254
  {
260
255
  name: 'security-review',
261
- paths: ['audit/security-<rid>.md', 'audit/security.md', 'rd/security-review.md'],
256
+ paths: [
257
+ 'audit/security-<rid>.md',
258
+ 'audit/security.md',
259
+ 'rd/security-review-<rid>.md',
260
+ 'rd/security-review.md'
261
+ ],
262
262
  label: 'security-review'
263
263
  },
264
264
  {
@@ -10,14 +10,11 @@ import { type ArtifactPrerequisite, type RequestType } from '../artifacts/artifa
10
10
  import type { RequestArtifactRole, RequestArtifactState } from '../artifacts/request-artifact-service.js';
11
11
  import type { PipelineGate } from './pipeline-verify-types.js';
12
12
  export declare function extractState(markdown: string): string;
13
- /**
14
- * scope is the change-id (the `.peaks/_runtime/<sessionId>/` dir the file lives
15
- * in), NOT the session-id. We resolve the on-disk location via
16
- * `showRequestArtifact` (which scans all top-level dirs and returns the
17
- * actual dir the file was found in) instead of assuming
18
- * `.peaks/_runtime/<sessionId>/<role>/requests/`.
19
- */
20
- export declare function findRequestFile(projectRoot: string, role: string, rid: string): Promise<{
13
+ /** The rid's artifact file, read from ONE session: `sessionId` is required, and
14
+ * `null` — no resolvable scope — means NO CARRIER, never a scan (that branch
15
+ * reads every directory under `.peaks/_runtime/` and takes the first name that
16
+ * sorts). The dir the file was FOUND in comes back as `sessionId`. */
17
+ export declare function findRequestFile(projectRoot: string, role: string, rid: string, sessionId: string | null): Promise<{
21
18
  path: string;
22
19
  content: string;
23
20
  sessionId: string;
@@ -54,6 +51,25 @@ export declare function findRequestFile(projectRoot: string, role: string, rid:
54
51
  export declare function contractPrerequisite(role: RequestArtifactRole, state: RequestArtifactState, requestType: RequestType, probeName: string): ArtifactPrerequisite | null;
55
52
  export declare function contractEvidencePaths(role: RequestArtifactRole, state: RequestArtifactState, requestType: RequestType, probeName: string): string[] | null;
56
53
  export declare function rdGatesForType(requestType: RequestType): PipelineGate[];
54
+ /**
55
+ * The QA phase's gate list for one type.
56
+ *
57
+ * Both halves are read off the type's own table. WHICH EVIDENCE the phase owes is
58
+ * the type's `qa:` row, resolved through the same contract accessor
59
+ * `rdGatesForType` uses — a row the contract carries builds its gate, a row it
60
+ * does not carry builds none. WHETHER the phase exists at all is
61
+ * `typeRequiresQaPhase`, the same call the checker makes, which is the part that
62
+ * used to be a list of three request types named here. The derivation and the
63
+ * arming that keeps it total are `pipeline-verify-qa-phase.ts`.
64
+ *
65
+ * Two of the six types are why this reads the table instead of naming its
66
+ * members. The minimal table — docs and chore — carries no `qa:` row, so those
67
+ * types owe no QA evidence and get an empty list; that is how both the checker
68
+ * and the commit-time carrier learn there is no phase to report. Config carries
69
+ * exactly one QA row instead: a test report, and no test cases. The member list
70
+ * was wrong about both, in opposite directions: one type was asked for a phase it
71
+ * does not owe, and the other never for the evidence its transition requires.
72
+ */
57
73
  export declare function qaGatesForType(requestType: RequestType): PipelineGate[];
58
74
  export declare const RD_QA_HANDOFF_STATES: Set<string>;
59
75
  export declare const QA_COMPLETE_STATES: Set<string>;
@@ -8,24 +8,26 @@
8
8
  */
9
9
  import { existsSync, readFileSync } from 'node:fs';
10
10
  import { join } from 'node:path';
11
- import { getPrerequisitesFor, prerequisiteBodyViolations } from '../artifacts/artifact-prerequisites.js';
11
+ import { getPrerequisitesFor } from '../artifacts/artifact-prerequisites.js';
12
+ import * as qaPhase from './pipeline-verify-qa-phase.js';
13
+ import { prerequisiteBodyViolations } from '../artifacts/prerequisite-checks.js';
12
14
  import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
13
15
  import { readArtifactState } from '../artifacts/request-artifact-state-helpers.js';
14
16
  export function extractState(markdown) {
15
17
  return readArtifactState(markdown) ?? 'unknown';
16
18
  }
17
- /**
18
- * scope is the change-id (the `.peaks/_runtime/<sessionId>/` dir the file lives
19
- * in), NOT the session-id. We resolve the on-disk location via
20
- * `showRequestArtifact` (which scans all top-level dirs and returns the
21
- * actual dir the file was found in) instead of assuming
22
- * `.peaks/_runtime/<sessionId>/<role>/requests/`.
23
- */
24
- export async function findRequestFile(projectRoot, role, rid) {
19
+ /** The rid's artifact file, read from ONE session: `sessionId` is required, and
20
+ * `null` — no resolvable scope — means NO CARRIER, never a scan (that branch
21
+ * reads every directory under `.peaks/_runtime/` and takes the first name that
22
+ * sorts). The dir the file was FOUND in comes back as `sessionId`. */
23
+ export async function findRequestFile(projectRoot, role, rid, sessionId) {
24
+ if (sessionId === null)
25
+ return null;
25
26
  const artifact = await showRequestArtifact({
26
27
  projectRoot,
27
28
  role: role,
28
- requestId: rid
29
+ requestId: rid,
30
+ sessionId
29
31
  });
30
32
  if (artifact === null)
31
33
  return null;
@@ -176,32 +178,27 @@ export function rdGatesForType(requestType) {
176
178
  }
177
179
  return gates;
178
180
  }
181
+ /**
182
+ * The QA phase's gate list for one type.
183
+ *
184
+ * Both halves are read off the type's own table. WHICH EVIDENCE the phase owes is
185
+ * the type's `qa:` row, resolved through the same contract accessor
186
+ * `rdGatesForType` uses — a row the contract carries builds its gate, a row it
187
+ * does not carry builds none. WHETHER the phase exists at all is
188
+ * `typeRequiresQaPhase`, the same call the checker makes, which is the part that
189
+ * used to be a list of three request types named here. The derivation and the
190
+ * arming that keeps it total are `pipeline-verify-qa-phase.ts`.
191
+ *
192
+ * Two of the six types are why this reads the table instead of naming its
193
+ * members. The minimal table — docs and chore — carries no `qa:` row, so those
194
+ * types owe no QA evidence and get an empty list; that is how both the checker
195
+ * and the commit-time carrier learn there is no phase to report. Config carries
196
+ * exactly one QA row instead: a test report, and no test cases. The member list
197
+ * was wrong about both, in opposite directions: one type was asked for a phase it
198
+ * does not owe, and the other never for the evidence its transition requires.
199
+ */
179
200
  export function qaGatesForType(requestType) {
180
- const gates = [
181
- {
182
- name: 'qa-request-exists',
183
- description: 'QA request artifact created',
184
- passed: false,
185
- detail: ''
186
- }
187
- ];
188
- if (requestType === 'feature' || requestType === 'refactor' || requestType === 'bugfix') {
189
- gates.push({ name: 'test-cases', description: 'QA test cases', passed: false, detail: '' });
190
- gates.push({
191
- name: 'test-report',
192
- description: 'QA test report with execution results',
193
- passed: false,
194
- detail: ''
195
- });
196
- }
197
- // The `security-findings` / `performance-findings` gates were removed here
198
- // security review or performance review — `peaks-qa/SKILL.md` says so, and
199
- // the v2.11.0 D1/D4 trim dropped both from every `qa:verdict-issued` table.
200
- // The evidence they used to demand is now checked on the RD side, at the
201
- // paths the contract actually names (`audit/security-<rid>.md`,
202
- // `audit/perf.md` and `rd/security-review.md` / `rd/perf-baseline.md` as the
203
- // declared legacy tiers behind them).
204
- return gates;
201
+ return qaPhase.qaPhaseGates(qaPhase.typeRequiresQaPhase(requestType), qaPhase.QA_EVIDENCE_GATES.filter((gate) => qaPhase.QA_STATES.some((state) => contractEvidencePaths('qa', state, requestType, gate.relativePath) !== null)));
205
202
  }
206
203
  export const RD_QA_HANDOFF_STATES = new Set(['qa-handoff', 'handed-off', 'implemented']);
207
204
  export const QA_COMPLETE_STATES = new Set(['verdict-issued']);
@@ -292,10 +289,8 @@ export function resolveRdEvidencePaths(gates, rdEvidenceDir, projectRoot, rid, r
292
289
  * at the contract's own paths (`audit/security-<rid>.md`,
293
290
  * `audit/perf-<rid>.md`). */
294
291
  export function resolveQaEvidencePaths(gates, projectRoot, rdEvidenceDir, requestType, rid, violations, nextActions, tracker) {
295
- const QA_EVIDENCE_PROBE = {
296
- 'test-cases': 'qa/test-cases/<rid>.md',
297
- 'test-report': 'qa/test-reports/<rid>.md'
298
- };
292
+ // Derived from the declared gates — a restatement could resolve a renamed path.
293
+ const QA_EVIDENCE_PROBE = Object.fromEntries(qaPhase.QA_EVIDENCE_GATES.map((gate) => [gate.name, gate.relativePath]));
299
294
  let anyEvidenceResolved = tracker.anyEvidenceResolved;
300
295
  let allResolvedPathsCanonical = tracker.allResolvedPathsCanonical;
301
296
  for (const gate of gates.slice(1)) {
@@ -0,0 +1,102 @@
1
+ /**
2
+ * peaks-workflow — the QA phase, derived from the type tables.
3
+ *
4
+ * WHY THIS IS A MODULE OF ITS OWN. A measured budget, not taste: the file-size
5
+ * census records the gated excess by EQUALITY, and `pipeline-verify-gate-support`
6
+ * already carries its share of that sum. A file under its cap adds nothing to it,
7
+ * so the reasoning below — which a contributor has to be able to find — is paid
8
+ * for here, at zero census cost.
9
+ *
10
+ * WHY A DERIVATION AT ALL. Two layers answered one question — *does this request
11
+ * need a QA phase?* — and gave different answers, because neither read the answer
12
+ * off the type tables that define the contract. One named three request types;
13
+ * the other asked unconditionally. A request whose table carries no QA row at all
14
+ * therefore satisfied every prerequisite its own contract lists and was then
15
+ * refused at commit time for a phase that contract never asked for.
16
+ *
17
+ * The tables are the authority. `MINIMAL_TABLE` carries no `qa:` row, which is
18
+ * what "these types have no QA phase" has always meant, and what
19
+ * `request transition --role qa --state verdict-issued` has always enforced
20
+ * against the same table.
21
+ *
22
+ * WHY IT IS ARMED. A derivation nobody checks is a restatement with better
23
+ * manners. A table row can name a QA artifact no gate stands for, and that row
24
+ * would then build no gate and say nothing about it — the same drift, one layer
25
+ * down. So the declared gate list is reconciled against every type's QA rows once
26
+ * per process, and a mismatch THROWS. The cost is deliberate and wider than it
27
+ * looks: the CLI registers every command eagerly, so an unrepresentable row does
28
+ * not merely fail `verify-pipeline` — it fails EVERY `peaks` invocation that
29
+ * reaches this module, the commit leg and `workflow verdict-aggregate` included.
30
+ * That is the fail-closed
31
+ * direction, and naming the row keeps the repair one line.
32
+ */
33
+ import { type RequestType } from '../artifacts/artifact-prerequisites.js';
34
+ import type { PipelineGate } from './pipeline-verify-types.js';
35
+ /**
36
+ * Every state the QA role can be in, taken from the repository's own state model
37
+ * rather than restated here.
38
+ *
39
+ * WHY IT IS NOT JUST `verdict-issued`. The terminal state is the one the phase's
40
+ * evidence is resolved at, so an earlier version keyed both the derivation and the
41
+ * reconciliation to it alone — which left the `qa:running` row a feature's table
42
+ * already carries outside the arming. A row at any other state would have been
43
+ * silently unrepresentable. The arming is total over the state axis instead.
44
+ */
45
+ export declare const QA_STATES: readonly import("../artifacts/request-artifact-state-helpers.js").RequestArtifactState[];
46
+ /**
47
+ * Every QA evidence gate the checker can build, each naming the contract path it
48
+ * stands for. The NAME is the checker's own — `peaks workflow skip` takes gate
49
+ * names and the violation text prints the description — while the PATH is the
50
+ * contract's, and it is the half that makes a gate list derivable instead of
51
+ * restated beside the tables it is supposed to be read from.
52
+ */
53
+ export declare const QA_EVIDENCE_GATES: ReadonlyArray<{
54
+ name: string;
55
+ description: string;
56
+ relativePath: string;
57
+ }>;
58
+ /**
59
+ * Does this type's table carry a QA phase?
60
+ *
61
+ * One derivation, so the gate list and the checker's verdict cannot disagree: the
62
+ * phase exists for a type exactly when its table carries a QA prerequisite —
63
+ * counted across every QA state, so a type whose only QA row sits at a
64
+ * non-terminal state is not read as having no phase at all.
65
+ */
66
+ export declare function typeRequiresQaPhase(requestType: RequestType): boolean;
67
+ /**
68
+ * The request types whose table carries NO QA phase — the set a skip may cover.
69
+ *
70
+ * DERIVED, not listed. The skip allowlist used to spell `['docs', 'config', 'chore']`,
71
+ * and `config` carries a QA phase (its table demands `SECURITY_REVIEW` and
72
+ * `TEST_REPORT`), so a plantable record could bypass a phase the contract requires.
73
+ * Reading the answer off the same derivation the pipeline uses means a table change
74
+ * moves the allowlist with it — in both directions, without anyone remembering.
75
+ */
76
+ export declare const QA_FREE_TYPES: ReadonlyArray<RequestType>;
77
+ /**
78
+ * Fill in the QA request gate for a phase that HAS one.
79
+ *
80
+ * A type whose table carries no QA row has no QA gate to fill, and that is not a
81
+ * special case to handle at the call site: the artifact is still honoured — its
82
+ * state and its location are read either way — so a tree that ran QA for a type
83
+ * whose table does not demand it keeps passing.
84
+ */
85
+ export declare function markQaRequestGate(gates: PipelineGate[], artifactPath: string): void;
86
+ /**
87
+ * The QA phase's gate list for one type: the phase gate when the phase exists,
88
+ * then one gate per piece of evidence the caller resolved from the contract. An
89
+ * empty list IS the answer for a type with no QA phase.
90
+ *
91
+ * The `security-findings` / `performance-findings` gates were removed here
92
+ * security review or performance review — `peaks-qa/SKILL.md` says so, and the
93
+ * v2.11.0 D1/D4 trim dropped both from every `qa:verdict-issued` table. The
94
+ * evidence they used to demand is now checked on the RD side, at the paths the
95
+ * contract actually names (`audit/security-<rid>.md`, `audit/perf.md` and
96
+ * `rd/security-review.md` / `rd/perf-baseline.md` as the declared legacy tiers
97
+ * behind them).
98
+ */
99
+ export declare function qaPhaseGates(required: boolean, evidence: ReadonlyArray<{
100
+ name: string;
101
+ description: string;
102
+ }>): PipelineGate[];
@@ -0,0 +1,176 @@
1
+ /**
2
+ * peaks-workflow — the QA phase, derived from the type tables.
3
+ *
4
+ * WHY THIS IS A MODULE OF ITS OWN. A measured budget, not taste: the file-size
5
+ * census records the gated excess by EQUALITY, and `pipeline-verify-gate-support`
6
+ * already carries its share of that sum. A file under its cap adds nothing to it,
7
+ * so the reasoning below — which a contributor has to be able to find — is paid
8
+ * for here, at zero census cost.
9
+ *
10
+ * WHY A DERIVATION AT ALL. Two layers answered one question — *does this request
11
+ * need a QA phase?* — and gave different answers, because neither read the answer
12
+ * off the type tables that define the contract. One named three request types;
13
+ * the other asked unconditionally. A request whose table carries no QA row at all
14
+ * therefore satisfied every prerequisite its own contract lists and was then
15
+ * refused at commit time for a phase that contract never asked for.
16
+ *
17
+ * The tables are the authority. `MINIMAL_TABLE` carries no `qa:` row, which is
18
+ * what "these types have no QA phase" has always meant, and what
19
+ * `request transition --role qa --state verdict-issued` has always enforced
20
+ * against the same table.
21
+ *
22
+ * WHY IT IS ARMED. A derivation nobody checks is a restatement with better
23
+ * manners. A table row can name a QA artifact no gate stands for, and that row
24
+ * would then build no gate and say nothing about it — the same drift, one layer
25
+ * down. So the declared gate list is reconciled against every type's QA rows once
26
+ * per process, and a mismatch THROWS. The cost is deliberate and wider than it
27
+ * looks: the CLI registers every command eagerly, so an unrepresentable row does
28
+ * not merely fail `verify-pipeline` — it fails EVERY `peaks` invocation that
29
+ * reaches this module, the commit leg and `workflow verdict-aggregate` included.
30
+ * That is the fail-closed
31
+ * direction, and naming the row keeps the repair one line.
32
+ */
33
+ import { getPrerequisitesFor, VALID_REQUEST_TYPES } from '../artifacts/artifact-prerequisites.js';
34
+ import { allowedStatesForRole } from '../artifacts/request-artifact-state-helpers.js';
35
+ /**
36
+ * Every state the QA role can be in, taken from the repository's own state model
37
+ * rather than restated here.
38
+ *
39
+ * WHY IT IS NOT JUST `verdict-issued`. The terminal state is the one the phase's
40
+ * evidence is resolved at, so an earlier version keyed both the derivation and the
41
+ * reconciliation to it alone — which left the `qa:running` row a feature's table
42
+ * already carries outside the arming. A row at any other state would have been
43
+ * silently unrepresentable. The arming is total over the state axis instead.
44
+ */
45
+ export const QA_STATES = allowedStatesForRole('qa');
46
+ /**
47
+ * Every QA evidence gate the checker can build, each naming the contract path it
48
+ * stands for. The NAME is the checker's own — `peaks workflow skip` takes gate
49
+ * names and the violation text prints the description — while the PATH is the
50
+ * contract's, and it is the half that makes a gate list derivable instead of
51
+ * restated beside the tables it is supposed to be read from.
52
+ */
53
+ export const QA_EVIDENCE_GATES = [
54
+ { name: 'test-cases', description: 'QA test cases', relativePath: 'qa/test-cases/<rid>.md' },
55
+ {
56
+ name: 'test-report',
57
+ description: 'QA test report with execution results',
58
+ relativePath: 'qa/test-reports/<rid>.md'
59
+ }
60
+ ];
61
+ /**
62
+ * Every QA prerequisite this type's table carries, at any state the QA role can
63
+ * be in.
64
+ *
65
+ * THE REFUSAL IS NAMED ON PURPOSE. `getPrerequisitesFor` reads a record keyed by
66
+ * type, so a non-member reaches `undefined` and throws a bare `TypeError` — before
67
+ * the derivation existed, a list of names answered such a caller with a gate list
68
+ * instead. A value that no longer works must say what it wanted, which value it
69
+ * got, and what the alternatives are.
70
+ */
71
+ function qaPrerequisitesOfType(requestType) {
72
+ if (!VALID_REQUEST_TYPES.includes(requestType)) {
73
+ throw new Error(`pipeline-verify: "${String(requestType)}" is not a request type — expected one of ${VALID_REQUEST_TYPES.join(', ')}`);
74
+ }
75
+ return QA_STATES.flatMap((state) => getPrerequisitesFor('qa', state, requestType));
76
+ }
77
+ /**
78
+ * Does this type's table carry a QA phase?
79
+ *
80
+ * One derivation, so the gate list and the checker's verdict cannot disagree: the
81
+ * phase exists for a type exactly when its table carries a QA prerequisite —
82
+ * counted across every QA state, so a type whose only QA row sits at a
83
+ * non-terminal state is not read as having no phase at all.
84
+ */
85
+ export function typeRequiresQaPhase(requestType) {
86
+ return qaPrerequisitesOfType(requestType).length > 0;
87
+ }
88
+ /**
89
+ * The request types whose table carries NO QA phase — the set a skip may cover.
90
+ *
91
+ * DERIVED, not listed. The skip allowlist used to spell `['docs', 'config', 'chore']`,
92
+ * and `config` carries a QA phase (its table demands `SECURITY_REVIEW` and
93
+ * `TEST_REPORT`), so a plantable record could bypass a phase the contract requires.
94
+ * Reading the answer off the same derivation the pipeline uses means a table change
95
+ * moves the allowlist with it — in both directions, without anyone remembering.
96
+ */
97
+ export const QA_FREE_TYPES = Object.freeze(VALID_REQUEST_TYPES.filter((requestType) => !typeRequiresQaPhase(requestType)));
98
+ /**
99
+ * Fill in the QA request gate for a phase that HAS one.
100
+ *
101
+ * A type whose table carries no QA row has no QA gate to fill, and that is not a
102
+ * special case to handle at the call site: the artifact is still honoured — its
103
+ * state and its location are read either way — so a tree that ran QA for a type
104
+ * whose table does not demand it keeps passing.
105
+ */
106
+ export function markQaRequestGate(gates, artifactPath) {
107
+ const requestGate = gates[0];
108
+ if (requestGate === undefined)
109
+ return;
110
+ requestGate.passed = true;
111
+ requestGate.detail = `found at ${artifactPath}`;
112
+ }
113
+ /**
114
+ * The QA phase's gate list for one type: the phase gate when the phase exists,
115
+ * then one gate per piece of evidence the caller resolved from the contract. An
116
+ * empty list IS the answer for a type with no QA phase.
117
+ *
118
+ * The `security-findings` / `performance-findings` gates were removed here
119
+ * security review or performance review — `peaks-qa/SKILL.md` says so, and the
120
+ * v2.11.0 D1/D4 trim dropped both from every `qa:verdict-issued` table. The
121
+ * evidence they used to demand is now checked on the RD side, at the paths the
122
+ * contract actually names (`audit/security-<rid>.md`, `audit/perf.md` and
123
+ * `rd/security-review.md` / `rd/perf-baseline.md` as the declared legacy tiers
124
+ * behind them).
125
+ */
126
+ export function qaPhaseGates(required, evidence) {
127
+ if (!required)
128
+ return [];
129
+ const gates = [
130
+ {
131
+ name: 'qa-request-exists',
132
+ description: 'QA request artifact created',
133
+ passed: false,
134
+ detail: ''
135
+ }
136
+ ];
137
+ for (const gate of evidence) {
138
+ gates.push({ name: gate.name, description: gate.description, passed: false, detail: '' });
139
+ }
140
+ return gates;
141
+ }
142
+ /**
143
+ * THE ARM — the reconciliation behind the load-time refusal below.
144
+ *
145
+ * `prerequisitesOfType` is a parameter rather than a direct call so an arm can
146
+ * drive this with a table of its own. That is the only way to show the refusal is
147
+ * reachable: a check that can only ever run against the table it already agrees
148
+ * with cannot be observed to fail.
149
+ *
150
+ * It is handed EVERY QA state's rows — `qaPrerequisitesOfType` above, whose
151
+ * `QA_STATES` is the repository's own model — so a `qa:` row at a state the phase
152
+ * does not end in is armed too. Keying only the terminal state is how the
153
+ * `qa:running` row went unarmed.
154
+ */
155
+ function qaGateReconciliationFailures(types, prerequisitesOfType) {
156
+ const failures = [];
157
+ for (const requestType of types) {
158
+ for (const prerequisite of prerequisitesOfType(requestType)) {
159
+ // The same path set the contract resolver matches on, so a row accepted
160
+ // through a legacy tier is covered by the gate that tier stands behind.
161
+ const contractPaths = [
162
+ prerequisite.relativePath,
163
+ ...(prerequisite.legacyRelativePath !== undefined ? [prerequisite.legacyRelativePath] : []),
164
+ ...(prerequisite.legacyRelativePaths ?? [])
165
+ ];
166
+ if (QA_EVIDENCE_GATES.some((gate) => contractPaths.includes(gate.relativePath)))
167
+ continue;
168
+ failures.push(`the "${requestType}" table carries the QA prerequisite ${prerequisite.relativePath} and no gate in QA_EVIDENCE_GATES stands for it`);
169
+ }
170
+ }
171
+ return failures;
172
+ }
173
+ const QA_GATE_RECONCILIATION_FAILURES = qaGateReconciliationFailures(VALID_REQUEST_TYPES, qaPrerequisitesOfType);
174
+ if (QA_GATE_RECONCILIATION_FAILURES.length > 0) {
175
+ throw new Error(`pipeline-verify: the QA gate list does not follow the type tables — ${QA_GATE_RECONCILIATION_FAILURES.join('; ')}`);
176
+ }