From 47d7323eb8473157603cb283014cf136f1b4b18f Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 24 Nov 2026 07:18:11 -0600 Subject: [PATCH] claimant: classify well-formed {"task": null} exit-5 claim answer as no_match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port of the one novel hunk preserved on archer/repo-sweep-primary-snapshot (#13919 section 2). In _collect_handed_offs, cmd_claim's "nothing claimable" answer — a well-formed {"task": null} body with exit 5 (or 0) — was classified cli_nonzero because the non-zero-exit check ran first. The well-formed null-task check now runs before the non-zero fallback for exit codes 0 and 5; any other exit code stays cli_nonzero. Adds the two boundary rows to TestSinkClaimDiagnostics: exit 5 with a null-task body is no_match; exit 5 without one stays cli_nonzero. Refs #13919 (section 2 only; the issue stays open for its other sections). --- pm-stack/opencode-claimant/claimant.py | 16 +++++++++++++--- pm-stack/opencode-claimant/test_claimant.py | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pm-stack/opencode-claimant/claimant.py b/pm-stack/opencode-claimant/claimant.py index 33689d13dc..3063d90f81 100755 --- a/pm-stack/opencode-claimant/claimant.py +++ b/pm-stack/opencode-claimant/claimant.py @@ -1289,10 +1289,20 @@ def _collect_handed_offs(queue: str, want: int, *, diagnostic=None) -> Dict[int, row = data if isinstance(data, dict) else None claimed_id = row.get("id") if isinstance(row, dict) else None if claimed_id is None: - if result.returncode != 0: - outcome = "cli_nonzero" - elif row is not None and "task" in row and row["task"] is None: + if ( + row is not None + and "task" in row + and row["task"] is None + and result.returncode in (0, 5) + ): + # cmd_claim's "nothing claimable" answer: a well-formed + # {"task": null} body with exit 5 (or 0). That is the + # ordinary empty result, not a CLI failure, so classify it + # before the non-zero-exit fallback. Any other exit code is + # a broker error and stays cli_nonzero. outcome = "no_match" + elif result.returncode != 0: + outcome = "cli_nonzero" else: outcome = "missing_claim_row" break diff --git a/pm-stack/opencode-claimant/test_claimant.py b/pm-stack/opencode-claimant/test_claimant.py index 5cda9fdc65..4f3980e3f8 100644 --- a/pm-stack/opencode-claimant/test_claimant.py +++ b/pm-stack/opencode-claimant/test_claimant.py @@ -1775,6 +1775,8 @@ def test_fixed_categories_do_not_copy_cli_output_and_preserve_attempts(self): (Result(13, "private"), "cli_nonzero"), (Result(0, "private"), "invalid_json"), (Result(0, '{"task":null,"ignored":"private"}'), "no_match"), + (Result(5, '{"task":null,"ignored":"private"}'), "no_match"), + (Result(5, '{"ignored":"private"}'), "cli_nonzero"), (Result(0, '{"ignored":"private"}'), "missing_claim_row"), ) for fixture, category in fixtures: