Skip to content

research(plan-memory-rphase): ADOPT Direction B — shadow cache file with @dual-pair annotation - #230

Merged
artyhoo merged 2 commits into
stagingfrom
research/plan-memory-rphase
May 25, 2026
Merged

research(plan-memory-rphase): ADOPT Direction B — shadow cache file with @dual-pair annotation#230
artyhoo merged 2 commits into
stagingfrom
research/plan-memory-rphase

Conversation

@artyhoo

@artyhoo artyhoo commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

R-phase verdict for meta-orchestrator-plan-memory-rphase umbrella:

  • ADOPT Direction B — shadow cache file (.claude/orchestrator-prompts/_plan-cache.md) committed to repo; auto-updated via !shell injection in SKILL.md §1 on every invocation.
  • REJECT Direction A — in-place edit of wave-sequencing-plan.md (blast radius HIGH per Q1; concurrent-write race risk per Q3; ~90s update latency > 5s falsifier per Q4).
  • SSOT row docs(research): cross-worktree gitignored coord-doc sync — verdict ADAPT #77 appended: Cline Memory Bank committed-markdown sub-pattern, ADAPT verdict (~85% match on storage format; update trigger diverges).

Files changed

T19 Cold-QA: BLOCKERS=0, MAJORS=0, MINORS=0

§1.7 Forward-check applied

SSOT register touched — §4b triggered per phase-research-coverage.md §1.7.

  • no-paid-llm-in-ci.md §1: evidence from DeepWiki queries (session-bound, not CI-billed) + local tool calls — compliant (docs/meta-factory/research-patches/2026-05-25-plan-memory-rphase.md:200 — «Fully compliant with no-paid-llm-in-ci.md §1»).
  • build-first-reuse-default.md §3: ADAPT verdict (not BUILD) after confirmed ~85% match on Cline committed-markdown sub-pattern — compliant (docs/meta-factory/research-patches/2026-05-25-plan-memory-rphase.md:241 — §3 prior-art extension, 4 items a-d with DeepWiki 3-query evidence).
  • doc-authority-hierarchy.md §2: patch inherits folder-level authority from docs/meta-factory/research-patches/README.md; SSOT row follows existing table format — compliant.
  • Principle 10 (10-research-patch-annotation.test.ts): <!-- scope:plan-memory-rphase --> annotation on first line of patch — verified by pre-push hook (18/18 principle tests pass).

§1.7 Backward-check applied

Commits

  • 42c43ac research(plan-memory-rphase): ADOPT Direction B — shadow cache file with @dual-pair annotation
  • 1651b65 fix(plan-memory-rphase): add missing scope annotation to research patch

ATTN

audit-ai-docs.test.ts mutation tests have elevated timeouts locally when ts-morph absent — pre-existing (zero diff from staging baseline). CI will pass (pnpm workspace has ts-morph in GitHub Actions).

artyhoo added 2 commits May 25, 2026 19:23
…ith @dual-pair annotation

R-phase verdict for meta-orchestrator-plan-memory-rphase umbrella.
Answers Q1–Q8 with command/file:line/DeepWiki evidence. Runs §3 prior-art
extension on 4 deferred items (AIF /aif-evolve, state.md measurement,
Tier-1 sweep, 6-item Superpowers negative-claim coverage). Commits to
ADOPT Direction B: shadow cache file (.claude/orchestrator-prompts/_plan-cache.md),
committed markdown, deterministic auto-update on every /meta-orchestrator
invocation via existing !shell injection, @dual-pair annotation for drift
check. Direction A (extend wave-sequencing-plan.md §0 in-place) blocked by
HIGH blast radius (Q1: 1,125-char rows, 6–8 non-unique fragments) and
concurrent-session race risk (Q3: 19 commits in 90 days). All 5 falsifiers
checked; none fire (Q4: ~90s avg > 5s threshold; §6.2: 85+ UNTRACKED > ≤5;
§6.3: 63 kickoffs > ≤4). SSOT row #77 appended: Cline Memory Bank
committed-markdown sub-pattern, ADAPT (~85% match on storage format;
REJECT on-demand update trigger). T15: Track row admission declared for
I-phase shipping PR.

Prior-art: prior-art-evaluations.md#77 (Cline Memory Bank committed-markdown sub-pattern, ADAPT — Direction B shadow cache file adopts committed-markdown storage, rejects on-demand update trigger in favour of deterministic auto-update on every invocation)
Principle 10 requires <!-- scope:<slug> --> on first line of every
research patch. The patch 2026-05-25-plan-memory-rphase.md was missing
this annotation; pre-push hook caught the violation.

Prior-art: skipped — single-line annotation fix, no new capability
@artyhoo
artyhoo merged commit 2d8468e into staging May 25, 2026
27 of 28 checks passed
artyhoo pushed a commit that referenced this pull request Aug 9, 2026
…ip pivot

Round-1 verdicts: REVISE x2 (3 BLOCKER, 18 MAJOR combined). Load-bearing
changes: Part-2 transport pivots from a send_message bus to park-chips
riding the D1 chip channel (bus discovery is impossible — sessions cannot
self-title, schema-verified; night-local senders would re-admit the
wake-up cost; bursts are the observed park shape). D7 hardened (isSidechain
filter, model-keyed window table, F10 placement constraint, consumer-generic
wording, guarded TMPDIR). D8 reshaped to SSOT #108 hook-writes-residue form,
parked on the open #108 operator decision + bench-test. D9 kickoff gains its
bridge-profile marker (acceptance-contour rule is live) + K-pass station.
F3 downgraded to unverified (selection-conditioned statistic). SSOT consult
now cites #108/#121/#122/#230 by ID.
artyhoo added a commit that referenced this pull request Aug 9, 2026
…ADR + D9 kickoff (#1325)

* docs(arch-prep): pipeline chips + session bus + context handoff — design-state handoff

Mid-contour /arch handoff: Parts 1/3/4 settled (chips, handoff policy with
operator-corrected thresholds, calibration research task), Part 2 (signal bus)
reopened for a value-rethink by operator directive. Continuation session
resumes via §0 protocol; this doc dogfoods the Part-3 residue mechanism.

* docs(arch): pipeline chips + session bus + context handoff — reviewed ADR + D9 kickoff

Part-2 bus rethink executed per prep-doc §0: friction inventory (6 relay
classes, live-probed evidence incl. F5 split verdict + 25-session ccd
topology) collapses the drafted 5-signal broadcast bus to ONE edge-pair —
the attended-day parked-question round-trip (D3-D5), with chips (D1-D2)
and the Stop-hook context-arm + PreCompact backstop (D6-D8) carrying the
rest. D9 calibration research kickoff authored (no bridge:auto marker by
design — dispatch only after staging merge).

* docs(arch): round-2 revision after cold two-altitude review — park-chip pivot

Round-1 verdicts: REVISE x2 (3 BLOCKER, 18 MAJOR combined). Load-bearing
changes: Part-2 transport pivots from a send_message bus to park-chips
riding the D1 chip channel (bus discovery is impossible — sessions cannot
self-title, schema-verified; night-local senders would re-admit the
wake-up cost; bursts are the observed park shape). D7 hardened (isSidechain
filter, model-keyed window table, F10 placement constraint, consumer-generic
wording, guarded TMPDIR). D8 reshaped to SSOT #108 hook-writes-residue form,
parked on the open #108 operator decision + bench-test. D9 kickoff gains its
bridge-profile marker (acceptance-contour rule is live) + K-pass station.
F3 downgraded to unverified (selection-conditioned statistic). SSOT consult
now cites #108/#121/#122/#230 by ID.

* docs(arch): round-2 delta findings applied — bounded fixes + two operator forks

All round-1 findings closed per both delta seats (BLOCKER 3/3, rest
resolved/accepted). Round-2 fixes: allowed-tools MCP adds DROPPED (would
turn principle 21 red — MCP_TOOL_RE rejects underscored ccd server names;
regex defect routed as separate owner issue); chip title/tldr contract
fits the 60-char cap; stage-gate resolved at click time not frozen;
principle-18 substring extension asserts the three chip gates; park-chip
emitter = dispatcher-only v1; seat line + venue-tier row in §4; D8
rescoped to the #108 PreCompact ITEM (composite row) with its own
liveness bench + named reader (pipeline §1 injection) + emitClaude path
(plugin output skips PreCompact); §2 park numbers corrected (7+1 of 30
substantive); F6 closed-moot, F9 (chip visibility/seat) added; F1 and
F10 restated as explicit operator forks. 2-round review cap reached —
remaining items are operator-facing by design.

---------

Co-authored-by: Test <test@example.com>
artyhoo added a commit that referenced this pull request Aug 9, 2026
…ecycle protocol (SLP) (#1346)

* docs(arch-prep): pipeline chips + session bus + context handoff — design-state handoff

Mid-contour /arch handoff: Parts 1/3/4 settled (chips, handoff policy with
operator-corrected thresholds, calibration research task), Part 2 (signal bus)
reopened for a value-rethink by operator directive. Continuation session
resumes via §0 protocol; this doc dogfoods the Part-3 residue mechanism.

* docs(arch): pipeline chips + session bus + context handoff — reviewed ADR + D9 kickoff

Part-2 bus rethink executed per prep-doc §0: friction inventory (6 relay
classes, live-probed evidence incl. F5 split verdict + 25-session ccd
topology) collapses the drafted 5-signal broadcast bus to ONE edge-pair —
the attended-day parked-question round-trip (D3-D5), with chips (D1-D2)
and the Stop-hook context-arm + PreCompact backstop (D6-D8) carrying the
rest. D9 calibration research kickoff authored (no bridge:auto marker by
design — dispatch only after staging merge).

* docs(arch): round-2 revision after cold two-altitude review — park-chip pivot

Round-1 verdicts: REVISE x2 (3 BLOCKER, 18 MAJOR combined). Load-bearing
changes: Part-2 transport pivots from a send_message bus to park-chips
riding the D1 chip channel (bus discovery is impossible — sessions cannot
self-title, schema-verified; night-local senders would re-admit the
wake-up cost; bursts are the observed park shape). D7 hardened (isSidechain
filter, model-keyed window table, F10 placement constraint, consumer-generic
wording, guarded TMPDIR). D8 reshaped to SSOT #108 hook-writes-residue form,
parked on the open #108 operator decision + bench-test. D9 kickoff gains its
bridge-profile marker (acceptance-contour rule is live) + K-pass station.
F3 downgraded to unverified (selection-conditioned statistic). SSOT consult
now cites #108/#121/#122/#230 by ID.

* docs(arch): round-2 delta findings applied — bounded fixes + two operator forks

All round-1 findings closed per both delta seats (BLOCKER 3/3, rest
resolved/accepted). Round-2 fixes: allowed-tools MCP adds DROPPED (would
turn principle 21 red — MCP_TOOL_RE rejects underscored ccd server names;
regex defect routed as separate owner issue); chip title/tldr contract
fits the 60-char cap; stage-gate resolved at click time not frozen;
principle-18 substring extension asserts the three chip gates; park-chip
emitter = dispatcher-only v1; seat line + venue-tier row in §4; D8
rescoped to the #108 PreCompact ITEM (composite row) with its own
liveness bench + named reader (pipeline §1 injection) + emitClaude path
(plugin output skips PreCompact); §2 park numbers corrected (7+1 of 30
substantive); F6 closed-moot, F9 (chip visibility/seat) added; F1 and
F10 restated as explicit operator forks. 2-round review cap reached —
remaining items are operator-facing by design.

* docs(arch-prep): session-bus v2 fresh-take handoff — membrane protocol

Operator read the round-2 explanation and re-opened Part 2 with three
counter-resolutions: (1) addressing inverts to an ID-cascade at spawn
(parents register children; the fresh-/arch handoff moment doubles as the
address-book handover), (2) night autonomy — the top-tier seat decides
parked strategic questions overnight, operator reviews in the morning
(deliberate control-model change superseding 'stay parked — never guess'),
(3) bursts accepted. Fresh Fable session designs from zero reading ONLY
§1; verified facts (§2 — incl. two NEW ones: self-ID via hook stdin
session_id, and no click-free session birth in the ccd toolset) + prior
takes (§3 digest) stay sealed until the Opus skeptic phase. ADR #1325
Parts 1/3/4 stand; D3-D5/§4/F1 re-opened.

* docs(arch): session-bus v2 — Phase-A from-zero draft (membrane-sealed)

Phase A of the v2 fresh-take protocol (arch-prep-session-bus-v2.md $0).
Author input: prep $0 + $1 ONLY. Sealed surfaces untouched at authoring
time: prep $2, prep $3, merged ADR Part-2 sections, branch git history.
All environmental assumptions tagged [A1]-[A10] and registered in $12
for the Phase-B fact-check; two cold mid-tier review seats follow per
arch/SKILL.md $2.

* docs(arch): session-bus v2 — Phase-B fact reconciliation

Opened prep $2-$5 (per protocol, after the pure draft landed as
42f8836) and corrected the draft against verified facts:
- [A4] resolved: self-ID via hook stdin session_id -> registry
  self-publish; root-seeding launcher magic dropped; [A3] moot.
- [A1]/[A2] resolved: delivery = user turn in running targets;
  night vehicle = operator-launched local session with pre-existing
  loop (cron-born sessions are messaging-blocked both ways).
- No programmatic session birth: day spawn = chip/paste; night
  topology fixed at lights-out; no chips inside the bus.
- aif workers messaging-blocked: dispatcher doorbells PARKED on
  observe; ANSWERED goes to local parkers only (bridge unpause is
  the workers' edge).
- Digest items absorbed: queue-not-interrupt, stale-target isRunning
  rule, venue-tier naming, answer.ts as the only rework channel,
  dispatcher $3 + night-mode delta-8 amended in the same change.
- Added old-ADR $4 scoring-row answers table; $12 rewritten as the
  fact register with citations + carried probes.

* docs(arch): session-bus v2 — r1 revision after two cold REVISE verdicts

Restructured into two separately-shippable parts:
- Part I: night-autonomy control model, bus-free (the return leg is
  already automatic via answer.ts unpause); THREE policy surfaces
  (dispatcher $3 row + night-mode delta items 1 AND 8); night
  artifacts REUSE <plan>.decisions.md + morning report; corpus-vs-
  envelope validation required before landing.
- Part II: doorbell overlay, probe-gated (P1 idle-wake, P2 night-loop
  arm-predicate extension, P3 isRunning stickiness).

Key corrections: self-ID-via-hook interpretation SUPERSEDED (hook
session_id and ccd local_<uuid> are disjoint namespaces, no join) --
addressing re-keyed to role->{cwd,branch} per-role files in the
coordination canon, resolved at send via list_sessions cwd-match;
ANSWERED reserved + workers.* dropped (empty recipient class);
grammar carries task=<task.id> only; executable claim reshaped to a
packages/ grep-gate; night latency claim downgraded until P1/P2.

Full finding-by-finding dispositions inlined in $14 (both reports).

* docs(arch): session-bus v2 — r2 repairs + operator split directive

Round-2 cold verification (REVISE) absorbed, finding-by-finding in
$14b. Key changes:
- P2 arm-predicate driver RETIRED (Stop hook cannot originate turns;
  global predicate = load-bearing; D7 owns the arm layout). Night leg
  now rests on P1 (idle-wake) and F4 (CLI spawn), both probes.
- Addressing: branch tiebreak dropped (live-stale 3/4, absent on
  repo-root); cwd-only exactly-one-match rule; seat-worktree
  invariant; liveness predicate removed; P4 join-verification is the
  Part-II entry condition; pagination bounded.
- Kill-switch: OFF tombstone (dir absence self-healed); seat writes
  gated by the same enable check.
- Part-I amendment reworded bus-free; arch $4 recorded as
  availability degradation, not reassignment; corpus gate carries the
  population-proxy caveat; grep-gate channel constrained outside
  packages/; SSOT consult marked nominal for this area.
- Operator mid-r2 directive recorded: night as several communicating
  self-respawning sessions -> F4 elevated to co-critical probe;
  positive F4 retires the T_soft defer-to-morning floor.

Review cap (2 rounds) reached -- routing fork with the operator.

* docs(arch): session-bus v2 — night continuation ladder (handoff vs compact)

Operator follow-up formalized: handoff and auto-compact fill the same
continuation slot; F4's outcome decides which fills it at night.
Rung 1: artifact-first recording makes either safe (state re-derivable
from seat file + questions.ts + decisions.md). Rung 2: Part-3 handoff
(ADR D6-D8, reused not re-opened) -- day always, night iff F4. Rung 3:
auto-compact in place with D8 PreCompact preservation + T_soft floor.
Probes P1/P4/F4 deferred to separate tasks per operator.

* docs(arch-prep): autonomous-night v3 handoff — /night-mode joins the seat design

Continuation handoff (not a membrane fresh-take): v2 spec stands
r2-repaired at the review cap. v3 scope per operator directives:
/night-mode designed into the four-skill architecture; all seats use
the bus; self-cleaning at a context cap; chips where needed;
maximally autonomous within the reversibility envelope. Carries the
unresolved Part-I routing fork, the probe register (P1/F4 co-critical),
and five open design questions.

* docs(arch): autonomous-night v3 design — night as mode, seat lifecycle protocol, ceiling

Phase-1 ideation output of the v3 contour (arch-prep-night-v3 §1 directives).
Part I of session-bus v2 folded in (routing decision §1.1). Night = MODE not
seat role (D-v3.1, operator-ratified); one seat-lifecycle SSOT + four pointers
(D-v3.2); self-cleaning bound to D6/D7/D9 with new probe recipe F4b (D-v3.3);
explicit autonomy ceiling reconciling v2 floor with night-mode item 8 (D-v3.4);
one new chip edge (morning report); zero new bus verbs; corpus-vs-envelope
validation run (25 entries, ~10/21 in-envelope — envelope stands).

Prior-art: skipped — design doc only, no new capability; sequencing of settled
in-repo mechanisms (ADR D6-D8, v2 §4-§9, night-mode/SDD).

* docs(arch): night-v3 r1 — repairs after two cold REVISE verdicts

Absorbs top-down (2 BLOCKER / 7 MAJOR / 6 MINOR) + bottom-up (1 BLOCKER /
3 MAJOR / 6 MINOR). Headline repairs: F4b re-scoped to sandbox PROBE (zero
hook edits reaffirmed; consumer-shipped surface + inverted billing fact
corrected — Agent-SDK credit at API rates, cost-GO gate added); ceiling
re-cut by decision OBJECT after the lane cut failed on corpus member
#1311.4 (v2 §4 floor clause explicitly superseded, pointer at landing);
SLP phases split NOW vs PART-II-GATED; three roles enumerated (/pipeline
= day seat by policy); rule-file gates added (Class B, paths channel,
principle-31 + index regen); all 6 relative links fixed to ../../../;
full disposition table inlined (§13, 23 findings).

Prior-art: skipped — design doc revision, no new capability.

* docs(arch): night-v3 r2 repairs — spec ROUND-2 REPAIRED at the review cap

r2 verification: REVISE at cap, design spine verified sound (21/23 r1
dispositions DISCHARGED, both BLOCKERs closed, object cut re-tested cold
on three corpus members). All residue repaired in place: 4KB index ceiling
precondition billed (4088/4096 spent — free bytes before landing the new
rule); /pipeline night delta billed as the FOURTH policy surface; item 5
added to the night-mode item mapping; paths-channel labelling corrected to
principle-31 branch (a); seat-file vocabulary Part-II-gated in §2; floor-
dominates-stage-scope precedence added (§6, live case #1311.3); §7 chip
commitments billed in §10.5; §10 reordered [Part-I]-first so Part-I
extraction stays cheap. Dispositions inlined at §13b.

Prior-art: skipped — design doc revision, no new capability.

* docs(arch): night-v3 post-cap absorptions — billing fact live-verified, F4b audience directive

Two operator inputs after the review cap (fact/directive absorption, no
design re-opening): (1) billing re-verified against official sources —
the announced 2026-06-15 separate Agent-SDK credit pool was PAUSED on its
effective date; claude -p / Agent SDK draw from the subscription pool;
r1's memory-based correction and the underlying memory record were both
stale; cost-GO gate retired, re-open falsifier recorded. (2) F4b landing
audience decided: consumer-shipped self-cleaning autonomy is the product
intent (operator directive quoted); engineering guards non-negotiable;
F10 wording fork still closes formally at S2a. Dispositions in §13b.

Prior-art: skipped — design doc fact refresh, no new capability.

* docs(autonomous-night-v3): Phase C — Part-I night envelope + seat lifecycle protocol

Lands the v3 spec §10 work list (docs/superpowers/specs/2026-08-09-autonomous-night-v3-design.md):

- [Part-I] four policy surfaces in ONE change: dispatcher §3 Night cell
  (bus-free wording, v2 NEW-M1), night-mode delta items 1+8 (night-envelope
  conditional, §6 object cut, ambiguous-object→floor tie rule, decisions.md
  entry-shape extension), pipeline night delta (no new-scope planning at
  night); night-mode also gains the §5 seat-class item mapping sentence.
- [Part-I] morning report: «bus anomalies» section + night-decided parks
  listing + night-end chip paragraph + best-effort dismiss_task note.
- [Part-I] supersession pointer at the v2 §4 floor clause («merges into
  shared branches») → v3 §6 object cut; all other floor items unchanged.
- [v3] new .claude/rules/seat-lifecycle.md (SLP) — Class B, paths: channel
  (principle 31 branch (a)) over the four seat-architecture SKILL.md files;
  four 3-5-line pointer blocks; compensating grep check at
  packages/core/skills/seat-lifecycle-pointer.test.ts.
- [v3] rule-index bytes freed first (4088/4096 → 4070 after adding the row):
  trimmed three verbose Fires: lines (git-conflict-merge-forward,
  evidence-regeneration, zcode-parity-doctrine) per the renderer's stated
  remedy; index + AGENTS.md region regenerated.
- [v3] v2 §13 F4 probe entry extended: F4a+F4b as PROBES with the v3 §4
  checks incl. the live-verified subscription-pool billing fact; cost-GO
  gate retired. Zero hook edits anywhere in this change.

Prior-art: skipped — doc/discipline artifacts + one suite test only; no new dependency, no ≥80-LOC file under packages/, no new capability.
§1.7: forward+backward applied (full sections in PR body); cold backward sweep GO — pointer parity asserted at packages/core/skills/seat-lifecycle-pointer.test.ts:19; channel declaration per packages/core/principles/31-rule-channel-declaration.ts:1

---------

Co-authored-by: Test <test@example.com>
artyhoo added a commit that referenced this pull request Aug 9, 2026
… F10 closed consumer-generic (#1349)

## Summary

Stage S2a of the pipeline-chips/session-bus contour: the Stop hook gains the D7 context-arm — a deterministic handoff trigger that measures the session's context from the transcript and, past a soft threshold, blocks once per tier with a generic "write a handoff note / finish mechanical tails in place" reminder. Closes operator fork F10 as consumer-generic (evidence: the operator's 2026-08-09 consumer-shipped directive), recorded in the ADR §7 row.

## Changes

- `.claude/hooks/end-of-turn-reminder.sh` — D7 context-arm: last MAIN-THREAD assistant entry (`select(.isSidechain != true)`), sum of input+cache_read+cache_creation tokens; model→window table with `unknown → 200k` fallback + the self-evident `>200k ⇒ 1M` override; computed at the TOP with every early return routed through the extended `_autonomy_exit` shim (2026-07-24 postmortem); `decision:block` riding the SAME block as any recap/autonomy line; once-per-session-per-tier debounce (`${TMPDIR:-/tmp}/aif-ctx-<sid>-<tier>`, brace-grouped flag write); generic consumer wording, zero framework refs (test-asserted).
- `packages/core/hooks/end-of-turn-reminder.test.ts` — 13 new discriminating cases (65/65 green): threshold pair 139999/140000, sidechain filter, per-tier debounce incl. `1m-deep` re-fire at 510k, 1M override at 250k, both 1M model-id spellings, ZCode no-usage inertness, composition with Branch A and with the F10 autonomy arm inside the exit shim.
- `.claude/rules/zcode-parity-doctrine.md` §2 — row 9 `parity → zcode-gap` + rollup recount (10+1+2+1+4+2=20), per the row-13 one-working-arm precedent.
- `docs/superpowers/specs/2026-08-09-pipeline-chips-session-bus-design.md` §7 — F10 `OPEN → CLOSED consumer-generic` with the ratifying directive cited.
- `plugin/hooks/end-of-turn-reminder` — twin regenerated (byte-identical modulo generated header).
- `tests/install-sh/baselines/*` — 8 fingerprints regenerated (the shipped hook changed).

Thresholds are provisional parameters — D9 (`context-degradation-calibration`, aif task `0517063b`) calibrates them.

## Prior-art consult

- [x] Capability commits in this PR carry a `Prior-art:` trailer (or `skipped — <≥20 chars rationale>` for hook-flagged commits that aren't real capability additions). See CONTRIBUTING.md. (`Prior-art: skipped — extends the existing Stop-hook arm per merged ADR D7; no new capability, no new dependency`)
- [x] If a new capability area surfaced during this PR: n/a — no new capability area; the ADR's D6 consult (SSOT #230/#122) covers the handoff-policy prior art.
- [x] If existing entries matched: n/a (no SSOT entry touched).
- [x] context7 queries: n/a — implementation of an already-designed, already-consulted mechanism.

## Test plan

- [x] §1.7-свод lands in squash-body (`gh pr merge --squash --body "$(gh pr view <N> --json body -q .body)"`)
- [x] `npx vitest run packages/core/hooks/end-of-turn-reminder.test.ts` — 65/65
- [x] `npx vitest run packages/core/principles/21-agnosticism-conformance.test.ts` — 14/14
- [x] `bash tests/install-sh/byte-identical.test.sh` — 2 pass / 0 fail (incl. shellcheck 21 files clean)
- [x] `shellcheck -S warning .claude/hooks/end-of-turn-reminder.sh` clean
- [x] Manual smoke: 153k transcript → single `decision:block` with the generic line; ZCode-shape (no usage) → silent; read-only TMPDIR → no stderr leak, fail-open re-fire preserved.

## Provenance

Stage S2a of `docs/superpowers/specs/2026-08-09-pipeline-chips-session-bus-design.md` §6 (D7, all seven constraints) · base `e23477857dbf` (staging post-#1346) · substrate: in-session (per §6 route "prefer in-session") · model: Fable 5 (implementation) + cold reviewer sub-agent (T19) · fidelity Round 2.

## Review findings

Cold T19 review (fresh reviewer over the actual diff, then Round-2 verification against the committed tree — not the author's narrative):

- Round 1: **REVISE** — 1 BLOCKER (install-sh fingerprints not regenerated → deterministic red snapshot gate), 2 MINOR (debounce flag write leaked stderr on failure — redirect applied after the simple-command's own; three surviving mutations: `-1m` table branch, `1m-deep` tier, combined autonomy+ctx composition in the exit shim).
- Round 2 (same seat, resumed; input = the committed tree at `c603779d54`): **GO** — all three closed with live-run evidence (byte-identical 2/2; read-only-TMPDIR probe `rc=0 stderr_bytes=0`; each new test verified to discriminate its mutation).

### Watch-list

- `[1m]`/`-1m` model-id marker reachability in real CC transcripts is unverified in-repo — if real transcripts never carry it, window resolution rests solely on the `>200k` override (matches the ADR's stated honest limit). Routed to D9 calibration as an input. Round 2: N/A (documented limit, not a defect).

## Fidelity verdict

FIDELITY: GO
Basis: docs/superpowers/specs/2026-08-09-pipeline-chips-session-bus-design.md
Round: 2
Audited-SHA: c603779
Evidence: packages/core/hooks/end-of-turn-reminder.test.ts:1288

## Parked questions

none

## §1.7 Self-discipline check (REQUIRED if PR touches discipline-bearing files)

### §1.7 Forward-check applied

- attention-is-not-a-mechanism.md §1: the handoff trigger is a deterministic gate-shaped injection (measured tokens → block), not "the model will notice its context is long"; delivery is decision:block, the only model-reaching Stop channel (`.claude/hooks/end-of-turn-reminder.sh:477` composition comment block).
- no-paid-llm-in-ci.md: the arm is bash+jq over the transcript; zero API-billed calls.
- rule-enforcement-channel-selection.md: the handoff decision itself is judgment → the arm injects the policy line, never forces the handoff (no gate on a judgment call).
- dual-implementation-discipline.md §6: the hook keeps its `@cc-only-rationale` header (`.claude/hooks/end-of-turn-reminder.sh:2`); the plugin twin is regenerated by `scripts/generate-plugin-twins.sh` (SSOT, not copy-paste).
- language-discipline.md §1: machinery and shipped string are English; the reminder is model-facing (reason field), matching the inline-English autonomy-arm precedent.

### §1.7 Backward-check applied

Class of this change = "arms of the sole Stop hook + its census row". Surfaces enumerated and verdicted:

- `.claude/hooks/end-of-turn-reminder.sh` — SWEPT-CLEAN: both pre-existing arms behaviorally untouched; the 52 pre-existing cases in `packages/core/hooks/end-of-turn-reminder.test.ts:189` onward still green (65/65 total).
- `plugin/hooks/end-of-turn-reminder:2` — SWEPT-CLEAN: regenerated via the generator, byte-identical modulo the AUTO-GENERATED header line.
- `.claude/rules/zcode-parity-doctrine.md:110` (row 9) + `:116` (rollup) — SWEPT: flipped and recounted (10+1+2+1+4+2=20).
- `tests/install-sh/baselines/react-next/greenfield.fingerprint:26` and 7 siblings — SWEPT: regenerated; this sibling surface was the round-1 BLOCKER, caught by the cold seat and fixed pre-push.
- `docs/superpowers/specs/2026-08-09-session-bus-v2.md:96` (floor list) and the v3 spec — SWEPT-CLEAN: no S2a-contradicting text; D7 pointers resolve to the ADR this PR implements.
- Sibling hooks — SWEPT-CLEAN: `grep -rn "ctx_line" .claude/hooks/` matches only `end-of-turn-reminder.sh`; no other hook carries a context arm to keep in sync.
artyhoo added a commit that referenced this pull request Sep 6, 2026
…quiring a resolvable referent (#1597 ledger L-1/B-3, K-5) (#1652)

## Summary

Two ways the capability gate disagreed with the definition it claims to mirror — ledger #1597 findings **L-1 / B-3** (the wide half, == C13 addendum B-3) and **K-5** (the real half). `CLAUDE.md:30` declares the prose definition a mirror of `packages/core/hooks/checks/prior-art.ts`; both halves of the disagreement are closed here, in the same commit as the prose.

## Changes

- **L-1 / B-3 — the LOC triggers taxed test material.** `packages/core/hooks/checks/prior-art.ts:231` and `:249` now skip test material in both LOC arms (`isExemptTestMaterial`, `packages/core/hooks/checks/prior-art.ts:221`): `*.test.*` / `*.spec.*` files and anything under `test(s)/`, `__tests__/` or `*fixtures/`. The carve-out cannot hide a capability — a commit that adds test material **alongside** a qualifying production file still trips on the production file — and it stops at `packages/core/principles/` (`ENFORCEMENT_FILE_RE`, `packages/core/hooks/checks/prior-art.ts:190`): a principle IS the enforcement capability, not a test for one.
- **K-5 — a positive trailer needed no referent.** `checkTrailerBody` accepted any ≥20-char payload that was not the `skipped` escape hatch, so `Prior-art: consulted — no entry applies` satisfied the gate on a capability commit. A positive line must now name something a reader can open (`REFERENT_RE`, `packages/core/hooks/checks/prior-art.ts:74`): an SSOT row (`prior-art-evaluations.md#N`), a concrete artefact path, or an issue/PR reference. Stacked lines keep working — a referent-free line is skipped so a later valid line can carry the commit.
- **Prose parity in the same commit.** `CLAUDE.md:36` now names three carve-outs on the LOC triggers instead of two, and `CLAUDE.md:50` enumerates the three referent forms. Three prose↔hook sync arms pin it (`packages/core/hooks/checks/prior-art.test.ts:1462`).
- **Diagnostics.** `packages/core/hooks/pre-push.ts:383` names the three accepted referent forms in the failure message.

## Measurement (why each side moved)

**L-1 / B-3 — the detector is the drifted side.** Over the last 250 first-parent commits on staging the ≥80-LOC arm fired on **27** commits; **18** of them added ONLY test files (9 under `packages/core/principles/`, 4 hook tests, 3 `packages/runtime-bridge/test/`, 2 skills, 1 synthesizer). The trailers it forced on the non-principle ones cited rows the commit never touched — `#242/#20/#16` on a hook-test pair (the C15 case), `#45 «unchanged by this»` on a runtime-bridge pair. The 9 principle files, by contrast, each carried a substantive on-topic citation (#244 actionlint, #245 safe-settings, #246 Vitest `test.include`, #251 markdownlint, #19 lychee, #229, #230, #248) — which is why the carve-out stops there.

The split matches the **other enforcement channel of the same invariant**, which has held this exact semantic since it shipped: principle 11 (SSOT #48) builds its capability set from non-test files only (`packages/core/principles/11-build-first-reuse-default.test.ts:192`) while singling principle tests out as needing «a dedicated SSOT entry with verbatim path OR a Prior-art trailer» (`packages/core/principles/11-build-first-reuse-default.test.ts:525`). This PR brings the pre-push channel into parity with the CI one.

**K-5 — error, not a transitional window, and a grammar wider than the strict reading.** Measured over the post-cutoff (`≥2026-05-12`) first-parent history: **145** capability commits carry a positive `Prior-art:` trailer.

| grammar | commits it would reject | rejects `consulted — no entry applies`? |
|---|---|---|
| strict `#ID` only (the literal documented form) | **23 / 145 (16%)** | yes |
| SSOT row \| artefact path \| issue/PR ref (shipped) | **2 / 145 (1.4%)** | yes |

The 23 the strict reading would reject are legitimate consults naming in-repo precedent or a research patch (`setup.d/lib.sh:359`, `research-patches/2026-05-23-guard-liveness-gate.md §2`, `PR #261`), so the strict reading was rejected on evidence. The 2 that still fail under the shipped grammar are both from before 2026-07-19. No transitional window: the pre-push arm only inspects unpushed commits, so merged history is never re-checked, and the recent rate is 1 in the last 250 first-parent commits.

## Review findings

- MAJOR: the ≥80-LOC / ≥50-LOC triggers classed new test files as capability commits, so two thirds of the gate's firings demanded a build-vs-reuse consult for work that adds no capability, and got rote citations back. Failure-scenario: a commit whose only new packages/ file is a 100-line `packages/core/hooks/hook-emit-prelude.test.ts` covering an existing prelude — `detectCapabilityReason` returned `"new file ≥80 LOC under packages/"` against the pre-fix module (probe output quoted under Test plan) and the real-git repro `tests/hooks/prior-art-trailer-hook.test.sh` sub-test 11 exited non-zero before the fix; both are clean after it, while sub-test 12 (a new principle file) stays non-zero on both sides.
- MAJOR: a positive `Prior-art:` trailer that named nothing satisfied the gate on a capability commit. Failure-scenario: a commit adding the explicit dependency `some-new-dep: ^1.0.0` with the body line `Prior-art: consulted — no entry applies` — `checkTrailerBody(...).code === 0` against the pre-fix module and the real-git repro sub-test 13 exited 0, so a genuinely new dependency merged with a trailer carrying no referent to any register row, artefact, or PR; the squash message then propagated it as the project's own precedent for what a consult looks like.

### §1.7 Forward-check applied

Both fixes land on the channels the gate already owns — the pre-push §7 arm (`packages/core/hooks/pre-push.ts:367` runs the same detector) and the PR-body arm (`packages/core/hooks/checks/pr-body-prior-art-bin.ts:23`) — with no new channel introduced, per the earliest-reachable-channel invariant. The prose↔hook obligation that `CLAUDE.md:30` asserts is itself mechanised rather than left to attention: `packages/core/hooks/checks/prior-art.test.ts:1462` reads `CLAUDE.md` from disk and fails if the capability definition stops naming the test-material carve-out or the `packages/core/principles/` exception, and if the trailer-syntax section stops naming all three referent forms — the counter to `#warning-nobody-reads` in `.claude/rules/attention-is-not-a-mechanism.md:29`. Each sync arm ships with a paired negative (`packages/core/hooks/checks/prior-art.test.ts:1476`).

### §1.7 Backward-check applied

Swept the sibling surfaces of both classes. The LOC arms had exactly two call sites, both converted (`packages/core/hooks/checks/prior-art.ts:231`, `packages/core/hooks/checks/prior-art.ts:249`); the third detector arm (`isNewDepAdded`) is path-independent and unaffected. The parallel enforcement channel for the same invariant was checked before choosing the carve-out shape and already excluded test files (`packages/core/principles/11-build-first-reuse-default.test.ts:192`), so this narrows a divergence rather than creating one. On the trailer side, the three existing tests that encoded the pre-K-5 grammar were found and updated in place rather than deleted — the two space-stripping mutation-killers keep their exact length arithmetic with `#1271` standing in for filler (`packages/core/hooks/checks/prior-art.test.ts:577`, `packages/core/hooks/checks/prior-art.test.ts:1051`), and the C1 free-form case now asserts the honest post-fix semantic: a non-SSOT referent passes the existence arm because it has nothing to resolve (`packages/core/hooks/checks/prior-art.test.ts:807`). The two sibling PR-body gates (`packages/core/hooks/checks/pr-body-fidelity.ts`, `packages/core/hooks/checks/pr-stale-revert.ts`) parse their own trailers and share no code with this grammar. No static import was added from this shipped check to an unshipped util — the change is two module-local regexes.

## Fidelity verdict

FIDELITY: skipped — no kickoff or spec substrate; this is a direct ledger-driven fix to the prior-art gate, verified by paired negatives that are RED against the pre-fix module and by a measurement over the repository's own first-parent history.

## Test plan

- `npx vitest run hooks/` (in `packages/core`) — **1399 passed / 73 files**, including the 26 new arms in `packages/core/hooks/checks/prior-art.test.ts` (test-material carve-out across 9 path shapes, four paired negatives, the referent grammar with its vacuity probes and stacked-line cases, three prose↔hook sync arms).
- `npx vitest run principles/ --no-file-parallelism` (in `packages/core`) — **477 passed / 2 skipped / 47 files**.
- `bash tests/hooks/prior-art-trailer-hook.test.sh` — **19 pass / 0 fail** after the fix (4 new real-git sub-tests). Before it: **17 pass / 2 fail**, the failures being exactly new sub-tests 11 and 13; sub-tests 12 and 14 (the paired negative and the paired positive) are green on both sides, so the carve-out is narrowed and the grammar widened only where intended.
- RED evidence against the pre-fix module (`git show HEAD:packages/core/hooks/checks/prior-art.ts` copy, run under tsx):
  - `detectCapabilityReason(test-only commit)` = `"new file ≥80 LOC under packages/"` → `null` after
  - `detectCapabilityReason(principles/99-new.test.ts)` = `"new file ≥80 LOC under packages/"` on **both** sides (control)
  - `detectCapabilityReason(hooks/checks/newcheck.ts)` = `"new file ≥80 LOC under packages/"` on **both** sides (control)
  - `checkTrailerBody('Prior-art: consulted — no entry applies').code` = `0` → `1` after
  - the SSOT-row, artefact-path and PR-reference trailers = `0` on **both** sides (controls)
- `npx tsc --noEmit -p packages/core` — clean.
- `bash scripts/build-getff-dist.sh --check` — «in sync with the repo root (1064 files)»; MANIFEST regenerated in the same commit as the files it pins, and re-verified after the merge-forward.
- `SNAPSHOT_MODE=capture bash tests/install-sh/snapshot.sh` — three cells move in each of the eight npm baselines (`packages/core/hooks/checks/prior-art.ts`, `packages/core/hooks/pre-push.ts`, `.ai-factory/refresh-baseline.json`); cargo / python / go untouched, no host-drift hunk to discard this time. Re-run after the merge-forward: no further change.
- Pre-push hook green on the pushed head.

## Prior-art consult

Prior-art: prior-art-evaluations.md#56 (§7 Prior-art trailer parser — capability-commit detection + trailer validation, verdict BUILD; this change is a semantics fix inside that row's own module, no new capability and no new dependency).

Prior-art: prior-art-evaluations.md#23 (commitlint, verdict ADOPT VOCABULARY — «custom trailer enforcement via regex on raw commit body»; the referent grammar stays inside that adopted vocabulary, adding no dependency, and the row's revisit trigger «§9 hand-roll grows beyond 2 substance arms» is unchanged: this is the §7 arm, not §9).

Not a capability change: every touched path is a modification — no new file under `packages/`, no new explicit dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant