fix(extract): explain a semantic omission that was not a truncation (#4101)
Landed from PR #4280 (squashed, authorship preserved).
This commit is contained in:
1 parent
8a8977cac6
commit
1088605003
2 files changed
+58
-3
No files matched your search
+23
-3
@@ -4283,12 +4283,32 @@ def dispatch_command(cmd: str) -> None:
|
||||
_omitted_files = list(fresh.get("uncovered_files") or [])
|
||||
if _omitted_files or _partial_semantic_files:
|
||||
_extraction_incomplete = True
|
||||
_coverage_note = ""
|
||||
if _omitted_files and not _partial_semantic_files:
|
||||
# #4101: every omitted file here came back from a
|
||||
# chunk that was NOT truncated or hollow — the model
|
||||
# returned a complete, well-formed response that
|
||||
# simply did not address every dispatched file. A
|
||||
# bare "a re-run will retry them" reads as transient,
|
||||
# but re-sending the same oversized chunk reproduces
|
||||
# the same omission every time, so a retry loop with
|
||||
# no --token-budget change looks like extraction
|
||||
# never finishing rather than what it actually is: a
|
||||
# coverage gap at this chunk size.
|
||||
_coverage_note = (
|
||||
" None of this run's chunks came back truncated — the "
|
||||
"model returned complete, well-formed responses that "
|
||||
"simply did not address every file. Retrying with the "
|
||||
"same --token-budget will likely omit the same files "
|
||||
"again; try a smaller --token-budget to split the "
|
||||
"corpus into more, smaller chunks."
|
||||
)
|
||||
print(
|
||||
f"[graphify extract] semantic extraction is incomplete: "
|
||||
f"{len(_omitted_files)} dispatched file(s) produced no nodes and "
|
||||
f"{len(_partial_semantic_files)} came back truncated or hollow. "
|
||||
f"The shrink guard stays armed for this write; pass "
|
||||
f"--allow-partial to overwrite a larger existing graph anyway.",
|
||||
f"{len(_partial_semantic_files)} came back truncated or hollow."
|
||||
f"{_coverage_note} The shrink guard stays armed for this write; "
|
||||
f"pass --allow-partial to overwrite a larger existing graph anyway.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
try:
|
||||
|
||||
@@ -79,6 +79,41 @@ def test_a_chunk_that_omitted_files_arms_the_shrink_guard(monkeypatch, tmp_path,
|
||||
assert "semantic extraction is incomplete" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_an_omission_with_no_truncation_gets_the_coverage_note(monkeypatch, tmp_path, capsys):
|
||||
"""#4101: when every omitted file came back from a chunk that was NOT
|
||||
truncated or hollow, the message must say so explicitly and point at
|
||||
--token-budget, rather than the bare "a re-run will retry them" framing
|
||||
that reads as transient when retrying the same chunk size reproduces the
|
||||
exact same omission every time."""
|
||||
_record_force(monkeypatch)
|
||||
_arm(monkeypatch, tmp_path, uncovered=("GUIDE.md",))
|
||||
_run()
|
||||
err = capsys.readouterr().err
|
||||
assert "0 came back truncated or hollow" in err
|
||||
assert "None of this run's chunks came back truncated" in err
|
||||
assert "--token-budget" in err
|
||||
|
||||
|
||||
def test_a_truncated_run_does_not_get_the_coverage_note(monkeypatch, tmp_path, capsys):
|
||||
"""Control: when a chunk DID come back truncated/hollow, the #4101 note
|
||||
must stay silent — that case already has a correct, different cause."""
|
||||
_record_force(monkeypatch)
|
||||
_arm(monkeypatch, tmp_path, partial=("GUIDE.md",))
|
||||
_run()
|
||||
err = capsys.readouterr().err
|
||||
assert "None of this run's chunks came back truncated" not in err
|
||||
|
||||
|
||||
def test_omission_and_truncation_together_does_not_get_the_coverage_note(monkeypatch, tmp_path, capsys):
|
||||
"""When SOME chunks truncated, the omission is no longer provably a pure
|
||||
coverage-at-this-chunk-size gap, so the note must not fire."""
|
||||
_record_force(monkeypatch)
|
||||
_arm(monkeypatch, tmp_path, uncovered=("GUIDE.md",), partial=("GUIDE.md",))
|
||||
_run()
|
||||
err = capsys.readouterr().err
|
||||
assert "None of this run's chunks came back truncated" not in err
|
||||
|
||||
|
||||
def test_a_hollow_chunk_arms_the_shrink_guard(monkeypatch, tmp_path, capsys):
|
||||
"""After every retry a hollow chunk is returned (not raised) with its
|
||||
files marked partial; that is the reporter's run 2."""
|
||||
|
||||
Reference in new issue
Block a user