Skip to content
Closed
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
30 changes: 26 additions & 4 deletions tests/test_opencode_live_draft_state_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,37 @@ 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_survives_when_live_head_moved(
tmp_path: Path,
script: str,
) -> None:
"""The event cannot exempt a different live head even when it is still draft."""
"""A stale draft-conversion event still exempts a draft PR whose live head moved.

PR #1697 (`fix(opencode): retire stale draft/head dispatches without
false failure`) deliberately reordered both step bodies to check
closed/draft *before* head-SHA-match, following a real production
incident: contextual-orchestrator PR #1000 stayed draft the whole time,
but a push landed between the event snapshot and this step's live
re-fetch, and the old head-match-first ordering failed hard with
`::error::...head moved while validating live review state.` and exit 1
even though no review was ever being requested against a stable target
(https://github.com/ContextualWisdomLab/contextual-orchestrator/actions/runs/33548447878/job/100066104033).
Comment on lines +195 to +203

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Cross-repository reference breaks traceability

The new docstring uses “contextual-orchestrator PR #1000,” violating the required owner/repo#num format for cross-repository references.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Draft/closed is a no-op exit either way -- no receipt-gate fetch, no
OIDC exchange, no dispatch, no polling -- so there is no genuine
correctness reason to distinguish a moved head from an unmoved one here;
this test's harness combines that moved head with the *event-level*
stale-draft-conversion metadata this file exercises throughout (unlike
`test_opencode_required_verdict_regression.py`'s own coverage of the
same #1697 fix, which does not vary event action/draft metadata), so it
is kept -- updated, not deleted -- for that distinct angle. This test
previously asserted the old, superseded ``head moved`` exit-1 behavior
this fix retired; do not reinstate that expectation.
"""
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
Comment on lines +217 to +219

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Moved head labeled exact

With different event and live heads, the asserted live exact head message is false. The test now preserves a misleading operator diagnostic.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.



@pytest.mark.parametrize("script", (request_review_script(), fail_closed_script()))
Expand Down
Loading