fix(graph): check grounding against a graph stale only by changed source - #241
Merged
Merged
Conversation
When the only reason the graph is stale is changed source files, mex check now grounds instead of skipping: unchanged files are checked against the snapshot, nodes in edited tree-sitter files are re-extracted and hashed exactly as a refresh would, and everything else (deleted files, edited TypeScript/JavaScript, nodes not located exactly) is reported as the new GROUNDING_UNVERIFIED warning. Nothing is reported gone or moved from a stale snapshot; every other non-fresh reason still skips grounding. Also release the graph.db descriptor when a read-only grounding runtime closes; on Windows the open handle broke the next in-process refresh. Closes #228
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.
Closes #228.
Problem
After any source edit the graph becomes
stale, andmex checkskipped every grounding check until a fullmex graph refresh(75–175 s on the eval subjects, #209). The score did not move for the very edit grounding exists to catch: Hono scored 8 before and after a grounded-body edit.What changes
When the only reason the graph is not fresh is changed source files (and the complete changed-path list is known),
checkgrounds anyway:extractFile+ body-hash normalization a refresh uses → realGROUNDING_DRIFTor cleanGROUNDING_UNVERIFIED— compiler spans come from a whole program, so exact equality can't be proven per fileGROUNDING_UNVERIFIEDGROUNDING_UNVERIFIEDis a new warning, counted in the score, telling the user to runmex graph refresh.GROUNDING_GONE,AMBIGUOUSor moved.engine-impl.ts,maintenance.tsandextraction/**are untouched.Also fixed: closing a read-only grounding runtime now releases the descriptor that binds
graph.db, not only the SQLite reader. On Windows the open handle made the next in-process refresh fail with "The live graph changed before candidate publication". This was pre-existing onmain, and this change would have spread it to stale checks.Tests
test/graph-grounding-source-drift.test.ts(new):UNVERIFIED. Onmainit fails: the body edit reads clean before the refresh and DRIFT after.main).test/graph-migration.test.tsasserted the old "stale ⇒ no grounding issues" rule; it now expectsUNVERIFIEDfor the edited TypeScript grounding and anchor.main.mainfailures now pass because of the descriptor fix:builds fingerprints, detects body drift, re-grounds…anda successful no-op agent session preserves drift….Real reproduction (copies of the eval subjects)
Counts are
grounds_toentries detected out of the total for that symbol.graph refreshcompose()bodyUNVERIFIEDtestClientUNVERIFIEDextractGroundingsbodyUNVERIFIEDcreateRepositoryGraphPortUNVERIFIED* The missed one is #226 (root
grounds_toskipped).main: 5).main: 11, including all 8 grounding issues that existed before the edit, whichmainloses while stale).checkwall time on a stale Hono: about 12.4 s onmainvs 13.1 s with this change, about what a check on a fresh graph already costs.Accepted cost
UNVERIFIEDuntil the next refresh.UNVERIFIEDwhile the graph is stale.