Repository navigation
Conversation
…context cache #774: the injection guard's tracked-file check listed the repository with a plain `git ls-files`, which quotes/octal-escapes non-ASCII path bytes (core.quotePath, on by default), then compared that line against a raw, unquoted relative path. A tracked memory file whose path ran through a non-ASCII directory never matched, so the guard answered "not tracked" and injected it. Both `ls-files` invocations now run with `-c core.quotePath=false`. #775: the start-context cache's manifest invalidated only on source mtime, so upgrading past a change to the injection guard did not invalidate a cache that already held bytes rendered before that guard existed (the cache-hit path never consults the guard). The manifest now carries a VERSION= stamp (_REMEMBER_CACHE_FORMAT_VERSION); a manifest missing it or naming a different version is always a miss, additive to the existing mtime check. Both fixes are red-before/green-after with a new regression test each (TestNonAsciiTrackedPathBypassesGuard, test_manifest_without_a_version_stamp_is_a_miss). Closes #774 Closes #775 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…n-ASCII Self-review on the previous commit (both the Explore reviewer and oss:auditor independently found the same gap) showed `-c core.quotePath=false` only stops git from quoting non-ASCII bytes; a literal backslash, double quote, or control byte in a tracked path is still C-quoted by `git ls-files` unconditionally, so the guard's literal string comparison still silently answered "not tracked" for those characters -- the same bypass #774 closed for non-ASCII, still open for this narrower class. Added `_remember_git_unquote_into`, which strips a `ls-files` C-quoted wrapper and expands its escape set via `printf '%b'`, and wired it into the comparison in `_remember_file_tracked_state_into`. New regression test class `TestQuotedSpecialCharacterTrackedPathBypassesGuard` (tracked backslash-directory path refused; untracked positive control still delivered), red before this fix, green after. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.
What changed
#774 -- The shared injection guard's tracked-file check (
_remember_root_tracked_state_into/_remember_file_tracked_state_intoinscripts/lib-memory-context.sh) comparedgit ls-filesoutput against a raw relative path.
git ls-filesquotes and octal-escapes any non-ASCII byte in apath whenever
core.quotePathis on (the default everywhere), so a tracked path running through anon-ASCII directory name never matched the raw comparison and was injected instead of refused.
Fixed by adding
-c core.quotePath=falseto bothls-filesinvocations.Self-review on that first fix (two independent spawns, an Explore subagent and
oss:auditor, bothagainst
agents/developer/review.mdand its own checklist) found the fix incomplete:core.quotePath=falseonly covers non-ASCII bytes, butgit ls-filesC-quotes a literalbackslash, double quote, or control byte in a path unconditionally, and the same literal-string
comparison bypass still let those through. Follow-up fix: a new
_remember_git_unquote_intohelper unquotes each
ls-filesline (printf '%b'after stripping the C-quote wrapper) before thecomparison runs.
#775 -- The start-context cache (
_remember_start_cache_context_load) never consults theinjection guard on a cache hit, and its manifest previously invalidated only on source-file mtime,
which an upgrade to the guard does not change. A cache published before the guard existed, or
before a later guard fix, could keep replaying content the current guard would refuse. Fixed by
adding
_REMEMBER_CACHE_FORMAT_VERSION, written as aVERSION=line in the manifest and checkedby the loader; a missing (pre-fix shape) or mismatched stamp is now always a miss, additive to the
existing mtime checks.
Closes #774
Closes #775
Tests
Both issues were watched red before their fix and green after:
tests/test_injection_guard_754_755_756.py::TestNonAsciiTrackedPathBypassesGuard-- red viagit stash push -- scripts/lib-memory-context.shthen re-running (failed for the right reason:assert 'PLANTED-BY-REPO' not in out); green after the quotePath=false fix. Includes a positiveuntracked-file control.
tests/test_injection_guard_754_755_756.py::TestQuotedSpecialCharacterTrackedPathBypassesGuard(added during self-review) -- same red/green shape for a tracked path with a literal backslash in
a directory name; green after the unquote fix. Includes the same positive control.
tests/test_start_context_cache_668.py::test_manifest_without_a_version_stamp_is_a_miss-- redvia a hand-built pre-fix-shape manifest (
SRC=lines only, noVERSION=), observed as a servedcache hit (
load.returncode == 0) before the fix; green (== 1) after.Full-file runs after both fixes:
tests/test_injection_guard_754_755_756.py19 passed,tests/test_start_context_cache_668.py7 passed. Also ran.oss/assemble_changelog.py --check(12 fragments, ok) and
lane_setup.py --laneagainst all three touched files (all threeCROSS_CUTTING_GUARDS rows report no additional guard tests exist in this repo). Full repository-wide
pytestwas not run locally, per this repo's policy that CI (3 OSes, 4 interpreters) is the gate.Cross-platform
The quotePath=false and unquote fixes are reasoned, not separately observed, to behave the same on
all three CI legs' bash where bash exists.
The new regression tests for #774/#775 are skipped on windows-latest because the whole test file
already carries a pre-existing blanket win32 skip (#79); this is an existing convention, not
something this diff weakens.
Docs
README.mdwas checked (grepped for injection-guard/tracked-file/cache-manifest terminology,zero hits) -- it documents nothing about this internal guard/cache mechanism, so no doc change is
needed.
[AI-generated]