Backlog item G. The `coverage:` line under-reported a skill chosen in a PRIOR turn:
enforce-coverage-verify credited channel=skill only if the Skill tool ran in the
CURRENT turn, so an honest `skill:X` continuation line was BLOCKED -> the controller
learned to under-report as direct/chain. Two-sided systemic fix, no weakening:
- enforce-coverage-verify: decide() also accepts skill:X when X was invoked anywhere
earlier in THIS session (new priorSkillNames param; main() collects them via
sessionToolUses). Still unforgeable -- a real Skill tool_use must exist in the
transcript. The only residual is possibly-stale attribution, far better than the
forced dishonest direct-reporting it replaces.
- enforce-prompt-injection: the §17 reminder now lists active skills carried over
from earlier turns (read from the transcript) and tells the controller to report
`coverage: skill:<name>` when work continues under one -- the proactive half, so
the correct line is not merely allowed but prompted.
TDD: RED -> GREEN per behavior. tools-vitest 2032 passed / 2 skipped.
Plan docs/superpowers/plans/2026-05-31-discipline-guard-backlog.md (item G).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes the TDD-gate cross-actor gap: when a subagent (spawned by a Task in the
controller's current turn) writes the failing test and confirms RED, the
controller's subsequent production edit was falsely blocked because the gate only
scanned the controller's own turn. Net strengthening, no discipline weakened.
- Part 1 (enforce-runtime-write-deny): block the Write tool from any
~/.claude/projects/**/*.jsonl (session/subagent transcripts). Memory *.md there
stays writable (never matches .jsonl$). Resolving normalizer defeats ./.. evasion.
This makes the agent-<id>.jsonl that Part 2 trusts unforgeable (it was the last
ungated write channel; Bash/PowerShell/Read gates already covered it).
- Part 2 (enforce-tdd-gate): decide() also credits a subagent's matching test edit
+ RED via a new subagentEntriesList. turnTaskAgentIds() reads the hex agentId from
the harness-written Task tool_result (the controller cannot forge its own
tool_result; hex-only match blocks "agentId: ../../x" path traversal).
subagentTranscriptPaths() derives <dir>/<controller-session>/subagents/agent-<id>.jsonl.
main() reads them best-effort (missing/unreadable -> no extra credit = stricter).
No new weakening: a delegated subagent doing real TDD is legitimate; the only
forgery vector (overwriting the agent jsonl) is closed by Part 1. Existing
controller-turn behaviour is preserved (empty subagent list == old logic).
OWNER (settings.json, Claude can't edit it): enforce-tdd-gate is already a
registered PreToolUse hook -> Part 2 goes live on merge. enforce-runtime-write-deny
must be registered on PreToolUse(Edit|Write|MultiEdit|NotebookEdit) for Part 1 to be live.
TDD: RED -> GREEN per behavior. tools-vitest 2027 passed / 2 skipped.
Backlog item C (=Z); plan docs/superpowers/plans/2026-05-31-discipline-guard-backlog.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes the remaining parallel-session-lock remarks on top of the keying fix
(7a469dc9), with NO weakening of same-worktree serialization:
- D: the block message now identifies the holder by its STABLE session_id and
marks the recorded pid as transient ("may change between attempts"). Chasing
the pid is what led to closing the wrong session. Decision logic is unchanged
(text only) — existing /pid N/ triage assertion still holds.
- B: pruneStaleLocks() best-effort deletes leaked lock files that are ALREADY
stale by the shared isStale() definition (now exported from the pure module —
single source of truth). Active within-TTL locks are never touched, so the
serialization guarantee is not weakened. Wired into the PreToolUse branch of
main(), wrapped so hygiene can never break the gate (fail-open).
- C (no code): release-on-SessionEnd needs only a settings.json registration
(owner action) — the existing !tool_name branch already releases. Documented
in the plan. Until then, leaked locks self-heal via B + the 5-min TTL takeover.
TDD: RED -> GREEN per behavior. tools-vitest 2014 passed / 2 skipped.
Backlog items B/C/D; plan docs/superpowers/plans/2026-05-31-discipline-guard-backlog.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
enforce-parallel-session-lock keyed the lock on the hook's process.cwd(),
which collapses to the main repo dir after a session resume — so sessions in
DIFFERENT git worktrees shared one lock and false-blocked each other (observed:
a brainrepo-worktree session blocked launching agents by a discipline-guard
session). New resolveWorkspacePath() keys on the session's stable cwd
(event.cwd) resolved to the git work-tree root (git -C <cwd> rev-parse
--show-toplevel), with fallback to process.cwd() so behaviour never regresses
when event.cwd is absent. Same-worktree concurrency stays serialized
(unchanged) — discipline not weakened; only cross-worktree false-blocks fixed.
TDD: RED (5 resolveWorkspacePath cases) -> GREEN -> tools-vitest 2003 passed /
2 skipped. Backlog item F; plan
docs/superpowers/plans/2026-05-31-discipline-guard-backlog.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`npm ci` does a clean install strictly from the committed lockfile
(deterministic, no version drift) — needed to restore junction node_modules
in a fresh worktree. Distinct from `npm install`/`npm i`, which stay
hard-blacklisted because they can pull new/updated versions; the blacklist
runs before the whitelist, so they remain blocked. Word boundary after `ci`
prevents `npm cider`-style prefix matches; chain semantics still block
`npm ci && <mutating>`.
TDD: RED (3 allow-cases failed default-deny) -> GREEN (/^npm\s+ci\b/) ->
tools-vitest 1998 passed / 2 skipped (2000). Backlog item A; plan
docs/superpowers/plans/2026-05-31-discipline-guard-backlog.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sibling Claude session 2026-05-30 found that lastTurnEntries treats
harness-injected skill bodies as spurious turn boundaries, breaking both
enforce-memory-coverage (can't find user's coverage line) AND
enforce-normative-content-rules::detectLegitSkillActive (can't find the
Skill tool_use that lives in the assistant message BEFORE the body).
Refinement applied here: this session inspected 29 isMeta:true entries
across the live transcript (8f4ba767-...jsonl) via a debug helper and
found isMeta:true is ALSO used for "Continue from where you left off"
auto-resume, Stop hook feedback strings, and <local-command-caveat>
wrappers — those are real user-equivalent boundaries that must remain
visible. Sibling's blanket "skip isMeta" proposal would have broken them.
Discriminator: skip ONLY when isMeta === true AND typeof sourceToolUseID
=== 'string' (tool-spawned content). Skill bodies have the linking field;
the other isMeta sources do not. The sourceToolUseID field is harness-
controlled and not writable by controller from inside a tool call —
cannot be spoofed.
Behaviour after fix:
* Skill body injection → skipped → walk continues back to find user's
real prompt (with coverage line).
* The assistant message containing the Skill tool_use is now inside the
turn → detectLegitSkillActive finds it → normative writes pass when
invoked under an active claude-md-management skill.
* "Continue from where you left off." → still treated as turn boundary.
* Stop hook feedback strings → still treated as turn boundary.
TDD:
* 3 new tests in tools/enforce-hook-helpers.test.mjs under the
"lastTurnEntries / lastUserPromptText / lastAssistantText / turnToolUses"
describe block:
- lastTurnEntries skips skill body injections (isMeta + sourceToolUseID)
- lastTurnEntries does NOT skip "Continue from where you left off"
(isMeta but no sourceToolUseID)
- turnToolUses includes Skill tool_use spawned in same turn as the
injected skill body
* 2/3 RED→GREEN (the "Continue" negative test passed on baseline already
since its string content satisfies the existing string-content branch).
Scope:
* Fixes 2 of the 5 structural quirks documented in the Stream H
completion log (enforce-memory-coverage gap, enforce-normative-
content-rules detectLegitSkillActive gap).
* Does NOT fix: enforce-read-path-deny LEGIT_SKILLS exemption gap
(separate hook, no lastTurnEntries dependency); TDD-gate cross-actor
blindness (different mechanism — actor session boundaries);
detectFullTestRun regex narrowness (command-pattern matching).
Regression: vitest tools 1788/1788 GREEN (was 1785; +3 new tests).
Plan: docs/superpowers/plans/2026-05-30-lastturnentries-skill-body-skip.md
Closes Stream H completely. Appends a "Final activation — Layer 4 verified
live" section to the completion log documenting:
- User completed Action 2 (.claude/settings.json batch replacement) via
.scratch/activate-stream-h.ps1 on 2026-05-30 ~12:38 МСК. Backup at
.claude/settings.json.backup-20260530-123741. 7 new hook entries appended.
- User completed Action 1 (keytar install + ROUTER_LLM_KEY in user env)
with --legacy-peer-deps to resolve the histoire/vite peer conflict
(memory quirk 74). ROUTER_LLM_KEY (35 chars) exported user-level. Base
URL left at Anthropic default — no ProxyAPI middleware.
- Live verification via .scratch/verify-layer-4.ps1 → both opt-in
integration tests under ROUTER_LLM_LIVE_TEST=1 PASS on real API calls:
* single Sonnet judge returns a parseable YES/NO — 1950 ms
* 3-judge consensus reaches all three models with real (non-null)
verdicts — 2021 ms (Sonnet 4.6 + Haiku 4.5 + Opus 4.7 each returned
a real YES/NO; no fallback to doubt)
Total duration 4.54 s. 4 real API calls. Cost ~$0.01-0.05.
Layer 4 LLM-judge now active on live traffic. Router-gate v4 reaches the
master-plan target ~0.5-0.8% bypass rate. Architectural floor ~0.5%
irreducible per the 7 fundamental limits documented in memory
`feedback_asymptote_floor_irreducible.md`.
Carry-over: PowerShell 5.1 mojibake on em-dashes inside .scratch/ helper
scripts is cosmetic only; affects the final summary banner, not the
verification itself. Non-blocking.
Docs-only change; covered by docs-only short-circuit in
enforce-verify-before-push (§5 п.13 CLAUDE.md).
Stream H closed. No further follow-ups required.
Closes Stream H. Adds the canonical completion artifact at
docs/observer/notes/2026-05-30-stream-h-completion.md documenting:
- All 10 commits landed in this Stream H push (2a3b5b4d..d75c8922 main).
- Per-task summary linking each H<N> to its commit SHA + 1-line rationale.
- Two manual actions the user needs to perform outside Claude to activate
the new hooks: (1) npm install keytar + store ROUTER_LLM_KEY in keychain,
(2) append 7 hook entries to .claude/settings.json (verbatim JSON
provided). Both are blocked from in-Claude execution by structural
router-gate hooks (read-path-deny on settings.json without LEGIT_SKILLS
exemption; npm install in router-gate hard-blacklist).
- 5 defects/quirks discovered during execution with follow-up direction
(read-path-deny skill exemption gap, TDD-gate cross-actor blindness,
detectFullTestRun regex narrowness, findOverride stub, subagent vitest
output misread).
- 5 intentional deferrals listed (H10 worktree bootstrap; full LLM-judge
activation pending Action 1; Smoke 8 live test pending Action 2; no
normative bump because Stream H is infrastructure not Tooling-canon;
worktree cleanup conditional on local presence).
- Cumulative state after Stream H: 1776/1776 vitest tools GREEN, 6 hooks
ready to activate, 2 brain-retro analyzer extensions live, recovery
runbook published with 7 fabrication patterns.
Docs-only change; covered by docs-only short-circuit in
enforce-verify-before-push (§5 п.13 CLAUDE.md).
Stream H Task 11 of 11 — final consolidation.
Code-quality reviewer flagged 2 IMPORTANT factual inaccuracies in
recovery-procedures.md (commit 3ce73a68):
1. Section 6 RECOMMENDED code example imported resolvePathNormalize from
the wrong module path (tools/shell-content-rules.mjs). Actual exporter
is tools/enforce-router-gate.mjs (verified via Grep at line 174).
shell-content-rules.mjs only exports defaultPathNormalize. A future
reader copying the RECOMMENDED pattern would get an import error.
Also corrected the call signature: resolvePathNormalize() takes no
arguments and is async — returns the normalize function directly.
2. Section 4 (Stale-process) cited tools/enforce-bash-content-gate.mjs —
no such file exists in tools/ (verified via Glob). Correct hook
filenames are enforce-router-gate.mjs (Bash) and
enforce-powershell-gate.mjs (PowerShell).
Fix: replace both module references with the verified correct filenames
(Grep'd against tools/ exports + Glob'd file existence). Also includes
the lefthook MD032 blank-lines-around-lists auto-format diff carried
over from the previous commit's post-commit hook.
Surgical edit — no new content, no restructuring.
Adds first-time recovery runbook with:
- 3 self-recovery levels (Level 1 ≤5min sentinel reset, Level 2 ≤15min VS Code
restart, Level 3 destructive workspace rebuild)
- Stale-process / hook reload trap (Smoke 5 chistaa-session hypothesis +
refutation method); key takeaway: live restart-test is the only way to
confirm a hook-modifying fix landed
- Self-fabrication patterns — 7 cases enumerated from Smokes 3/4/5/7 with
pattern signature, detection signal, mitigation for each
- Test methodology lesson — Smoke 5 root cause showed unit tests with inline
mocks can give false-green if they bypass the live resolver function; debug
scripts have the same trap
- Smoke methodology — statusline-setup system prompt overrides user tasks
(Smoke 9 Run 1); use semgrep-scanner for echo-probes, statusline-setup OK
for gate-inheritance smokes
Docs-only change; verified via docs-only short-circuit in enforce-verify-
before-push (§5 п.13 CLAUDE.md).
Stream H Task 1 of 11. Plan: docs/superpowers/plans/2026-05-30-router-gate-v4-stream-H.md
findOverride/findOverrideAttempt/loadOverrideVocab become permanent stubs returning null/null/empty.
Non-deleted hooks (verify-before-push, tdd-gate, memory-coverage, branch-switch) still import these
symbols and need them to compile; runtime always reports 'no override'.
Adapted 15 existing tests in enforce-hook-helpers.test.mjs and 7 in enforce-semgrep-security.test.mjs
that asserted old vocab behaviour; all now assert stub behaviour (null/empty).
1824/1824 vitest tools GREEN.
Stream G of router-gate v4 deployment.
Opt-in live smoke (ROUTER_LLM_LIVE_TEST=1 + ROUTER_LLM_KEY); auto-skips otherwise
so it never pollutes the unit regression in worktrees where undici is unresolved.
Checkpoint-1 live result on owner machine: PASS (2/2) — single Sonnet judge + 3-judge
consensus (Sonnet 4.6 + Haiku 4.5 + Opus 4.7) reach all models with real verdicts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Дополняет handoff чем фактически произошло 29.05.2026:
- 3 партиции (не 1) пришлось чинить: activity_log_y2026_m05 (id=599),
balance_transactions_y2026_m05 (id=462), pd_processing_log_y2026_m05 (id=191).
Race condition бил по всем 3 tenant-scoped audit-таблицам.
Всего 18 mismatches → 0, 9 tenant-scopes, 679 rows rebuilt.
- Laravel AuditRebuildChain не работает на проде: crm_supplier_worker не
может SET session_replication_role (требуется SUPERUSER). Tests проходят
потому что используют postgres superuser. Это first-ever rebuild attempt
на проде раскрыл gap.
- Workaround использован .github/workflows/sql-rebuild-audit-chain.yml
через sudo -u postgres psql. Future fix — отдельный план.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Task 5 плана 2026-05-29-audit-rebuild-per-tenant-fix.md.
Активированы 2 декларативных правила в ADR-018:
- rebuild-must-use-shared-config: AuditRebuildChain.php должен читать
partition_clause из AuditChainConfig (require_pattern matches существующему
коду после Task 4 fix).
- verify-must-use-shared-config: VerifyAuditChains.php должен читать TABLES из
AuditChainConfig (require_pattern matches коду после Task 2 refactor).
llm_judge=false (declarative only, zero cost).
adr-judge на staged diff: 0 violations / 0 advisories.
Ref: docs/superpowers/plans/2026-05-29-audit-rebuild-per-tenant-fix.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 TDD tasks (~день кода): extract shared AuditChainConfig, refactor VerifyAuditChains (regression-safe), failing tests для multi-tenant/BYPASSRLS/single-row, rewrite AuditRebuildChain через LAG OVER (partition_clause ORDER BY id) симметрично verify, активация ADR-018 enforcement rules, Pint/Larastan/Pest --parallel smoke, handoff для прод-cleanup activity_log_y2026_m05 через gh workflow run artisan-run.yml. Self-review GREEN на spec coverage / placeholders / типы. Execution mode: subagent-driven.
Two operational gotchas discovered в session 29.05.2026 (router-gate v3.6-3.8 sweep + post-sweep memory updates):
1. §5 п.13 NB — docs-only short-circuit считает строго .md-суффикс.
cspell-words.txt / package.json / lefthook.yml рядом со spec.md
делают diff mixed → verify-before-push активен → нужен vitest sentinel
ИЛИ override. Прецедент: commit 46c43169.
2. §5 +п.15 — enforce-memory-coverage hook не принимает chain-каналы
(chain:commit-push-mem-sync etc); требует строго direct:memory-sync
в свежем turn'е. Memory updates как часть multi-step задачи планировать
отдельным turn'ом или использовать memory dump override.
Прецедент: 4-й шаг sweep задачи заблокирован.
Via /claude-md-management:revise-claude-md skill flow.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>