feat(extract): a flagless extract that ingests docs clears the code-only scope (#4923)
Running `extract` without --code-only on a corpus with docs, past the API-key
check, is an explicit move back to a full graph, so the recorded scope is cleared.
An aborted run (no key) and a corpus with no docs leave it alone, so a plain
`extract` cannot silently drop the scope.
(cherry picked from commit e0b76cdac3)
This commit is contained in:
1 parent
b80cd8384b
commit
93b7a9c1e3
2 files changed
+33
No files matched your search
@@ -4363,6 +4363,12 @@ def dispatch_command(cmd: str) -> None:
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
# #4923: a flagless extract that is really ingesting docs (it got past
|
||||
# the key check above) is an explicit scope change back to a full graph.
|
||||
# An aborted run or a corpus with no docs leaves the recorded scope alone.
|
||||
if not code_only and semantic_files:
|
||||
_write_build_cfg(graphify_out, excludes=None, code_only=False)
|
||||
|
||||
# Track whether this run's extraction was incomplete (a whole extractor
|
||||
# pass crashed, or some semantic chunks failed). A partial result must not
|
||||
# be force-written over a good complete graph — the final write falls back
|
||||
|
||||
@@ -183,3 +183,30 @@ def test_build_state_differs_by_scope(tmp_path):
|
||||
kw = dict(watch_root=tmp_path, follow_symlinks=False, no_cluster=False,
|
||||
gitignore=True, excludes=None, scan_digest="x")
|
||||
assert _current_build_state(**kw, code_only=True) != _current_build_state(**kw, code_only=False)
|
||||
|
||||
|
||||
def test_aborted_flagless_extract_keeps_scope(tmp_path):
|
||||
_corpus(tmp_path)
|
||||
assert _gfy(tmp_path, "extract", str(tmp_path), "--code-only").returncode == 0
|
||||
env = {k: "" for k in ("GEMINI_API_KEY", "GOOGLE_API_KEY", "ANTHROPIC_API_KEY",
|
||||
"OPENAI_API_KEY", "MOONSHOT_API_KEY", "DEEPSEEK_API_KEY")}
|
||||
r = _gfy(tmp_path, "extract", str(tmp_path), env=env)
|
||||
assert r.returncode == 1 and "no LLM API key" in r.stderr
|
||||
assert _cfg(tmp_path)["code_only"] is True
|
||||
|
||||
|
||||
def test_flagless_extract_that_ingests_docs_resets_scope(tmp_path):
|
||||
_corpus(tmp_path)
|
||||
assert _gfy(tmp_path, "extract", str(tmp_path), "--code-only").returncode == 0
|
||||
assert _cfg(tmp_path)["code_only"] is True
|
||||
# dead local ollama: passes the key gate (localhost), then fails to connect
|
||||
_gfy(tmp_path, "extract", str(tmp_path), "--backend", "ollama",
|
||||
env={"OLLAMA_BASE_URL": "http://127.0.0.1:1"})
|
||||
assert _cfg(tmp_path)["code_only"] is False
|
||||
|
||||
|
||||
def test_flagless_extract_on_doc_free_corpus_keeps_scope(tmp_path):
|
||||
(tmp_path / "a.py").write_text("def foo():\n return 1\n")
|
||||
assert _gfy(tmp_path, "extract", str(tmp_path), "--code-only").returncode == 0
|
||||
assert _gfy(tmp_path, "extract", str(tmp_path)).returncode == 0
|
||||
assert _cfg(tmp_path)["code_only"] is True
|
||||
Reference in new issue
Block a user