peaks-loop 4.0.47 → 4.0.49

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 (126) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README-en.md +1 -1
  3. package/README.md +1 -1
  4. package/agents/karpathy-reviewer.md +11 -10
  5. package/dist/cli/cli-helpers.d.ts +34 -0
  6. package/dist/cli/cli-helpers.js +57 -0
  7. package/dist/cli/commands/code-job-shape-commands.js +8 -0
  8. package/dist/cli/commands/code-runtime-commands.js +48 -8
  9. package/dist/cli/commands/compact-command.js +110 -0
  10. package/dist/cli/commands/config-commands.js +15 -9
  11. package/dist/cli/commands/dashboard-long-run.js +6 -0
  12. package/dist/cli/commands/dispatch-commands.js +11 -1
  13. package/dist/cli/commands/doctor/invoke-from-code.js +6 -0
  14. package/dist/cli/commands/feedback-commands.d.ts +11 -7
  15. package/dist/cli/commands/feedback-commands.js +49 -17
  16. package/dist/cli/commands/final-review-commands.js +12 -0
  17. package/dist/cli/commands/hooks-commands.js +4 -4
  18. package/dist/cli/commands/job-commands.js +8 -0
  19. package/dist/cli/commands/loop-eval-commands.js +31 -0
  20. package/dist/cli/commands/perf-audit-commands.js +2 -0
  21. package/dist/cli/commands/playwright-commands.js +12 -0
  22. package/dist/cli/commands/prd-commands.js +1 -1
  23. package/dist/cli/commands/qa-commands.js +22 -0
  24. package/dist/cli/commands/request-commands.js +8 -0
  25. package/dist/cli/commands/scan-commands.js +1 -1
  26. package/dist/cli/commands/security-audit-commands.js +2 -0
  27. package/dist/cli/commands/slice-integrate-commands.js +22 -0
  28. package/dist/cli/commands/statusline-commands.js +44 -4
  29. package/dist/cli/commands/sub-agent/detached.d.ts +14 -1
  30. package/dist/cli/commands/sub-agent/detached.js +47 -22
  31. package/dist/cli/commands/sub-agent-shutdown-commands.js +11 -0
  32. package/dist/cli/commands/verdict-aggregate-command.js +95 -13
  33. package/dist/cli/commands/workflow-commands.js +1 -1
  34. package/dist/cli/index.js +5 -45
  35. package/dist/services/artifacts/artifact-prerequisites.d.ts +38 -7
  36. package/dist/services/artifacts/artifact-prerequisites.js +140 -65
  37. package/dist/services/artifacts/request-artifact-service.d.ts +8 -0
  38. package/dist/services/artifacts/request-artifact-service.js +77 -46
  39. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +57 -0
  40. package/dist/services/artifacts/request-artifact-state-helpers.js +91 -10
  41. package/dist/services/audit/enforcers/active-skill-resolver.js +14 -1
  42. package/dist/services/audit-independent/perf-audit-service.d.ts +9 -0
  43. package/dist/services/audit-independent/perf-audit-service.js +27 -5
  44. package/dist/services/audit-independent/security-audit-service.d.ts +12 -2
  45. package/dist/services/audit-independent/security-audit-service.js +28 -6
  46. package/dist/services/code/auto-compact-lifecycle.d.ts +194 -0
  47. package/dist/services/code/auto-compact-lifecycle.js +229 -11
  48. package/dist/services/code/auto-compact-orchestrator.js +118 -7
  49. package/dist/services/code/compact-event-settle.d.ts +134 -0
  50. package/dist/services/code/compact-event-settle.js +240 -0
  51. package/dist/services/compact-history/compact-history-service.d.ts +14 -0
  52. package/dist/services/compact-statusline/compact-statusline-service.js +56 -22
  53. package/dist/services/config/config-restore.d.ts +12 -1
  54. package/dist/services/config/config-restore.js +35 -4
  55. package/dist/services/config/config-rollback.js +6 -1
  56. package/dist/services/context/auto-compact-types.d.ts +20 -2
  57. package/dist/services/context/harness-context-witness.d.ts +310 -0
  58. package/dist/services/context/harness-context-witness.js +606 -0
  59. package/dist/services/evidence/evidence-generator.js +86 -49
  60. package/dist/services/feedback/feedback-promotion-service.d.ts +137 -14
  61. package/dist/services/feedback/feedback-promotion-service.js +341 -20
  62. package/dist/services/feedback/promotion-artifact-evidence.d.ts +69 -0
  63. package/dist/services/feedback/promotion-artifact-evidence.js +332 -0
  64. package/dist/services/final-review/final-review-service.d.ts +9 -0
  65. package/dist/services/final-review/final-review-service.js +36 -12
  66. package/dist/services/ide/ide-registry.d.ts +19 -0
  67. package/dist/services/ide/ide-registry.js +21 -0
  68. package/dist/services/job/job-progress-store.js +18 -3
  69. package/dist/services/job/job-state-store.js +7 -0
  70. package/dist/services/observability/jsonl-store.d.ts +19 -0
  71. package/dist/services/observability/jsonl-store.js +27 -2
  72. package/dist/services/observability/observability-service.d.ts +10 -3
  73. package/dist/services/observability/observability-service.js +16 -3
  74. package/dist/services/polyrepo/polyrepo-dispatcher.js +11 -0
  75. package/dist/services/prd/handoff-auto-regen.js +31 -27
  76. package/dist/services/prd/handoff-frontmatter.d.ts +44 -0
  77. package/dist/services/prd/handoff-frontmatter.js +75 -0
  78. package/dist/services/prd/handoff-service.d.ts +41 -2
  79. package/dist/services/prd/handoff-service.js +124 -8
  80. package/dist/services/prd/handoff-types.d.ts +3 -2
  81. package/dist/services/prd/handoff-types.js +3 -2
  82. package/dist/services/qa/qa-business-review-state.js +23 -0
  83. package/dist/services/sc/sc-service.d.ts +8 -0
  84. package/dist/services/sc/sc-service.js +8 -1
  85. package/dist/services/scan/karpathy-service.js +2 -2
  86. package/dist/services/session/getSessionDir.d.ts +33 -0
  87. package/dist/services/session/getSessionDir.js +60 -0
  88. package/dist/services/session/session-checkpoint-service.js +8 -0
  89. package/dist/services/skill/resume-detector.js +29 -11
  90. package/dist/services/skills/hooks-codegate-superpowers.d.ts +6 -0
  91. package/dist/services/skills/hooks-codegate-superpowers.js +61 -2
  92. package/dist/services/skills/hooks-settings-service.js +14 -4
  93. package/dist/services/skills/session-start-hook-constants.d.ts +45 -0
  94. package/dist/services/skills/session-start-hook-constants.js +45 -0
  95. package/dist/services/skills/skill-statusline-service.d.ts +14 -0
  96. package/dist/services/slice/slice-check-service.js +29 -11
  97. package/dist/services/slice/slice-review-state.js +23 -0
  98. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +47 -10
  99. package/dist/services/workflow/pipeline-verify-gate-support.js +221 -103
  100. package/dist/services/workflow/pipeline-verify-service.d.ts +1 -1
  101. package/dist/services/workflow/pipeline-verify-service.js +47 -33
  102. package/dist/services/workflow/pipeline-verify-types.d.ts +15 -6
  103. package/dist/services/workspace/claude-settings-template.d.ts +56 -8
  104. package/dist/services/workspace/claude-settings-template.js +98 -20
  105. package/dist/services/workspace/workspace-claude-settings-materializer.js +78 -7
  106. package/dist/shared/runtime-root.d.ts +73 -0
  107. package/dist/shared/runtime-root.js +77 -0
  108. package/package.json +6 -6
  109. package/skills/bee/peaks-prd/SKILL.md +7 -5
  110. package/skills/bee/peaks-qa/SKILL.md +5 -5
  111. package/skills/bee/peaks-qa/references/qa-runbook.md +2 -2
  112. package/skills/bee/peaks-qa/references/qa-transition-gates.md +7 -7
  113. package/skills/bee/peaks-rd/SKILL.md +8 -6
  114. package/skills/bee/peaks-rd/references/artifact-per-request.md +2 -2
  115. package/skills/bee/peaks-rd/references/parallel-review-fanout.md +7 -5
  116. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +13 -13
  117. package/skills/bee/peaks-rd/references/rd-runbook.md +9 -5
  118. package/skills/bee/peaks-rd/references/rd-transition-gates.md +9 -7
  119. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +6 -6
  120. package/skills/peaks-code/SKILL.md +1 -1
  121. package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
  122. package/skills/peaks-code/references/local-artifact-workspace.md +1 -1
  123. package/skills/peaks-code/references/resume-detection.md +13 -7
  124. package/skills/peaks-code/references/runbook.md +3 -2
  125. package/skills/peaks-code/references/session-overload-signal-index.md +2 -1
  126. package/skills/peaks-code/references/workflow-gates-and-types.md +8 -6
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The one seam through which a `.peaks/_runtime` path is built.
3
+ *
4
+ * Slice 2026-09-15 (runtime-path-unrepresentable). Three attempts to *detect*
5
+ * a caller-supplied id reaching a runtime join all failed the same way: the
6
+ * shipped text rule caught 4 of 12 fixture shapes where the name-based
7
+ * predicate it replaced caught 8, and the version that reached 10 of 12 gave
8
+ * back the change that reached 12 because it cost seven findings on live code —
9
+ * two of them structural (a guard helper, and readers that take the guarded
10
+ * value as a parameter). Its measured verdict: reassignment between guard and
11
+ * join, and guard-after-join, are **domination failures inside a single
12
+ * function, invisible to any text key**.
13
+ *
14
+ * So the instrument is retired in favour of a property. The id cannot reach a
15
+ * runtime join unguarded because there is no longer a join that accepts an
16
+ * unguarded string: `RuntimeRoot.join` takes `GuardedSegment`, and a
17
+ * `GuardedSegment` can only be produced by `guardRuntimeSegment`, which throws
18
+ * on the shapes the escapes used. A newly written unguarded join is a type
19
+ * error at authoring time — not a removed guard that some later scan notices.
20
+ *
21
+ * The raw root is not obtainable as a string except through `dir()`, which is
22
+ * named so that a join written from it (`join(root.dir(), id)`) reads at review
23
+ * time as the bypass it is. `dir()` exists because callers legitimately
24
+ * enumerate the root itself; it is not a join.
25
+ */
26
+ import { join } from 'node:path';
27
+ import { isUnsafePathInput } from './path-safety.js';
28
+ /**
29
+ * Check a caller-supplied string and brand it for use as a runtime path
30
+ * segment. `label` names the id in the error the way the caller knows it
31
+ * ("session id", "project id"), because the throw site is one function away
32
+ * from the caller that supplied it.
33
+ *
34
+ * Rejects exactly the shapes `isUnsafePathInput` rejects: separators, `..`,
35
+ * absolute and drive-prefixed paths, UNC and URL shapes, and empty segments.
36
+ */
37
+ export function guardRuntimeSegment(value, label) {
38
+ if (isUnsafePathInput(value)) {
39
+ throw new Error(`Invalid ${label}: ${value} (must be a single path segment)`);
40
+ }
41
+ return value;
42
+ }
43
+ /**
44
+ * The `.peaks/_runtime` root of one project, as a capability rather than a
45
+ * string. `#path` is a private field, so the raw root cannot be read off the
46
+ * object and joined by an unguarded `join()`.
47
+ */
48
+ export class RuntimeRoot {
49
+ #path;
50
+ constructor(path) {
51
+ this.#path = path;
52
+ }
53
+ /** The runtime root of `projectRoot`. */
54
+ static at(projectRoot) {
55
+ return new RuntimeRoot(join(projectRoot, '.peaks', '_runtime'));
56
+ }
57
+ /**
58
+ * Join guarded segments onto the root. At least one segment is required: a
59
+ * zero-argument `join()` would hand back the bare root as a `string`, which
60
+ * is the capability this class exists to withhold.
61
+ */
62
+ join(first, ...rest) {
63
+ return join(this.#path, first, ...rest);
64
+ }
65
+ /**
66
+ * The root itself, for READ-only enumeration (`readdir`, `existsSync`) — not
67
+ * for joining. Deliberately a method rather than a property so a bypass is
68
+ * legible at the call site.
69
+ */
70
+ dir() {
71
+ return this.#path;
72
+ }
73
+ }
74
+ /** The runtime root of `projectRoot`. */
75
+ export function runtimeRoot(projectRoot) {
76
+ return RuntimeRoot.at(projectRoot);
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peaks-loop",
3
- "version": "4.0.47",
3
+ "version": "4.0.49",
4
4
  "description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
5
5
  "author": "SquabbyZ",
6
6
  "keywords": [
@@ -102,10 +102,10 @@
102
102
  "picomatch": "4.0.4",
103
103
  "yaml": "^2.9.0",
104
104
  "zod": "^4.4.3",
105
- "peaks-loop-internal-runtime": "0.0.32",
106
- "peaks-loop-shared": "0.0.81",
107
- "peaks-loop-mut": "0.1.45",
108
- "peaks-loop-shared-channel": "0.0.49"
105
+ "peaks-loop-internal-runtime": "0.0.34",
106
+ "peaks-loop-mut": "0.1.47",
107
+ "peaks-loop-shared": "0.0.83",
108
+ "peaks-loop-shared-channel": "0.0.51"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@changesets/cli": "2.31.1",
@@ -141,7 +141,7 @@
141
141
  "test:dev": "vitest run tests/unit",
142
142
  "test:dev:cli": "vitest run tests/unit",
143
143
  "test:unit": "vitest run tests/unit",
144
- "test:integration": "vitest run tests/integration",
144
+ "test:integration": "vitest run --config vitest.config.integration.ts tests/integration",
145
145
  "test:capability-guard": "vitest run --config vitest.config.integration.ts tests/integration/capability-guard",
146
146
  "test:cli": "vitest run tests/unit",
147
147
  "test:workflow": "vitest run tests/unit",
@@ -122,7 +122,7 @@ Then display: `Peaks-Loop Skill: peaks-prd | Peaks-Loop Gate: startup | Next: <o
122
122
 
123
123
  ## Mandatory per-request artifact
124
124
 
125
- Every PRD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/_runtime/<session-id>/prd/requests/<request-id>.md`. The artifact is the canonical trace; the chat transcript is not. Handoff to RD/UI/QA is blocked while the artifact is missing or in `draft` state. After user confirmation, the **immutable handoff** is written separately at `.peaks/_runtime/<sid>/prd/handoff.md` (Step 5.5 below) — sha256-locked, schemaVersion: 2 — and is the source of truth for RD, QA, and the 4 audit sub-agents (code-reviewer / security-reviewer / karpathy-reviewer / qa-test-cases-writer).
125
+ Every PRD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/_runtime/<session-id>/prd/requests/<request-id>.md`. The artifact is the canonical trace; the chat transcript is not. Handoff to RD/UI/QA is blocked while the artifact is missing or in `draft` state. After user confirmation, the **immutable handoff** is written separately at `.peaks/_runtime/<sid>/prd/handoff-<rid>.md` (Step 5.5 below) — sha256-locked, schemaVersion: 2 — and is the source of truth for RD, QA, and the 4 audit sub-agents (code-reviewer / security-reviewer / karpathy-reviewer / qa-test-cases-writer).
126
126
 
127
127
  Use `<request-id>` of the form `YYYY-MM-DD-<kebab-slug>` (or whatever id the user assigned) so PRD/UI/RD/QA/SC can cross-link the same request.
128
128
 
@@ -198,15 +198,17 @@ peaks request show <request-id> --role prd --project <repo> --json
198
198
 
199
199
  # 5.5 — write the immutable handoff (sha256-locked; BLOCKING before RD/QA handoff)
200
200
  # Reads the PRD request artifact body, computes sha256, writes a v2.11.0 handoff
201
- # at .peaks/_runtime/<sid>/prd/handoff.md that downstream RD + QA + 4 audit
202
- # sub-agents consume as the authoritative source of truth. Dry-run by default
203
- # (omit --apply) so the operator can review before commit.
201
+ # at .peaks/_runtime/<sid>/prd/handoff-<rid>.md that downstream RD + QA + 4 audit
202
+ # sub-agents consume as the authoritative source of truth. The rid is part of
203
+ # the filename: one capsule per SLICE, so a second slice in the same session
204
+ # cannot overwrite the first's. Dry-run by default (omit --apply) so the
205
+ # operator can review before commit.
204
206
  peaks prd handoff init \
205
207
  --rid <request-id> --sid <session-id> --change-id <change-id> \
206
208
  --body "@.peaks/_runtime/<session-id>/prd/requests/<request-id>.md" \
207
209
  --goals <G-ids> --ac <AC-ids> --preserve <P-ids> \
208
210
  [--project <repo>] [--apply]
209
- peaks prd handoff verify --path .peaks/_runtime/<session-id>/prd/handoff.md
211
+ peaks prd handoff verify --path .peaks/_runtime/<session-id>/prd/handoff-<request-id>.md
210
212
 
211
213
  peaks skill presence:clear --project <repo> # handoff complete, remove presence indicator
212
214
  ```
@@ -104,9 +104,9 @@ Project-level security + perf plans live at `.peaks/_runtime/<sessionId>/qa/secu
104
104
 
105
105
  ## QA fan-out (业务 only — v2.11.0 D1)
106
106
 
107
- When peaks-qa is the **main loop** (i.e. it is the active skill and is about to run its own sub-agent dispatch, rather than being a sub-agent itself), it fans out only the **business verification** sub-agent: `qa-business`. Security and performance review are **NOT** peaks-qa's responsibility in v2.11.0 — they are owned by peaks-rd's 4-way audit fan-out (code-review + security-review + perf-baseline + karpathy-review) and the rd-side evidence files (`rd/security-review.md`, `rd/perf-baseline.md`). peaks-qa reads those files by reference; it does NOT re-do them.
107
+ When peaks-qa is the **main loop** (i.e. it is the active skill and is about to run its own sub-agent dispatch, rather than being a sub-agent itself), it fans out only the **business verification** sub-agent: `qa-business`. Security and performance review are **NOT** peaks-qa's responsibility in v2.11.0 — they are owned by peaks-rd's 4-way audit fan-out (code-review + security-review + perf-baseline + karpathy-review) and the rd-side evidence files (`audit/security-<rid>.md`, `audit/perf-<rid>.md`). peaks-qa reads those files by reference; it does NOT re-do them.
108
108
 
109
- > **v2.15.0+ 校准:** `qa-business` 只跑业务/产品视角的 6 项验收清单(业务流程 / 需求覆盖 / 边界 case / UI 装配 / 异常态语调 / 能上线吗),**不跑技术指标**(覆盖率 / 性能 / 安全)。技术指标由 RD 4-way fan-out 自决,QA 只读 `rd/security-review.md` + `rd/perf-baseline.md`。详见 `.peaks/memory/peaks-loop-slice-review-and-qa-perspective.md`。
109
+ > **v2.15.0+ 校准:** `qa-business` 只跑业务/产品视角的 6 项验收清单(业务流程 / 需求覆盖 / 边界 case / UI 装配 / 异常态语调 / 能上线吗),**不跑技术指标**(覆盖率 / 性能 / 安全)。技术指标由 RD 4-way fan-out 自决,QA 只读 `audit/security-<rid>.md` + `audit/perf-<rid>.md`。详见 `.peaks/memory/peaks-loop-slice-review-and-qa-perspective.md`。
110
110
 
111
111
  If the PRD or project warrants it, subdivide `qa-business` further into roles like `qa-business-api` / `qa-business-frontend` / `qa-business-regression`. Subdivision must stay ≤ 2 levels deep (RL-4).
112
112
 
@@ -128,7 +128,7 @@ When this skill is running in the main Claude session (not as a sub-agent), befo
128
128
  - verify API behavior and frontend behavior when either surface exists;
129
129
  - generate a validation report with commands, browser evidence, findings, and residual risks.
130
130
 
131
- **Out of scope (v2.11.0 D1/D4):** peaks-qa does **not** own security review or performance review. Those are owned by peaks-rd's audit fan-out (sub-agents `security-review` and `perf-baseline`) and the rd-side evidence files. peaks-qa reads `rd/security-review.md` and `rd/perf-baseline.md` by reference; it does NOT produce `qa/security-findings.md` or `qa/performance-findings.md` of its own.
131
+ **Out of scope (v2.11.0 D1/D4):** peaks-qa does **not** own security review or performance review. Those are owned by peaks-rd's audit fan-out (sub-agents `security-review` and `perf-baseline`) and the rd-side evidence files. peaks-qa reads `audit/security-<rid>.md` and `audit/perf-<rid>.md` by reference; it does NOT produce `qa/security-findings.md` or `qa/performance-findings.md` of its own.
132
132
 
133
133
  ## Mandatory per-request artifact
134
134
 
@@ -148,7 +148,7 @@ See `references/qa-runbook.md` for the full 10-step runbook (steps #0–#9) with
148
148
 
149
149
  You cannot declare a phase complete from memory. CLI enforcement: the gates below are ALSO enforced by `peaks request transition`, which fails with `code: PREREQUISITES_MISSING` if any are absent. Per-type required files: feature / refactor → test-cases + test-reports + security-findings + performance-findings; bugfix → test-cases + test-reports + security-findings (perf optional); config → security-findings only; docs / chore → none.
150
150
 
151
- Gate index: A (test-cases), A2 (tests executed), A3 (security reference — v2.11.0: read rd/security-review.md), A4 (performance reference — v2.11.0: read rd/perf-baseline.md), B (test-reports with results), C (all 3 QA files present before verdict: test-cases + test-reports + requests — security/perf evidence live under rd/), D (browser screenshots), E (acceptance coverage scan), F (QA artifact lint).
151
+ Gate index: A (test-cases), A2 (tests executed), A3 (security reference — v2.12.0+: read audit/security-<rid>.md), A4 (performance reference — v2.12.0+: read audit/perf-<rid>.md), B (test-reports with results), C (all 3 QA files present before verdict: test-cases + test-reports + requests — security/perf evidence live under audit/), D (browser screenshots), E (acceptance coverage scan), F (QA artifact lint).
152
152
 
153
153
  → see `references/qa-transition-gates.md` for the full per-gate contract + `ls` / `grep` shell snippets.
154
154
 
@@ -194,7 +194,7 @@ Every QA invocation must produce a test-report artifact at `.peaks/_runtime/<ses
194
194
 
195
195
  ## Mandatory validation gates
196
196
 
197
- QA cannot pass a change until the report contains evidence for every applicable gate. The 9 gates (0 test-case generation, 1 test-report, 2 unit tests, 3 API validation, 4 frontend browser validation, 5 browser-error feedback loop, 8 library version regressions, 9 validation report, 10 acceptance coverage) are mapped to Peaks-Loop Gates A/A2/B/C/D/E/F. **v2.11.0 D1/D4 trim:** Gates A3 (security) and A4 (performance) are no longer peaks-qa's responsibility — security review and performance baseline live under peaks-rd's audit fan-out (rd/security-review.md + rd/perf-baseline.md) and are cited by reference from the test report.
197
+ QA cannot pass a change until the report contains evidence for every applicable gate. The 9 gates (0 test-case generation, 1 test-report, 2 unit tests, 3 API validation, 4 frontend browser validation, 5 browser-error feedback loop, 8 library version regressions, 9 validation report, 10 acceptance coverage) are mapped to Peaks-Loop Gates A/A2/B/C/D/E/F. **v2.11.0 D1/D4 trim:** Gates A3 (security) and A4 (performance) are no longer peaks-qa's responsibility — security review and performance baseline live under peaks-rd's audit fan-out (audit/security-<rid>.md + audit/perf-<rid>.md) and are cited by reference from the test report.
198
198
 
199
199
  If Playwright MCP is unavailable, the LLM checks its own tool list for the Playwright MCP server entry; if absent, the LLM tells the user the install command (`claude mcp add playwright -- npx @playwright/mcp@latest` for Claude Code) and marks the gate blocked with the missing capability. Screenshots, logs, manual steps, or other tools must not substitute for the mandatory frontend browser gate. Do not silently downgrade frontend validation to API-only testing.
200
200
 
@@ -36,8 +36,8 @@ peaks openspec validate <change-id> --project <repo> --prefer-external --json
36
36
  # 5. EXECUTE tests against the actual implementation — Peaks-Loop Gate A2
37
37
  # Run the project test command. Record output. Tests on paper are worthless.
38
38
  # NOTE (v2.11.0 D1/D4): Security review + performance check are NOT run by peaks-qa.
39
- # They are owned by peaks-rd's audit fan-out and surface as rd/security-review.md and
40
- # rd/perf-baseline.md under .peaks/_runtime/<sessionId>/rd/. Read them by reference;
39
+ # They are owned by the independent audit skills and surface as audit/security-<rid>.md
40
+ # and audit/perf-<rid>.md under .peaks/_runtime/<sessionId>/audit/. Read them by reference;
41
41
  # do NOT re-do them or create qa/security-findings.md / qa/performance-findings.md.
42
42
 
43
43
  # 6. write test-report — MANDATORY, write to .peaks/_runtime/<sessionId>/qa/test-reports/<request-id>.md
@@ -11,7 +11,7 @@
11
11
  | config | (none) | `qa/test-reports/<rid>.md` |
12
12
  | docs / chore | (none) | (none) |
13
13
 
14
- Security and performance evidence surface under `rd/security-review.md` and `rd/perf-baseline.md` (peaks-rd's audit fan-out) and are referenced by reference from the QA test report body. The pre-v2.11.0 `qa/security-findings.md` / `qa/performance-findings.md` files are no longer required; existing ones are kept for auditability but ignored by the gate.
14
+ Security and performance evidence surface under `audit/security-<rid>.md` and `audit/perf-<rid>.md` (the independent `peaks-security-audit` / `peaks-perf-audit` skills, v2.12.0+; slice `2026-09-14-audit-artifact-rid-scoping` put the rid in the filename so two slices in one session cannot overwrite each other's evidence) and are referenced by reference from the QA test report body. The older `rd/security-review.md` / `rd/perf-baseline.md` and the ridless `audit/security.md` / `audit/perf.md` remain accepted back-compat tiers. The pre-v2.11.0 `qa/security-findings.md` / `qa/performance-findings.md` files are no longer required; existing ones are kept for auditability but ignored by the gate.
15
15
 
16
16
  **Peaks-Loop Gate A — After test-case generation:**
17
17
  ```bash
@@ -29,18 +29,18 @@ npx vitest run --changed --reporter=verbose 2>&1 | tail -30
29
29
 
30
30
  **Peaks-Loop Gate A3 — Security review referenced (v2.11.0 D1/D4: read-only reference, NOT a separate QA file):**
31
31
  ```bash
32
- # peaks-qa does NOT own a qa/security-findings.md. peaks-rd's audit fan-out
33
- # produces rd/security-review.md; QA references it by path in the test report body.
34
- grep -E "rd/security-review\\.md|security-review" .peaks/_runtime/<sessionId>/qa/test-reports/<rid>.md 2>&1
32
+ # peaks-qa does NOT own a qa/security-findings.md. The security audit produces
33
+ # audit/security-<rid>.md; QA references it by path in the test report body.
34
+ grep -E "audit/security|rd/security-review|security-review" .peaks/_runtime/<sessionId>/qa/test-reports/<rid>.md 2>&1
35
35
  # Expected: at least one reference to the rd-side security review.
36
36
  # Empty → BLOCKED: the test report must cite where security evidence lives.
37
37
  ```
38
38
 
39
39
  **Peaks-Loop Gate A4 — Performance baseline referenced (v2.11.0 D1/D4: read-only reference, NOT a separate QA file):**
40
40
  ```bash
41
- # peaks-qa does NOT own a qa/performance-findings.md. peaks-rd's audit fan-out
42
- # produces rd/perf-baseline.md; QA references it by path in the test report body.
43
- grep -E "rd/perf-baseline\\.md|perf-baseline" .peaks/_runtime/<sessionId>/qa/test-reports/<rid>.md 2>&1
41
+ # peaks-qa does NOT own a qa/performance-findings.md. The perf audit produces
42
+ # audit/perf-<rid>.md; QA references it by path in the test report body.
43
+ grep -E "audit/perf|rd/perf-baseline|perf-baseline" .peaks/_runtime/<sessionId>/qa/test-reports/<rid>.md 2>&1
44
44
  # Expected: at least one reference to the rd-side perf baseline.
45
45
  # Empty → BLOCKED: the test report must cite where perf evidence lives.
46
46
  ```
@@ -172,16 +172,18 @@ If any gate fails, return to development for fixes or hand off as blocked. Do no
172
172
 
173
173
  **v2.12.0 collapse (Group A — Tier 1+2+3):** the previous 5-way fan-out (slice 004 4-way + slice 5/6 `karpathy-reviewer` addition) totalled **5 sub-agents**. The `security-reviewer` and `perf-baseline-reviewer` slots moved out of the RD 3-way fan-out into two new standalone audit skills:
174
174
 
175
- - `peaks-security-audit` — CLI: `peaks security-audit run`. Writes `audit/security.md` (under `.peaks/_runtime/<sessionId>/audit/security.md`). Required RD-side prereq `AUDIT_SECURITY`.
176
- - `peaks-perf-audit` — CLI: `peaks perf-audit run`. Writes `audit/perf.md` (under `.peaks/_runtime/<sessionId>/audit/perf.md`). Required RD-side prereq `AUDIT_PERF`.
175
+ - `peaks-security-audit` — CLI: `peaks security-audit run`. Writes `audit/security-<rid>.md` (under `.peaks/_runtime/<sessionId>/audit/security-<rid>.md`). Required RD-side prereq `AUDIT_SECURITY`.
176
+ - `peaks-perf-audit` — CLI: `peaks perf-audit run`. Writes `audit/perf-<rid>.md` (under `.peaks/_runtime/<sessionId>/audit/perf-<rid>.md`). Required RD-side prereq `AUDIT_PERF`.
177
+
178
+ **The rid is part of the filename** (slice `2026-09-14-audit-artifact-rid-scoping`). Two slices run in the same session share `.peaks/_runtime/<sessionId>/audit/`, so a ridless filename makes the second slice's write silently destroy the first slice's audit — which is what happened to `audit/perf.md` on 2026-09-13, irrecoverably. The bare `audit/security.md` / `audit/perf.md` (and the older `rd/security-review.md` / `rd/perf-baseline.md`) are still **read** as back-compat fallbacks, but never write there.
177
179
 
178
180
  Both audit skills consume the immutable peaks-prd handoff (`prd/handoff.md`) and the project-scoped audit templates under `.peaks/project-scan/{security-template, perf-template, audit-output-schema}.md`. The handoff presence is enforced by the `AUDIT_REQUIRES_HANDOFF` prereq. The 1-minor-release back-compat window (v2.12.0) keeps the old `rd/security-review.md` and `rd/perf-baseline.md` paths readable via `mustContainAny` — see `references/rd-fanout-contracts.md` §"Deprecated reviewer back-compat".
179
181
 
180
182
  **Current 3-way fan-out** (always runs for feature / refactor / bugfix; no fan-out for config / docs / chore):
181
183
 
182
- 1. `code-reviewer` — writes `rd/code-review.md` (Gate B3).
184
+ 1. `code-reviewer` — writes `rd/code-review-<rid>.md` (Gate B3). **Not** `rd/code-review.md`: the ridless name is shared by every slice in the session, so slice 2 would overwrite slice 1's review (it did on 2026-09-13). The ridless path is still read as a back-compat fallback.
183
185
  2. `qa-test-cases-writer` — writes `qa/test-cases/<rid>.md` (Gate C2).
184
- 3. `karpathy-reviewer` — writes `rd/karpathy-review.md` (the **hard Karpathy-Gate**, KARPATHY_REVIEW prereq).
186
+ 3. `karpathy-reviewer` — writes `rd/karpathy-review-<rid>.md` (the **hard Karpathy-Gate**, KARPATHY_REVIEW prereq). Same rule: the ridless `rd/karpathy-review.md` is read but never written.
185
187
 
186
188
  Full dispatch contract (when-to-fan-out rules, dispatch template, prereq gates) lives in **`references/parallel-review-fanout.md`**. Read that file before issuing any 3-way fan-out.
187
189
 
@@ -269,11 +271,11 @@ Do not bypass PRD/QA artifacts. Do not install hooks, agents, MCP, or settings.
269
271
 
270
272
  Do not bypass the parallel review fan-out when the slice has a code-review / qa-test-cases / karpathy-review surface — see `## Parallel review fan-out` above. The three review activities are fan-out, not sequential; sequential re-implementation of the same logic by the main RD loop defeats the wall-clock benefit and is treated as a red-line violation.
271
273
 
272
- **Security / perf audit boundary (v2.12.0):** security and perf audit run as standalone audit skills (`peaks-security-audit`, `peaks-perf-audit`) whose outputs land at `audit/security.md` / `audit/perf.md`. RD does **not** dispatch `security-reviewer` or `perf-baseline-reviewer` sub-agents. See `references/rd-fanout-contracts.md` §"Deprecated reviewer back-compat".
274
+ **Security / perf audit boundary (v2.12.0):** security and perf audit run as standalone audit skills (`peaks-security-audit`, `peaks-perf-audit`) whose outputs land at `audit/security-<rid>.md` / `audit/perf-<rid>.md`. RD does **not** dispatch `security-reviewer` or `perf-baseline-reviewer` sub-agents. See `references/rd-fanout-contracts.md` §"Deprecated reviewer back-compat".
273
275
 
274
276
  ## Karpathy cost self-review (slice 2026-07-30-karpathy-cost-self-review)
275
277
 
276
- The `karpathy-reviewer` sub-agent now reports its own runtime cost in the JSON envelope at `rd/karpathy-review.md` (fields `evaluationCost` + `costRatio`; see `agents/karpathy-reviewer.md` §4). The **orchestrator-side** command `peaks job karpathy-cost-check --review-file <path>` reads that envelope and decides whether to downgrade a `'block'` gateAction to `'warn'` when `costRatio > 10`. **24h-mode is the override** — the check is entirely skipped when `peaks session 24h-mode state` reports `24H_ACTIVE`.
278
+ The `karpathy-reviewer` sub-agent now reports its own runtime cost in the JSON envelope at `rd/karpathy-review-<rid>.md` (fields `evaluationCost` + `costRatio`; see `agents/karpathy-reviewer.md` §4). The **orchestrator-side** command `peaks job karpathy-cost-check --review-file <path>` reads that envelope and decides whether to downgrade a `'block'` gateAction to `'warn'` when `costRatio > 10`. **24h-mode is the override** — the check is entirely skipped when `peaks session 24h-mode state` reports `24H_ACTIVE`.
277
279
 
278
280
  The main RD loop MUST call `peaks job karpathy-cost-check` after every `peaks request transition --state qa-handoff` and before the next-slice work begins. If the decision kind is `downgraded`, the LLM MUST honor the downgraded `warn` and proceed to the next slice; the `'block'` was an artifact of the reviewer's own cost, not the slice's quality. If the decision kind is `reported` (costRatio > 50, gate not `'block'`), the LLM MAY continue; the sediment will be appended by `peaks memory extract` at handoff time. The full design lives in `.peaks/memory/2026-07-30-karpathy-evaluation-cost-self-review-design.md` (sediment locked 2026-07-30).
279
281
 
@@ -99,8 +99,8 @@ For each slice in this request:
99
99
  |---|---|---|---|
100
100
  | `.peaks/_runtime/<sessionId>/prd/handoff.md` | per-slice — immutable peaks-prd source of truth (v2.11.0+) | RD, QA, all sub-agents | Goals, non-goals, acceptance criteria, architecture, slice graph, mock strategy, cross-cutting decisions. sha256-hashed in frontmatter; sub-agents verify the hash before reading. |
101
101
  | `.peaks/_runtime/<sessionId>/rd/requests/<rid>.md` | per-slice — one request, one planning artifact | QA, SC, the lint gate | Red-line scope, in-scope / out-of-scope, unit-test requirements, **Implementation evidence** (file list, `pnpm test` output, git diff excerpts), MCP usage, handoff, status. **This is the file the lint gate checks for placeholders.** |
102
- | `.peaks/_runtime/<sessionId>/rd/code-review.md` | per-session — the engineering review | QA, the human reviewer | Code review findings + fixes. |
103
- | `.peaks/_runtime/<sessionId>/rd/security-review.md` | per-session — the security review | QA | Security review findings + fixes. |
102
+ | `.peaks/_runtime/<sessionId>/rd/code-review-<rid>.md` | per-slice — the engineering review | QA, the human reviewer | Code review findings + fixes. |
103
+ | `.peaks/_runtime/<sessionId>/audit/security-<rid>.md` | per-slice — the independent security audit | QA | Security audit findings + verdict. |
104
104
 
105
105
  > **v2.11.0 change (Group A):** `rd/tech-doc.md` is removed. The per-slice source of truth moves to the immutable peaks-prd handoff (`prd/handoff.md`); the per-slice planning record is `rd/requests/<rid>.md`. The "per-session" content category is no longer RD's responsibility — it lives upstream in the PRD handoff.
106
106
 
@@ -4,8 +4,10 @@
4
4
 
5
5
  **v2.12.0 collapse (Group A — Tier 1+2+3):** the previous 4-way fan-out (slice 004) plus the appended `karpathy-reviewer` (slice 5/6) totalled **5 sub-agents**. The `security-reviewer` and `perf-baseline-reviewer` slots moved out of the RD fan-out into two new standalone audit skills:
6
6
 
7
- - `peaks-security-audit` — CLI: `peaks security-audit run`. Writes `.peaks/_runtime/<sessionId>/audit/security.md`. Required RD-side prereq `AUDIT_SECURITY`.
8
- - `peaks-perf-audit` — CLI: `peaks perf-audit run`. Writes `.peaks/_runtime/<sessionId>/audit/perf.md`. Required RD-side prereq `AUDIT_PERF`.
7
+ - `peaks-security-audit` — CLI: `peaks security-audit run`. Writes `.peaks/_runtime/<sessionId>/audit/security-<rid>.md`. Required RD-side prereq `AUDIT_SECURITY`.
8
+ - `peaks-perf-audit` — CLI: `peaks perf-audit run`. Writes `.peaks/_runtime/<sessionId>/audit/perf-<rid>.md`. Required RD-side prereq `AUDIT_PERF`.
9
+
10
+ The rid is part of the filename (slice `2026-09-14-audit-artifact-rid-scoping`): every slice in a session shares `.peaks/_runtime/<sessionId>/audit/`, so a ridless name means the second slice's audit silently replaces the first slice's. The ridless locations are still read as fallbacks.
9
11
 
10
12
  Both audit skills consume the immutable peaks-prd handoff (`prd/handoff.md`) and the project-scoped audit templates under `.peaks/project-scan/{security-template, perf-template, audit-output-schema}.md`. The handoff presence is enforced by the `AUDIT_REQUIRES_HANDOFF` prereq. The 1-minor-release back-compat window (`v2.12.0`) keeps the old `rd/{security-review,perf-baseline}.md` paths readable via `mustContainAny` — see `tests/unit/rd/deprecated-reviewer-back-compat.test.ts` (8 cases) and `tests/unit/artifact-prerequisites-typed.test.ts`.
11
13
 
@@ -44,14 +46,14 @@ Note: sub-agent 1 (code-reviewer) and sub-agent 3 (karpathy-reviewer) write to `
44
46
  - Read the git diff for this slice (`git diff main...HEAD` or equivalent).
45
47
  - Read `.peaks/_runtime/<sessionId>/prd/handoff.md` for slice intent (v2.11.0: the immutable peaks-prd handoff replaces `rd/tech-doc.md`). Verify the handoff hash matches the dispatched value before proceeding.
46
48
  - Inspect for: correctness, type safety, error handling, mutation patterns, file-size, naming, dead code, regressions, contract drift.
47
- - Output: `.peaks/_runtime/<sessionId>/rd/code-review.md` with sections: Summary, Findings, Required Fixes, Recommended, Verdict.
49
+ - Output: `.peaks/_runtime/<sessionId>/rd/code-review-<rid>.md` with sections: Summary, Findings, Required Fixes, Recommended, Verdict. (Rid in the filename — a ridless `rd/code-review.md` is shared by every slice in the session and gets overwritten by the next one; it is still read as a fallback.)
48
50
  - Required for Gate B3.
49
51
  - **v2.11.0 Tier 7 (Group D) + 2026-09-09-ecc-dynamic:** the code-reviewer dispatch goes through the **ECC bridge** (`src/services/code-review/ecc-bridge.ts`). Fallback order is **native plugin → cache-backed generic agent → inline**:
50
52
  1. **Native plugin** (`detectEcc` state `ready`): invoke the Agent tool with `subagent_type: "ecc:code-reviewer"` (plugin `ecc` + agent `code-reviewer`; see `DEFAULT_NATIVE_ECC_AGENT_ID`); it returns the structured envelope `{ passed, violations[], gateAction }`.
51
53
  2. **Cache-backed generic agent** (`detectEcc` state `ready-via-cache` — plugin or its review agent absent, but a materialized ECC agent exists under `~/.peaks/agents/ecc/`): resolve the agent's REAL name first — `resolveMaterializedAgentName(['code-reviewer', 'code-review'])` from `peaks-loop-mut` (upstream ships `code-reviewer.md`; a hardcoded `code-review.md` never resolves). Read `~/.peaks/agents/ecc/<resolved>.md`, pass the name through as `detectEcc({ ..., cacheAgentName: resolved })`, build the prompt with `buildCacheBackedEccPrompt({ rid, instructions, diff })` (agent body + diff + `ECC_OUTPUT_CONTRACT`), dispatch a **generic** sub-agent, and validate its reply with `isEccEnvelope`. No ECC plugin required. If the cache is empty, run `peaks ecc install` first (dynamic acquisition); if that fails offline, degrade to inline.
52
54
  3. **Inline** (`detectEcc` states `plugin-missing` / `agent-missing` / `dispatch-failed` / `envelope-malformed`): fall back to inline review — TXT note `code-review-ecc-degraded-to-inline`.
53
55
 
54
- In all dispatchable cases the envelope is rendered by the SAME bridge adapter (`adaptEccEnvelopeToRdCodeReview`) into the canonical `rd/code-review.md` markdown shape that Gate B3 reads (`mustContain: ['## Findings', 'CRITICAL']`). The materialized copy lives under `~/.peaks/agents/ecc/` — peaks-loop NEVER writes into `~/.claude/`.
56
+ In all dispatchable cases the envelope is rendered by the SAME bridge adapter (`adaptEccEnvelopeToRdCodeReview`) into the canonical `rd/code-review-<rid>.md` markdown shape that Gate B3 reads (`mustContain: ['## Findings', 'CRITICAL']`). The materialized copy lives under `~/.peaks/agents/ecc/` — peaks-loop NEVER writes into `~/.claude/`.
55
57
 
56
58
  **Sub-agent 2 — qa-test-cases-writer (always runs for feature / refactor / bugfix):**
57
59
  - Read the git diff and the PRD acceptance criteria.
@@ -63,7 +65,7 @@ Note: sub-agent 1 (code-reviewer) and sub-agent 3 (karpathy-reviewer) write to `
63
65
  **Sub-agent 3 — karpathy-reviewer (always runs for feature / refactor / bugfix — the hard gate):**
64
66
  - Inspect the diff + handoff against the 4 Karpathy-guidelines.
65
67
  - Read `.peaks/_runtime/<sessionId>/prd/handoff.md` (v2.11.0: architecture summary — the immutable peaks-prd handoff replaces `rd/tech-doc.md`).
66
- - Output: `.peaks/_runtime/<sessionId>/rd/karpathy-review.md` containing a `## Karpathy-Gate` header and the 4 guideline section markers (Think Before Coding / Simplicity First / Surgical Changes / Goal-Driven Execution).
68
+ - Output: `.peaks/_runtime/<sessionId>/rd/karpathy-review-<rid>.md` containing a `## Karpathy-Gate` header and the 4 guideline section markers (Think Before Coding / Simplicity First / Surgical Changes / Goal-Driven Execution). (Rid in the filename, same reason as the code review; the ridless `rd/karpathy-review.md` is still read as a fallback.)
67
69
  - Required for the `KARPATHY_REVIEW` prereq. The transition CLI gate reads those markers and refuses `rd:qa-handoff` when the file is missing or the markers are absent.
68
70
  - See `references/rd-fanout-contracts.md` §"karpathy-reviewer contract" for the JSON envelope shape + file format.
69
71
 
@@ -11,9 +11,9 @@ end of implementation, RD fires 3 sub-agents in parallel via
11
11
  > skills consumed at pre-RD / pre-QA time:
12
12
  >
13
13
  > - `peaks-security-audit` — CLI: `peaks security-audit run`. Output:
14
- > `audit/security.md`. Required RD-side prereq: `AUDIT_SECURITY`.
14
+ > `audit/security-<rid>.md`. Required RD-side prereq: `AUDIT_SECURITY`.
15
15
  > - `peaks-perf-audit` — CLI: `peaks perf-audit run`. Output:
16
- > `audit/perf.md`. Required RD-side prereq: `AUDIT_PERF`.
16
+ > `audit/perf-<rid>.md`. Required RD-side prereq: `AUDIT_PERF`.
17
17
  >
18
18
  > Both audit skills consume the immutable peaks-prd handoff
19
19
  > (`prd/handoff.md`) and the project-scoped audit templates under
@@ -29,7 +29,7 @@ end of implementation, RD fires 3 sub-agents in parallel via
29
29
  > **Karpathy pointer (Slice 1/6):** Each of the 3 sub-agents below operates under the 4 Karpathy guidelines. The canonical reference is `andrej-karpathy-skills:karpathy-guidelines` (full text) and `peaks-rd/SKILL.md` §"Karpathy enforcement". The dispatch primitive also injects the verbatim context block from `rd-sub-agent-dispatch.md` §"Karpathy-guidelines context" into every sub-agent prompt. Sub-agents MUST NOT silently drop the block.
30
30
 
31
31
  - **Sub-agent 1 — code-reviewer** runs `code-review` against the diff and
32
- writes `rd/code-review.md`. **v2.11.0 Tier 7 (Group D) + 2026-09-09-ecc-dynamic:**
32
+ writes `rd/code-review-<rid>.md`. **v2.11.0 Tier 7 (Group D) + 2026-09-09-ecc-dynamic:**
33
33
  the dispatch goes through the **ECC bridge** (`src/services/code-review/ecc-bridge.ts`)
34
34
  with fallback order **native plugin → cache-backed generic agent → inline**:
35
35
  - `detectEcc` state `ready` → `Agent({ subagent_type: 'ecc:code-reviewer', ... })`
@@ -58,22 +58,22 @@ end of implementation, RD fires 3 sub-agents in parallel via
58
58
  writer's only write target is `qa/test-cases/<rid>.md`.
59
59
  - **Sub-agent 3 — karpathy-reviewer** (Slice 5/6 — hard gate) inspects
60
60
  the diff + handoff against the 4 Karpathy-guidelines and writes
61
- `rd/karpathy-review.md` (v2.11.0: the immutable peaks-prd handoff
61
+ `rd/karpathy-review-<rid>.md` (v2.11.0: the immutable peaks-prd handoff
62
62
  at `prd/handoff.md` replaces `rd/tech-doc.md`). The file MUST
63
63
  contain a `## Karpathy-Gate` header and at least one of the 4
64
64
  guideline section markers; the transition CLI gate reads those
65
65
  markers and refuses `rd:qa-handoff` when the file is missing or
66
66
  the markers are absent. The sub-agent returns a JSON envelope
67
67
  `{ passed, violations, gateAction }` (see contract below). Do NOT
68
- modify code; the writer's only write target is `rd/karpathy-review.md`.
68
+ modify code; the writer's only write target is `rd/karpathy-review-<rid>.md`.
69
69
 
70
70
  > **Removed from v2.12.0 fan-out (back-compat window only):**
71
71
  > - ~~Sub-agent — security-reviewer~~ — moved to standalone
72
- > `peaks-security-audit` skill; output `audit/security.md`. The legacy
72
+ > `peaks-security-audit` skill; output `audit/security-<rid>.md`. The legacy
73
73
  > path `.peaks/_runtime/<sessionId>/rd/security-review.md` remains
74
74
  > readable via `mustContainAny` for the v2.12.0 1-minor-release window.
75
75
  > - ~~Sub-agent — perf-baseline-reviewer~~ — moved to standalone
76
- > `peaks-perf-audit` skill; output `audit/perf.md`. The legacy path
76
+ > `peaks-perf-audit` skill; output `audit/perf-<rid>.md`. The legacy path
77
77
  > `.peaks/_runtime/<sessionId>/rd/perf-baseline.md` remains readable
78
78
  > via `mustContainAny` for the v2.12.0 1-minor-release window.
79
79
  >
@@ -103,7 +103,7 @@ on the produced artifacts, and only then attempts
103
103
  `peaks request transition --state qa-handoff`. The aggregation step
104
104
  runs 3 ls checks: Gate B3 (code-review file), Gate C2 (qa-test-cases
105
105
  pre-draft, the 2nd sub-agent's deliverable), and the KARPATHY_REVIEW
106
- prereq (the 3rd sub-agent's `rd/karpathy-review.md`). The audit
106
+ prereq (the 3rd sub-agent's `rd/karpathy-review-<rid>.md`). The audit
107
107
  prereqs (`AUDIT_SECURITY` + `AUDIT_PERF` + `AUDIT_REQUIRES_HANDOFF`)
108
108
  are NOT fan-out outputs — they are produced by the standalone audit
109
109
  skills and consumed by the CLI gate. A failure in any of the 3
@@ -140,7 +140,7 @@ karpathy §1 Think Before Coding + §3 Surgical Changes.
140
140
  any violation is detected, `gateAction` is `warn`. When clean,
141
141
  `gateAction` is `pass`.
142
142
 
143
- **File write**: the sub-agent writes ONLY `rd/karpathy-review.md`,
143
+ **File write**: the sub-agent writes ONLY `rd/karpathy-review-<rid>.md`,
144
144
  formatted as:
145
145
 
146
146
  ```md
@@ -208,9 +208,9 @@ failing the gate.
208
208
 
209
209
  | Request type | Required RD evidence (under `.peaks/_runtime/<sessionId>/`) |
210
210
  |---|---|
211
- | feature / refactor | `prd/handoff.md` (immutable) + `audit/security.md` (peaks-security-audit) + `audit/perf.md` (peaks-perf-audit) + `rd/code-review.md` + `rd/karpathy-review.md` + `qa/test-cases/<rid>.md` |
212
- | bugfix | `prd/handoff.md` (immutable) + `audit/security.md` (peaks-security-audit) + `audit/perf.md` (peaks-perf-audit, perf-shaped only) + `rd/code-review.md` + `rd/karpathy-review.md` + `qa/test-cases/<rid>.md` |
213
- | config | `audit/security.md` (peaks-security-audit) |
211
+ | feature / refactor | `prd/handoff.md` (immutable) + `audit/security-<rid>.md` (peaks-security-audit) + `audit/perf-<rid>.md` (peaks-perf-audit) + `rd/code-review-<rid>.md` + `rd/karpathy-review-<rid>.md` + `qa/test-cases/<rid>.md` |
212
+ | bugfix | `prd/handoff.md` (immutable) + `audit/security-<rid>.md` (peaks-security-audit) + `audit/perf-<rid>.md` (peaks-perf-audit, perf-shaped only) + `rd/code-review-<rid>.md` + `rd/karpathy-review-<rid>.md` + `qa/test-cases/<rid>.md` |
213
+ | config | `rd/security-review.md` (genuinely ridless — `SECURITY_REVIEW.relativePath` carries no `<rid>`) |
214
214
  | docs / chore | (no extra evidence required) |
215
215
 
216
216
  Always required (in addition to the type-specific row):
@@ -225,6 +225,6 @@ DO NOT attempt the qa-handoff transition; CLI will reject with
225
225
  >
226
226
  > **v2.12.0 change (Group A — Tier 4+5):** `rd/security-review.md` and
227
227
  > `rd/perf-baseline.md` are removed from the required-evidence matrix;
228
- > `audit/security.md` (peaks-security-audit) + `audit/perf.md`
228
+ > `audit/security-<rid>.md` (peaks-security-audit) + `audit/perf-<rid>.md`
229
229
  > (peaks-perf-audit) replace them. The `AUDIT_REQUIRES_HANDOFF` prereq
230
230
  > enforces the immutable handoff consumption by the audit skills.
@@ -131,9 +131,13 @@ peaks codegraph affected --project <repo> <changed-files...> --json
131
131
  # writes). Falls back to empty diff if git is unavailable (degraded mode).
132
132
 
133
133
  # 1.z Karpathy scan (Slice 5/6 + Slice 6/6 — `peaks scan karpathy` + karpathy-reviewer sub-agent)
134
- # After the slice is implemented, scan `rd/karpathy-review.md` for the
134
+ # After the slice is implemented, scan `rd/karpathy-review-<rid>.md` for the
135
135
  # 4 Karpathy guidelines (Think / Simplicity / Surgical / Goal) and verify
136
136
  # the hard Karpathy-Gate (KARPATHY_REVIEW prereq in artifact-prerequisites.ts).
137
+ # NOTE: `peaks scan karpathy` itself has no rid and probes the ridless
138
+ # back-compat name `rd/karpathy-review.md`; it reports `block` for a slice
139
+ # that wrote only the rid-scoped name. `peaks request transition` is the
140
+ # authoritative gate.
137
141
  # The structural scanner covers regex / file-presence checks; the semantic
138
142
  # review is owned by the karpathy-reviewer sub-agent.
139
143
  #
@@ -142,7 +146,7 @@ peaks codegraph affected --project <repo> <changed-files...> --json
142
146
  # peaks scan karpathy --project <path> --format json # machine-readable
143
147
  # peaks scan karpathy --project <path> --scope all # full audit (gateAction: block if missing)
144
148
  # Required output before `peaks request transition --state qa-handoff`:
145
- # - `rd/karpathy-review.md` exists with `## Karpathy-Gate` header
149
+ # - `rd/karpathy-review-<rid>.md` exists with `## Karpathy-Gate` header
146
150
  # - 4 title-case section headers present (Think Before Coding / Simplicity First / Surgical Changes / Goal-Driven Execution)
147
151
  # - `gateAction: pass` (or `warn` with documented justification)
148
152
  #
@@ -153,7 +157,7 @@ peaks codegraph affected --project <repo> <changed-files...> --json
153
157
  # which is the project-internal draft at
154
158
  # `skills/peaks-rd/references/karpathy-reviewer-prompt.md` plus a
155
159
  # `rd/karpathy-reviewer-agent-handoff.md` install guide.
156
- # Hard gate: missing karpathy-reviewer sub-agent OR missing rd/karpathy-review.md
160
+ # Hard gate: missing karpathy-reviewer sub-agent OR missing rd/karpathy-review-<rid>.md
157
161
  # → `peaks request transition --state qa-handoff` returns `code: PREREQUISITES_MISSING`.
158
162
  # Escape hatch (assisted mode): `--allow-incomplete --confirm`.
159
163
 
@@ -163,8 +167,8 @@ peaks codegraph affected --project <repo> <changed-files...> --json
163
167
 
164
168
  # 7. AFTER implementation, BEFORE QA handoff — RUN THESE GATES:
165
169
  # Peaks-Loop Gate B2: unit tests exist and pass for the changed surface → npx vitest run --changed (or project equivalent; the changed-only mode is the peaks slice check default as of run 017; use --run-tests for the full suite, or invoke /peaks-code-test to run the full suite standalone)
166
- # Peaks-Loop Gate B3: code review evidence → .peaks/_runtime/<sessionId>/rd/code-review.md
167
- # Peaks-Loop Gate B4: security review evidence → .peaks/_runtime/<sessionId>/rd/security-review.md
170
+ # Peaks-Loop Gate B3: code review evidence → .peaks/_runtime/<sessionId>/rd/code-review-<rid>.md
171
+ # Peaks-Loop Gate B4: security review evidence → .peaks/_runtime/<sessionId>/audit/security-<rid>.md
168
172
  # Peaks-Loop Gate B5 (NEW): RD artifact body has no unfilled placeholders.
169
173
  peaks request lint <rid> --role rd --project <repo> --session-id <session-id> --json
170
174
  # Peaks-Loop Gate B6 (NEW): declared --type still matches the actual diff after implementation.
@@ -10,9 +10,11 @@ You cannot declare a phase complete from memory. Each gate below is a `ls` or `g
10
10
  >
11
11
  > | Type | rd:implemented requires | rd:qa-handoff also requires |
12
12
  > |---|---|---|
13
- > | feature / refactor | `rd/tech-doc.md` | `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` (filled Results table, or `N/A — no perf surface` in Notes) + **`qa/test-cases/<rid>.md`** (added in slice 004; pre-drafted by the 4th sub-agent in the parallel fan-out) |
14
- > | bugfix | `rd/bug-analysis.md` (lighter than tech-doc; root cause + fix + regression test plan) | `rd/code-review.md` + `rd/security-review.md` + **`qa/test-cases/<rid>.md`**; `rd/perf-baseline.md` only when the bug is performance-shaped (matches the L449-452 "When this applies" criteria) |
15
- > | config | (none) | `rd/security-review.md` only |
13
+ > | feature / refactor | `rd/tech-doc.md` | `rd/code-review-<rid>.md` + `audit/security-<rid>.md` + `audit/perf-<rid>.md` (filled Results table, or `N/A — no perf surface` in Notes) + **`qa/test-cases/<rid>.md`** (added in slice 004; pre-drafted by the 4th sub-agent in the parallel fan-out) |
14
+ > | bugfix | `rd/bug-analysis.md` (lighter than tech-doc; root cause + fix + regression test plan) | `rd/code-review-<rid>.md` + `audit/security-<rid>.md` + **`qa/test-cases/<rid>.md`**; `audit/perf-<rid>.md` only when the bug is performance-shaped (matches the L449-452 "When this applies" criteria) |
15
+ > | config | (none) | `rd/security-review.md` only — this one is genuinely ridless (`SECURITY_REVIEW.relativePath` carries no `<rid>`) |
16
+ >
17
+ > The `<rid>`-bearing names are the ones `peaks request transition` resolves first; the pre-rid names (`rd/code-review.md`, `rd/security-review.md`, `audit/security.md`, `audit/perf.md`) stay **readable** as back-compat tiers for sessions written before slice `2026-09-14-audit-artifact-rid-scoping` — read, never written. Exception: `rd/perf-baseline.md` is the RD-side Gate B9 baseline (a different artifact from `audit/perf-<rid>.md`) and is still both written by `peaks perf baseline --apply` and read as `AUDIT_PERF`'s oldest legacy tier.
16
18
  > | docs / chore | (none) | (none) |
17
19
  >
18
20
  > The escape hatch `--allow-incomplete --reason "<text>"` still exists for one-off exceptions; the bypass is recorded in the artifact transition note.
@@ -68,16 +70,16 @@ npx vitest run --changed --reporter=verbose 2>&1 | tail -20
68
70
 
69
71
  **Peaks-Loop Gate B3 — Before QA handoff: code review evidence exists:**
70
72
  ```bash
71
- ls .peaks/_runtime/<sessionId>/rd/code-review.md 2>&1
72
- # Expected: .peaks/_runtime/<sessionId>/rd/code-review.md
73
+ ls .peaks/_runtime/<sessionId>/rd/code-review-<rid>.md 2>&1
74
+ # Expected: .peaks/_runtime/<sessionId>/rd/code-review-<rid>.md
73
75
  # "No such file" → BLOCKED. Run code review (use code-reviewer agent or equivalent),
74
76
  # record findings, fix CRITICAL/HIGH issues, then re-check.
75
77
  ```
76
78
 
77
79
  **Peaks-Loop Gate B4 — Before QA handoff: security review evidence exists:**
78
80
  ```bash
79
- ls .peaks/_runtime/<sessionId>/rd/security-review.md 2>&1
80
- # Expected: .peaks/_runtime/<sessionId>/rd/security-review.md
81
+ ls .peaks/_runtime/<sessionId>/audit/security-<rid>.md 2>&1
82
+ # Expected: .peaks/_runtime/<sessionId>/audit/security-<rid>.md
81
83
  # "No such file" → BLOCKED. Run security review (use security-reviewer agent or equivalent),
82
84
  # fix CRITICAL/HIGH issues, record findings, then re-check.
83
85
  ```
@@ -4,7 +4,7 @@ Every RD handoff artifact carries a **YAML frontmatter block** so peaks-qa (and
4
4
 
5
5
  ## Path
6
6
 
7
- `.peaks/_runtime/<sessionId>/prd/handoff.md` — the canonical immutable PRD handoff path (v2.11.0+). The handoff is written by peaks-prd, sha256-hashed in frontmatter, and verified by every downstream sub-agent against the dispatched hash before reading.
7
+ `.peaks/_runtime/<sessionId>/prd/handoff-<rid>.md` — the canonical immutable PRD handoff path (v2.11.0+; one capsule per slice since `2026-09-14-prd-capsule-rid-scoping`). The pre-scoping `.peaks/_runtime/<sessionId>/prd/handoff.md` is still readable as the legacy tier. The handoff is written by peaks-prd, sha256-hashed in frontmatter, and verified by every downstream sub-agent against the dispatched hash before reading.
8
8
 
9
9
  > **v2.11.0 change (Group A):** the per-session `rd/tech-doc.md` is removed; the immutable peaks-prd handoff replaces it as the slice's source-of-truth architecture document.
10
10
 
@@ -19,7 +19,7 @@ scope:
19
19
  files:
20
20
  - src/services/slice/schema-router.ts
21
21
  - src/services/audit/audit-goal-service.ts
22
- handoffPath: .peaks/_runtime/<sessionId>/prd/handoff.md
22
+ handoffPath: .peaks/_runtime/<sessionId>/prd/handoff-<rid>.md
23
23
  handoffHash: sha256:<64 hex chars>
24
24
  decisions:
25
25
  - id: D1
@@ -34,10 +34,10 @@ nextActions:
34
34
  - "If Gate C passes, transition to txt handoff"
35
35
  gateEvidence:
36
36
  projectScan: .peaks/project-scan/project-scan.md
37
- prdHandoff: .peaks/_runtime/<sessionId>/prd/handoff.md
38
- codeReview: .peaks/_runtime/<sessionId>/rd/code-review.md
39
- securityReview: .peaks/_runtime/<sessionId>/rd/security-review.md
40
- perfBaseline: .peaks/_runtime/<sessionId>/rd/perf-baseline.md
37
+ prdHandoff: .peaks/_runtime/<sessionId>/prd/handoff-<rid>.md
38
+ codeReview: .peaks/_runtime/<sessionId>/rd/code-review-<rid>.md
39
+ securityReview: .peaks/_runtime/<sessionId>/audit/security-<rid>.md
40
+ perfBaseline: .peaks/_runtime/<sessionId>/audit/perf-<rid>.md
41
41
  schemaVersion: '2.0'
42
42
  ---
43
43
  ```
@@ -203,7 +203,7 @@ Before the first planning action, run `peaks fresh-context preflight --prompt "<
203
203
  |---|---|---|
204
204
  | `< 0.85` | normal | skip — LLM keeps working |
205
205
  | `0.85 ≤ ratio < 0.95` | **pre-compact zone** | `peaks code auto-compact` fires **automatically** (deferred only when in-flight sub-agent batch is running; fires the moment the batch lands). The LLM does not prompt the user. |
206
- | `ratio ≥ 0.95` | **red-line (Karpathy §4)** | synchronous gate — `peaks code auto-compact` invoked immediately; `peaks code context-now` returns `action: 'red-line'` and refuses to advance until ratio drops below 0.85. **Karpathy §4 automatic exception** — LLM cannot opt out. |
206
+ | `ratio ≥ 0.95` | **red-line (Karpathy §4)** | `peaks code auto-compact` invoked immediately; `peaks code context-now` returns `action: 'red-line'`. **Since 4.0.47 the red line REQUESTS the compaction and says it is waiting — it does NOT block sub-agent dispatch, and it does not refuse to advance.** Keep working and re-probe with `peaks code context-now`; the harness performs the compaction, and nothing peaks-loop can do lowers the ratio on its own, so blocking here was a deadlock rather than a gate. If the ratio keeps climbing and no compaction lands, report that and hand control back — do not stall. `--bypass-red-line` is a no-op. |
207
207
 
208
208
  **Probe primitive (single source of truth):** `peaks code context-now --json`. Do NOT use `peaks context check --prompt-size` (deprecated, will silently under-report ratio). Returns `{ ratio, action: 'ok' | 'soft-warn' | 'auto-compact-now' | 'red-line' }` — Code reads `action` and dispatches `peaks code auto-compact` on `auto-compact-now` or `red-line` without user confirmation.
209
209
 
@@ -20,7 +20,7 @@ The mapping below uses peaks's own paths verbatim. Each row also notes where pea
20
20
  |---|---|---|---|
21
21
  | **AgentCard** (capability advertisement) | `peaks-skill-output-style` + `.peaks/.active-skill.json` | `.peaks/.active-skill.json`, `.peaks/.session.json` | peaks is a *local* tool, not a service. The "card" is the active-skill file plus a peek at `.peaks/PROJECT.md` for human-readable history. There is no `/.well-known/agent-card.json` endpoint. |
22
22
  | **Task** (stateful unit of work) | `peaks request` state machine for a single `<rid>` | `.peaks/_runtime/<sid>/{prd,rd,qa,ui,sc}/requests/<rid>.md` (the request artefact); `.peaks/_runtime/<sid>/<role>/session.json` (per-session metadata) | peaks's task lifecycle is `prd:confirmed-by-user → handed-off`, then per role `draft → spec-locked → implemented → qa-handoff`, then `qa:running → verdict-issued`. The full state graph is enforced by `peaks request transition`. A2A's Task object is JSON; peaks's task is **a set of files with a `state` field per role**. |
23
- | **Artifact** (immutable output) | `rd/tech-doc.md`, `rd/code-review.md`, `rd/security-review.md`, `qa/test-cases/<rid>.md`, `qa/test-reports/<rid>.md`, `qa/security-findings.md`, `qa/performance-findings.md`, `sc/handoff.md` | as listed | peaks's artefacts are *append-once*, not strictly immutable: a `qa/test-reports/<rid>.md` may be re-emitted on repair cycles. The convention is "newest write wins; the file at the end of the workflow is the truth", which is close enough to A2A's immutable-Artifact semantics for translation purposes. |
23
+ | **Artifact** (immutable output) | `rd/tech-doc.md`, `rd/code-review-<rid>.md`, `audit/security-<rid>.md`, `qa/test-cases/<rid>.md`, `qa/test-reports/<rid>.md`, `qa/security-findings.md`, `qa/performance-findings.md`, `sc/handoff.md` | as listed | peaks's artefacts are *append-once*, not strictly immutable: a `qa/test-reports/<rid>.md` may be re-emitted on repair cycles. The convention is "newest write wins; the file at the end of the workflow is the truth", which is close enough to A2A's immutable-Artifact semantics for translation purposes. |
24
24
  | **Message** (non-artifact communication) | `peaks skill presence` heartbeat + transition `--reason` notes | `.peaks/.active-skill.json` (`lastHeartbeat`), transition notes in `.peaks/_runtime/<sid>/<role>/requests/<rid>.md` | peaks does **not** separate Messages from Artifacts at the storage layer; a "message" is anything that is not the artefact body (the `<!-- peaks-memory:start -->` markers, the `state` field, the `--reason` text on a transition). Treat these as inline metadata of the artefact, not as separate objects. |
25
25
  | **Part** (atomic content unit) | Markdown sections within an artefact, frontmatter fields | inline within the artefact | peaks's Artifacts are single Markdown files, so the "Part" concept maps to a heading or a frontmatter field. A `Part`'s `kind` in A2A terms is `text` (the prose), `file` (a `<!-- peaks-memory:start -->` block as a structured chunk), or `data` (the frontmatter). A2A's `form` / `iframe` / video `Part` kinds are not produced by peaks. |
26
26
 
@@ -78,8 +78,8 @@ A user runs `peaks-code` for a "add user authentication" feature. Mapping the re
78
78
  .peaks/_runtime/<sessionId>/ui/design-draft.md → A2A Artifact (kind=visual-spec)
79
79
  .peaks/_runtime/<sessionId>/rd/tech-doc.md → A2A Artifact (kind=implementation-plan)
80
80
  .peaks/_runtime/<sessionId>/qa/test-cases/001.md → A2A Artifact (kind=test-cases)
81
- .peaks/_runtime/<sessionId>/rd/code-review.md → A2A Artifact (kind=review, status=fixed)
82
- .peaks/_runtime/<sessionId>/rd/security-review.md → A2A Artifact (kind=security-review)
81
+ .peaks/_runtime/<sessionId>/rd/code-review-<rid>.md → A2A Artifact (kind=review, status=fixed)
82
+ .peaks/_runtime/<sessionId>/audit/security-<rid>.md → A2A Artifact (kind=security-review)
83
83
  .peaks/_runtime/<sessionId>/qa/test-reports/001.md → A2A Artifact (kind=test-report, verdict=pass)
84
84
  .peaks/_runtime/<sessionId>/qa/security-findings.md → A2A Artifact (kind=security-findings)
85
85
  .peaks/_runtime/<sessionId>/qa/performance-findings.md → A2A Artifact (kind=performance-findings)
@@ -53,7 +53,7 @@ Files written into these directories during the workflow (not pre-created — th
53
53
  - `rd/project-scan.md` (Code step 0.6)
54
54
  - `rd/tech-doc.md` (feature/refactor planning; required by `rd → implemented` gate)
55
55
  - `rd/bug-analysis.md` (bugfix planning; required by `rd → implemented` gate for `--type bugfix`)
56
- - `rd/code-review.md`, `rd/security-review.md` (required by `rd → qa-handoff` gate for feature/bugfix/refactor; security-review only for config)
56
+ - `rd/code-review-<rid>.md`, `audit/security-<rid>.md` (required by `rd → qa-handoff` gate for feature/bugfix/refactor; the `config` type instead requires the ridless `rd/security-review.md`)
57
57
  - `rd/mock-plan.md` (frontend-only mode)
58
58
  - `ui/design-draft.md` (UI step)
59
59
  - `system/existing-system.md` (Code step 0.7; legacy projects only)