Repository navigation
Merged
Conversation
… names A failed seed write to logs/autonomous/save-HHMMSS.log, followed by the lazy log() call that sources log.sh, left REMEMBER_LOG_DIR's resolution unvalidated: nothing stopped mkdir -p from building a directory tree under cwd if REMEMBER_DIR ever carried a relative value or an embedded newline. log.sh now refuses such a value outright and reports to hook-errors.log instead. Separately, autonomous save-log names carried only HHMMSS, so a seed could land on a same-time-of-day file left over from an earlier day still inside the retention window. Names now carry the date and the writing process's PID (save-YYYYMMDD-HHMMSS-PID.log). Could not reproduce the original path-content corruption on current main (0.40.0) via the cold resolver, the env-cache publish/load pair, or an end-to-end run of the reported scenario on the warm/fast path -- documented in tests/test_remember_dir_guard_902.py's module docstring. The guard and the naming fix are defense-in-depth per the maintainer's own accepted plan on the issue, independent of whichever mechanism produced the corruption on 0.33.0. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Self-review (Explore + oss:auditor) on the previous commit found two real gaps: 1. The REMEMBER_DIR guard added to log.sh only protects log.sh's own mkdir -p "$REMEMBER_DIR/logs". It did not protect post-tool-hook.sh's own mkdir -p "$REMEMBER_DIR/logs/autonomous" -- the literal call site issue #902 names -- which runs on the fast path BEFORE log.sh is ever sourced. Fixed with a twin _remember_dir_is_unsafe() defined directly in post-tool-hook.sh, gating that mkdir. Several other mkdir -p "$REMEMBER_DIR/..." sites remain unguarded elsewhere in the hook suite (session-start-hook.sh, session-end-hook.sh, write-handoff.sh); centralising the check across five files is an architecture decision out of this issue's scope and is reported to the maintainer separately rather than patched here. 2. The commit message, changelog and test docstring overclaimed that the guard's FATAL message "reports to hook-errors.log" -- every hook sources log.sh as `source ... 2>/dev/null`, which swallows that stderr for the fast/common paths. This is the same swallowing the pre-existing mkdir-failure FATAL already had (not a new regression), but the prose was wrong to assert otherwise; corrected in the test module's own docstring. Also fixes an allowlist drift in test_locale_ranges_695.py: inserting the new guard function shifted four pre-existing, already-allowlisted bracket ranges in post-tool-hook.sh down by 10 lines each. Co-Authored-By: Claude Sonnet 5 <[email protected]>
38e7313's guard answered an unsafe REMEMBER_DIR with `return 1` before log.sh had defined log(), dispatch(), report_error() or _remember_date. Every hook sources log.sh as `source ... 2>/dev/null`, so the FATAL was swallowed and SessionStart died 127 on its first call -- breaking #294's newline-in-project-dir case, which must exit 0 and write a status=unavailable record (PR #912 CI, every leg). The guard now skips the mkdir and points MEMORY_LOG_FILE at /dev/null (at source time and on the midnight rollover), and dispatch() skips its own mkdir -p "$REMEMBER_DIR/tmp" for the same refused value -- reachable again now that dispatch is defined -- falling back to its existing "output NOT SHOWN" path. Safe absolute paths take the same branches as before. Tests: the newline and relative must-fire cases now also assert the source completes, every caller-facing function is defined, and log() writes nowhere under cwd; a new case drives dispatch() to a real listener with a relative REMEMBER_DIR and asserts no tmp/ appears under cwd (red without the dispatch guard). The plain-path positive control asserts the daily log still lands in <store>/logs/. Changelog fragment no longer claims the refusal reaches hook-errors.log. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
check_release_tree.py FAILs a nested default expansion (${X:-${Y}...}),
and log.sh is compiled into every hook, so the two MEMORY_LOG_FILE
assignments added in the previous commit tripped it eight times in the
built tree. Same behaviour, spelled as an if/else.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…th guards PR #912 at 50a8acc: 4 failures on every Windows leg, all in this lane's tests, none in the hooks. 1. The cold/warm env-cache case and both save-log name tests drive post-tool-hook.sh through test_post_tool_hook_spawns' `_run`, which invokes a bare "bash" -- on the Windows runner that is the System32 WSL launcher (rc 1, UTF-16 "... to install." on stdout). That module skips win32 for exactly this reason; the importing tests now carry the same skip instead of silently dropping it. 2. The twin-logic test printed windows=0 on Git Bash. It handed the extracted function to `bash -c SCRIPT`, so on Windows the script was carried in CreateProcess's one command-line string and re-split by the MSYS runtime. The same function text, sourced from log.sh on disk, accepted C:/fakestore in the same job (test_must_not_fire_windows_drive_colon_slash passed on both Windows legs), so the guard itself is not judging drive letters unsafe there. The test now runs from a script file, the way a hook is always read. New: test_drive_letter_forms_accepted_by_both_guards, run with OSTYPE msys, cygwin and unset: log.sh's guard and post-tool-hook.sh's twin both accept C:/x, c:/x, C:\x and /c/x and both refuse relative/x, C:x and a newline-bearing value. Mutation check: dropping the backslash from log.sh's drive-letter bracket turns all three parametrisations red. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e_902 test_windows_skip_triage_497 requires every module that blanket-skips on win32 to be listed in docs/windows-skip-triage.md. The save-log name test inherits test_post_tool_hook_spawns' bare-"bash" harness, which is the WSL launcher on the Windows runner; listed as convertible. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
fdaviddpt
added a commit
that referenced
this pull request
Oct 6, 2026
* docs(trap.d): log round-1 v0.41.0 release-audit findings Gate 3's oss:release-auditor found two non-blocking (misreports) findings in the v0.40.0..HEAD delta (#911/#912): the #902 FATAL refusal is unreadable because log()'s own stderr fallback never fires once MEMORY_LOG_FILE is /dev/null, and the #902 changelog fragment overclaims mkdir-guard coverage since bootstrap-dirs.sh builds the same tree ahead of the guard on the slow path. Logged rather than filed per findings.md's misreports routing; /oss:curate decides later whether either becomes a rule. Co-Authored-By: Max <noreply> * docs(trap.d): clarify misreports routing note Co-Authored-By: Max <noreply>
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #902
What the report described
On 0.33.0 (macOS, bash 3.2, iCloud-synced project), a failed seed write to
logs/autonomous/save-HHMMSS.logwas followed by thousands of directories under the project root. Each was named after that log file's content, so a log directory path had been resolved to a relative, newline-containing value and thenmkdir -p'd under cwd.What this changes
log.shrefuses aREMEMBER_DIRthat is not absolute, or that contains a newline or carriage return, before itsmkdir -p "$REMEMBER_DIR/logs".post-tool-hook.shapplies the same check before its ownmkdir -p "$REMEMBER_DIR/logs/autonomous", the call site the report names, which runs on the fast path beforelog.shis sourced. Windows drive paths (C:/x,C:\x) are accepted, as inlib-memory-dir.sh.save-YYYYMMDD-HHMMSS-PID.log, so a seed can never append to a same-time-of-day file left over from an earlier day. The readers (the retention sweep insave-session.sh, the docs) use the*.logglob and need no change.What it does not claim
tests/test_remember_dir_guard_902.py. These changes are defence in depth: whatever produced the value on 0.33.0 can no longer turn it into directories under the project.thresholds.autonomous_log_retention_days(default 7) reclaims every*.logthere by age.mkdir -p "$REMEMBER_DIR/..."sites in session-start, session-end andwrite-handoff.share not guarded here. Centralising the check across files is a follow-up, not this fix.check_release_treeOK.Tests
tests/test_remember_dir_guard_902.pyandtests/test_save_log_date_pid_name_902.py: a planted relative path and a planted newline path are each refused, with no directory created under cwd; a normal absolute path and Windows drive paths still pass.test_locale_ranges_695.py: its allowlist line numbers moved.bash -npasses under bash 5 and/bin/bash3.2; both new test files parse as Python 3.9.Cleaning up existing junk directories (for the reporter)
From the project root, list first and only then delete. This removes only directories whose name is one or more
HH:MM:SS [post-tool] save triggeredlines:🤖 Generated with Claude Code
[AI-generated]