Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/opencode-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ jobs:
fi
if [ "${live_poll_head,,}" != "${HEAD_SHA,,}" ]; then
echo "::notice::Pull request head moved while waiting for a current-head OpenCode verdict; retiring superseded Required OpenCode Review poll."
exit 1
exit 0
Comment thread
seonghobae marked this conversation as resolved.
Resolved
Comment thread
seonghobae marked this conversation as resolved.
Resolved
fi
if [ "$live_poll_state" = "closed" ]; then
echo "PR closed while waiting for the current-head OpenCode verdict; the poll is no longer required."
Expand Down
9 changes: 3 additions & 6 deletions tests/test_opencode_poll_self_retirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ def test_poll_live_state_revalidation_fails_closed_on_malformed_evidence() -> No
def test_poll_executes_superseded_head_retirement_before_reviews_read(
tmp_path: Path,
) -> None:
"""A moved head exits non-passing before the Reviews API is consulted."""
"""A moved head exits successfully before the Reviews API is consulted."""
head_sha = "a" * 40
result, calls = _run_poll_loop(
tmp_path,
head_sha=head_sha,
live_pr={"head": {"sha": "b" * 40}, "draft": False, "state": "open"},
)

assert result.returncode == 1
assert result.returncode == 0
assert "retiring superseded Required OpenCode Review poll" in result.stdout
assert calls == ["api repos/ContextualWisdomLab/example/pulls/42"]

Expand Down Expand Up @@ -393,7 +393,6 @@ def test_poll_fails_closed_after_wall_clock_deadline_with_every_gh_call_succeedi
"::error::No current-head OpenCode verdict after 180 minutes of "
"polling; failing closed and releasing the runner." in result.stdout
)
# Distinct diagnostic from the transport-failure path: nothing here failed.
assert "consecutive times" not in result.stdout
assert calls == [
"api repos/ContextualWisdomLab/example/pulls/42",
Expand All @@ -420,7 +419,7 @@ def test_poll_wall_clock_deadline_does_not_interfere_with_a_fast_verdict(
"body": "Source-backed current-head semantic review.",
}
],
date_epochs=[1000, 1000], # baseline call, then one in-bounds iteration check
date_epochs=[1000, 1000],
)

assert result.returncode == 0, result.stderr
Expand Down Expand Up @@ -453,8 +452,6 @@ def test_wall_clock_deadline_is_distinct_from_and_additional_to_transport_counte
"::error::No current-head OpenCode verdict after 180 minutes of "
"polling; failing closed and releasing the runner." in loop
)
# The deadline check must precede this iteration's gh calls so an
# already-expired deadline never spends another API request.
assert loop.index('-ge "$poll_deadline_epoch"') < loop.index(
'live_poll_pr="$(timeout 30s gh api'
)
40 changes: 40 additions & 0 deletions tests/test_opencode_superseded_poll_success.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Regression for successful retirement of superseded OpenCode verdict polls."""

from __future__ import annotations

from pathlib import Path
import os
import subprocess


WORKFLOW_PATH = Path(".github/workflows/opencode-review.yml")


def _superseded_poll_guard() -> str:
"""Return the production in-loop moved-head guard from the OpenCode workflow."""
workflow_text = WORKFLOW_PATH.read_text(encoding="utf-8")
marker = ' if [ "${live_poll_head,,}" != "${HEAD_SHA,,}" ]; then\n'
guard_body = workflow_text.split(marker, 1)[1].split(" fi\n", 1)[0]
return marker + guard_body + " fi\n"
Comment thread
seonghobae marked this conversation as resolved.
Resolved


def test_superseded_poll_retires_successfully() -> None:
"""A moved head must release stale required-review work without a false red status."""
script = "\n".join(
(
"set -euo pipefail",
'HEAD_SHA="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"',
'live_poll_head="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"',
_superseded_poll_guard(),
)
)
result = subprocess.run(
["bash", "-c", script],
check=False,
capture_output=True,
text=True,
env=os.environ.copy(),
)

assert result.returncode == 0
assert "retiring superseded Required OpenCode Review poll" in result.stdout
Loading