chore(memory): BLK-045 + BDR-139 + LRN-265, LRN-266 — bugfix safety residuals

This commit is contained in:
bchanot committed 2026-11-06 17:36:33 +01:00
1 parent 31457c7472
commit da40dba796
7 files changed
+285 -5

No files matched your search

+8
View File
@@ -383,3 +383,11 @@ rules:
- **Real cause**: unknown. Not set by the repo (`lib/cc.sh`, hooks: no OOMScoreAdjust). Suspects: inherited from launcher (dtach under `systemd-run --user --scope`, sshd, or the RC/remote-control process).
- **Solution**: none yet. Next: trace `/proc/<pid>/oom_score_adj` up the parent chain of a live claude; then set `OOMScoreAdjust` (e.g. 500) on the `cc` scope so a claude runaway dies first.
- **Status**: open 2026-11-06.
## BLK-045 — Hook-running test suites could reach real claude CLI: fail-open inline stubs, 3 suites unstubbed [resolved] (2026-11-06)
- **Date**: 2026-11-06
- **Friction**: hook-running test suites could still reach real `claude` CLI (BLK-043 family). Inline stubs in detect-plan + session-digest ran `claude probe` before checking stub won PATH; red control did not stop suite. graphify-gate, memory, push-guard ran `hooks/session-start.sh` with no stub; cc.test.sh shims same fail-open shape.
- **Real cause**: stub pattern (LRN-263) copied inline, fail-open: failed write (no `set -e`) or noexec TMPDIR (`command -v` skips non-exec) → real CLI; relative work dir passes same-cwd check, breaks after hook's `cd`.
- **Solution**: shared `lib/tests/claude-stub.sh`: `stub_first_or_die` (command -v == stub else exit 1), `claude_stub_install` (absolute dir via `cd -P`, every step `|| exit 1`, control from `/`, `GIT_CEILING_DIRECTORIES`), `claude_stub_calls`; 6 suites adopt, each ends zero-call check; `lib/tests/claude-stub.test.sh` proves fail-closed (no-op chmod script + sentinel fake claude). Commits dc5f127, 7ca6b18 on bugfix/safety-residuals.
- **Status**: resolved dc5f127
+9
View File
@@ -1503,3 +1503,12 @@ Supersedes [[BDR-030]].
- **Alternatives rejected**: fine parser with carrier/wrapper lists (r2, endless holes); doctrine + soft_deny only (no deterministic refusal); ask (inert in headless sub-agents, BDR-090); folding into withheld guard-bash.sh (BLK-022 spec would turn red).
- **Residuals**: destination built outside the text; old-style tar C letter, long-option abbreviations; tool names built by expansion; archive members escaping a safe destination; the cd-then-ssh FP; prose or a heredoc body quoting a complete extraction command into a system dir is refused too (it hit this memory write: memory bodies go through Write + --body-file, prose uses `<pkg> <dir>` placeholders).
- **Gates**: verifier ECARTS(2) → CONFORME; security PASS ×2 (4 MEDIUM then 2 MEDIUM fixed: size cap, control-byte RS, obfuscated names, globs, cpio pass-through, busybox timing); 134+ tests under gawk/mawk/busybox awk; make test green. Commits 5507972..f02fd8a, settings 42e37cb via index, docs 8d5a7bd.
## BDR-139 — Pre-commit exempts only .claude/{memory,tasks,audits,deploy}/ + .githooks/, --no-renames [accepted] (2026-11-06)
- **Date**: 2026-11-06
- **Status**: accepted
- **Decision**: gitflow pre-commit exempts on main/develop only staged sets wholly under `.claude/memory/`, `.claude/tasks/`, `.claude/audits/`, `.claude/deploy/`, `.githooks/`; listed with `git diff --cached --name-only --no-renames`. `.claude/rules/`, `.claude/settings.json`, agents, skills = code for hook → branch first. Commit c5bd0f8; tests `lib/gitflow-test.sh` T21d-h; both hook copies regenerated; citers CLAUDE.global.md, gitflow-aiguillage.md, settings.json prose.
- **Why**: `.claude/**` let project config read by every session (rules, settings) land on protected base unreviewed; `--name-only` printed only rename destination → `git mv .claude/rules/x .claude/tasks/x` hid deletion. Allowlist = exactly side-car paths skills commit (memory-commit, deploy-commit, /tour audits): no skill flow taxed. Develop history: 1 commit (858e7a7, `.claude/settings.json`) would now need branch.
- **Alternatives rejected**: keep `.claude/**` (BDR-045 status quo, leak stays); also exempt `.claude/settings.json` (user picked no: config = reviewed change); size/heuristic narrowing (BDR-045 (D), fuzzy).
- **Residual**: hook fails open if `git diff --cached` errors (pre-existing; Gitea protection backstop). Partly revises [[BDR-045]] (exemption narrowed, aiguillage unchanged). See [[LRN-084]].
+1
View File
@@ -701,3 +701,4 @@ rules:
- 2026-11-06: machine OOM reboot 2026-11-05 23:55 root-caused: detect_plan `claude config get planType` fork bomb via SessionStart (BLK-043), SD13 fake HOME trigger. /bugfix: 3 lenses → r2 (hotfix off main, worktree), GATE 0 MET, verifier ECARTS(1 SC2016) → CONFORME, security PASS ×2; 49aa2ff. BLK-044 open (oom_score_adj -1000). Merge + Part B pending.
- capitalize pre-compact: 2 learnings (hook never calls claude CLI; worktree ignored symlinks + diff3); TODO BLK-043 merge checked, Part B kept. 4c digest switch committed 4a7ce37.
- 2026-11-06: BLK-043 Part B /hotfix 2f45452: session-digest suite stubs claude CLI (SD0 control, SD15 zero calls), 53/53 under TasksMax=256, security PASS (MEDIUM stub-first-on-PATH queued in TODO shortcut). 4c merge pending user.
- 2026-11-06: 4c merged ddb04f4. /bugfix safety-residuals (bugfix/safety-residuals): 5 items 9b3961e d93f06c dc5f127 97c6afc c5bd0f8 + gate round 7ca6b18; plan r3 after 3 lenses + confirm (0 BLOCKER, 8 MAJOR folded); GATE 0 MET, verifier ECARTS(2) → CONFORME, security PASS x2. BLK-045, BDR-139, LRN-265/266. Merge on signal; 4d next.
+12
View File
@@ -1966,3 +1966,15 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Pattern**: fresh `git worktree` lacks gitignored symlinks of main tree (`skills/darwin-skill`) → suites reading them go red (run-reconcile T6c): environment, not diff. Recreate link before blaming change.
- **Context**: hotfix worktree 2026-11-06; back-merge conflict used diff3 style.
- **Future use**: worktree setup → mirror ignored symlinks (`git status --ignored`). Conflict resolution here: strip `|||||||` base marker too, not only `<<<<<<<`/`=======`/`>>>>>>>`.
## LRN-265 — awk reads an assignment-shaped path operand as var=value and reads stdin: normalize at entry (2026-11-06)
- **Pattern**: awk takes an operand matching `^[A-Za-z_][A-Za-z0-9_]*=` as `var=value` assignment, not file → reads stdin. User path `x=1.md` or dir `a=b` → checks pass vacuously, content from stdin (empty, or tty hang). Fix at entry point, not per call site: prefix `./` only to assignment-shaped relative paths (output byte-identical otherwise); `printf '%s\n'` not `echo` (`-n` name).
- **Context**: `lib/memory.sh` `--body-file`, `check`/`upgrade` dir; ~30 awk calls take file operands; fix 9b3961e + 7ca6b18. Regression runs `</dev/null` or red-before hangs on terminal.
- **Future use**: any shell lib passing user paths to awk (or `sed`-like tools with operand syntax): normalize once where path enters. Review grep: `awk '…' "$var"` with user-sourced var.
## LRN-266 — Bench the existing rule against a new form before adding twins; --no-renames in path allowlists (2026-11-06)
- **Pattern**: before adding a guard rule for a new form, bench whether EXISTING rule already covers it. Claude Code permission `*` spans spaces: `Bash(rtk read */.env*)` already denies `rtk read -n sub/.env` (`*` = `-n sub`); only root-level target escaped → 2 rules, not 20. Bench row must test old rule on new cmd (proves need), not new rule alone (proves only match). Also gate on `sent` column = intended cmd (model may reorder args). Path allowlists over git output: `--name-only` lists rename destination only → use `--no-renames` so source path is checked.
- **Context**: bugfix/safety-residuals 2026-11-06: plan r1 had 20 deny lines, simplicity + correctness lenses cut to 2; bench R3-R7 (results.tsv). Pre-commit allowlist c5bd0f8 T21f rename case.
- **Future use**: every deny/ask addition (BDR-136 bench) and every path-based guard: (1) row with existing rule × new form first, (2) rename case in allowlist tests.