Repository navigation
Conversation
…is deleted `-nt` is true against a config layer that does not exist, which is the right answer for a layer that NEVER existed, but the same loop treats a layer that EXISTED when the cache was published and was since DELETED identically -- deleting a file changes no mtime a `-nt` check looks at, so that case kept serving the deleted layer's values indefinitely (split out of #842, reported by @books-around-trees). Both caches now also record which of their standard layers existed at publish time, and reject the cache if that no longer matches: - scripts/log.sh's flattened-config cache gets a second header line, `#RCFG_EXISTS=<0/1 manifest>`, validated the same way the existing identity line is. - scripts/lib-env-cache.sh's resolved-environment cache embeds a `1:`/`0:` prefix into each existing `CACHE_CONFIG=` value instead of adding a new line -- a separate header line there blew the #330/#395 hot-path `read` builtin budget by exactly one when tried first. New tests pin the deletion case against both caches, each paired with a positive control (an unchanged run must still hit the cache) and a case for a layer that never existed (must still count as a hit). Co-Authored-By: Claude Sonnet 5 <[email protected]>
This was referenced Oct 2, 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.
_remember_cfg_flatten_cache_load(scripts/log.sh) and_remember_env_cache_load(scripts/lib-env-cache.sh) decide whether their cache is still fresh with[ "$_f" -nt "$_src" ], checked against each config layer.-ntis true when the layer file doesn't exist. That's the right answer for a layer that never existed. It's the wrong answer for a layer that existed when the cache was written and has since been deleted, because deleting a file changes no mtime that-ntlooks at. As a result, the cache kept serving the deleted layer's values indefinitely.Both caches now record which of their fixed layers existed when the cache was written. On load, if that record doesn't match which layers exist now, the cache is rejected, regardless of what
-ntsays.scripts/log.sh: adds a header line,#RCFG_EXISTS=<one 0/1 digit per layer>, read second, after the#REMEMBER_DIR=identity line. A malformed value is treated the way a malformed identity line already is: the cache file is deleted and rejected. A record that doesn't match is treated as stale: rejected, but not deleted.scripts/lib-env-cache.sh: prefixes each existingCACHE_CONFIG=<path>value with1:or0:instead of adding a line. A separate line pushed the per-prompt hook over its read limit by one, whichtests/test_hot_path_cost_pin_330.pycaught. The prefix is removed as a fixed two-character prefix, not split on the first colon, so a Windows drive-letter path is unaffected.Closes #843. Reported in #842 by @books-around-trees.
Testing
tests/test_config_flatten_cache_668.py: 3 new tests.tests/test_env_cache_deleted_layer_843.py: the same three cases for the env cache, run throughscripts/user-prompt-hook.sh. The file is skipped on Windows (it needs a bash hook subprocess), and is listed indocs/windows-skip-triage.md.pytest: 2803 passed, 59 skipped, 0 failed.Known gap (not a regression)
A separate review flagged a narrow race. The publisher checks which layers exist when it writes the cache, but the cached values were read earlier, during the layer merge. If a layer is deleted in that window (a few milliseconds), the cache records it as absent while still holding its values. Later loads then see "absent then, absent now" and accept the cache. The same window exists at
scripts/lib-env-cache.shpublish. It also existed before this change. Closing it would mean recording existence during the merge and passing that through to both publishers. Left as a possible follow-up.Cross-platform claims
1:/0:prefix with a Windows path, and how-ntbehaves against a missing file on Git Bash. CI covers the matrix.🤖 Generated with Claude Code
[AI-generated]