fix(s31): close 1 review BLOCKER — refuse --semantic-retrieval when it cannot take effect
This commit is contained in:
parent
fc69285f2c
commit
8e9f6603d7
2 changed files with 98 additions and 2 deletions
|
|
@ -518,8 +518,53 @@ def _generation_prompts(sink: list[str]) -> list[str]:
|
|||
return [p for p in sink if "SavingsProposal" in p]
|
||||
|
||||
|
||||
def test_semantic_retrieval_flag_parses_offline(capsys) -> None:
|
||||
"""(a) the flag is accepted in single-project mode and the run still stops offline."""
|
||||
def test_semantic_retrieval_flag_parses_offline(tmp_path, capsys) -> None:
|
||||
"""(a) the flag is accepted in single-project mode and the run still stops offline.
|
||||
|
||||
Carries ``--verdict-dir`` because the flag is now refused without it (Step 3) — the inbox path
|
||||
need not exist, since the Steg-7 load is deliberately tolerant of a missing folder."""
|
||||
rc = run.main(
|
||||
[
|
||||
_PID,
|
||||
"--docs-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--bundle-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--verdict-dir",
|
||||
str(tmp_path / "inbox"),
|
||||
"--semantic-retrieval",
|
||||
"--live-dry-run",
|
||||
]
|
||||
)
|
||||
assert rc == 0
|
||||
assert "LIVE-DRY-RUN OK" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_semantic_retrieval_without_bundle_dir_is_refused(tmp_path, capsys) -> None:
|
||||
"""The flag is REFUSED, never ignored: without ``--bundle-dir`` the Step-1 fold never runs, so
|
||||
the opt-in could not affect anything the run emits. The refusal names the missing flag verbatim
|
||||
(the repo's offender-naming idiom) and carries no traceback."""
|
||||
rc = run.main(
|
||||
[
|
||||
_PID,
|
||||
"--docs-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--verdict-dir",
|
||||
str(tmp_path / "inbox"),
|
||||
"--semantic-retrieval",
|
||||
]
|
||||
)
|
||||
err = capsys.readouterr().err
|
||||
assert rc == 1
|
||||
assert "run refused:" in err
|
||||
assert "--bundle-dir" in err
|
||||
assert "Traceback" not in err
|
||||
|
||||
|
||||
def test_semantic_retrieval_without_verdict_dir_is_refused(capsys) -> None:
|
||||
"""Same contract on the other half: ``--verdict-dir`` is the ONLY route by which ``main()`` can
|
||||
hand ``run_project`` a non-empty store, so without it the fold's ``store.verdicts`` guard
|
||||
short-circuits and the flag is inert."""
|
||||
rc = run.main(
|
||||
[
|
||||
_PID,
|
||||
|
|
@ -528,11 +573,35 @@ def test_semantic_retrieval_flag_parses_offline(capsys) -> None:
|
|||
"--bundle-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--semantic-retrieval",
|
||||
]
|
||||
)
|
||||
err = capsys.readouterr().err
|
||||
assert rc == 1
|
||||
assert "run refused:" in err
|
||||
assert "--verdict-dir" in err
|
||||
assert "Traceback" not in err
|
||||
|
||||
|
||||
def test_semantic_retrieval_with_both_dirs_is_not_refused(tmp_path, capsys) -> None:
|
||||
"""The refusal must be exactly as wide as the condition that makes the flag inert — with both
|
||||
flags present the run proceeds (here to the offline dry-run return), not to a refusal."""
|
||||
rc = run.main(
|
||||
[
|
||||
_PID,
|
||||
"--docs-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--bundle-dir",
|
||||
str(BUNDLE_DIR),
|
||||
"--verdict-dir",
|
||||
str(tmp_path / "inbox"),
|
||||
"--semantic-retrieval",
|
||||
"--live-dry-run",
|
||||
]
|
||||
)
|
||||
out = capsys.readouterr()
|
||||
assert rc == 0
|
||||
assert "LIVE-DRY-RUN OK" in capsys.readouterr().out
|
||||
assert "LIVE-DRY-RUN OK" in out.out
|
||||
assert "--semantic-retrieval" not in out.err
|
||||
|
||||
|
||||
def test_semantic_retrieval_is_not_refused_in_portfolio_mode(capsys) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue