fix(uncertainty): withdraw the real-absence claim over untracked source - #978
Closed
nhuphuoc-bic wants to merge 1 commit into
Closed
nhuphuoc-bic wants to merge 1 commit into
nhuphuoc-bic wants to merge 1 commit 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.
Contributor
Author
|
Superseded by #987 — same change, reopened from my personal account so the contribution is attributed correctly. The commit here was authored with an address that matches no GitHub account, so it credited nobody. Nothing about the code changed; the description there is shorter and carries a measurement taken after this one was opened. |
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.
The problem
_stalenessproves the graph current from two signals: build commit vsHEAD, and the target file's mtime vs the build timestamp. Neither can see a source file git has never been told about — the commit still matches, and a file the graph holds no row for has no mtime to compare.An incremental update discovers changes through
git diff, so such a file is absent from the index however current the build is. The consequence is that the strongest sentence this module produces lands on exactly the case it is least true for:The agent stops looking for the consumer it just wrote. Per this module's own docstring — "saying so is what stops an agent grepping anyway" — that is the marker doing harm rather than nothing.
Measured on a 1,489-file TypeScript monorepo: create a
.tsimporting an indexed symbol, runupdate→0 files updated, and the reference count does not move.git addthe same file →1 files updated, 2 nodes, 3 edges, count moves. Remove it → back.The change
Untracked source becomes a third staleness signal, evaluated from
_settled()on both paths that would otherwise report the graph as current — including the early return taken when a graph carries nolast_updatedmetadata, which is where the first draft of this silently did nothing.Two things keep it quiet where it should be:
get_all_files(). A repo whose languages this build does not parse never reports a file the index was never going to hold.--porcelainalready honours.gitignore, so build output and vendored trees stay out.It is empty-result-only like every other marker here, so no response that carries results changes, and the note stays inside
MAX_CONFIDENCE_CHARS.Cost: one
git statuson a path that already spawns a subprocess for_live_git_head, and only ever on an empty result — never the hot path. Measured at ~10 ms on the monorepo above.Tests
Six cases in
tests/test_uncertainty.py, all of which fail when the signal is removed (verified — 3 fail on the message assertions, the others guard the quiet paths):git add) is present, within the character budgetconfidencekey — the token-budget guaranteeruffandmypyclean; full suite2991 passed, 9 skipped, 2 xpassed.A question for you
The marker is attached only when
total_results == 0, per the deliberate rule inquery.pythat non-empty responses stay byte-identical. But the dangerous shape of this bug is often low, not zero — three new files exist, andreferences_toreturns 11 instead of 14, which no one thinks to doubt.Extending the note to non-empty results would cover that, at the cost of the rule you wrote for token economy. I have kept this PR inside your existing rule; happy to add it if you think the trade is worth it.
Relation to
integration/token-efficiency-hardeningThis composes with
_find_content_mismatchesthere rather 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. Based onmainfor review convenience — rebase or cherry-pick as suits you, as with #969.