Skip to content

fix: Use manifest mtimes for cache validation - #281

Open
Pringled wants to merge 4 commits into
mainfrom
fix/cache-validate-manifest-mtime
Open

Pringled wants to merge 4 commits into
mainfrom
fix/cache-validate-manifest-mtime

Conversation

@Pringled

@Pringled Pringled commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

get_validated_cache treated a file as stale only if its mtime was later than the cache save time, but a file changed during indexing, or restored with an older mtime was missed. We now check against the manifest entry which we also use for incremental rebuilding. This means we also don't needFileStatus.NEWER and the write_time anymore.

I also fixed two semi-related issue that greppie pointed out (but were already on main):

  • The startup validation could throw an error if a file is deleted during validation
  • We ran stat() on twice every file during validation (which adds like 0.2 seconds to every query on larger codebases if using the CLI).

This PR resolves #279

@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/semble/cache.py 100.00% <100.00%> (ø)
src/semble/index/create.py 100.00% <100.00%> (ø)
src/semble/index/files.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how cache validity checks file modification times.

The PR appears safe to merge, with a narrow concurrent-edit risk in incremental indexing.

Reviews (3) · Last reviewed commit: "Call stat() only once"

Comment thread src/semble/cache.py Outdated
Comment thread src/semble/index/create.py
@Pringled
Pringled requested a review from stephantul October 3, 2026 05:43
@muhammadaliqasmi

Copy link
Copy Markdown

Thanks for the quick fix, @Pringled. I checked this branch (a96b59f) against both reproductions from #279:

  • CLI, cp -p (older mtime): on main (aa634b1) the second search still returns def old_function_name(). On this branch it returns def brand_new_function().
  • Python, edit between build and save: on main I get cache considered valid: True / loaded_from_disk: True and the old content. On this branch I get False / False and the new content.

The full test suite passes on this branch as well (370 passed, Python 3.13, Linux).

Dropping write_time / FileStatus.NEWER entirely is cleaner than the minimal patch I proposed, since the manifest is now the only source of truth for staleness.


Verified with AI assistance. The results above are from real runs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cached index treated as valid after a file changes, if its new mtime is older than the cache save time (edit during indexing, cp -p, rsync -a)

2 participants