Skip to content

ci: refresh PR mergeability before queue decisions - #68

Merged
seonghobae merged 1 commit into
mainfrom
codex/rest-merge-state-guard
Jun 25, 2026
Merged

ci: refresh PR mergeability before queue decisions#68
seonghobae merged 1 commit into
mainfrom
codex/rest-merge-state-guard

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

  • Refresh each open PR with REST mergeable_state before scheduler decisions.
  • Prefer REST dirty, behind, and unknown over potentially stale GraphQL mergeStateStatus.
  • Prevent stale CLEAN readings from enabling auto-merge on conflicted PRs, and route approved behind PRs to update_branch with workflow GITHUB_TOKEN / github-actions[bot] guidance.

Why

A live downstream scheduler run showed stale GraphQL merge state: PR #450 was actually dirty but auto-merge stayed enabled, while approved behind PRs like #451 were not routed to update-branch. The scheduler now reads GitHub REST mergeability before acting.

Verification

  • python3 -m coverage run -m pytest
  • python3 -m coverage report --fail-under=100
  • python3 scripts/ci/pr_review_merge_scheduler.py --self-test
  • python3 -m py_compile scripts/ci/pr_review_merge_scheduler.py
  • python3 -m interrogate -c pyproject.toml .
  • git diff --check

Copilot AI review requested due to automatic review settings June 25, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the PR review/merge scheduler to refresh each open PR’s mergeability using GitHub’s REST mergeable_state before making queue decisions, reducing reliance on potentially stale GraphQL mergeStateStatus/mergeStateStatus-adjacent signals.

Changes:

  • Add REST mergeability fetching/normalization helpers and enrich fetched PR payloads with restMergeableState.
  • Use an effective_merge_state() to prefer REST DIRTY, BEHIND, and UNKNOWN when deciding whether to disable auto-merge, wait, or request update_branch.
  • Extend unit tests to cover REST mergeability helper behavior and decision routing when REST and GraphQL disagree.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/ci/pr_review_merge_scheduler.py Adds REST mergeability enrichment and updates decision logic to prefer REST evidence (incl. explicit handling for UNKNOWN).
tests/test_pr_review_merge_scheduler.py Updates PR fixtures and adds/extends tests to validate REST mergeability helpers and new decision behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/ci/pr_review_merge_scheduler.py
Comment thread scripts/ci/pr_review_merge_scheduler.py
@seonghobae
seonghobae force-pushed the codex/rest-merge-state-guard branch from 0c65cc1 to 5c6f069 Compare June 25, 2026 18:15
@opencode-agent

opencode-agent Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 5c6f069444b0a42b0f4c474feb9b97019a53ecf0
  • Workflow run: 28191640929
  • Workflow attempt: 1
  • Gate result: APPROVE (approval step)

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Changes enhance merge safety by adding REST mergeable_state checks. Verification posture: Linter/static: PASS (no new lint issues), TDD/regression: PASS (tests cover new states), Coverage: 100%, Docstring coverage: 100%, DAG: [mermaid graph], PoC/execution: Verified scheduler behavior in self-test, DDD/domain: Consistent with GitHub merge workflows, CDD/context: Matches repository conventions, Similar issues: None found, Claim/concept check: REST mergeable_state docs verified, Standards search: Matches GitHub API conventions, Compatibility/convention: Backward-compatible, Breaking-change/backcompat: None, Performance: No degradation, Developer experience: Improves scheduler transparency, User experience: Reduces stale merge states, Security/privacy: No new risks

Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including scripts/ci/pr_review_merge_scheduler.py, tests/test_pr_review_merge_scheduler.py.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence proves 100% test coverage.
Docstring coverage: coverage execution evidence proves 100% docstring coverage.
DAG: Change Flow DAG maps scripts/ci/pr_review_merge_scheduler.py through bounded evidence, review risk, and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, and current-head workflow evidence were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions and compatibility surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: changed files did not identify a user-facing UI surface; bounded evidence was reviewed for UX impact.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: No blocking issues found
  • Head SHA: 5c6f069444b0a42b0f4c474feb9b97019a53ecf0
  • Workflow run: 28191640929
  • Workflow attempt: 1

Change Flow DAG

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["CI script: pr_review_merge_scheduler.py"]
  S1 --> I1["review and security gate shell path"]
  I1 --> R1["Review risk: CI script: pr_review_merge_scheduler.py"]
  R1 --> V1["bash -n plus Strix self-test"]
  Evidence --> S2["Test: test_pr_review_merge_scheduler.py"]
  S2 --> I2["regression suite"]
  I2 --> R2["Review risk: Test: test_pr_review_merge_scheduler.py"]
  R2 --> V2["targeted test run"]
Loading

@opencode-agent opencode-agent 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.

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Changes enhance merge safety by adding REST mergeable_state checks. Verification posture: Linter/static: PASS (no new lint issues), TDD/regression: PASS (tests cover new states), Coverage: 100%, Docstring coverage: 100%, DAG: [mermaid graph], PoC/execution: Verified scheduler behavior in self-test, DDD/domain: Consistent with GitHub merge workflows, CDD/context: Matches repository conventions, Similar issues: None found, Claim/concept check: REST mergeable_state docs verified, Standards search: Matches GitHub API conventions, Compatibility/convention: Backward-compatible, Breaking-change/backcompat: None, Performance: No degradation, Developer experience: Improves scheduler transparency, User experience: Reduces stale merge states, Security/privacy: No new risks

Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including scripts/ci/pr_review_merge_scheduler.py, tests/test_pr_review_merge_scheduler.py.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence proves 100% test coverage.
Docstring coverage: coverage execution evidence proves 100% docstring coverage.
DAG: Change Flow DAG maps scripts/ci/pr_review_merge_scheduler.py through bounded evidence, review risk, and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, and current-head workflow evidence were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions and compatibility surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: changed files did not identify a user-facing UI surface; bounded evidence was reviewed for UX impact.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: No blocking issues found
  • Head SHA: 5c6f069444b0a42b0f4c474feb9b97019a53ecf0
  • Workflow run: 28191640929
  • Workflow attempt: 1

@seonghobae
seonghobae merged commit 590b4ec into main Jun 25, 2026
4 checks passed
@seonghobae
seonghobae deleted the codex/rest-merge-state-guard branch June 25, 2026 18:38
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.

2 participants