fix(tools): okf_adjudicate exits 2 on a malformed plan
A SegmentationError raised by the plan grammar escaped main() as a traceback and exit 1, while every other malformed-plan case in the same file already returned 2. Exit codes are the interface a caller scripts against, and exit 1 with a traceback is the code an unhandled bug produces -- it says "this command broke" where the truth is "this file is not a plan". The refusal itself is unchanged: nothing was written before and nothing is written now, and the grammar in src/ is untouched. What changes is one line on stderr naming the error code, and the exit code. Both branches that can raise are covered: the pre-write parse of a non-empty plan, and the required-field check reached through the empty branch. The old behaviour was pinned by test_an_entries_value_that_is_not_a_list_is_still_refused, which asserted that a wrongly-typed `entries` reaches the caller as a raised SegmentationError and recorded that as a finding rather than fixing it. That test is rewritten here, in the same commit as the code, to assert exit 2 plus the code on stderr. A second test pins the one-line stderr shape on the non-empty branch. Suite 1072 -> 1073 passed; ruff and mypy --strict clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
acf2ac24d7
commit
a72053f66f
3 changed files with 68 additions and 8 deletions
|
|
@ -39,6 +39,7 @@ from typing import Any
|
|||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
||||
|
||||
from llm_ingestion_okf.errors import SegmentationError # noqa: E402
|
||||
from llm_ingestion_okf.segmentation import PLAN_FIELDS, parse_segmentation_plan # noqa: E402
|
||||
|
||||
#: This tool's identity, written into the artifact so an operator reading a
|
||||
|
|
@ -265,6 +266,14 @@ def main(argv: list[str] | None = None) -> int:
|
|||
file=sys.stderr,
|
||||
)
|
||||
return 2
|
||||
except SegmentationError as exc:
|
||||
# A malformed plan is a refusal, not a crash. Letting the grammar's
|
||||
# error escape gave a traceback and exit 1, which a caller scripting on
|
||||
# exit codes reads as "this command broke" -- the same code an unhandled
|
||||
# bug would produce. One line, and the same 2 every other malformed plan
|
||||
# already got.
|
||||
print(f"{ADJUDICATOR_ID}: FAILED - malformed plan [{exc.code}]: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue