fix(cli): report absolute index totals on re-index of unchanged files (#874)#884
Open
Dashsoap wants to merge 1 commit into
Open
fix(cli): report absolute index totals on re-index of unchanged files (#874)#884Dashsoap wants to merge 1 commit into
Dashsoap wants to merge 1 commit into
Conversation
…colbymchenry#874) `codegraph index` printed "0 nodes, 0 edges" when run after `init` on an unchanged tree, making it look like the index had been wiped — even though the data was fully intact (`status`/`query` still worked, and re-running `init` was unaffected). Root cause: indexAll() reports nodesCreated/edgesCreated as the *net delta* of the run (after - before). On a re-index with no file changes, every file's content hash matches in storeExtractionResult(), so nothing is re-inserted and the delta is legitimately 0 — but the index is still fully populated. Fix: add optional absolute totalNodes/totalEdges to IndexResult (populated from the same getNodeAndEdgeCount() the delta already reads). The CLI now prefers the absolute totals when the delta is 0, printing e.g. "8 nodes, 11 edges (index already up to date)" instead of "0 nodes, 0 edges". Behavior preserved: - first full index (empty DB): delta == totals, unchanged output - --force re-index (clears first): real rebuild counts, unchanged output - changed files: real net delta shown (no 'up to date' suffix) Adds regression tests pinning that a re-index of unchanged files keeps totalNodes/totalEdges populated while the delta is 0, and that data stays queryable.
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.
Fixes #874.
What
codegraph indexprinted "0 nodes, 0 edges" when run afteriniton an unchanged tree, making it look like the index had been wiped. This makes the CLI report the absolute node/edge totals in that case (e.g.8 nodes, 11 edges (index already up to date)).Why
The index was never actually empty — the reporter noted
statusstill worked and re-runninginitwas fine. I reproduced it locally:Root cause:
indexAll()reportsnodesCreated/edgesCreatedas the net delta of the run (after - before):On a re-index with no file changes, every file’s content hash matches in
storeExtractionResult()(it early-returns without re-inserting), so the delta is legitimately 0 — but the index is fully populated.initshows a non-zero count only because it starts from an empty DB (before == 0, so delta == total).Fix
Add optional
totalNodes/totalEdgestoIndexResult, populated from the samegetNodeAndEdgeCount()the delta already reads (zero extra queries). The CLI prefers the absolute totals when the delta is 0:Behavior preserved (verified locally)
8 nodes, 11 edges(delta == total, unchanged)index --force(clears first)8 nodes, 11 edges(real rebuild, unchanged)8 nodes, 11 edges (index already up to date)← the fixTests
Adds
__tests__/index-reindex-totals.test.tspinning that a re-index of unchanged files keepstotalNodes/totalEdgespopulated while the delta is 0, and that data stays queryable. Full suite green (1377 passed) andtsc --noEmitclean.