Skip to content

fix(graph): read impact's knowledge links from the committed scaffold (#224) - #243

Merged
theyashasvipandey merged 2 commits into
mainfrom
fix/224-impact-committed-groundings
Sep 24, 2026
Merged

theyashasvipandey merged 2 commits into
mainfrom
fix/224-impact-committed-groundings

Conversation

@theyashasvipandey

@theyashasvipandey theyashasvipandey commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #224.

Problem

mex impact read knowledge links only from the _mex_grounded_source cache in .mex/graph.db. Only setup, mex sync and mex graph ground fill that cache; mex graph, rebuild and refresh never 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

  • impact now reads grounds_to from the committed scaffold at query time, through extractGroundings(), 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.
  • Files are found and read with the Wiki index's own contained, bounded walk and reader (discoverMarkdownFiles, readContainedSource, WIKI_CORPUS_LIMITS), honouring wiki.exclude. impact therefore sees the same files as wiki for-code.
  • A grounding recorded under a renamed node's old id still attaches to the current node through node_aliases.
  • Existing behaviour is kept: the drifted-file exclusion, the { type: "grounding", node, file } record shape, and the admission order from impact drops grounding records first when it runs out of budget #225.
  • Nothing is dropped silently. A new grounding-omitted record 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_source stays in place for check's baselines.

Reproduction: mex repo, committed 975f152, graph-only build

Surface main this PR
impact, default budget 0/12 11/12
impact --max-output-tokens 20000 0/12 11/12
wiki for-code 12/12 12/12

The twelfth grounding (rebuildGraph in patterns/safe-graph-snapshot-evolution.md) names a node id that no longer exists and has no alias. mex check reports it as GROUNDING_AMBIGUOUS / GROUNDING_GONE, so it needs a scaffold fix. for-code only returns it because the dead id is passed in directly.

Latency: about +0.65 s per impact call on this repo (7.2 s → 7.9 s, median of 9). About 350 ms is loading the YAML/Markdown parser that extractGroundings() 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 with for-code. mex check still verifies anchors.

  • Two remaining differences from for-code, both in how the Wiki indexes files:

    • A pre-wiki file with only a root grounds_to has no Wiki entity, so impact returns it and for-code does not.
    • Groundings inside <!-- mex:entity --> blocks are read by for-code only.

    Both are documented in src/committed-groundings.ts.

Tests

  • New: test/graph-impact-committed-groundings.test.ts, 7 tests, each failing against main's source and passing here:
    • fresh clone with an empty cache
    • stale cache row
    • renamed-node alias
    • root, mex: and mixed shapes
    • file over the size limit
    • scaffold changed during the call
    • same files as wiki for-code
  • Updated: impact unit tests in test/graph-cli-agent.test.ts now declare their groundings in real scaffold files instead of a fake cache row.
  • Scoped run: 154 pass, 2 fail. The two failures are in test/graph-cli-freshness.test.ts and fail identically on main (known local Windows baseline).
  • The full suite has not run yet (the local run was stopped because the machine ran low on memory). CI will cover it.

…#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.
@theyashasvipandey
theyashasvipandey merged commit 67b44fc into main Sep 24, 2026
9 checks passed
@theyashasvipandey
theyashasvipandey deleted the fix/224-impact-committed-groundings branch September 25, 2026 05:52
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.

impact never shows knowledge on a fresh clone: it reads only the graph.db grounding cache

1 participant