Skip to content

fix(opencode): correct stale draft/head-moved test expectation from #1697 - #1709

Closed
seonghobae wants to merge 1 commit into
mainfrom
fix/draft-head-moved-test-ordering-1697
Closed

fix(opencode): correct stale draft/head-moved test expectation from #1697#1709
seonghobae wants to merge 1 commit into
mainfrom
fix/draft-head-moved-test-ordering-1697

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Changes

tests/test_opencode_live_draft_state_regression.py:

.github/workflows/opencode-review.yml is untouched — this is a test-only fix; #1697's real, evidence-backed behavior change stands as merged.

Test plan

  • tests/test_opencode_live_draft_state_regression.py + tests/test_opencode_required_verdict_regression.py — 60 passed
  • tests/test_opencode_agent_contract.py tests/test_opencode_security_boundaries.py tests/test_required_workflow_queue_contract.py (part of fix(opencode): do not fail draft PRs when the head moves mid-check #1697's own verification scope, re-run here to confirm no regression) — 170 passed
  • coverage run -m pytest tests && coverage report --show-missing (100% gate on scripts/ci) — running; will update this PR once confirmed
  • No workflow file changed, so actionlint was not required.

Note on required checks

The org-wide GitHub Actions capacity incident (being addressed separately this session) may delay this PR's own required checks from completing promptly. If that happens, this PR may need a bypass-merge per this org's standing chicken-and-egg authorization for exactly that situation — but I am not merging this myself; that decision is left to a human/maintainer.

🤖 Generated with Claude Code


Devin Review

…1697

test_draft_exemption_fails_closed_when_live_head_moved in
tests/test_opencode_live_draft_state_regression.py still asserted the
pre-#1697 behavior (exit 1, "head moved while validating live") that
PR #1697 deliberately replaced with a graceful exit 0 ("still a draft
on the live exact head"). #1697's own PR body verification scope did
not include this test file, so the mismatch went uncaught and this
test has been failing against origin/main ever since #1697 merged.

#1697's reorder is correct: for both draft+head-unchanged and
draft+head-moved, the script exits via the identical unconditional
draft-check before ever comparing heads and before any consequential
action (no receipt-gate fetch, OIDC exchange, dispatch, or polling) --
there is no distinct-case correctness reason to fail one and not the
other. Rebased on the real production incident #1697 cites
(contextual-orchestrator PR #1000, spurious hard failure at
https://github.com/ContextualWisdomLab/contextual-orchestrator/actions/runs/33548447878/job/100066104033).

Renamed to test_draft_exemption_survives_when_live_head_moved and
rewrote the docstring to cite #1697 and its evidence, matching this
file's own pattern of sourcing rationale in docstrings. Kept (not
deleted) since this harness uniquely combines a moved live head with
event-level stale-draft-conversion metadata, a distinct angle from
#1697's own new tests in test_opencode_required_verdict_regression.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 73c9519b-3491-4109-9c2e-f608ab283f60

📥 Commits

Reviewing files that changed from the base of the PR and between 6f70174 and 72777ee.

📒 Files selected for processing (1)
  • tests/test_opencode_live_draft_state_regression.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 2 potential issues.

Devin Review

Comment on lines +195 to +203
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).

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.

Comment on lines +217 to +219
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

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.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded — this exact conflict (test_draft_exemption_fails_closed_when_live_head_moved vs. #1697's deliberate check reorder) was independently investigated and fixed in parallel via #1705, which was merged into #1710 and landed on main. Verified directly: tests/test_opencode_live_draft_state_regression.py passes 19/19 on current main right now, with the equivalent reasoning already documented in that test's updated docstring. Merging this PR as-is would actually regress: its branch predates #1710's sleep-stubbing fix, so its diff against main would remove the fake-sleep stub and reintroduce the ~120s real-sleep hang in the sibling test. No valid delta remains outside what's already merged.

@seonghobae seonghobae closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant