peaks-loop 4.0.46 → 4.0.48

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 (207) hide show
  1. package/CHANGELOG.md +54 -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.d.ts +22 -0
  9. package/dist/cli/commands/code-runtime-commands.js +139 -16
  10. package/dist/cli/commands/compact-command.js +241 -1
  11. package/dist/cli/commands/config-commands.js +15 -9
  12. package/dist/cli/commands/container-commands.js +3 -3
  13. package/dist/cli/commands/core/skill-command.js +45 -10
  14. package/dist/cli/commands/cron-commands.js +2 -1
  15. package/dist/cli/commands/dashboard-long-run.js +6 -0
  16. package/dist/cli/commands/dispatch-commands.js +11 -1
  17. package/dist/cli/commands/doctor/invoke-from-code.js +6 -0
  18. package/dist/cli/commands/e2e-verify.js +3 -3
  19. package/dist/cli/commands/governance-classify-contract-commands.js +1 -0
  20. package/dist/cli/commands/hooks-commands.js +14 -5
  21. package/dist/cli/commands/job-commands.js +8 -0
  22. package/dist/cli/commands/loop-commands.js +1 -0
  23. package/dist/cli/commands/loop-eval-commands.js +15 -0
  24. package/dist/cli/commands/perf-audit-commands.js +2 -0
  25. package/dist/cli/commands/playwright-commands.js +14 -1
  26. package/dist/cli/commands/prd-commands.js +1 -1
  27. package/dist/cli/commands/qa-commands.js +22 -0
  28. package/dist/cli/commands/reinject-command.d.ts +72 -0
  29. package/dist/cli/commands/reinject-command.js +174 -0
  30. package/dist/cli/commands/request-commands.js +14 -3
  31. package/dist/cli/commands/scan-commands.js +1 -1
  32. package/dist/cli/commands/security-audit-commands.js +2 -0
  33. package/dist/cli/commands/shadcn-commands.js +1 -0
  34. package/dist/cli/commands/slice-integrate-commands.js +5 -0
  35. package/dist/cli/commands/statusline-commands.js +44 -4
  36. package/dist/cli/commands/sub-agent/detached.d.ts +14 -1
  37. package/dist/cli/commands/sub-agent/detached.js +47 -22
  38. package/dist/cli/commands/sub-agent-shutdown-commands.js +11 -0
  39. package/dist/cli/commands/test-commands.js +2 -1
  40. package/dist/cli/commands/verdict-aggregate-command.js +95 -13
  41. package/dist/cli/commands/vm-commands.js +7 -7
  42. package/dist/cli/commands/workflow-commands.js +1 -1
  43. package/dist/cli/commands/workspace/init-command.js +24 -2
  44. package/dist/cli/commands/worktree-lease-commands.js +4 -4
  45. package/dist/cli/index.js +10 -3
  46. package/dist/cli/program.js +5 -0
  47. package/dist/hooks/pre-tool-use-sub-agent.js +1 -1
  48. package/dist/services/adapter/adapter-registry.js +1 -1
  49. package/dist/services/artifacts/artifact-prerequisites.d.ts +38 -7
  50. package/dist/services/artifacts/artifact-prerequisites.js +130 -65
  51. package/dist/services/artifacts/artifact-service.js +1 -1
  52. package/dist/services/artifacts/request-artifact-service.d.ts +8 -0
  53. package/dist/services/artifacts/request-artifact-service.js +18 -8
  54. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +57 -0
  55. package/dist/services/artifacts/request-artifact-state-helpers.js +91 -10
  56. package/dist/services/audit-independent/perf-audit-service.d.ts +9 -0
  57. package/dist/services/audit-independent/perf-audit-service.js +27 -5
  58. package/dist/services/audit-independent/security-audit-service.d.ts +12 -2
  59. package/dist/services/audit-independent/security-audit-service.js +28 -6
  60. package/dist/services/capability-guard-runner/contracts/J01.js +2 -1
  61. package/dist/services/capability-guard-runner/contracts/J02.js +3 -3
  62. package/dist/services/capability-guard-runner/contracts/J04.js +4 -2
  63. package/dist/services/capability-guard-runner/contracts/J07.js +2 -1
  64. package/dist/services/code/auto-compact-lifecycle.d.ts +130 -1
  65. package/dist/services/code/auto-compact-lifecycle.js +180 -4
  66. package/dist/services/code/auto-compact-orchestrator.d.ts +53 -9
  67. package/dist/services/code/auto-compact-orchestrator.js +166 -34
  68. package/dist/services/code/compact-event-settle.d.ts +122 -0
  69. package/dist/services/code/compact-event-settle.js +219 -0
  70. package/dist/services/code/orchestrator-can-do.d.ts +4 -2
  71. package/dist/services/code/orchestrator-can-do.js +37 -5
  72. package/dist/services/codegraph/codegraph-exclude-reconciler.js +2 -1
  73. package/dist/services/codegraph/codegraph-process-runner.js +3 -2
  74. package/dist/services/compact/request-transition-hook.js +5 -2
  75. package/dist/services/compact-history/compact-history-service.d.ts +75 -0
  76. package/dist/services/compact-history/compact-history-service.js +49 -0
  77. package/dist/services/config/config-restore.d.ts +12 -1
  78. package/dist/services/config/config-restore.js +35 -4
  79. package/dist/services/config/config-rollback.js +6 -1
  80. package/dist/services/config/config-safety.d.ts +52 -0
  81. package/dist/services/config/config-safety.js +75 -1
  82. package/dist/services/context/auto-compact-dispatcher.d.ts +7 -37
  83. package/dist/services/context/auto-compact-dispatcher.js +113 -40
  84. package/dist/services/context/auto-compact-reader.d.ts +68 -28
  85. package/dist/services/context/auto-compact-reader.js +155 -1
  86. package/dist/services/context/auto-compact-types.d.ts +89 -12
  87. package/dist/services/context/auto-compact-types.js +16 -32
  88. package/dist/services/context/harness-context-witness.d.ts +310 -0
  89. package/dist/services/context/harness-context-witness.js +606 -0
  90. package/dist/services/context/harness-window-config.d.ts +412 -0
  91. package/dist/services/context/harness-window-config.js +607 -0
  92. package/dist/services/context/main-session-monitor.d.ts +27 -0
  93. package/dist/services/context/main-session-monitor.js +32 -1
  94. package/dist/services/context/post-compact-reinjection.d.ts +221 -0
  95. package/dist/services/context/post-compact-reinjection.js +491 -0
  96. package/dist/services/dispatch/merge-back-runner.js +5 -5
  97. package/dist/services/dispatch/service-shutdown.js +3 -3
  98. package/dist/services/doc/doc-generator.js +2 -1
  99. package/dist/services/env/shell-probe.js +1 -1
  100. package/dist/services/evidence/evidence-generator.js +86 -49
  101. package/dist/services/final-review/final-review-service.d.ts +9 -0
  102. package/dist/services/final-review/final-review-service.js +36 -12
  103. package/dist/services/fuzzy-matching/fzf-pick-service.js +2 -0
  104. package/dist/services/hooks/auto-compact-hook-install.d.ts +10 -2
  105. package/dist/services/hooks/auto-compact-hook-install.js +8 -0
  106. package/dist/services/ide/adapters/claude-code-adapter.d.ts +107 -3
  107. package/dist/services/ide/adapters/claude-code-adapter.js +154 -7
  108. package/dist/services/ide/ide-registry.d.ts +31 -0
  109. package/dist/services/ide/ide-registry.js +35 -0
  110. package/dist/services/ide/ide-types.d.ts +59 -0
  111. package/dist/services/job/job-state-store.js +7 -0
  112. package/dist/services/lint/detect-eslint.js +2 -2
  113. package/dist/services/lint/eslint-runner.js +3 -1
  114. package/dist/services/loop/evaluator-dispatcher.js +2 -1
  115. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +1 -1
  116. package/dist/services/memory/project-memory-service/store/paths.d.ts +9 -1
  117. package/dist/services/memory/project-memory-service/store/paths.js +15 -6
  118. package/dist/services/polyrepo/polyrepo-dispatcher.js +11 -0
  119. package/dist/services/prd/best-practice-auto-trigger.js +1 -0
  120. package/dist/services/prd/handoff-auto-regen.js +31 -27
  121. package/dist/services/prd/handoff-frontmatter.d.ts +44 -0
  122. package/dist/services/prd/handoff-frontmatter.js +75 -0
  123. package/dist/services/prd/handoff-service.d.ts +41 -2
  124. package/dist/services/prd/handoff-service.js +81 -8
  125. package/dist/services/prd/handoff-types.d.ts +3 -2
  126. package/dist/services/prd/handoff-types.js +3 -2
  127. package/dist/services/qa/qa-business-review-state.js +9 -0
  128. package/dist/services/release/version-precheck-service.d.ts +2 -1
  129. package/dist/services/release/version-precheck-service.js +82 -12
  130. package/dist/services/runtime/vendor-adapter.d.ts +29 -4
  131. package/dist/services/runtime/vendors/claude-code.js +1 -1
  132. package/dist/services/runtime/vendors/codex.js +1 -1
  133. package/dist/services/runtime/vendors/copilot.js +1 -1
  134. package/dist/services/sc/sc-service.js +1 -1
  135. package/dist/services/scan/diff-scope-service.js +2 -2
  136. package/dist/services/scan/file-size-scan.js +2 -2
  137. package/dist/services/scan/karpathy-service.js +2 -2
  138. package/dist/services/scan/orphan-service.js +2 -1
  139. package/dist/services/scan/type-sanity-service.js +2 -2
  140. package/dist/services/session/session-checkpoint-service.js +8 -0
  141. package/dist/services/skill/resume-detector.js +29 -11
  142. package/dist/services/skillhub/tar-runtime.js +1 -0
  143. package/dist/services/skills/hooks-codegate-superpowers.d.ts +14 -0
  144. package/dist/services/skills/hooks-codegate-superpowers.js +99 -3
  145. package/dist/services/skills/hooks-settings-service.d.ts +12 -0
  146. package/dist/services/skills/hooks-settings-service.js +91 -14
  147. package/dist/services/skills/session-start-hook-constants.d.ts +86 -0
  148. package/dist/services/skills/session-start-hook-constants.js +86 -0
  149. package/dist/services/skills/skill-presence-service.js +9 -0
  150. package/dist/services/skills/skill-statusline-service.d.ts +14 -0
  151. package/dist/services/slice/slice-check-service.js +31 -12
  152. package/dist/services/slice/slice-decompose-runners.js +2 -1
  153. package/dist/services/slice/slice-review-state.js +8 -0
  154. package/dist/services/upgrade/upgrade-service.js +1 -0
  155. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +47 -10
  156. package/dist/services/workflow/pipeline-verify-gate-support.js +212 -93
  157. package/dist/services/workflow/pipeline-verify-service.js +24 -23
  158. package/dist/services/workflow/pipeline-verify-types.d.ts +10 -3
  159. package/dist/services/workflow/workflow-skip-service.js +2 -1
  160. package/dist/services/workspace/claude-settings-template.d.ts +56 -8
  161. package/dist/services/workspace/claude-settings-template.js +98 -20
  162. package/dist/services/workspace/migrate-service.js +1 -1
  163. package/dist/services/workspace/workspace-claude-settings-materializer.js +124 -9
  164. package/dist/services/workspace/workspace-service.js +8 -0
  165. package/dist/services/worktree/host-worktree-reconciler.js +1 -0
  166. package/dist/services/worktree/long-path-cleanup.js +3 -2
  167. package/dist/shared/process.js +1 -1
  168. package/package.json +6 -6
  169. package/scripts/install-skills.mjs +1 -0
  170. package/scripts/watch.mjs +3 -1
  171. package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
  172. package/skills/bee/peaks-prd/SKILL.md +8 -6
  173. package/skills/bee/peaks-qa/SKILL.md +7 -7
  174. package/skills/bee/peaks-qa/references/qa-runbook.md +2 -2
  175. package/skills/bee/peaks-qa/references/qa-transition-gates.md +7 -7
  176. package/skills/bee/peaks-rd/SKILL.md +10 -8
  177. package/skills/bee/peaks-rd/references/artifact-per-request.md +2 -2
  178. package/skills/bee/peaks-rd/references/parallel-review-fanout.md +7 -5
  179. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +13 -13
  180. package/skills/bee/peaks-rd/references/rd-runbook.md +9 -5
  181. package/skills/bee/peaks-rd/references/rd-transition-gates.md +9 -7
  182. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +6 -6
  183. package/skills/bee/peaks-reviewer/SKILL.md +1 -1
  184. package/skills/bee/peaks-sc/SKILL.md +1 -1
  185. package/skills/bee/peaks-security-audit/SKILL.md +1 -1
  186. package/skills/bee/peaks-txt/SKILL.md +1 -1
  187. package/skills/bee/peaks-ui/SKILL.md +1 -1
  188. package/skills/peaks-audit/SKILL.md +1 -1
  189. package/skills/peaks-code/SKILL.md +3 -3
  190. package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
  191. package/skills/peaks-code/references/local-artifact-workspace.md +1 -1
  192. package/skills/peaks-code/references/resume-detection.md +13 -7
  193. package/skills/peaks-code/references/runbook.md +3 -2
  194. package/skills/peaks-code/references/session-overload-signal-index.md +2 -1
  195. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  196. package/skills/peaks-code/references/workflow-gates-and-types.md +8 -6
  197. package/skills/peaks-content/SKILL.md +1 -1
  198. package/skills/peaks-doctor/SKILL.md +1 -1
  199. package/skills/peaks-final-review/SKILL.md +1 -1
  200. package/skills/peaks-ide/SKILL.md +1 -1
  201. package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
  202. package/skills/peaks-resume/SKILL.md +1 -1
  203. package/skills/peaks-slice-decompose/SKILL.md +1 -1
  204. package/skills/peaks-solo/SKILL.md +1 -1
  205. package/skills/peaks-sop/SKILL.md +1 -1
  206. package/skills/peaks-status/SKILL.md +1 -1
  207. package/skills/peaks-test/SKILL.md +1 -1
@@ -9,7 +9,7 @@ description: |
9
9
  visibility: internal
10
10
  ---
11
11
 
12
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
12
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
13
13
 
14
14
  ## Loop hygiene (every turn — MANDATORY)
15
15
 
@@ -172,22 +172,24 @@ 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
 
188
190
  ## Reviewer fan-out detached mode (Phase C, slice 2026-08-10)
189
191
 
190
- Reviewer fan-out may run in detached mode for any of the 3-way fan-out roles (`code-reviewer`, `qa-test-cases-writer`, `karpathy-reviewer`). Detached mode spawns a real OS process via `peaks sub-agent dispatch --mode detached --vendor <vendor>`, isolated from the orchestrator session. Use detached mode when the reviewer's expected runtime exceeds 60s OR processes ≥ 20 source files. Pass `--mode detached` explicitly per reviewer role; the default remains `in-process` (backward compat). The karpathy-reviewer's G8 infinite-context marker (auto-compact at 0.85/0.95, unlimited spend) is honored automatically when `--mode detached` is used. See `peaks-code/references/sub-agent-dispatch.md` §"Detached Mode" for the full contract.
192
+ Reviewer fan-out may run in detached mode for any of the 3-way fan-out roles (`code-reviewer`, `qa-test-cases-writer`, `karpathy-reviewer`). Detached mode spawns a real OS process via `peaks sub-agent dispatch --mode detached --vendor <vendor>`, isolated from the orchestrator session. Use detached mode when the reviewer's expected runtime exceeds 60s OR processes ≥ 20 source files. Pass `--mode detached` explicitly per reviewer role; the default remains `in-process` (backward compat). The karpathy-reviewer's `<peaks-auto-compact>` marker is honored automatically when `--mode detached` is used. Note what that marker does and does not do (corrected 2026-09-13, rid `2026-09-13-defects-e`): it asks the child to persist durable state to `.peaks/_runtime/<sid>/detached/<rid>/compact/<n>.json` before its own harness compacts the session — the child cannot compact itself, and nothing is spliced back into its prompt. See `peaks-code/references/sub-agent-dispatch.md` §"Detached Mode" for the full contract.
191
193
 
192
194
  ## Refactor hard gates
193
195
 
@@ -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
  ```
@@ -4,7 +4,7 @@ visibility: internal
4
4
  description: Third-party independent code-review skill for Peaks. Use as a parallel reviewer to karpathy-reviewer when a workflow needs an out-of-band (non-RD-model) review pass to mitigate single-LLM self-dogfood blind spots. Emits a schema-validated ReviewerEnvelope (no free-form LLM JSON). v2.14.0 G4.
5
5
  ---
6
6
 
7
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
7
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
8
8
 
9
9
  ## Loop hygiene (every turn — MANDATORY)
10
10
 
@@ -8,7 +8,7 @@ description: |
8
8
  visibility: internal
9
9
  ---
10
10
 
11
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
11
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
12
12
 
13
13
  ## Loop hygiene (every turn — MANDATORY)
14
14
 
@@ -12,7 +12,7 @@ metadata:
12
12
  - schema: .peaks/project-scan/audit-output-schema.md
13
13
  ---
14
14
 
15
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
15
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
16
16
 
17
17
  ## Loop hygiene (every turn — MANDATORY)
18
18
 
@@ -8,7 +8,7 @@ description: |
8
8
  visibility: internal
9
9
  ---
10
10
 
11
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
11
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
12
12
 
13
13
  ## Loop hygiene (every turn — MANDATORY)
14
14
 
@@ -8,7 +8,7 @@ description: |
8
8
  visibility: internal
9
9
  ---
10
10
 
11
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
11
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
12
12
 
13
13
  ## Loop hygiene (every turn — MANDATORY)
14
14
 
@@ -3,7 +3,7 @@ name: peaks-audit
3
3
  description: Gate autonomous LLM work on a 6-dimension audit + user-accepted goal. Use IMMEDIATELY after a need is expressed, BEFORE any PRD/RD/QA work starts.
4
4
  ---
5
5
 
6
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
6
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
7
7
 
8
8
  ## Loop hygiene (every turn — MANDATORY)
9
9
 
@@ -3,7 +3,7 @@ name: peaks-code
3
3
  description: Code-domain loop engineering orchestrator for the Peaks-Loop skill family. Use when the user asks Peaks-Loop to handle a code-repo workflow end-to-end (端到端/全流程/需求开发), especially from a product document (PRD/飞书文档/Feishu doc) through implementation and validation. Coordinates peaks-prd, peaks-rd, peaks-qa, peaks-ui, peaks-sc, and peaks-txt while preserving user confirmation gates. Triggers on `/peaks-code`, "peaks code", "全流程开发", "端到端迭代". General primitives (peaks-resume / peaks-status / peaks-test) are sibling skills, not children.
4
4
  ---
5
5
 
6
- <!-- peaks:loop-hygiene — generated block; keep byte-identical in every SKILL.md -->
6
+ <!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 22. -->
7
7
 
8
8
  ## Loop hygiene (every turn — MANDATORY)
9
9
 
@@ -37,7 +37,7 @@ of ~30 minutes clears the gate's "already passed" list, so a file you cleared ea
37
37
  denied again after a long pause. That is the gate resetting, not you regressing.
38
38
  <!-- /peaks:loop-hygiene -->
39
39
 
40
- > **Detached sub-agent mode (Phase A, slice 2026-08-10).** When the orchestrator requires true parallelism with isolated context windows and survives orchestrator session exit, dispatch sub-agents with `--mode detached --vendor <claude|codex|copilot>`. The CLI spawns a real OS process via `ProcessSupervisor` (Windows `DETACHED_PROCESS` + `CREATE_NEW_PROCESS_GROUP`, POSIX `setsid` + `nohup`); the child vendor LLM receives a 5–8KB minimum prompt slice (no orchestrator session history) and self-compacts at 0.85 / 0.95 against the vendor window via the `<peaks-auto-compact>` marker (G8 — unlimited spend authorized). Orchestrator MUST emit one line of prose before every detached dispatch: `⏳ Spawning detached sub-agent via <vendor>: rid=<rid> (ETA ~60s)`. Status is read from `.peaks/_runtime/<sid>/detached/<rid>/status.json`; `LifecycleOwner` enforces 100% cleanup of `pid` / `log.txt` / `status.json` / `owner-session` on every exit path. `--no-throttle --max-concurrent <N>` bypasses `ResourceBudgetGuard` (user accepts risk; default max=8). See `references/sub-agent-dispatch.md` §"Detached Mode" for the full contract. Default mode remains `in-process` for backward compat (existing 106+ dispatch tests untouched).
40
+ > **Detached sub-agent mode (Phase A, slice 2026-08-10).** When the orchestrator requires true parallelism with isolated context windows and survives orchestrator session exit, dispatch sub-agents with `--mode detached --vendor <claude|codex|copilot>`. The CLI spawns a real OS process via `ProcessSupervisor` (Windows `DETACHED_PROCESS` + `CREATE_NEW_PROCESS_GROUP`, POSIX `setsid` + `nohup`); the child vendor LLM receives a 5–8KB minimum prompt slice (no orchestrator session history) and, via the `<peaks-auto-compact>` marker, is told to persist durable state to `.peaks/_runtime/<sid>/detached/<rid>/compact/<n>.json` before its own harness compacts the session (G8, corrected 2026-09-13 rid `2026-09-13-defects-e`: the child cannot compact itself and nothing is spliced back into its prompt; peaks runtime simply has no token-cost throttle, which is not the same as a granted budget). Orchestrator MUST emit one line of prose before every detached dispatch: `⏳ Spawning detached sub-agent via <vendor>: rid=<rid> (ETA ~60s)`. Status is read from `.peaks/_runtime/<sid>/detached/<rid>/status.json`; `LifecycleOwner` enforces 100% cleanup of `pid` / `log.txt` / `status.json` / `owner-session` on every exit path. `--no-throttle --max-concurrent <N>` bypasses `ResourceBudgetGuard` (user accepts risk; default max=8). See `references/sub-agent-dispatch.md` §"Detached Mode" for the full contract. Default mode remains `in-process` for backward compat (existing 106+ dispatch tests untouched).
41
41
  ---
42
42
 
43
43
  ## Scope (RL-8 — red line, locked 2026-07-08)
@@ -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)
@@ -12,12 +12,18 @@
12
12
  sid=$(peaks session info --active --project "$(git rev-parse --show-toplevel)" --json | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['sessionId'])")
13
13
 
14
14
  # 2. Enumerate the session's artifact tree (one `find` call, no new CLI)
15
- find ".peaks/$sid/" -type f 2>/dev/null | sort
15
+ find ".peaks/_runtime/$sid/" -type f 2>/dev/null | sort
16
16
 
17
17
  # 3. For each role request artifact present, read its `state:` field
18
- # (one-pass grep; only files that exist)
19
- for f in .peaks/$sid/prd/requests/*.md .peaks/$sid/rd/requests/*.md .peaks/$sid/qa/requests/*.md; do
20
- [ -f "$f" ] && echo "$f: $(grep -m1 '^state:' "$f" | awk '{print $2}')"
18
+ # (only files that exist). Artifacts are append-only: every round appends its
19
+ # own `## Status` block and `request transition` rewrites the NEWEST
20
+ # `- state:` line in place, so the LAST match is the current state and the
21
+ # earlier ones are history. Reading the FIRST match returns a superseded
22
+ # round — that was the 2026-09-14 defect. The leading `-` is part of the
23
+ # field: an unanchored `^state:` matches nothing (artifacts write
24
+ # `- state:`), so it reported an empty state, silently.
25
+ for f in .peaks/_runtime/$sid/prd/requests/*.md .peaks/_runtime/$sid/rd/requests/*.md .peaks/_runtime/$sid/qa/requests/*.md; do
26
+ [ -f "$f" ] && echo "$f: $(grep '^-[[:space:]]*state:' "$f" | tail -n1 | sed 's/^-[[:space:]]*state:[[:space:]]*//; s/[[:space:]]*$//')"
21
27
  done
22
28
 
23
29
  # 4. Compute "deepest completed gate" by file-presence + state mapping
@@ -28,7 +34,7 @@ done
28
34
 
29
35
  | Files present | State | Deepest completed gate | Resume point (if any) |
30
36
  |---|---|---|---|
31
- | only `.peaks/$sid/.session.json` | (no slice) | (none) | fresh — skip to Step 1 |
37
+ | only `.peaks/_runtime/$sid/session.json` | (no slice) | (none) | fresh — skip to Step 1 |
32
38
  | `prd/requests/<rid>.md` | `state: handed-off` | Gate B (swarm converged) | resume at Step 3 (swarm) — but if swarm already ran and produced `rd/tech-doc.md` / `qa/test-cases/<rid>.md`, drop to deepest |
33
39
  | `rd/requests/<rid>.md` | `state: qa-handoff` | Gate C (RD done) | resume at Step 6 (QA validation) |
34
40
  | `qa/requests/<rid>.md` | `state: verdict-issued` | Gate D (QA done) | resume at Step 10 (TXT handoff) |
@@ -39,8 +45,8 @@ done
39
45
  | Missing file | Resume at |
40
46
  |---|---|
41
47
  | `rd/tech-doc.md` (for `feature`/`refactor`) or `rd/bug-analysis.md` (for `bugfix`) | Step 3b (RD planning) |
42
- | `rd/code-review.md` or `rd/security-review.md` | Step 5 (RD review fan-out) |
43
- | `rd/perf-baseline.md` (for `feature`/`refactor`) | Step 5 (perf baseline) |
48
+ | `rd/code-review-<rid>.md` or `audit/security-<rid>.md` | Step 5 (RD review fan-out) |
49
+ | `audit/perf-<rid>.md` (for `feature`/`refactor`) | Step 5 (perf baseline) |
44
50
  | `qa/test-cases/<rid>.md` | Step 6 (QA test-case generation) |
45
51
  | `qa/test-reports/<rid>.md` or `qa/security-findings.md` or `qa/performance-findings.md` | Step 6 (QA execution) |
46
52
  | `txt/handoff.md` | Step 10 (TXT handoff) |
@@ -153,8 +153,9 @@ peaks request transition <rid> --role rd --state implemented --project <repo> --
153
153
 
154
154
  # 5. Peaks-Loop Code review + security review BEFORE qa-handoff transition.
155
155
  # Produce the evidence files the CLI gate enforces:
156
- # - .peaks/_runtime/<id>/rd/code-review.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
157
- # - .peaks/_runtime/<id>/rd/security-review.md (required for feature/bugfix/refactor/config)
156
+ # - .peaks/_runtime/<id>/rd/code-review-<rid>.md (CRITICAL/HIGH findings + fixes; required for feature/bugfix/refactor)
157
+ # - .peaks/_runtime/<id>/audit/security-<rid>.md (required for feature/bugfix/refactor; the ridless rd/security-review.md is the config-type requirement)
158
+ # The pre-rid names remain accepted back-compat tiers, but writing one re-opens the two-slices-one-session collision (slice 2026-09-14-audit-artifact-rid-scoping).
158
159
  # Then transition. If --type is docs/chore the gate is empty and the transition is unguarded.
159
160
  peaks request transition <rid> --role rd --state qa-handoff --project <repo> --json
160
161
 
@@ -45,7 +45,8 @@ LLM senses context pressure
45
45
  │ │ ├─ Job mode → MUST auto-compact now
46
46
  │ │ └─ non-Job → wait for next idle turn, then compact
47
47
  │ ├─ 0.85 ≤ ratio < 0.95 → pre-compact zone; auto-compact MUST fire
48
- │ └─ ratio ≥ 0.95 → red-line; synchronous gate (Karpathy §4)
48
+ │ └─ ratio ≥ 0.95 → red-line; compact REQUESTED, dispatch NOT blocked (Karpathy §4)
49
+ │ keep working, re-probe, do not stall
49
50
  ├─► Check statusline compact bar (signal #4)
50
51
  │ ├─ queued / preparing / compacting / verifying → wait
51
52
  │ ├─ failed → read failure reason, do NOT spawn new session
@@ -449,7 +449,7 @@ peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-
449
449
 
450
450
  - **Cross-platform spawn**: Windows uses `DETACHED_PROCESS` + `CREATE_NEW_PROCESS_GROUP`; POSIX uses `setsid` + `nohup`. Implementation: `packages/peaks-loop-internal-runtime/src/process-supervisor.ts`.
451
451
  - **Minimum-context prompt**: `PromptBuilder` emits a 5–8KB slice `{rid, role, vendor, files, refs}` plus the verbatim `<peaks-auto-compact>` marker. The forbidden marker `@@@ORCHESTRATOR_SESSION_HISTORY_BOUNDARY@@@` MUST NOT appear in any prompt (unit-tested; regression fails vitest).
452
- - **G8 infinite context**: the child LLM self-monitors context; on ≥0.85 it compacts and writes `.peaks/_runtime/<sid>/detached/<rid>/compact/<n>.json`; on ≥0.95 it writes `status.json` note `'compact-emergency'`. peaks runtime does NOT throttle on token cost — user authorized unlimited spend for G8 (recorded as `tokenUsage` on the dispatch record for audit visibility only).
452
+ - **G8 infinite context (corrected 2026-09-13, rid `2026-09-13-defects-e`)**: the child does **not** and **cannot** compact its own session. `/compact` is not model-invokable, hooks may only observe or veto, there is no `--compact` flag, and no external process can reach a running session's memory — compaction is the child's own harness acting on its own window. What the `<peaks-auto-compact>` marker actually asks for is the reachable half: write the durable state (summary / task state / decisions kept / options discarded) to `.peaks/_runtime/<sid>/detached/<rid>/compact/<n>.json` and heartbeat to `status.json`, so nothing load-bearing lives only in a conversation that will be summarised. Nothing flows back into the child's context — its prompt is the `-p` argv string fixed at spawn. Token cost: peaks runtime has no token-cost throttle to relax (the only guard, `ResourceBudgetGuard`, throttles RSS / CPU / fan-out, never spend), so there is no cost cap — but that is an absence of throttling, not a granted permission with a flag behind it.
453
453
  - **Lifecycle closure invariant**: `pid` / `log.txt` / `status.json` / `owner-session` 100% cleaned on every exit path (success / crash / OOM / SIGTERM). `peaks sub-agent cleanup --orphan` is the only orphan-killing path (RL-15: user-only decision; default is "do nothing").
454
454
  - **Resource budget guard**: `ResourceBudgetGuard` enforces `runtime RSS ≤ 200MB / idle CPU ≤ 5% / fan-out ≤ 8 (default)`. `--no-throttle` bypasses (user accepts risk; adds warning to envelope). `--max-concurrent <N>` overrides the 8 default.
455
455
  - **Vendor-neutral**: `VendorAdapterRegistry` registers `ClaudeAdapter` (Phase A) / `CodexAdapter` + `CopilotAdapter` (Phase B). Missing vendor CLI → fallback to default with `dispatchRecord.warning = 'vendor fallback: <id>→claude'`.
@@ -104,11 +104,13 @@ The CLI gate (`peaks request transition --state qa-handoff`) is the authoritativ
104
104
 
105
105
  | Request type | Required RD evidence (under `.peaks/_runtime/<sessionId>/`) |
106
106
  |---|---|
107
- | `feature` / `refactor` | `rd/tech-doc.md` + `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` + `qa/test-cases/<rid>.md` (qa/test-cases pre-drafted by the 4th sub-agent in peaks-rd's parallel fan-out — slice 004) |
108
- | `bugfix` | `rd/bug-analysis.md` + `rd/code-review.md` + `rd/security-review.md` + `qa/test-cases/<rid>.md` (rd/perf-baseline.md only when the bug is performance-shaped) |
109
- | `config` | `rd/security-review.md` |
107
+ | `feature` / `refactor` | `rd/tech-doc.md` + `rd/code-review-<rid>.md` + `audit/security-<rid>.md` + `audit/perf-<rid>.md` + `qa/test-cases/<rid>.md` (qa/test-cases pre-drafted by the 4th sub-agent in peaks-rd's parallel fan-out — slice 004) |
108
+ | `bugfix` | `rd/bug-analysis.md` + `rd/code-review-<rid>.md` + `audit/security-<rid>.md` + `audit/perf-<rid>.md` + `qa/test-cases/<rid>.md` (the perf artifact is always required; a bug with no perf surface satisfies it with the `N/A — no perf surface` stub) |
109
+ | `config` | `rd/security-review.md` (this one is genuinely ridless — `SECURITY_REVIEW.relativePath` carries no `<rid>`) |
110
110
  | `docs` / `chore` | (no extra evidence required) |
111
111
 
112
+ > The four rid-scoped names above are the gate's **primary** tier (slice `2026-09-14-audit-artifact-rid-scoping`): two slices in one session share `rd/` and `audit/`, so a ridless write silently destroyed the earlier slice's evidence. The pre-rid names (`rd/code-review.md`, `audit/security.md`, `audit/perf.md`, `rd/security-review.md`, `rd/perf-baseline.md`) remain accepted as **back-compat tiers** — they keep old sessions passing, but a new slice must write the rid-scoped name or it reopens the collision.
113
+
112
114
  Always required (in addition to the type-specific row): `ls .peaks/_runtime/<sessionId>/rd/requests/<rid>.md`. Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with PREREQUISITES_MISSING.
113
115
 
114
116
  ```bash
@@ -116,10 +118,10 @@ Always required (in addition to the type-specific row): `ls .peaks/_runtime/<ses
116
118
  ls .peaks/_runtime/<sessionId>/rd/requests/<rid>.md
117
119
 
118
120
  # Type-specific RD evidence (must match the type recorded in the artifact body)
119
- # feature / refactor → ls rd/tech-doc.md rd/code-review.md rd/security-review.md rd/perf-baseline.md qa/test-cases/<rid>.md
121
+ # feature / refactor → ls rd/tech-doc.md rd/code-review-<rid>.md audit/security-<rid>.md audit/perf-<rid>.md qa/test-cases/<rid>.md
120
122
  # (qa/test-cases/<rid>.md pre-drafted by the 4th sub-agent in peaks-rd's parallel fan-out — slice 004)
121
- # bugfix → ls rd/bug-analysis.md rd/code-review.md rd/security-review.md qa/test-cases/<rid>.md
122
- # (rd/perf-baseline.md only when the bug is performance-shaped)
123
+ # bugfix → ls rd/bug-analysis.md rd/code-review-<rid>.md audit/security-<rid>.md audit/perf-<rid>.md qa/test-cases/<rid>.md
124
+ # (the perf artifact is always required; use the "N/A — no perf surface" stub when there is no perf surface)
123
125
  # config → ls rd/security-review.md
124
126
  # docs / chore → (no extra evidence required)
125
127
  # Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with PREREQUISITES_MISSING.