Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/verification/smoke-mktemp-template-guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Verification: smoke-mktemp-template-guard

`lib/session/observe/tests/smoke.sh` created a temporary stub directory with a bare `stub="$(mktemp -d)"` and never removed it, failing `tests/test-mktemp-template-guard.sh` rules R1 and R3 on `ubuntu-latest` and `macos-latest`. Line 132 now uses an explicit `${TMPDIR:-/tmp}` template with `|| exit 1`, registers an `EXIT` trap (`trap 'rm -rf "${stub:-}"' EXIT`), and removes `$stub` once case `[30b]` completes.

## Green run

```
Command: bash tests/test-mktemp-template-guard.sh
Exit: 0
Output:
=== G1: the live tree has no bare mktemp and no unguarded test use ===
PASS scanned 877 files
PASS no violations
=== 11 passed, 0 failed ===
Verdict: PASS
```

```
Command: bash lib/session/observe/tests/smoke.sh
Exit: 0
Output:
[30b] session-semantic: the default command asks for Haiku (stub claude on PATH)
ok: default command pins --model haiku
smoke: all 120 passed
Verdict: PASS
```

Running `smoke.sh` with an isolated `TMPDIR` leaves zero `session-observe-smoke.*` directories behind after exit.

## Negative control

Before the fix (at `origin/master` `b6c9545b`, with bare `stub="$(mktemp -d)"` at `lib/session/observe/tests/smoke.sh:132`):

```
Command: bash tests/test-mktemp-template-guard.sh
Exit: 1
Output:
=== G1: the live tree has no bare mktemp and no unguarded test use ===
PASS scanned 877 files
FAIL violations:
R1 lib/session/observe/tests/smoke.sh:132: stub="$(mktemp -d)"
=== 10 passed, 1 failed ===
Verdict: RED, as expected
```

## Rollback

Revert the commit. The change is limited to a test script and holds no persistent state.
4 changes: 3 additions & 1 deletion lib/session/observe/tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ echo "[30] session-semantic --json: valid JSON with status ok"
if SESSION_SEMANTIC_CMD="cat $SEMOUT" "$CS" --root "$DIR/tests/fixtures" --days 0 --json | python3 -m json.tool >/dev/null 2>&1; then ok "valid json"; else no "json invalid"; fi

echo "[30b] session-semantic: the default command asks for Haiku (stub claude on PATH)"
stub="$(mktemp -d)"
stub="$(mktemp -d "${TMPDIR:-/tmp}/session-observe-smoke.XXXXXX")" || exit 1
trap 'rm -rf "${stub:-}"' EXIT
printf '#!/bin/sh\nprintf "%%s\\n" "$*" > "%s/args"\ncat "%s"\n' "$stub" "$SEMOUT" > "$stub/claude"; chmod +x "$stub/claude"
(unset SESSION_SEMANTIC_CMD; PATH="$stub:$PATH" "$CS" --root "$DIR/tests/fixtures" --days 0 >/dev/null 2>&1)
if grep -q -- '--model haiku' "$stub/args" 2>/dev/null; then ok "default command pins --model haiku"; else no "default command has no model pin: $(cat "$stub/args" 2>/dev/null)"; fi
rm -rf "$stub"

echo "[31] skills --latency: tiny-frequent total 150ms over 3 fires (max 50)"
out="$("$CC" skills --latency --file "$LFIX")"
Expand Down
Loading