chore(memory): dead-deny lock done, BDR-145, LRN-280, hand edit queued

This commit is contained in:
bchanot committed 2026-11-12 14:30:29 +01:00
1 parent 79f1a3fc2c
commit 72ae6084da
6 files changed
+168 -1

No files matched your search

@@ -0,0 +1,117 @@
# PLAN r3 — dead deny lock (test half), /feat 2026-11-12
Contract: .claude/tasks/contracts/2026-11-12-dead-deny-lock-1239.md
Branch: feature/dead-deny-lock (off develop 1226d05)
File: lib/tests/push-guard.test.sh only. settings.json is NOT touched (user hand edit after merge).
Style: foreign code, keep the file's inline style (`check`, heredoc lists, small helpers like
`has_deny`/`rv` already exist); lines ≤ 80 chars; `set -u`, no `-e`, no pipefail.
## Facts (read-only)
- push-guard.test.sh:300-322 T41 heredoc list of required deny entries incl. 4 `Write(...)` + 4 `Edit(...)`.
- :324-348 T42: base = fresher of origin/main / main; `lost` = base deny entries absent from
`$S` (settings.json); `check T42-nothing-removed "$lost" ""`.
- main and origin/main (2026-11-06) hold `Bash(docker run * -v /:*)` and `Bash(git push * :*)`, not the
4 Write lines nor the working forms `Bash(docker run * -v /:/*)`, `Bash(git push * :**)`.
- Current suite: PASS=130 FAIL=0, "T42 base: origin/main".
- `$WORK` is a mktemp dir removed by the EXIT trap.
## r2 changes (challenge round 1: correctness CONCERNS(1), robustness CONCERNS(2), simplicity SOLID)
- Base (main) has no `Write(` deny entry at all: the justified list holds only the 2 Bash entries main
carries; the 4 Write lines just leave T41 (reason in a comment). User 2026-11-12 [gated]: a list row
absent from base FAILS (T42e), so the list is emptied in the release commit that ships the removal;
listing the Write lines would turn red at once.
- In-suite positive proof T42d (settings minus the list → nothing lost) replaces the out-of-`make test`
worktree CHECK (auto-mode hard_deny shape, BLK-040) (robustness 2, correctness 2).
- Working forms `-v /:/*` and ` :**` go into the T41 heredoc, unconditional (all three lenses).
- List = one heredoc, reason as a `#` comment line above each entry, flush-left; `grep -v '^#'` keeps the
entries (no tab, no temp .tsv) (simplicity 2, robustness 3, correctness 4).
- `deny_lost` at top level after `rv()`; the stale T42 comment rewritten once (simplicity 3-4).
- TODO.md:92 rewritten to "exactly the 6"; rtk forms split into their own item (user 2026-11-12 [gated]).
## r3 changes (challenge round 2: robustness FATAL(2), correctness CONCERNS(2), simplicity CONCERNS(1))
- T42e "row absent from base → fail" had no green path (release prep: base still has the rows; after
finish: stale) and stayed red on an empty list (`grep -c -f empty` prints nothing). User re-gate
2026-11-12 [gated]: expiry by version. One variable `removed_ok_until=3.0.0` (the release that ships the
removal); T42e fails once version.txt is past it while the list is non-empty, naming the rows. Green at
every step: prep 3.0.0 (equal), main/develop after finish (equal), next bump (hotfix or release) red
until the list is emptied in that bump, where main no longer carries the rows.
- T42d simulates the user's real edit: `$S` minus the 6 literal entries, then `deny_lost` must be empty
(an empty or wrong list now fails T42d) (simplicity r2-1).
- AC3 asserts no line starting `Write(` in the file (all 4 gone from T41) (correctness r2-2, robustness r2-3).
- One forgive-rule comment (list header); the has_deny comment keeps only the Write-twin reason and why T41
holds the working forms; T42 comment unchanged except one clause (simplicity r2-3).
- Line refs corrected: has_deny :301, T41 heredoc :305-324, T42 comment :327-328; the jq filter may be
split across lines inside its quotes to stay ≤ 80 chars.
## PLAN
[ ] T41 heredoc (:305-324) — delete the 4 lines `Write(**/.git/config)`, `Write(**/.gitconfig)`,
`Write(~/.gitconfig)`, `Write(~/.config/git/config)`; append 2 lines `Bash(docker run * -v /:/*)`
and `Bash(git push * :**)`. Keep everything else. Above `has_deny()` (:301) add 2 comment lines:
"# Write twins of the 4 Edit lines dropped 2026-11-12: a Write(glob) deny never
# blocks the Write tool, the Edit form does. The 2 Bash lines guard the working forms."
[ ] Right after `check T41-new-deny-present …`, top level, the justified list (heredoc body flush-left,
no leading spaces; the indentation here is the plan's layout only):
# Deny entries of the last release dropped on purpose, forgiven by T42 until
# version.txt passes removed_ok_until (T42e): empty the list in that bump.
removed_ok_until=3.0.0
grep -v '^#' > "$WORK/removed-ok" <<'EOF'
# mixed `* -v /:*` form never matches; `-v /:/*` kept (2026-10-23)
Bash(docker run * -v /:*)
# mixed `* :*` form never matches; ` :**` kept (2026-10-23)
Bash(git push * :*)
EOF
[ ] T42e right after the list, top level (no base needed):
cur=$(tr -d '[:space:]' < "$ROOT/version.txt")
expired=""
if [ -s "$WORK/removed-ok" ] && [ "$cur" != "$removed_ok_until" ] &&
[ "$(printf '%s\n' "$removed_ok_until" "$cur" | sort -V | tail -1)" = "$cur" ]; then
expired=$(tr '\n' ' ' < "$WORK/removed-ok"); fi
check T42e-list-not-expired "$expired" ""
[ ] T42 comment (:327-328): append ", except the justified list above" after "is still there"; rest
verbatim.
[ ] Top level, right after `rv() { … }`, add:
deny_lost() { # <settings file> → base deny entries missing from it, minus the list
git -C "$ROOT" show "$base:settings.json" 2>/dev/null \
| jq -r --slurpfile now "$1" '<the existing select filter, unchanged, may wrap>' \
| grep -vxF -f "$WORK/removed-ok"
}
In the else branch replace the `lost=$(…)` pipeline with `lost=$(deny_lost "$S")`;
`check T42-nothing-removed "$lost" ""` unchanged.
[ ] In the else branch, after T42-nothing-removed (each line ≤ 80 chars):
T42c (lock still bites):
probe=$(printf '%s\n' "$basedeny" | grep -vxF -f "$WORK/removed-ok" | head -1)
jq --arg e "$probe" '.permissions.deny -= [$e]' "$S" > "$WORK/s-probe.json"
check T42c-lock-bites \
"$(deny_lost "$WORK/s-probe.json" | grep -cxF -- "$probe")" 1
T42d (the user's hand edit, TODO.md:92, simulated):
jq '.permissions.deny -= ["Bash(docker run * -v /:*)",
"Bash(git push * :*)", "Write(**/.git/config)", "Write(**/.gitconfig)",
"Write(~/.gitconfig)", "Write(~/.config/git/config)"]' "$S" > "$WORK/s-after.json"
check T42d-edit-forgiven "$(deny_lost "$WORK/s-after.json")" ""
(no line of the jq array may START with `Write(`: keep a quote or spaces before each entry.)
## Edge cases
- Before the user's edit: T41, T42, T42c, T42d, T42e green (version 2.0.0 < 3.0.0).
- After the user's edit of exactly the 6: T41 green (no Write required), T42 forgives the 2 Bash rows,
T42d green. Any other removal → T42 red.
- Release 3.0.0 prep (version.txt = 3.0.0, base = old main with the rows): T42 forgives, T42e equal →
green. After finish (base = 3.0.0 main without the rows): nothing lost, T42e equal → green on main,
develop, any hotfix branch before its bump.
- Next bump (3.0.1 hotfix or 3.1.0 release prep): T42e red naming the 2 rows until the list is emptied in
that bump; emptying is safe because main no longer carries them. Empty list → T42e green.
- If the user's edit has not landed by then: emptying the list while the rows are still present is
harmless (nothing lost); removing them later needs a new row stamped with the next version.
- `grep -vxF` exits 1 on no output: fine under `set -u` without `-e`/pipefail. A missing removed-ok
file makes T42c fail (fail closed).
- SKIP path (no main ref): T41 and T42e still run; T42/T42c/T42d skipped.
- Expected count on this repo (base origin/main): PASS=133 FAIL=0 (130 + T42c + T42d + T42e).
## Tests
- The suite itself (T41 edited, T42 via deny_lost, T42c/T42d/T42e new), run only through `make test`.
## Disposition
- honors BDR-111 / T41-T42 non-weakening lock: still fails on any unlisted removal (T42c proves it).
- honors BDR-100: the citers of the 6 entries are TODO.md:92/:156 (closed at capitalize after the user's
edit) and this test; journal:646 history untouched.
- user decision 2026-11-12 [gated]: settings.json untouched here.
- LRN-275 explicit staging; LRN-277 no stdin readers in the brief.