fix(cache): stop a degraded semantic entry from pinning the corpus (#5083)
An under-produced semantic extraction (e.g. a doc chunk that returns only its file-level node) is saved to the unversioned content-hash cache without a `partial` flag. The #3203 shrink guard then refuses the graph write on every later run while the cache keeps serving the degraded chunk, so no LLM call is ever made again and the corpus stays un-updatable until the entry is deleted by hand. `save_semantic_cache` cannot read graph.json (and should not), so the shared shrink handler marks the entry the read path would serve `partial` once the guard has measured the shrink. `load_cached` already treats `partial` as a miss, so the next run re-dispatches the file and a complete extraction overwrites the same content-hash key with a clean entry. This covers both a fresh under-production and a run that replays an already-poisoned entry written by an older version. The guard's stderr now separates "fresh extraction is smaller" from "a cached smaller chunk is being replayed", names the marked cache entry, and stops recommending --allow-partial for the cached case: following that advice would write the degraded replay over the larger graph and drop the prior nodes. Tests: cache-level marking (prompt-fingerprinted and legacy flat fallback), plus two end-to-end CLI repros that fail on the old code. The second demonstrates the reported loop: the next run hit the poisoned cache and refused again without ever calling the model.
This commit is contained in:
1 parent
6c8002eca4
commit
fc7f700f9e
4 files changed
+414
-2
No files matched your search
@@ -1849,6 +1849,98 @@ def save_semantic_cache(
|
||||
return saved
|
||||
|
||||
|
||||
def mark_semantic_cache_partial(
|
||||
files: Iterable[str | Path],
|
||||
root: Path = Path("."),
|
||||
*,
|
||||
mode: str | None = None,
|
||||
prompt: "str | Path | None" = None,
|
||||
prompt_file: "str | Path | None" = None,
|
||||
cache_root: "Path | None" = None,
|
||||
) -> list[Path]:
|
||||
"""Stamp the serving semantic cache entry for each file ``partial: True``.
|
||||
|
||||
The semantic cache is deliberately unversioned and content-hash keyed, so a
|
||||
degraded extraction — e.g. a document chunk that returned only its
|
||||
file-level node — is otherwise replayed as authoritative on every later
|
||||
run. The #3203 shrink guard keeps refusing the graph write while the cache
|
||||
keeps suppressing the LLM call that could heal it, so the corpus is stuck
|
||||
until an operator deletes the entry by hand (#5083).
|
||||
|
||||
The guard compares against graph.json, which :func:`save_semantic_cache`
|
||||
deliberately does not read (the cache writer does not know the graph), so
|
||||
the CLI marks the entry after the fact instead. ``load_cached`` already
|
||||
treats ``partial`` as a miss: the next run re-dispatches the file and a
|
||||
complete extraction overwrites the same content-hash key with a clean
|
||||
entry, which is the self-healing path the ``_partial`` truncation flag
|
||||
already uses.
|
||||
|
||||
Marks the entry the read path would actually serve — the
|
||||
prompt-fingerprint namespace when it exists, else the pre-fingerprint flat
|
||||
layout ``load_cached`` falls back to — so a legacy entry cannot keep
|
||||
shadowing the marked one.
|
||||
|
||||
``files`` may be absolute, or relative to ``root`` (the shape of the shrink
|
||||
guard's canonical ``source_file`` keys). Returns the entry paths actually
|
||||
marked. Best-effort: a missing, unreadable or already-partial entry is
|
||||
skipped rather than failing the extraction.
|
||||
"""
|
||||
kind = "semantic" if mode is None else f"semantic-{mode}"
|
||||
location = cache_root if cache_root is not None else root
|
||||
prompt_fp = _resolve_prompt_fp(prompt, prompt_file)
|
||||
marked: list[Path] = []
|
||||
for value in files:
|
||||
p = Path(value)
|
||||
if not p.is_absolute():
|
||||
p = Path(root) / p
|
||||
try:
|
||||
h = file_hash(p, root, cache_root=cache_root)
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
candidates: list[Path] = []
|
||||
if prompt_fp:
|
||||
candidates.append(cache_dir(location, kind, prompt_fp) / f"{h}.json")
|
||||
candidates.append(cache_dir(location, kind) / f"{h}.json")
|
||||
entry = next(
|
||||
(c for c in candidates if c.exists()), None
|
||||
)
|
||||
if entry is None:
|
||||
continue
|
||||
# Extended-length form for I/O only: under a deep root the entry path
|
||||
# overruns Windows MAX_PATH. Report the logical path to callers.
|
||||
io_entry = Path(_os_long_path(entry))
|
||||
try:
|
||||
payload = json.loads(io_entry.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
continue
|
||||
if not isinstance(payload, dict) or payload.get("partial"):
|
||||
continue
|
||||
payload["partial"] = True
|
||||
# Match save_cached's I/O: the temp file and the replace dest both use
|
||||
# the extended-length form so a deep root cannot fail the write.
|
||||
fd, tmp_path = tempfile.mkstemp(
|
||||
dir=str(Path(_os_long_path(entry.parent))),
|
||||
prefix=f"{entry.stem}.",
|
||||
suffix=".tmp",
|
||||
)
|
||||
try:
|
||||
os.write(fd, json.dumps(payload).encode())
|
||||
os.close(fd)
|
||||
_os_replace_with_fallback(tmp_path, io_entry)
|
||||
except Exception:
|
||||
try:
|
||||
os.close(fd)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
os.unlink(tmp_path)
|
||||
except OSError:
|
||||
pass
|
||||
continue
|
||||
marked.append(entry)
|
||||
return marked
|
||||
|
||||
|
||||
def scope_semantic_result(
|
||||
result: dict,
|
||||
root: Path = Path("."),
|
||||
|
||||
+103
-2
@@ -458,11 +458,28 @@ def _handle_unverified_semantic_shrink(
|
||||
partial_semantic_files,
|
||||
failed_ast_sources,
|
||||
semantic_files,
|
||||
cached_semantic_files=None,
|
||||
sem_cache_mode=None,
|
||||
sem_prompt=None,
|
||||
cache_root=None,
|
||||
):
|
||||
"""Shared handling for the #3203 unverified-semantic-shrink guard on both the
|
||||
raw and clustered write paths (they differ only in where the flag is read
|
||||
from — ``merged`` vs ``G.graph``). Always prints the actionable notice.
|
||||
|
||||
The same under-produced source also has to be kept out of the semantic
|
||||
cache (#5083): the cache is unversioned and content-hash keyed, so a
|
||||
degraded chunk would otherwise be replayed as authoritative on every later
|
||||
run, the shrink guard would keep refusing the write, and no LLM call would
|
||||
ever be made again. ``save_semantic_cache`` cannot see graph.json (and must
|
||||
not: it has no business reading the graph), so the entry is stamped
|
||||
``partial`` here, after the guard has measured the shrink.
|
||||
``cached_semantic_files`` identifies which shrinking sources were REPLAYED
|
||||
from the cache this run (as opposed to freshly extracted), so the message
|
||||
can call out the poisoned-entry replay instead of repeating the
|
||||
``--allow-partial`` advice — which would commit the degraded replay and
|
||||
drop the prior nodes.
|
||||
|
||||
Returns None when there is no shrink, else ``(incomplete, manifest_files,
|
||||
cleared_semantic)`` — the latter two are None unless the guard armed
|
||||
(``not cli_allow_partial``), so the caller mirrors the original inline logic.
|
||||
@@ -485,16 +502,83 @@ def _handle_unverified_semantic_shrink(
|
||||
)
|
||||
stamped = {f for _flist in manifest_files.values() for f in _flist}
|
||||
cleared_semantic = {str(p) for p in semantic_files} - stamped
|
||||
|
||||
def _path_key(value) -> str:
|
||||
p = Path(value)
|
||||
if not p.is_absolute():
|
||||
p = Path(target) / p
|
||||
try:
|
||||
return os.path.normcase(str(p.resolve()))
|
||||
except (OSError, RuntimeError):
|
||||
return os.path.normcase(os.path.abspath(str(p)))
|
||||
|
||||
cached_keys = {_path_key(p) for p in (cached_semantic_files or [])}
|
||||
cached_sources = sorted(
|
||||
sf for sf in unverified_shrink if _path_key(sf) in cached_keys
|
||||
)
|
||||
fresh_sources = sorted(
|
||||
sf for sf in unverified_shrink if _path_key(sf) not in cached_keys
|
||||
)
|
||||
|
||||
marked: list[Path] = []
|
||||
try:
|
||||
from graphify.cache import mark_semantic_cache_partial as _mark_partial
|
||||
marked = _mark_partial(
|
||||
sorted(unverified_shrink),
|
||||
root=Path(target),
|
||||
mode=sem_cache_mode,
|
||||
prompt=sem_prompt,
|
||||
cache_root=cache_root,
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001 — cache marking is best-effort
|
||||
print(
|
||||
f"[graphify extract] warning: could not mark degraded semantic "
|
||||
f"cache entries: {exc}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
details = ", ".join(
|
||||
f"'{sf}' ({prior} -> {fresh} nodes)"
|
||||
for sf, (prior, fresh) in sorted(unverified_shrink.items())
|
||||
)
|
||||
print(
|
||||
f"[graphify extract] semantic extraction is incomplete: unverified semantic "
|
||||
f"shrink detected for {details}. The shrink guard stays armed for this write; "
|
||||
"pass --allow-partial to overwrite a larger existing graph anyway.",
|
||||
f"shrink detected for {details}.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if cached_sources:
|
||||
cached_details = ", ".join(
|
||||
f"'{sf}' ({unverified_shrink[sf][0]} -> {unverified_shrink[sf][1]} nodes)"
|
||||
for sf in cached_sources
|
||||
)
|
||||
replay_effect = (
|
||||
"--allow-partial was passed, so the degraded replay is being written "
|
||||
"over the existing graph and the prior nodes are dropped."
|
||||
if cli_allow_partial
|
||||
else "Do NOT pass --allow-partial here: it would write the degraded "
|
||||
"replay over the larger existing graph and drop the prior nodes."
|
||||
)
|
||||
print(
|
||||
f"[graphify extract] {cached_details} was replayed from the semantic "
|
||||
"cache, not freshly extracted, so re-running with the same cache would "
|
||||
"replay it again. " + replay_effect + " Re-run to re-extract the "
|
||||
"marked source(s).",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if marked:
|
||||
print(
|
||||
"[graphify extract] marked "
|
||||
f"{len(marked)} semantic cache entr{'y' if len(marked) == 1 else 'ies'} "
|
||||
f"partial for re-extraction on the next run: "
|
||||
f"{', '.join(str(p) for p in marked)}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if fresh_sources and not cli_allow_partial:
|
||||
print(
|
||||
"[graphify extract] The shrink guard stays armed for this write; "
|
||||
"pass --allow-partial to overwrite a larger existing graph anyway.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return incomplete, manifest_files, cleared_semantic
|
||||
|
||||
|
||||
@@ -5018,6 +5102,11 @@ def dispatch_command(cmd: str) -> None:
|
||||
_partial_semantic_files: set[str] = set()
|
||||
sem_cache_hits = 0
|
||||
sem_cache_misses = 0
|
||||
# Files served from the semantic cache this run (absolute paths), used
|
||||
# by the #3203 shrink handler to tell a poisoned cached replay from a
|
||||
# fresh under-production (#5083).
|
||||
_cached_semantic_paths: list[str] = []
|
||||
uncached_paths: list[str] = []
|
||||
# Deep mode uses its own namespace (cache/semantic-deep/) so deep and
|
||||
# standard results for the same content never shadow each other (#1894).
|
||||
sem_cache_mode = "deep" if deep_mode else None
|
||||
@@ -5042,6 +5131,10 @@ def dispatch_command(cmd: str) -> None:
|
||||
)
|
||||
sem_cache_hits = len(semantic_files) - len(uncached_paths)
|
||||
sem_cache_misses = len(uncached_paths)
|
||||
_uncached_set = set(uncached_paths)
|
||||
_cached_semantic_paths = [
|
||||
p for p in sem_paths_str if p not in _uncached_set
|
||||
]
|
||||
sem_result["nodes"].extend(cached_nodes)
|
||||
sem_result["edges"].extend(cached_edges)
|
||||
sem_result["hyperedges"].extend(cached_hyperedges)
|
||||
@@ -5439,6 +5532,10 @@ def dispatch_command(cmd: str) -> None:
|
||||
partial_semantic_files=_partial_semantic_files,
|
||||
failed_ast_sources=_failed_ast_sources,
|
||||
semantic_files=semantic_files,
|
||||
cached_semantic_files=_cached_semantic_paths,
|
||||
sem_cache_mode=sem_cache_mode,
|
||||
sem_prompt=sem_prompt,
|
||||
cache_root=out_root,
|
||||
)
|
||||
if _shrink is not None and _shrink[0]:
|
||||
_extraction_incomplete = True
|
||||
@@ -5596,6 +5693,10 @@ def dispatch_command(cmd: str) -> None:
|
||||
partial_semantic_files=_partial_semantic_files,
|
||||
failed_ast_sources=_failed_ast_sources,
|
||||
semantic_files=semantic_files,
|
||||
cached_semantic_files=_cached_semantic_paths,
|
||||
sem_cache_mode=sem_cache_mode,
|
||||
sem_prompt=sem_prompt,
|
||||
cache_root=out_root,
|
||||
)
|
||||
if _shrink is not None and _shrink[0]:
|
||||
_extraction_incomplete = True
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for graphify/cache.py."""
|
||||
import json
|
||||
import os
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
@@ -2073,3 +2074,74 @@ def test_scope_semantic_result_unscoped_is_a_no_op():
|
||||
|
||||
assert (dropped_files, dropped_items) == (set(), 0)
|
||||
assert [n["id"] for n in result["nodes"]] == ["n"]
|
||||
|
||||
|
||||
# -- #5083: mark a degraded entry partial so the next run self-heals ----------
|
||||
|
||||
def test_mark_semantic_cache_partial_forces_next_run_miss(tmp_path):
|
||||
"""A degraded entry stays on disk for inspection but stops being served."""
|
||||
from graphify.cache import load_cached, mark_semantic_cache_partial, save_semantic_cache
|
||||
|
||||
_reset_stat_index()
|
||||
doc = tmp_path / "doc.md"
|
||||
doc.write_text("# Doc\n")
|
||||
save_semantic_cache([{"id": "doc", "source_file": "doc.md"}], [], root=tmp_path)
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic") is not None
|
||||
|
||||
marked = mark_semantic_cache_partial(["doc.md"], root=tmp_path)
|
||||
|
||||
assert len(marked) == 1
|
||||
assert marked[0].exists()
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic") is None
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic", allow_partial=True)[
|
||||
"partial"
|
||||
] is True
|
||||
# A complete re-extraction overwrites the same content-hash key cleanly.
|
||||
save_semantic_cache([{"id": "doc", "source_file": "doc.md"}], [], root=tmp_path)
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic") is not None
|
||||
|
||||
|
||||
def test_mark_semantic_cache_partial_marks_the_flat_entry_it_would_serve(tmp_path):
|
||||
"""A pre-fingerprint flat entry must be marked, not shadowed by a new one."""
|
||||
from graphify.cache import (
|
||||
cache_dir,
|
||||
file_hash,
|
||||
load_cached,
|
||||
mark_semantic_cache_partial,
|
||||
)
|
||||
|
||||
_reset_stat_index()
|
||||
doc = tmp_path / "doc.md"
|
||||
doc.write_text("# Doc\n")
|
||||
flat = cache_dir(tmp_path, "semantic") / f"{file_hash(doc, tmp_path)}.json"
|
||||
flat.write_text(
|
||||
json.dumps({"nodes": [{"id": "doc", "source_file": "doc.md"}]}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
prompt = "a prompt"
|
||||
# The fingerprinted namespace misses, so the read path falls back to flat.
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic", prompt=prompt) is not None
|
||||
|
||||
marked = mark_semantic_cache_partial(["doc.md"], root=tmp_path, prompt=prompt)
|
||||
|
||||
assert marked == [flat]
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic", prompt=prompt) is None
|
||||
|
||||
|
||||
def test_mark_semantic_cache_partial_skips_missing_and_already_partial(tmp_path):
|
||||
from graphify.cache import load_cached, mark_semantic_cache_partial, save_semantic_cache
|
||||
|
||||
_reset_stat_index()
|
||||
doc = tmp_path / "doc.md"
|
||||
doc.write_text("# Doc\n")
|
||||
save_semantic_cache(
|
||||
[{"id": "doc", "source_file": "doc.md"}],
|
||||
[],
|
||||
root=tmp_path,
|
||||
partial_source_files=[doc],
|
||||
)
|
||||
|
||||
# Already partial -> nothing new to mark; a missing source is skipped.
|
||||
assert mark_semantic_cache_partial(["doc.md"], root=tmp_path) == []
|
||||
assert mark_semantic_cache_partial(["absent.md"], root=tmp_path) == []
|
||||
assert load_cached(doc, root=tmp_path, kind="semantic") is None
|
||||
@@ -315,3 +315,150 @@ def test_3203_allow_partial_override_permits_intentional_reduction(tmp_path, mon
|
||||
# With override, the 1-node graph is persisted
|
||||
graph = json.loads((out_dir / "graph.json").read_text(encoding="utf-8"))
|
||||
assert len(graph["nodes"]) == 1
|
||||
|
||||
|
||||
# -- 3. #5083: the degraded cache entry must not pin the corpus forever --------
|
||||
|
||||
_PROMPT = llmmod._extraction_system(deep=False)
|
||||
|
||||
|
||||
def _doc_result(sf: str, count: int, prefix: str) -> dict:
|
||||
return {
|
||||
"nodes": [
|
||||
{
|
||||
"id": f"{prefix}_{i}",
|
||||
"label": f"{sf} {i}",
|
||||
"file_type": "document",
|
||||
"source_file": sf,
|
||||
}
|
||||
for i in range(count)
|
||||
],
|
||||
"edges": [],
|
||||
"hyperedges": [],
|
||||
"input_tokens": 10,
|
||||
"output_tokens": 10,
|
||||
"uncovered_files": [],
|
||||
}
|
||||
|
||||
|
||||
def _mock_extract(result: dict, calls: list):
|
||||
def _run(files, **kwargs):
|
||||
calls.append([str(f) for f in files])
|
||||
on_chunk = kwargs.get("on_chunk_done")
|
||||
if on_chunk:
|
||||
on_chunk(0, 1, result)
|
||||
return result
|
||||
|
||||
return _run
|
||||
|
||||
|
||||
def _cache_entry(root: Path, path: Path) -> Path:
|
||||
from graphify.cache import _resolve_prompt_fp, cache_dir, file_hash
|
||||
|
||||
fp = _resolve_prompt_fp(_PROMPT)
|
||||
return cache_dir(root, "semantic", fp) / f"{file_hash(path, root)}.json"
|
||||
|
||||
|
||||
def _clear_partial_flag(entry: Path) -> None:
|
||||
"""Simulate an entry written by a graphify that predates this fix."""
|
||||
data = json.loads(entry.read_text(encoding="utf-8"))
|
||||
data.pop("partial", None)
|
||||
entry.write_text(json.dumps(data), encoding="utf-8")
|
||||
|
||||
|
||||
def _boot_corpus(tmp_path, monkeypatch, capsys, calls):
|
||||
corpus = tmp_path / "repo"
|
||||
corpus.mkdir()
|
||||
readme = corpus / "README.md"
|
||||
readme.write_text("# Readme\nInitial content\n", encoding="utf-8")
|
||||
monkeypatch.setattr(mainmod, "_check_skill_version", lambda _: None)
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "sk-fake")
|
||||
monkeypatch.setattr(
|
||||
llmmod, "extract_corpus_parallel", _mock_extract(_doc_result("README.md", 3, "readme_n"), calls)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
mainmod.sys, "argv", ["graphify", "extract", str(corpus), "--backend", "claude"]
|
||||
)
|
||||
assert _run_cli() == 0
|
||||
capsys.readouterr()
|
||||
return corpus, readme
|
||||
|
||||
|
||||
def test_5083_degraded_entry_is_marked_partial_and_next_run_reextracts(
|
||||
tmp_path, monkeypatch, capsys
|
||||
):
|
||||
calls: list = []
|
||||
corpus, readme = _boot_corpus(tmp_path, monkeypatch, capsys, calls)
|
||||
out_dir = corpus / "graphify-out"
|
||||
|
||||
readme.write_text("# Readme\nEdited content\n", encoding="utf-8")
|
||||
monkeypatch.setattr(
|
||||
llmmod, "extract_corpus_parallel", _mock_extract(_doc_result("README.md", 1, "readme_doc"), calls)
|
||||
)
|
||||
assert _run_cli() == 1
|
||||
err = capsys.readouterr().err
|
||||
assert "unverified semantic shrink detected for 'README.md' (3 -> 1 nodes)" in err
|
||||
assert "marked 1 semantic cache entry partial" in err
|
||||
|
||||
from graphify.cache import load_cached
|
||||
|
||||
assert load_cached(readme, root=corpus, kind="semantic", prompt=_PROMPT) is None
|
||||
kept = load_cached(
|
||||
readme, root=corpus, kind="semantic", prompt=_PROMPT, allow_partial=True
|
||||
)
|
||||
assert kept["partial"] is True
|
||||
assert len(kept["nodes"]) == 1
|
||||
# The graph on disk is untouched.
|
||||
assert len(json.loads((out_dir / "graph.json").read_text(encoding="utf-8"))["nodes"]) == 3
|
||||
|
||||
# Next run: the partial entry is a MISS, so the model is consulted again and
|
||||
# the healthy extraction lands instead of re-failing against the cache.
|
||||
monkeypatch.setattr(
|
||||
llmmod, "extract_corpus_parallel", _mock_extract(_doc_result("README.md", 24, "readme_h"), calls)
|
||||
)
|
||||
assert _run_cli() == 0
|
||||
assert any(str(readme) in c for c in calls[-1])
|
||||
assert len(json.loads((out_dir / "graph.json").read_text(encoding="utf-8"))["nodes"]) == 24
|
||||
|
||||
|
||||
def test_5083_cached_degraded_replay_is_marked_and_does_not_advise_allow_partial(
|
||||
tmp_path, monkeypatch, capsys
|
||||
):
|
||||
calls: list = []
|
||||
corpus, readme = _boot_corpus(tmp_path, monkeypatch, capsys, calls)
|
||||
|
||||
readme.write_text("# Readme\nEdited content\n", encoding="utf-8")
|
||||
monkeypatch.setattr(
|
||||
llmmod, "extract_corpus_parallel", _mock_extract(_doc_result("README.md", 1, "readme_doc"), calls)
|
||||
)
|
||||
assert _run_cli() == 1
|
||||
capsys.readouterr()
|
||||
|
||||
# Pretend the 1-node entry was written by a graphify that predates the fix:
|
||||
# the shrink guard refuses, but nothing marks the entry, so the next run
|
||||
# replays it without ever calling the model.
|
||||
entry = _cache_entry(corpus, readme)
|
||||
_clear_partial_flag(entry)
|
||||
|
||||
def _must_not_call(files, **kwargs): # pragma: no cover - must stay uncalled
|
||||
raise AssertionError(f"a cached degraded replay must not call the model: {files}")
|
||||
|
||||
monkeypatch.setattr(llmmod, "extract_corpus_parallel", _must_not_call)
|
||||
assert _run_cli() == 1
|
||||
err = capsys.readouterr().err
|
||||
assert "replayed from the semantic" in err
|
||||
assert "Do NOT pass --allow-partial" in err
|
||||
# No misleading "pass --allow-partial" advice for a cached replay.
|
||||
assert "pass --allow-partial to overwrite a larger existing graph" not in err
|
||||
assert "marked 1 semantic cache entry partial" in err
|
||||
assert json.loads(entry.read_text(encoding="utf-8"))["partial"] is True
|
||||
|
||||
# Re-run now re-extracts and heals the graph.
|
||||
monkeypatch.setattr(
|
||||
llmmod, "extract_corpus_parallel", _mock_extract(_doc_result("README.md", 24, "readme_h"), calls)
|
||||
)
|
||||
assert _run_cli() == 0
|
||||
assert any(str(readme) in c for c in calls[-1])
|
||||
assert len(
|
||||
json.loads((corpus / "graphify-out" / "graph.json").read_text(encoding="utf-8"))["nodes"]
|
||||
) == 24
|
||||
Reference in new issue
Block a user