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

+5 -1
View File
@@ -88,7 +88,11 @@ main() {
[ -n "$(field .tool_input.new_string)" ] && export CL_EDIT=1
dir="${TMPDIR:-/tmp}/claude-code-limits-$sid"
mark="$dir/$(hash16 "$file")"
[ "$mark" != "$dir/" ] && mkdir -p "$dir" 2>/dev/null || return 0
[ "$mark" != "$dir/" ] || return 0
# mkdir success is atomic proof the dir is ours; else accept only an
# owned 700 dir (find does not follow a symlink operand)
mkdir -m 700 "$dir" 2>/dev/null || [ -n "$(find "$dir" -maxdepth 0 \
-type d -user "$(id -u)" -perm 700 2>/dev/null)" ] || return 0
[ -e "$mark" ] && return 0
is_ours "$file" "$dir" || return 0
hits="$(over_lines "$file")"