Repository navigation
Description
Found by the round-one release audit of v0.21.0..HEAD before tagging 0.22.0. Ranked misreports — non-blocking, filed rather than held. This is a composition defect: neither PR's own diff contains it.
Symptom
A store whose logs/ directory can never be created, and a session with nothing new to flush, produce the identical outcome from the SessionEnd hook: exit 0, nothing in hook-errors.log. /remember:doctor reads that log and reports nothing wrong.
Location
scripts/session-end-hook.sh:148, 158, 164, 209. The hook sources log.sh at line 147 with stderr suppressed and then calls log and report_error with no guard — grep -n "declare -F" scripts/session-end-hook.sh returns nothing, while the same grep over scripts/ returns hits in post-tool-hook.sh and user-prompt-hook.sh only.
The sharpest instance is 157-159, and the comment above it states the intent that the code then defeats:
# Reported, not silently folded into the same no-op
# every other early exit in this hook takes: without this line, a store that
# can never be created and a session with nothing new to save are the same
# line in hook-errors.log, which is no line at all.
Mechanism
scripts/log.sh:59-62 returns 1 when it cannot create $REMEMBER_DIR/logs. log(), report_error() and dispatch() are defined at lines 450, 765 and 897 — all after that return. So on a store that cannot be created, none of the three exists.
Reaching line 158 requires [ ! -d "$REMEMBER_DIR" ], and log.sh's own mkdir -p "$REMEMBER_DIR/logs" would have created $REMEMBER_DIR had it succeeded. So line 158 is reachable only on the path where report_error is guaranteed undefined. The hook's docstring promise — "EXIT CODES: 0 Always ... A failed flush is reported loudly ... rather than swallowed silently" (lines 56-65) — is inverted exactly where it was written to hold.
Note the guard has to be declare -F, not command -v or type: on macOS /usr/bin/log is Apple's unified-logging CLI, so type log is true whether or not a shell function exists. 98fbef5 (#365) records this.
How it composed
98fbef5 (#365, closing #358 and #361) added exactly this guard to the two hooks that needed it. 58802ae (#368) added a fourth registered hook fifteen minutes later, without it. Both were green against a base that did not contain the other. The composed release ships a guard covering 2 of 4 registered hooks — session-start-hook.sh is the pre-existing third, guarded at 91, 234, 561, 579, 759, 1188.
Also: the test that should have caught it cannot
tests/test_session_end_hook_345.py:227-238 — test_missing_remember_dir_on_a_real_project_still_exits_zero walks this exact degraded path (shutil.rmtree(project / ".remember")) and asserts only result.returncode == 0. A command not found does not change the exit status, so the test passes identically whether report_error fires, is a no-op, or does not exist. test_no_project_at_all_still_exits_zero (line 200) has the same shape. Both would still pass if the code did nothing, which is this repo's own stated bar.
What would settle it
Whether declare -F report_error is true after source scripts/log.sh on a store whose logs/ cannot be created.
For the test half: add assert "WARNING" in result.stderr (or an assertion against hook-errors.log) to the test at line 227 and see whether it passes today. That assertion needs its own positive control — a case where the warning must fire — or it becomes the same vacuous shape one level up.
Activity
fix: guard session-end-hook.sh log/report_error calls the same way #365…
release 0.22.0 — guards that were written next door
fix: staging_append no longer crashes when log.sh is absent or return…
Flatten lib-staging-lock.sh's fallback report_error() hook-errors.log…
Detach SessionEnd before its preamble, so the hook fits any budget on…