fix(code_index): stabilize digest against runtime churn to stop rebuild thrash#5
Open
lanmower wants to merge 1 commit into
Open
fix(code_index): stabilize digest against runtime churn to stop rebuild thrash#5lanmower wants to merge 1 commit into
lanmower wants to merge 1 commit into
Conversation
fix(code_index): stabilize digest against runtime churn to stop rebuild thrash current_digest() hashed the full `git status --porcelain`, so ANY uncommitted change flipped the digest -- including transient runtime emissions (.gm/exec-spool, prd.yml, mem-*.json) that concurrent sessions churn constantly. Each flip forced index() to clear_codeinsight() and re-embed every chunk of all ~98 files (~280s in-wasm bge), wedging the watcher heartbeat for minutes; the digest never stabilized so the full rebuild ran on nearly every codesearch. Filter the porcelain to indexable-source paths only: drop anything under .gm/ and any path whose extension has no tree-sitter language (lang_for_ext). A real source edit still invalidates the index (sync-before-emit preserved); runtime churn no longer does. Sort the kept lines before hashing so ordering noise does not flip it. @
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.
@
Problem
current_digest()hashed the fullgit status --porcelain, so any uncommitted change flipped the digest -- including transient runtime emissions under.gm/(exec-spool files,prd.yml,mem-*.json) that concurrent sessions churn constantly. Every flip forcedindex()toclear_codeinsight()and re-embed every chunk of all ~98 files (~280s of in-wasm BGE embedding), wedging the watcher heartbeat for minutes. Because the tree was never clean, the digest never stabilized and the full rebuild ran on nearly everycodesearch.Observed repeatedly on 2026-06-04:
.status.jsonts frozen 200s+,busy_untilpushed minutes out, watcher log stuck atcode_index: indexing root=. files=98while a concurrent loop session held it.Fix
Filter the porcelain to indexable-source paths before hashing in
current_digest():.gm/(transient runtime state, never indexed)lang_for_extreturnsNone)A real source edit still flips the digest (sync-before-emit staleness preserved -- a stale index is never served after a genuine source change); runtime churn no longer does, so the full re-embed stops firing on every tick.
Smallest safe option: no schema change, no index-format change, no incremental-reindex rewrite -- only the staleness trigger is narrowed.
@