fix(uncertainty): withdraw the real-absence claim over untracked source - #987
Open
nhuphuoc215 wants to merge 3 commits into
Open
nhuphuoc215 wants to merge 3 commits into
nhuphuoc215 wants to merge 3 commits into
Conversation
An incremental update discovers changes through git, so a source file that was never added is absent from the index however current the build is. Neither staleness signal can see it: the build commit still matches HEAD, and a file the graph holds no row for has no mtime to compare. The result is that the strongest sentence this module produces is attached to exactly the case it is least true for. An agent writes a consumer, does not add it, asks who references the symbol, and is told the zero is a real absence -- so it stops looking for the file it just wrote. Adds untracked source as a third staleness signal, evaluated on both paths that would otherwise report the graph as current, including the early return taken when a graph carries no build timestamp. Source is calibrated from the extensions already in the index, so a repo whose languages this build does not parse never reports a file the index was never going to hold; --porcelain honours .gitignore, so build output stays out. Empty-result-only, like every other marker here, so no response that carries results changes.
code-review-graph reviewOverall risk: 0.65 (MEDIUM) — 14 changed function(s)/class(es), 2 affected flow(s), 5 test gap(s) Risk-scored changes
Affected execution flows
Test gaps
Token savings: this graph-backed report used ~6,064 fewer tokens (~55%) than reading every changed file in full (estimated, chars/4 approximation). Powered by code-review-graph — local-first analysis; no code leaves the CI runner. |
… count its room The review report on this PR listed _untracked_sources, _is_untracked_note, _untracked_note, _settled and _staleness as untested: the query-level tests prove the sentence reaches the agent, not each helper's own contract. Eleven tests now do — suffix calibration, the zero-not-raise paths for a missing git and a non-repository, the predicate, the pass-through and withdrawal in _settled, and the order of the three signals in _staleness. Writing them found a defect. The note's suffix was exactly MAX_CONFIDENCE_CHARS long, which left the count a budget of zero, and _fragment clipped it: 12 untracked files printed as "1~ source file(s)" — the one number the docstring calls the actionable part, wrong, inside a sentence about accuracy. The wording is 128 characters now, twelve digits of room, and the test asserts the note starts with the count for 1, 12, 1234 and 999999.
This branch has not been deployed
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.
_stalenessproves the graph current two ways: build commit vsHEAD, and the target file's mtime vs the build timestamp. Neither can see a file git has never been told about — the commit still matches, and a file with no row in the graph has no mtime to compare.An incremental update finds changes through
git diff, so that file is absent from the index however fresh the build is. The result is that the strongest sentence this module produces lands on the case it is least true for:It then stops looking for the file it just wrote.
This adds untracked source as a third staleness signal, called from
_settled()so it runs on both paths that would otherwise report the graph as current — including the early return taken when a graph has nolast_updated, which is where my first attempt silently did nothing.Two things keep it quiet. "Source" comes from the extensions already in the index rather than a fixed list, so a repo whose languages you don't parse never gets flagged; and
--porcelainalready honours.gitignore, so build output stays out. It is empty-result-only like every other marker here, so nothing that carries results changes. Cost is onegit statuson a path that already shells out for_live_git_head, ~10ms, never the hot path.Six tests, all of which fail when the signal is removed.
ruffandmypyclean, full suite2991 passed, 9 skipped, 2 xpassed.One thing I'd like your call on
Measured on a 1,489-file TypeScript monorepo, a single untracked consumer moved
callers_of4→3,importers_of7→6 andreferences_to12→11. All non-zero — so this marker never fires for any of them. The shape that actually bites is low, not empty, and low is worse because nobody thinks to doubt it.Extending the note to non-empty results would cover that. It only appears while untracked source exists, which is not the steady state, so "non-empty responses are unchanged" would still hold for virtually every call — the tokens are spent only in the window where the answer is wrong. Happy to push it onto this branch if you want it.
Relation to
integration/token-efficiency-hardeningComposes with
_find_content_mismatchesrather than overlapping it: that pass walks files already in the graph, so it catches the revert round-trip but not a file the index has never held.