Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions pm-stack/opencode-claimant/claimant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pm-stack/opencode-claimant/test_claimant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down