From 0007587ad85d126a3a4871c96204878c336448a1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 08:42:14 +0000 Subject: [PATCH] fix(tests): match live-head-moved regression to #1697's intentional reorder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1697 (commit 5c561a65) reordered opencode-review.yml's live-state checks so closed/draft admission runs before the head-SHA-match check, and exits 0 instead of 1 for an open, ready PR whose live head has moved. A draft PR whose live head has moved is therefore exempted by the draft check first — the head-moved branch is now unreachable while still draft. test_opencode_live_draft_state_regression.py's test_draft_exemption_fails_closed_when_live_head_moved still asserted the pre-#1697 behavior (returncode 1, "head moved while validating live" in stdout) for exactly that input shape, so it fails on current main. Update it to assert the actual current behavior (returncode 0, exempted via the draft-check message), matching the equivalent direct-production-step coverage #1697 already added in test_opencode_required_verdict_regression.py. Confirmed via a clean origin/main worktree that the regression pre-dates this change and is not introduced by it. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01BV96rXhqoR3tYZ9AeAVur4 --- ...st_opencode_live_draft_state_regression.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/test_opencode_live_draft_state_regression.py b/tests/test_opencode_live_draft_state_regression.py index a9d9c518bc..dcbabc2428 100644 --- a/tests/test_opencode_live_draft_state_regression.py +++ b/tests/test_opencode_live_draft_state_regression.py @@ -186,15 +186,29 @@ def test_stale_draft_request_reuses_live_ready_approval(tmp_path: Path) -> None: @pytest.mark.parametrize("script", (request_review_script(), fail_closed_script())) -def test_draft_exemption_fails_closed_when_live_head_moved( +def test_draft_exemption_applies_even_when_live_head_has_moved( tmp_path: Path, script: str, ) -> None: - """The event cannot exempt a different live head even when it is still draft.""" + """A still-draft PR exempts before the head-match check ever runs. + + #1697 reordered the live-state checks so closed/draft admission is + evaluated before the head-SHA-match check (a draft PR whose live head + moved between the event snapshot and this step's own live re-fetch must + not fail closed with red-X noise -- see + ``ContextualWisdomLab/contextual-orchestrator`` PR #1000). The + head-moved branch is therefore unreachable while still draft: this + exercise now exempts via the draft check, not the head-match check. + Equivalent direct coverage of the production step lives in + ``test_opencode_required_verdict_regression.py``'s + ``test_request_review_step_exempts_a_draft_pr_whose_live_head_has_moved`` + and ``test_fail_closed_step_exempts_a_draft_pr_whose_live_head_has_moved``. + """ result = _run_step(tmp_path, script, live_draft=True, live_head="b" * 40) - assert result.returncode == 1 - assert "head moved while validating live" in result.stdout + assert result.returncode == 0, result.stderr + assert "still a draft on the live exact head" in result.stdout + assert "head moved" not in result.stdout @pytest.mark.parametrize("script", (request_review_script(), fail_closed_script()))