Repository navigation
Conversation
lib-memory-dir.sh's per-invocation remember-config-<pid>.json relies solely on an EXIT trap to remove it. On Windows/Git Bash that trap does not reliably fire for this plugin's short-lived hook processes, so it leaked forever -- one machine accumulated 23,908 of them directly in %TEMP%. bootstrap-dirs.sh now relocates the file into $REMEMBER_DIR/tmp (a directory this plugin owns, small, and safe to sweep) once that directory exists, and sweeps any remember-config-*.json there whose mtime is stale enough that its owning process is long gone -- the backstop for the case the EXIT trap never runs at all. Falls back to the original $SYS_TMPDIR placement when the directory can't be created. lib-memory-dir.sh itself is untouched: it is pinned byte-for-byte against origin/main by tests/test_case_divergence_298.py, and creating REMEMBER_DIR from inside it (to hold the relocated file) would short-circuit the legacy-store migration guard, which depends on REMEMBER_DIR being absent until migration has had its chance to run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP
) Self-review (Explore reviewer) on b6bb7ce flagged that the comment explaining the new sed substitution overstated what it does: it reverses exactly one level of `trap -p`'s re-quoting, not requoting in general. Today's chain never needs more than one level (nothing in this codebase installs an EXIT trap before bootstrap-dirs.sh sources lib-memory-dir.sh), so the code itself is correct as-is -- this only tightens the comment so a future change chaining onto an already-once-substituted trap value does not trust a claim of generality the code does not back. Recorded as below-bar in the pull request body: the class the reviewer named (a second level of chaining) has no reachable caller in the shipped scripts today. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP
PR #371's windows-latest leg failed test_merged_config_lives_under_remember_dir_tmp: the expected and actual paths were identical except for separator style. Confirmed by reading resolve-paths.sh: on OSTYPE=msys/cygwin it deliberately rewrites PROJECT_DIR into native `C:\...` form (#263, so Claude Code's own slug computation matches), while every `/tmp/remember-config-$$.json` this plugin appends is bash string concatenation using `/`. The two halves land in one working Windows path with mixed separators; the relocation genuinely happened, and a raw substring compare across the mix was the bug, not the product. Added _norm_sep() and used it on both sides of the comparison. Checked every other assertion in this file and in test_tmpdir_cleanup.py for the same shape: none of the others compare raw path strings across the shell/Python boundary (they all use Path.exists()/.glob(), which Windows treats slash-agnostically already), so this was the only instance. Added two fast, bash-free tests pinning the exact CI failure string (must tolerate) and a genuine-fallback string (must still catch), plus confirmed the pre-fix naive substring check is False against the real CI strings before adding the fix. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP
This was referenced Aug 27, 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.
Fixes #362.
What
scripts/lib-memory-dir.sh's per-invocation merged-config file (remember-config-<pid>.json) relied solely on a bashEXITtrap to clean itself up. On Windows/Git Bash that trap does not reliably fire for this plugin's short-lived hook processes -- the harness kills the process rather than letting it exit through a path that runs the trap -- so the file leaked forever. One machine accumulated 23,908 of them directly in%TEMP%.scripts/bootstrap-dirs.shnow relocates the file into$REMEMBER_DIR/tmp(a directory this plugin already owns, small, and cheap to enumerate) once that directory exists, and sweeps anyremember-config-*.jsonthere whose mtime says its owning process is long gone (30 minutes) -- the backstop for exactly the case the EXIT trap cannot cover. Falls back to the original$SYS_TMPDIRplacement, unchanged, when the directory can't be created.scripts/lib-memory-dir.shitself is untouched. It is pinned byte-for-byte againstorigin/mainbytests/test_case_divergence_298.pyto protect the per-tool-call hot path, and (discovered while building the first version of this fix) creatingREMEMBER_DIRfrom inside it would short-circuitbootstrap-dirs.sh's legacy-migration guard, which depends onREMEMBER_DIRbeing absent on disk until migration has had its chance to run.Judgment calls (per the brief)
$REMEMBER_DIR/tmpis a directory this plugin owns outright, so a staleremember-config-*.jsonthere is unambiguously its own leak, and the directory is small enough that sweeping it is cheap regardless of how large the shared temp root has grown.Tests
New:
tests/test_stale_config_sweep_362.py-- red before the fix (3 of 5 tests failed: merged-config location, stale-file sweep, and an end-to-end kill-9 simulation of a process whose EXIT trap never runs), green after. Updatedtests/test_tmpdir_cleanup.pyso its existing regression assertion keeps checking a real location instead of going vacuous once the file moved.Full suite: 1626 passed, 43 skipped (pre-existing, platform-gated skips only), run twice -- once before finding the trap-chaining bug below, once clean after the fix and again after a rebase-equivalent full re-run.
Cross-platform
The defect itself is Windows/Git Bash-only and I am not on that platform. Observed (macOS): full suite green, including the kill-9 simulation and the trap-unescape fix verified directly. Reasoned, not observed: that
find -mmin,mv -facross%TEMP%<->.remember, and the trap-requote/unescape sed round-trip identically under Git Bash's bundled coreutils/sed on an actual Windows box. CI'swindows-latestleg exercises the new and updated test files (both already special-case Git Bash discovery underwin32), but I have not seen that leg's output for this branch.Review
Two independent reviews against the committed diff (Explore reviewer + oss:auditor), both delivering
FINDINGS: n/NO FINDINGSper the brief.trap -p's re-quoting; the reviewer showed that if a trap value had itself already passed through one round of the same substitution (a hypothetical EXIT trap installed beforelib-memory-dir.shruns, chained through twice), one level of escaping would remain and the original 'unexpected EOF' crash would resurface. Confirmed together with the reviewer that no shipped script installs an EXIT trap beforebootstrap-dirs.sh/lib-memory-dir.shrun today, so this class has no reachable caller in the current codebase -- below-bar, not filed. Tightened the inline comment in a follow-up commit (c941198) so it no longer claims general un-quoting, since that was the one part of the finding that was a real, cheap, in-scope fix rather than a design decision.lib-memory-dir.sh, and every downstreamREMEMBER_CONFIGconsumer. Class C (untrusted text) explicitly not applicable. Platform band: observed clean on macOS, Windows-specific claims reasoned and labelled as such.below-bar
The trap-chaining fix only reverses one level of
trap -p's re-quoting. It is correct for every code path that exists in this repo today (confirmed by both reviewers reading the full sourcing order ofresolve-paths.sh,detect-tools.sh, and every hook script), but would need a second unescape pass if some future change ever installed an EXIT trap beforebootstrap-dirs.shsourceslib-memory-dir.sh. No such input exists to reach it, so this is recorded rather than fixed further or filed.Docs
README.md-- updated: documents the newtmp/remember-config-<pid>.jsonfile, its relocation, and the sweep, next to the existingtmp/row in the Data files table.Compliance
Full suite run (not narrowed): the change touches
scripts/bootstrap-dirs.sh, a shared helper sourced by every entry point, so this met the brief's own bar for running it rather than a named subset. Changelog fragment checked directly with.oss/assemble_changelog.py --check(ok, 1 fragment) rather than relying ontest_command, per the brief.