fix(hooks): private code-limits state dir, bounded session start without timeout, pre-commit fails closed

code-limits: mkdir -m 700 without -p as the atomic proof, else one
find test (ours, dir, 700). session-start: one runner, timeout then
gtimeout then perl alarm (exec, no shell). pre-commit (generator +
both copies): a git diff or grep error blocks. memory.sh line rewrap;
claude-stub reads its log path from the env. Tests T16, SD19, PC1-4.
This commit is contained in:
bchanot committed 2026-11-13 18:25:33 +01:00
1 parent 27946d5280
commit 1f107c3c45
10 files changed
+159 -27

No files matched your search

+20
View File
@@ -81,5 +81,25 @@ echo short >> "$WORK/ours/sub/t.sh"
x="$(jq -n --arg c "$(cat "$WORK/ours/sub/t.sh")" '{content:$c}')"
check T15-symlinked-dir-tracked "$(fire "$WORK/link/t.sh" s10 "$x")" ""
# T16: state dir is 700; a pre-planted symlink dir gets no signal, no write
(umask 022; fire "$WORK/ours/new.ts" s11 "$x" >/dev/null)
check T16-dir-mode-700 "$(find "$TMPDIR/claude-code-limits-s11" \
-maxdepth 0 -type d -perm 700 | wc -l | tr -d ' ')" 1
mkdir "$WORK/sink"
ln -s "$WORK/sink" "$TMPDIR/claude-code-limits-s12"
printf '%s\n' "$big" > "$WORK/ours/sym.ts"
x="$(jq -n --arg c "$big" '{content:$c}')"
check T16-symlink-dir-silent "$(fire "$WORK/ours/sym.ts" s12 "$x")" ""
n="$(find "$WORK/sink" -mindepth 1 | wc -l | tr -d ' ')"
check T16-symlink-no-write "$n" 0
# a pre-existing 755 dir owned by us: no signal, no write
mkdir "$TMPDIR/claude-code-limits-s13"
chmod 755 "$TMPDIR/claude-code-limits-s13"
printf '%s\n' "$big" > "$WORK/ours/open.ts"
check T16-755-dir-silent "$(fire "$WORK/ours/open.ts" s13 "$x")" ""
check T16-755-no-write "$(find "$TMPDIR/claude-code-limits-s13" \
-mindepth 1 | wc -l | tr -d ' ')" 0
printf 'PASS=%d FAIL=%d\n' "$pass" "$fail"
[ "$fail" -eq 0 ]