peaks-loop 4.0.52 → 4.0.54

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 (46) hide show
  1. package/CHANGELOG.md +89 -2
  2. package/README-en.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/cli/commands/codegraph-commands.js +164 -5
  5. package/dist/cli/commands/core/memory-command.js +35 -2
  6. package/dist/cli/commands/dispatch-commands.js +4 -2
  7. package/dist/cli/commands/prd-commands.js +15 -0
  8. package/dist/cli/commands/sub-agent-shared.d.ts +23 -0
  9. package/dist/cli/commands/sub-agent-shared.js +39 -0
  10. package/dist/services/artifacts/artifact-prerequisites.js +34 -0
  11. package/dist/services/audit/enforcer-liveness.js +1 -1
  12. package/dist/services/codegraph/codegraph-config-repair-writer.d.ts +44 -0
  13. package/dist/services/codegraph/codegraph-config-repair-writer.js +112 -13
  14. package/dist/services/codegraph/codegraph-exclude-repair.d.ts +23 -1
  15. package/dist/services/codegraph/codegraph-exclude-repair.js +6 -0
  16. package/dist/services/dispatch/sub-agent-dispatcher.d.ts +0 -1
  17. package/dist/services/dispatch/sub-agent-dispatcher.js +0 -3
  18. package/dist/services/evidence/evidence-generator.js +11 -3
  19. package/dist/services/memory/project-memory-service/index.d.ts +1 -1
  20. package/dist/services/memory/project-memory-service/index.js +1 -1
  21. package/dist/services/memory/project-memory-service/store/atomic-write.d.ts +59 -0
  22. package/dist/services/memory/project-memory-service/store/atomic-write.js +167 -7
  23. package/dist/services/prd/gate-evidence-derivation.d.ts +160 -0
  24. package/dist/services/prd/gate-evidence-derivation.js +270 -0
  25. package/dist/services/prd/handoff-auto-regen.js +13 -1
  26. package/dist/services/prd/handoff-frontmatter.d.ts +1 -1
  27. package/dist/services/prd/handoff-frontmatter.js +62 -0
  28. package/dist/services/prd/handoff-gate-evidence.d.ts +95 -0
  29. package/dist/services/prd/handoff-gate-evidence.js +145 -0
  30. package/dist/services/prd/handoff-service.d.ts +21 -1
  31. package/dist/services/prd/handoff-service.js +45 -2
  32. package/dist/services/prd/handoff-types.d.ts +40 -0
  33. package/dist/services/prd/handoff-types.js +28 -1
  34. package/dist/services/prd/project-scan-reader.d.ts +7 -0
  35. package/dist/services/prd/project-scan-reader.js +7 -1
  36. package/dist/services/rd/reviewer-dispatch-policy.d.ts +36 -8
  37. package/dist/services/rd/reviewer-dispatch-policy.js +36 -8
  38. package/package.json +6 -6
  39. package/skills/bee/peaks-rd/SKILL.md +1 -1
  40. package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +26 -10
  41. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +1 -1
  42. package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +6 -1
  43. package/skills/peaks-code/references/periodic-checkpoint.md +7 -5
  44. package/skills/peaks-code/references/startup-sequence.md +1 -1
  45. package/skills/peaks-final-review/SKILL.md +1 -1
  46. /package/{docs → contracts}/test-style-contract.md +0 -0
@@ -26,12 +26,33 @@
26
26
  * PRD handoff + the project-scoped audit templates (slice v2.12.0
27
27
  * Tier 1+2+3 = Group A).
28
28
  *
29
- * The dispatch policy here is the **canonical decision table** consumed
30
- * by the LLM-side runner and pinned by tests:
31
- * - `tests/unit/rd/karpathy-skip-on-config-docs-chore.test.ts`
32
- * (5 → 3 element pinning)
33
- * - `tests/unit/rd/deprecated-reviewer-back-compat.test.ts`
34
- * (NEW in v2.12.0 — 8 cases; back-compat for the 2 removed slots)
29
+ * This module holds the machine-readable decision table for that collapse;
30
+ * the prose the LLM runner actually reads is
31
+ * `skills/bee/peaks-rd/references/parallel-review-fanout.md`. It used to
32
+ * describe itself as "consumed by the LLM-side runner", which named no
33
+ * mechanism — an LLM reads prose, not TypeScript exports — and that is the
34
+ * reason every export below sat at zero importers until slice F2.
35
+ *
36
+ * Pinning is half-done. The two test files this block used to cite —
37
+ * `tests/unit/rd/karpathy-skip-on-config-docs-chore.test.ts` (the 5 → 3
38
+ * element pinning) and
39
+ * `tests/unit/rd/deprecated-reviewer-back-compat.test.ts` (the 8
40
+ * back-compat cases) — were both deleted in `f17aa377`. The **predicate
41
+ * half** was re-pinned by `tests/unit/rd/reviewer-dispatch-policy.test.ts`
42
+ * (`7191140f`, 6 cases: `RD_DEPRECATED_REVIEWERS` + `isDeprecatedReviewer`).
43
+ * The **decision-table half** — `RD_FANOUT_REVIEWERS`' 3-element
44
+ * membership, `reviewerListFor`, `karpathySlotIndex`,
45
+ * `shouldDispatchKarpathy` — still has no pin.
46
+ *
47
+ * Slice F2 (rid-f2-ac1-wiring) gave this module its FIRST caller in
48
+ * `src/cli/commands/sub-agent-shared.ts` (`deprecatedReviewerWarnings`),
49
+ * invoked from the dispatch chokepoint in
50
+ * `src/cli/commands/dispatch-commands.ts` and pinned by
51
+ * `tests/unit/cli/sub-agent-dispatch-deprecated-reviewer.test.ts`. Before
52
+ * that, all 13 exports had zero importers across src/ + packages/ +
53
+ * scripts/, so nothing rejected or rerouted `security-reviewer` /
54
+ * `perf-baseline-reviewer` on the way in. That import is still the only
55
+ * one: the other 12 exports below remain unreferenced in this repo.
35
56
  *
36
57
  * For `config | docs | chore` request types, the slice already skips
37
58
  * the entire fanout (SKILL.md line 132 says "Config / docs / chore: no
@@ -47,8 +68,15 @@
47
68
  * back-compat window. The `isDeprecatedReviewer(name)` predicate lets
48
69
  * dispatchers (or legacy on-disk rd/{security-review,perf-baseline}.md
49
70
  * readers) detect a removed slot and route to the new audit skill
50
- * instead of failing the gate. See Tier 5 (`artifact-prerequisites.ts`)
51
- * for the matching prereq-side back-compat (`mustContainAny` form).
71
+ * instead of failing the gate. Tier 5 (`artifact-prerequisites.ts`)
72
+ * holds the matching prereq-side back-compat: `AUDIT_SECURITY` /
73
+ * `AUDIT_PERF` accept the legacy `rd/security-review.md` /
74
+ * `rd/perf-baseline.md` artifacts via `legacyRelativePaths`.
75
+ *
76
+ * Both halves are wired as of slice F2 and both ACCEPT the legacy slot.
77
+ * The dispatch side emits the reroute notice as a warning
78
+ * (`deprecatedReviewerWarnings`) rather than a refusal, precisely so it
79
+ * does not disagree with the prereq side about the same deprecation.
52
80
  */
53
81
  export const RD_REVIEW_REQUEST_TYPES = [
54
82
  'feat',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peaks-loop",
3
- "version": "4.0.52",
3
+ "version": "4.0.54",
4
4
  "description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
5
5
  "author": "SquabbyZ",
6
6
  "keywords": [
@@ -83,7 +83,7 @@
83
83
  "schemas/*.json",
84
84
  ".claude-plugin/**",
85
85
  "config/eslint/.peaks-rules.cjs",
86
- "docs/test-style-contract.md",
86
+ "contracts/test-style-contract.md",
87
87
  "README.md",
88
88
  "README-en.md",
89
89
  "CHANGELOG.md",
@@ -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.37",
106
- "peaks-loop-mut": "0.1.50",
107
- "peaks-loop-shared": "0.0.86",
108
- "peaks-loop-shared-channel": "0.0.54"
105
+ "peaks-loop-internal-runtime": "0.0.39",
106
+ "peaks-loop-shared": "0.0.88",
107
+ "peaks-loop-shared-channel": "0.0.56",
108
+ "peaks-loop-mut": "0.1.52"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@changesets/cli": "2.31.1",
@@ -65,7 +65,7 @@ Every RD action MUST align with the 4 Karpathy guidelines (full text at `andrej-
65
65
  3. **Surgical Changes** — touch only what the user's request requires. Remove imports / variables / functions that *your* changes made unused. Do not refactor adjacent code. Every changed line must trace to the user's request.
66
66
  4. **Goal-Driven Execution** — define verifiable success criteria (`peaks request show --role rd` carries ACs from PRD). For multi-step work, state plan + verify checkpoints before acting.
67
67
 
68
- Cross-references: Slice 1 PRD §AC-1. The 4-point assertion guard that PRD named was deleted in `f17aa377`; the block below is held by documentation only. The canonical skill id is `andrej-karpathy-skills:karpathy-guidelines`.
68
+ Cross-references: Slice 1 PRD §AC-1. The 4-point assertion guard that PRD named was deleted in `f17aa377`; it is re-pinned by `tests/unit/skills/karpathy-injection.test.ts`, which fails if any of the 4 titles above is dropped. The canonical skill id is `andrej-karpathy-skills:karpathy-guidelines`.
69
69
 
70
70
  ## Scope directory (slice 10 — read scopeDir from envelope)
71
71
 
@@ -20,10 +20,12 @@ end of implementation, RD fires 3 sub-agents in parallel via
20
20
  > `.peaks/project-scan/{security-template, perf-template, audit-output-schema}.md`.
21
21
  > The handoff presence is enforced by the `AUDIT_REQUIRES_HANDOFF` prereq.
22
22
  > The 1-minor-release back-compat window (`v2.12.0`) keeps the old
23
- > `rd/{security-review,perf-baseline}.md` paths readable via `mustContainAny` —
23
+ > `rd/{security-review,perf-baseline}.md` paths readable via
24
+ > `legacyRelativePaths` —
24
25
  > see `RD_DEPRECATED_REVIEWERS` in
25
26
  > `src/services/rd/reviewer-dispatch-policy.ts`. The two unit tests that
26
- > once pinned this were deleted in `f17aa377` and have not been replaced.
27
+ > once pinned this were deleted in `f17aa377`; see §"Deprecated reviewer
28
+ > back-compat" for which half has been re-pinned since and which has not.
27
29
 
28
30
  ## The 3 sub-agents
29
31
 
@@ -72,15 +74,16 @@ end of implementation, RD fires 3 sub-agents in parallel via
72
74
  > - ~~Sub-agent — security-reviewer~~ — moved to standalone
73
75
  > `peaks-security-audit` skill; output `audit/security-<rid>.md`. The legacy
74
76
  > path `.peaks/_runtime/<sessionId>/rd/security-review.md` remains
75
- > readable via `mustContainAny` for the v2.12.0 1-minor-release window.
77
+ > readable via `legacyRelativePaths` for the v2.12.0 1-minor-release window.
76
78
  > - ~~Sub-agent — perf-baseline-reviewer~~ — moved to standalone
77
79
  > `peaks-perf-audit` skill; output `audit/perf-<rid>.md`. The legacy path
78
80
  > `.peaks/_runtime/<sessionId>/rd/perf-baseline.md` remains readable
79
- > via `mustContainAny` for the v2.12.0 1-minor-release window.
81
+ > via `legacyRelativePaths` for the v2.12.0 1-minor-release window.
80
82
  >
81
83
  > See `RD_DEPRECATED_REVIEWERS` in
82
84
  > `src/services/rd/reviewer-dispatch-policy.ts`. The unit test that once
83
- > pinned this was deleted in `f17aa377` and has not been replaced.
85
+ > pinned this was deleted in `f17aa377`; see §"Deprecated reviewer
86
+ > back-compat" for what replaced it.
84
87
 
85
88
  ## Hard prohibitions on all 3 sub-agents (single block)
86
89
 
@@ -199,13 +202,26 @@ failing the gate.
199
202
  - **Legacy review artifact paths**
200
203
  (`.peaks/_runtime/<sessionId>/rd/security-review.md`,
201
204
  `.peaks/_runtime/<sessionId>/rd/perf-baseline.md`) are accepted via
202
- `mustContainAny: [...]` on the `AUDIT_SECURITY` / `AUDIT_PERF` prereqs
205
+ `legacyRelativePaths` on the `AUDIT_SECURITY` / `AUDIT_PERF` prereqs
203
206
  during the back-compat window. v2.13.0 hard-deletes the legacy paths.
204
207
 
205
- **Pinning:** none. The routing + legacy-path acceptance live in
206
- `RD_DEPRECATED_REVIEWERS` / `isDeprecatedReviewer` in
207
- `src/services/rd/reviewer-dispatch-policy.ts`; the unit test that pinned
208
- them (8 cases) was deleted in `f17aa377` and has not been replaced.
208
+ **Pinning — half of it.** The **predicate half**
209
+ (`RD_DEPRECATED_REVIEWERS` + `isDeprecatedReviewer`) is pinned by
210
+ `tests/unit/rd/reviewer-dispatch-policy.test.ts` (`7191140f`, 6 cases), and
211
+ its dispatch-side *use* by
212
+ `tests/unit/cli/sub-agent-dispatch-deprecated-reviewer.test.ts`
213
+ (slice F2, `rid-f2-ac1-wiring`) — that one drives the real dispatch action
214
+ and fails if the reroute notice stops being emitted.
215
+
216
+ The **decision-table half** (`RD_FANOUT_REVIEWERS`' 3-element membership,
217
+ `reviewerListFor`, `karpathySlotIndex`, `shouldDispatchKarpathy`) has **no
218
+ pin**: the file that carried it was deleted in `f17aa377` and was not
219
+ replaced. The routing + legacy-path acceptance live in
220
+ `src/services/rd/reviewer-dispatch-policy.ts`; the module had **no caller
221
+ at all** until slice F2 wired `deprecatedReviewerWarnings`
222
+ (`src/cli/commands/sub-agent-shared.ts`) into the dispatch chokepoint. The
223
+ dispatch side therefore ACCEPTS the legacy slot and warns, rather than
224
+ refusing — matching the prereq-side acceptance above.
209
225
 
210
226
  ## Gate C evidence (RD-side, type-specific)
211
227
 
@@ -109,7 +109,7 @@ Any RD/QA/SC sub-agent dispatched by `peaks sub-agent dispatch --from-dag` (or b
109
109
 
110
110
  **Where the orchestrator reads the values from**: `data.orchestratorVisibleHint` (one line, copy verbatim) and `data.artifactsPublicPaths` (the public list of artifact paths the sub-agent will own). The CLI fills these in; the orchestrator just transcribes.
111
111
 
112
- **Regression guard**: none. The unit test that parsed `rd-sub-agent-dispatch.md` and asserted the G11.5 heading is present was deleted in `f17aa377`. The heading is held by convention only — do not delete it.
112
+ **Regression guard**: `tests/unit/skills/g11-5-title-lock.test.ts` — it pins this file's G11.5 heading and the `⏳ Spawning sub-agent via Task tool: <description>` form. The original guard (the unit test that parsed `rd-sub-agent-dispatch.md` and asserted the G11.5 heading is present) was deleted in `f17aa377`; the pin was restored in slice D2 (2026-09-18), which found that the AC-3 title-lock had covered only the peaks-code sibling of this file. Do not delete the heading.
113
113
 
114
114
  ---
115
115
 
@@ -42,6 +42,7 @@ schemaVersion: '2.0'
42
42
  ---
43
43
  ```
44
44
 
45
+ > The `gateEvidence` block above is the **feature-shaped** set, shown because it is the largest one. It is not a template to copy by hand: the producer derives the block from the request `type` (see the `gateEvidence` rule below), so a `config` slice's carries two keys and a `docs` / `chore` slice's capsule carries no such block at all.
45
46
  ## Field rules
46
47
 
47
48
  - `requestId` — kebab-case; matches the PRD `requestId`.
@@ -50,7 +51,11 @@ schemaVersion: '2.0'
50
51
  - `decisions[]` — every decision an LLM made that an implementer could question. `id` is local; `summary` is one line; `rationale` is ≤ 2 sentences.
51
52
  - `risks[]` — same shape; `mitigation` is required. A risk without a mitigation is a red line (gate blocked).
52
53
  - `nextActions[]` — verb-first; what peaks-qa should do next, in order.
53
- - `gateEvidence` — paths to the gate files peaks-qa will validate. Missing keys → Gate C failure.
54
+ - `gateEvidence` — paths to the gate files peaks-qa will validate. **DERIVED, never hand-written**: the producer computes it from the request `type` (`src/services/prd/gate-evidence-derivation.ts`), and Gate C reads the same `rd:qa-handoff` row, so the block and the gate cannot disagree. It declares that row's evidence, plus `projectScan` (Gate A's artifact — declared only where Gate C runs, since a path nothing verifies should not be declared):
55
+ - `feature` / `refactor` / `bugfix` → **5 keys**: `projectScan`, `prdHandoff`, `codeReview`, `securityReview`, `perfBaseline`
56
+ - `config` → **2 keys**: `projectScan`, `securityReview`. `CONFIG_TABLE['rd:qa-handoff']` is the security review alone, so a config slice has **no** `prdHandoff`; and its security evidence is the genuinely ridless `rd/security-review.md`, not `audit/security-<rid>.md`.
57
+ - `docs` / `chore` → **no `gateEvidence` block at all**. Those types have no `rd:qa-handoff` row: there is no evidence to declare and nothing for Gate C to check, so the block is omitted rather than filled with an unverified statement. Such a capsule is byte-identical to a pre-B2 one.
58
+ **The Gate C failure rule is scoped to the types above** — where that gate runs: a declared path that does not exist fails `peaks request transition --state qa-handoff` (`PREREQUISITES_MISSING`), naming the key. Two shapes are deliberately NOT failures: a capsule for a type with no `rd:qa-handoff` row (the check does not run), and an **empty** declaration (`gateEvidence: {}`) — a weak claim, not a false one, since the type's artifacts remain enforced by the table itself, so an empty map cannot open the gate. When the request type cannot be resolved at all, the block is omitted rather than half-declared.
54
59
  - `schemaVersion: '2.0'` — pinned (bumped from `'1.0'` in v2.11.0); bump only when the field set changes.
55
60
 
56
61
  > **v2.11.0 Group A change:** `schemaVersion` was bumped to `'2.0'`. The consumers listed under §Validation anchor on that value, so a file still carrying `'1.0'` is rejected at read time.
@@ -20,14 +20,16 @@ checkpoint as often as it wants.
20
20
 
21
21
  > **Slice 2026-06-24-efficiency-4p-bundle / G1 (P0.1) — frequency lock**:
22
22
  > The `--reason periodic` row above is hard-locked at **20 tool calls**.
23
- > The threshold is a textual contract between SKILL.md (line 79) and
24
- > this reference doc; the LLM runner is expected to fire
25
- > `peaks session checkpoint --reason periodic` once every 20 tool calls
23
+ > The threshold is a textual contract between `startup-sequence.md` (Step N:
24
+ > Periodic checkpoint) and this reference doc; the LLM runner is expected to
25
+ > fire `peaks session checkpoint --reason periodic` once every 20 tool calls
26
26
  > (i.e. on each 20-call mark, not "approximately every 20"). The CLI
27
27
  > does **not** expose a `--periodic-every <n>` override flag — the
28
28
  > cadence is owned by the skill, not the CLI. Any patch that relaxes
29
- > this must update both files in lockstep; no guard fails on the drift
30
- > — the test that pinned the cadence was deleted in `f17aa377`.
29
+ > this must update both files in lockstep —
30
+ > `tests/unit/skills/periodic-checkpoint-cadence.test.ts` fails on the
31
+ > drift (it pins the number in both files, the hard-lock wording, and the
32
+ > CLI's lack of the override).
31
33
 
32
34
  ## Checkpoint CLI contract
33
35
 
@@ -19,7 +19,7 @@ When a NEW conversation opens on a session whose `lastActivity` is from today AN
19
19
 
20
20
  ### Peaks-Loop Step N: Periodic checkpoint (auto-fire, no user action)
21
21
 
22
- Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write. See `periodic-checkpoint.md` (no guard fails on a missed cadence — the test that did was deleted in `f17aa377`).
22
+ Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write. See `periodic-checkpoint.md` (the cadence is pinned by `tests/unit/skills/periodic-checkpoint-cadence.test.ts`, which fails if either file's number drifts).
23
23
 
24
24
  ### Peaks-Loop Step 0.6: Audit + Goal (NEW)
25
25
 
@@ -230,6 +230,6 @@ When handing off, emit: rid, `allPass`, `needsAttention[]`, output path, source
230
230
  | `src/services/final-review/final-review-types.ts` | `FinalReviewOutput`, `DimensionEvidence`, verdict/evidence/confidence enums. |
231
231
  | `src/services/audit/audit-goal-service.ts:16` | Line of evidence that `LlmRunner` is reusable across audit + final-review (service-level integration). |
232
232
  | `tests/unit/final-review/final-review-service.test.ts` | Service-level unit tests (8 cases: evidence inlining, the no-evidence⇒no-`pass` gate, prompt bounds, plus contract guards). |
233
- | `docs/superpowers/plans/2026-06-25-slice-topology-multipass-phase-4.md:127` | Phase-4 plan prose (Task 14). |
233
+ | *(retired — no file)* | The Phase-4 plan prose (Task 14) this row used to cite was deleted in `e6e35842`; no file on this tree carries it, and nothing pins it since. |
234
234
  | `skills/bee/peaks-qa/SKILL.md` | Upstream QA skill — 4-dim review is downstream of all QA gates. |
235
235
  | `skills/peaks-audit/SKILL.md` | Sibling skill — produces the `audit-goal` JSON that this skill consumes. |
File without changes