chore(memory): phase 2 guards — BDR-136, LRN-256/257, EVAL-056, BLK-018 resolved, journal; TODO security follow-ups

This commit is contained in:
bchanot committed 2026-11-02 20:59:06 +01:00
1 parent 69a0b9b10c
commit fd31640b9c
6 files changed
+28

No files matched your search

+1
View File
@@ -195,6 +195,7 @@ rules:
- **Status**: open. Candidate fixes: (a) quote gate evidence verbatim in span prompt — untested vs classifier; (b) move finish+tag span permanently inline in /release-candidate — keeps prep span dispatched, costs the sonnet pin on ~5 mechanical commands, cheap; (c) permission rule allowing subagent `gitflow.sh finish` — weakens the guard, refused. Decide at next release.
- **Status (2026-10-23, reconcile)**: open. Did not recur at 2.0.0 (journal: release-executor finish passed), no fix applied (release-candidate SKILL.md:88-90 still dispatches `SPAN: finish`). Decide (a)/(b) at 3.0.0.
- **Reference**: skill `release-candidate` STEP 5. Pattern adjacent [[LRN-089]] (ambient-state/context assumptions across boundaries). Journal 2026-07-20.
- **Status (2026-11-02)**: resolved 536d39e: option b, /release-candidate runs gitflow.sh finish and the tag in the main loop under the ask prompt
## BLK-019 — notify-attention bell silent, toast OK (VS Code client default) — 2026-09-01
- **Friction**: hook fired, Windows toast arrived, native bell never audible. User heard only Windows toast sound. Looked like half-broken hook.
+8
View File
@@ -1479,3 +1479,11 @@ Supersedes [[BDR-030]].
- **Residual (user-accepted, F)**: Fable held or cap exceeded at the route event → no question, slot unstamped; hold lapse / compaction → next step upgrades unasked (breaker behaviour today). `/model <x>` while any dialog holds `asking` falls to native (pre-existing, BDR-126).
- **Gates**: r1 correctness FATAL(6) robustness FATAL(6) simplicity CONCERNS(4) → r2 → confirmation CONCERNS(6) → r3; feater DONE 28 TIER tests (590 → 618); GATE 0 MET 5/5; verifier CONFORME 11/11 first pass; security PASS (1 LOW fixed: `clean(skill)`). Commits 9a24a62, docs 789fd00.
- **Refs**: [[BDR-116]], [[BDR-123]], [[BLK-032]], [[LRN-231]], [[LRN-242]], [[LRN-254]].
## BDR-136 — Phase 2 guards: native ask merge gate, bench-proven shell rules, rtk rc 3 passthrough, router write guard with a session skill latch, code-limits signal [accepted] (2026-11-02)
- **Context**: BDR-125 phase 2, feature/phase2-guards, contract `.claude/tasks/contracts/2026-11-02-phase2-guards-1545.md`, bench `.claude/tasks/plans/2026-11-02-phase2-bench/`.
- **Decision**: (1) merge gate = native `ask` `Bash(git merge *)`, `Bash(bash *gitflow.sh finish*)`, `Bash(sh *gitflow.sh finish*)`; every finish prompts once, `/close` 5C + `/release-candidate` included; declined prompt → "nothing merged, branch kept", stop. (2) shell-form asks (`sh -c`, `sh -*c`, `bash -*c`, `dash -c`, bare `bash`/`sh`, `bash <(`, `/bin/{sh,bash}`, `/usr/bin/{sh,bash}`, `/usr/bin/env {sh,bash}`), denies `awk *system(*`, `head|tail|cat * .env*` + `* */.env*`, 20 `rtk read` twins; census T62/T63. Rule lands only when every bench row naming it hits its want + one positive row. (3) rtk hook rc 2|3 → original passes (native rules judge as typed). (4) router write guard: main-loop Edit/Write/NotebookEdit of code (config included; free `.md` `.txt` `<root>/.claude/` minus worktrees, `<root>/docs/`) redirected until `skillRun` latch (any skill typed or model-loaded on main), a route phase this turn, or typed `/route`; dropped by `/route clear|off`, `/clear`; fail-open. (5) code-limits PostToolUse `Edit|Write`: added lines > 80 cols, ours only, once per file per session, additionalContext. (6) release finish + tag in main loop (BLK-018 b), executor prep only.
- **Why**: doctrine rules mechanically checkable → deterministic; routing probe 11/21 code turns inline; rtk rewrite let `git push origin :ref` escape deny/ask.
- **Alternatives rejected**: `$.ui.ask` mod gate, phrase-list gate (challenges 2026-10-25); 16 routing rows for the guard (run slot drops mid-run, would open first-use + ask-tier dialogs); `git -C * merge *` (asks on any commit text with " merge ", sub-agent ask refused); quoted finish rule (matcher ignores quote in pattern); `gitflow_finish*`, `bash -s*` (bench RAN); `Bash(/*)` (kills `*/rtk` twins); per-spawn guard.
- **Residuals**: Bash write forms outside guard; latch reset on register.ts reload; sourced `gitflow_finish`, `git -C <dir> merge`; `rtk read -n .env` flag-first (security MEDIUM, TODO); code-limits TMPDIR state dir ownership unchecked; silent in this repo (code-origin foreign).
- **Gates**: plan r1 correctness FATAL(8) robustness FATAL(5) → r2 → confirmation CONCERNS(4) → r3; user interactive ask check; SDD 11 tasks; final opus review With fixes → fix wave; GATE 0 ABANDONED(2) user-accepted; verifier ECARTS(6) → ECARTS(2) human-gated; security PASS (1 MEDIUM, 3 LOW). Refs [[BDR-125]], [[BDR-068]], [[BDR-123]], [[BLK-018]], [[LRN-256]], [[LRN-257]].
+7
View File
@@ -433,3 +433,10 @@ Dogfood: 3 blind lenses attacked the v1 plan for the plan-challenge feature itse
- **Result**: 0 code defect. Gates: 3 MET, phase 0 UNMET(1), phase 1 UNMET(2), all oracle drift from later gated commits (LRN-255). TODO: 5 done-but-open (proof, mcp remove, auto-memory dirs, profile charset, design-tool-gate hermetic) + BLK-021 TMPDIR resolved by cc.sh + phase 5 follow-up lump (1 of 3 done). Reconcile: open BLK 001/003/017/018/022/029 all known upstream/deferred; 8 flag-overlap contradiction candidates, none real.
- **Anomalies**: `gates.sh run` dirtied two merged contracts (restored by checkout); TODO line 74 and BDR-134 cite purged spec/plan paths (BDR-065 purge); compound Bash with `git config`/`git diff settings.json` denied by permission rules (split calls).
- **Action**: chore/todo-reconcile-bdr125 e58a617 (5 ticks, split follow-ups), merge on user signal. LRN-255.
## EVAL-056 — Phase 2 run: plan FATALs caught before code, final review 3 Important, oracles written before measurement abandoned [keep] (2026-11-02)
- **Checked**: phase 2 /ship-feature run quality (plan → challenge → SDD → gates).
- **Method**: challenge rounds, per-task reviews, final opus review, verifier x2, security gate; counted defects caught per stage.
- **Result**: plan r1 FATAL(8)+FATAL(5): bench script broken (pipe ate stdin), quoted finish form escaped the gate — both caught before any code. SDD 11 tasks, 1 fix round (Task 3). Final review: 3 Important (macOS T13, symlink whole-file report, guard undocumented) → fix wave. Verifier 1: ECARTS(6), 3 human-gated criteria written from the plan/spec rather than the contract; verifier 2: ECARTS(2) (post-merge user step, USAGE scope). Security PASS, 1 MEDIUM (`rtk read -n .env`).
- **Anomalies**: criterion 11 encoded a hypothesis (M3q ASKED) as an oracle before the bench measured it → abandoned; contract criteria 1/5/7 drifted from gated plan/spec decisions (r3 deviations not mirrored into the contract) → 3 human round-trips at the end.
- **Action**: write a measured oracle only after the measurement; when a plan revision deviates from a contract criterion, amend the criterion `[gated]` at the plan gate, not at GATE 1.
+1
View File
@@ -685,3 +685,4 @@ rules:
## 2026-11-02
- phase 5 profiles+packs shipped on feature/phase5-profiles-packs (13 tasks SDD, 3-lens challenge, gates MET/CONFORME/PASS after 3 passes): 9 packs, 9 profile fragments, profile.sh one-jq current --plain, cc <name> [profile], census; BDR-134, LRN-248..253, BLK-039/040, EVAL-054; TODO: router ask-before-Fable queued
- BDR-125 re-verification (gates x5, 31 SHAs, reconcile engine): 0 code defect, 5 done-but-open ticks → chore/todo-reconcile-bdr125 e58a617 (merge on signal); EVAL-055, LRN-255. /feat router-ask-tier (feature/router-ask-tier): plan r1 FATAL x2 → r3, feater 28 TIER tests, GATE 0 MET, verifier CONFORME 11/11, security PASS (1 LOW fixed); 9a24a62 + docs 789fd00; BDR-135, LRN-254. Merge on signal. Next: phase 2 guards via /ship-feature.
- Phase 2 guards (feature/phase2-guards): bench 16 ask + 7 deny approved (quoted finish rule, gitflow_finish*, bash -s* not), rtk rc 3 passthrough, router write guard (skill latch), code-limits hook, settings via index, release finish in main loop. Plan r1 FATAL x2 → r3; SDD 11 tasks; final review fix wave; gates: verifier ECARTS → human rulings (16 replaces 11, criteria 1/5/7 amended, USAGE in scope), security PASS (MEDIUM rtk read -n .env queued). BDR-136, LRN-256/257, EVAL-056, BLK-018 resolved. Merge on user signal; /close click after merge.
+10
View File
@@ -1921,3 +1921,13 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Pattern**: `bash lib/gates.sh run <contract>` REWRITES the `EVIDENCE:` lines of the contract file. Re-running a merged contract's gates for an audit: (1) oracles frozen on a base SHA (`c1-*.sh` vs develop 017a28b) read NOT-MET on later GATED changes (phase 5 added a pack-extras line to `rules/web-building.md`; 3330f0b restored "(dispatcher applies)" → 209/205 chars; 7899670 dropped `memory:`), (2) a CHECK string pinned to a test name goes stale after a review rename (`T10h-no-jq-rc0` → `T10h-empty-path-rc0`, 0b59687). Neither is a repo defect.
- **Context**: 2026-11-02 BDR-125 re-verification, 5 contracts re-gated: phase 5 / memory v2 write / minors MET, phase 0 UNMET(1), phase 1 UNMET(2), all explained by `git log -S`.
- **Apply**: on a re-audit, run gates, attribute each NOT-MET with `git log -S'<text>' -- <file>` to a gated commit, then `git checkout -- <contract>` to keep the ship-time evidence (historical record). Never commit re-run evidence over a merged contract.
## LRN-256 — Permission matcher facts CLI 2.1.316: quote in a pattern never matches, star spans a quoted argument, sourced functions unseen, ask prompts under auto (2026-11-02)
- **Pattern**: Claude Code permission matcher, CLI 2.1.316, measured headless auto mode + one interactive check (2026-11-02): (a) literal quote inside a rule pattern never matches (`Bash(bash "*gitflow.sh" finish*)` RAN on the quoted command); (b) `*` spans a quoted argument: `Bash(bash *gitflow.sh finish*)` asks on `bash "$HOME/.claude/lib/gitflow.sh" finish`; (c) a sourced function call (`source …; gitflow_finish`) not seen by `Bash(gitflow_finish*)`; (d) `echo … | bash -s` not seen by `Bash(bash -s*)` (pre-existing `Bash(* | bash -*)` deny does catch it); (e) `head -5 .env` escapes `Bash(head .env)`, `Bash(head * .env*)` catches it; (f) an ask prompts interactively under auto: "Ask rule Bash(git merge *) overrides auto mode for this command"; (g) an ask hit inside a headless sub-agent raises a request and never runs.
- **Context**: phase 2 bench `.claude/tasks/plans/2026-11-02-phase2-bench/` (results.tsv M*/S*/H*/C*/R*/L*, G1); supersedes the "ask inert under auto" reading of LRN-155.
- **Apply**: every new permission rule gets an isolated bench row (positive + negative + control) before landing; never rely on a quote in a pattern; spell finish call sites `bash … gitflow.sh finish`.
## LRN-257 — Headless permission bench: cd off the pipe, auto-mode controls, permissionMode per row, approve a rule only on all its rows (2026-11-02)
- **Pattern**: headless permission bench (`claude -p --setting-sources local --settings <file>`): (1) `printf … | cd "$4" && claude -p` runs the cd in a pipe subshell and claude reads the caller's stdin (the cases file) → `cd` on its own line, every call `</dev/null`; (2) controls carry `allow Bash(*)` + `defaultMode: auto` (+ `skipAutoPermissionPrompt`), else default mode asks everything; (3) parse the stream-json `system/init` `permissionMode` per row, reject rows not `auto`; (4) verdict = DENIED ("has been denied") / ASKED ("requested permissions") / else RAN (a non-zero command exit is still RAN); (5) a rule is approved only when every row naming it hits its want and one row expects ASKED/DENIED; (6) append-only results, ids selectable, full run in background.
- **Context**: phase 2 plan r1 bench broken (correctness BLOCKER), fixed r2/r3; run 2026-11-02, 41 cases + controls, all `auto`.
- **Apply**: reuse `.claude/tasks/plans/2026-11-02-phase2-bench/run.sh` + `bench.sh` for any future rule (docker mount spellings, `rtk read * .env*` twins).
+1
View File
@@ -88,6 +88,7 @@ Shared rules for every phase:
- [x] **Phase 2, guards** (shipped 2026-11-02 on feature/phase2-guards, merge on user signal: bench `.claude/tasks/plans/2026-11-02-phase2-bench/` (16 ask, 7 deny approved; quoted finish rule, `gitflow_finish*`, `bash -s*` not approved), rtk rc 3 passthrough 60ee4a9, router write guard with a session skill latch 22ff57b + 9bbd1d5, code-limits hook f21e265, locks T62/T63 9887c14, settings 6899a72, release finish in the main loop 536d39e, doctrine 0bf4620, CHANGELOG c3a6977; contract `.claude/tasks/contracts/2026-11-02-phase2-guards-1545.md`) (redesigned 2026-10-25 after a 3-lens challenge, re-challenged the same day: native ask gate, guard hosted in model-router, interpreters in prose, commit-msg hook deferred)
- [ ] Phase 2 residuals (stated 2026-11-02): Bash write forms are outside the routing guard (the harness auto-mode "prefer Bash" path); a register.ts reload resets the skill latch; `.claude/worktrees/` writes are code; code-limits state dirs stay in TMPDIR; not caught by a static rule: `… | bash -s`, a sourced `gitflow_finish`, `git -C <dir> merge` (soft_deny prose only).
- [ ] Phase 2 security gate follow-ups (2026-11-02, non-blocking): MEDIUM `rtk read -n .env` / `rtk read a.txt .env` typed directly pass every static deny (rc 3 → passthrough, no rule) → bench `Bash(rtk read * .env*)`, `Bash(rtk read * */.env*)` + `*/rtk` twins and teach phase2.jq the `* <path>` shape; LOW code-limits state dir (`mkdir -m 700`, owner check); LOW awk evasions (`system (`, `awk -f`, `gawk`/`mawk`); LOW pre-existing `cat x.key` (no dir prefix) parity gap; doctor.sh:255 jq message should name code-limits and push-guard.
- [ ] User hand edit (phase 2 hand-over): remove the 6 dead deny entries (`Bash(docker run * -v /:*)`, `Bash(git push * :*)`, `Write(**/.git/config)`, `Write(**/.gitconfig)`, `Write(~/.gitconfig)`, `Write(~/.config/git/config)`) and, if wanted, the 6 obsolete `rtk cat|head|tail` forms; lib/tests/push-guard.test.sh T41 (the 4 Write lines) and T42 (base = last release) must be edited alongside.
- Killed by the challenges: the phrase-list merge gate; the `$.ui.ask` mod gate (its BDR-068 exception detector was never true: finish runs in the user's reply turn; a hard_deny naming mod sources was the robustness BLOCKER); G2 destructive guard (BLK-022, stays a user-driven task); whole-file code-limit reports (1498 lines > 80 cols across 92 files, over-fires); parsing commit text from Bash; Bash write-form detection in the routing guard (no measured Bash evasion, every inline write was Edit/Write).
- Merge gate = native `ask` rules in settings.json, no mod (user pick 2026-10-25; bench r3 G1-G7: all forms DENIED headless incl. `"$HOME"`, absolute path, after `source`; `start` RAN): `Bash(bash */gitflow.sh finish*)`, `Bash(gitflow_finish*)`, `Bash(git merge *)`; evaluate in the same bench `Bash(git pull *)` and `git push x:develop` forms before adding them. Trade-off accepted: the BDR-068 /close auto-finish gets one dialog click (ask beats allow, no exemption); release-executor finish prompts too (its dispatcher runs finish inline if a sub-agent cannot prompt, BLK-018 option b). hard_deny line: "never edit `permissions.ask` to skip the gate".