fix(graph): read impact's knowledge links from the committed scaffold (#224) - #243
Merged
Merged
Conversation
…#224) impact answered from the _mex_grounded_source cache in graph.db, which only setup, sync and graph ground fill. A graph-only build left it empty, so a fresh clone returned no knowledge links (0 of 12 on this repository), and a checkout whose Markdown moved on kept returning dropped links. impact now reads grounds_to at query time through extractGroundings, so root, mex and mixed shapes all count. It walks the scaffold with the Wiki index's own contained, bounded discovery and reader, honouring wiki.exclude, so it agrees with wiki for-code. node_aliases still maps an old id to the current node. Files that cannot be read within bounds, a walk stopped by a corpus ceiling, and a scaffold that changes during the call each produce a grounding-omitted record instead of a silently partial answer. The cache table stays for check's baselines.
No module under src/graph imports the Wiki. The reader uses the Wiki index's discovery and contained reader, so it now sits beside markdown.ts, which the graph already uses the same way. The Wiki modules it imports reference nothing in the graph, so there is no cycle.
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 #224.
Problem
mex impactread knowledge links only from the_mex_grounded_sourcecache in.mex/graph.db. Only setup,mex syncandmex graph groundfill that cache;mex graph,rebuildandrefreshnever do. So a fresh clone plus a build returned no knowledge links, and a checkout whose Markdown had moved on kept returning links the scaffold had dropped.Change
impactnow readsgrounds_tofrom the committed scaffold at query time, throughextractGroundings(), so root,mex:and mixed shapes (Root-level grounds_to is invisible to check and wiki for-code in files that also have a mex: map #226) all count.discoverMarkdownFiles,readContainedSource,WIKI_CORPUS_LIMITS), honouringwiki.exclude.impacttherefore sees the same files aswiki for-code.node_aliases.{ type: "grounding", node, file }record shape, and the admission order from impact drops grounding records first when it runs out of budget #225.grounding-omittedrecord covers three cases:scaffold-unreadable: lists files that couldn't be read within bounds (capped at 20).scaffold-limit: a scaffold-wide limit stopped the walk.scaffold-changed: the scaffold changed during the call (checked by file identity before output), so every grounding record is withheld._mex_grounded_sourcestays in place forcheck's baselines.Reproduction: mex repo, committed
975f152, graph-only buildimpact, default budgetimpact --max-output-tokens 20000wiki for-codeThe twelfth grounding (
rebuildGraphinpatterns/safe-graph-snapshot-evolution.md) names a node id that no longer exists and has no alias.mex checkreports it asGROUNDING_AMBIGUOUS/GROUNDING_GONE, so it needs a scaffold fix.for-codeonly returns it because the dead id is passed in directly.Latency: about +0.65 s per
impactcall on this repo (7.2 s → 7.9 s, median of 9). About 350 ms is loading the YAML/Markdown parser thatextractGroundings()needs, and about 250 ms is the contained reads. Only each file's frontmatter block is parsed; this gave identical results to a full parse on all 145 files across five real scaffolds.Behaviour changes to review
Anchor-only links are no longer returned. A link that exists only as an inline
mex://anchor is dropped, because the cache held anchors too. The 4 Hono rows the issue called stale are anchors like this. The Wiki doesn't index anchors as groundings, so including them would break the match withfor-code.mex checkstill verifies anchors.Two remaining differences from
for-code, both in how the Wiki indexes files:grounds_tohas no Wiki entity, soimpactreturns it andfor-codedoes not.<!-- mex:entity -->blocks are read byfor-codeonly.Both are documented in
src/committed-groundings.ts.Tests
test/graph-impact-committed-groundings.test.ts, 7 tests, each failing againstmain's source and passing here:mex:and mixed shapeswiki for-codeimpactunit tests intest/graph-cli-agent.test.tsnow declare their groundings in real scaffold files instead of a fake cache row.test/graph-cli-freshness.test.tsand fail identically onmain(known local Windows baseline).