diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18e5d9e..dff8f16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.47.23 - 2026-11-16
+
+- Evaluate the latest verified check run per workflow and check name for PR merges. Report superseded runs as informational while preserving blocks for current failures, pending checks, distinct workflows and ambiguous history. Apply the same selection to required checks.
+
## 0.47.22 - 2026-11-16
- Register persistent stack replay desks and provide a reviewed CLI release path. Preserve the desk tip, index and working changes in verified local recovery refs before removing its checkout, with explicit selection for legacy desks. Stack archive names the desk release or pending-release remedy.
diff --git a/README.md b/README.md
index bd0d551..6edfb70 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
Keep many long-lived pull requests clean, rebuildable, and publishable from one
manifest.
-Current version: `0.47.22`
+Current version: `0.47.23`
`syncwheel` is a small CLI and workflow model for maintainers who carry several
PR branches against an upstream repository and need those branches to stay
diff --git a/VERSION b/VERSION
index ccecd68..cf7b6cd 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.47.22
+0.47.23
diff --git a/docs/github-pr-merge.md b/docs/github-pr-merge.md
index 3e418ec..edaaa78 100644
--- a/docs/github-pr-merge.md
+++ b/docs/github-pr-merge.md
@@ -45,10 +45,20 @@ At least one provenance filter (`--pr-author`, `--commit-author`, or
empty lists, unknown keys, tokens, commands, and secrets are rejected.
`--checks all` is the fail-closed default: at least one check must exist and
-every observed check must finish successfully or be skipped. A repository
-without CI may explicitly use `--checks none`; the merge plan then records a
-`checks_not_required` warning. This opt-out is clone-local and does not bypass
-required checks reported by GitHub branch protection or rulesets.
+every current check must finish successfully or be skipped. For the exact PR
+head, Syncwheel groups check runs by check name and verified workflow identity
+and evaluates the latest run in each group. A rerun attempt is compared only
+within its own run. Superseded runs are reported as informational warnings; a
+latest queued, cancelled or failed run still blocks. Ambiguous identity or
+ordering never hides a blocking observation. Incomplete or truncated check
+history blocks the merge even when the rows received so far are green. Legacy status contexts remain
+separate from workflow checks. The same selection applies to required checks,
+so success in an unrelated workflow with the same check name cannot hide a
+failure.
+
+A repository without CI may explicitly use `--checks none`; the merge plan
+then records a `checks_not_required` warning. This opt-out is clone-local and
+does not bypass required checks reported by GitHub branch protection or rulesets.
`private_free_rules` is a narrow fallback for private repositories on GitHub
Free. It applies only when GitHub returns its explicit plan-limit response for
diff --git a/docs/index.html b/docs/index.html
index 93767fd..93ed2ff 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1826,7 +1826,7 @@
-
AI-ready Git coordination v0.47.22
+
AI-ready Git coordination v0.47.23
Move at machine speed. Stay in control.
Syncwheel coordinates every Git lane used by humans, AI agents, CI and delivery systems—without sacrificing review, safety or recovery.
@@ -2602,7 +2602,7 @@
Your first verified plan in minutes.
- syncwheel v0.47.22 · MIT · a NestDevLab project
+ syncwheel v0.47.23 · MIT · a NestDevLab project
diff --git a/openpack.json b/openpack.json
index 1d32424..d84252e 100644
--- a/openpack.json
+++ b/openpack.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 2,
"name": "NestDevLab/syncwheel",
- "version": "0.47.22",
+ "version": "0.47.23",
"provides": [
{
"type": "skills",
diff --git a/scripts/syncwheel.py b/scripts/syncwheel.py
index f52563a..85e55e7 100755
--- a/scripts/syncwheel.py
+++ b/scripts/syncwheel.py
@@ -5577,45 +5577,129 @@ def github_blocker(blockers, code, detail, **evidence):
blockers.append(item)
-def github_ci_check_result(check):
+def github_ci_check_result(check, head):
if not isinstance(check, dict):
return None
+ if 'headSha' in check and (not head or check['headSha'] != head):
+ return None
+ if check.get('kind') == 'check-run' and (
+ not isinstance(check.get('name'), str) or not check['name']
+ or str(check.get('status') or '').upper() != 'COMPLETED'
+ ):
+ return None
status = str(check.get('conclusion') or check.get('status') or '').upper()
return status if status in {'SUCCESS', 'SKIPPED'} else None
-def github_required_check_names(rules):
- """Extract required check names from supported GitHub rule response shapes."""
- names = []
+def github_check_positive_integer(value):
+ return type(value) is int and value > 0
+
+
+def github_workflow_run_creation(check):
+ value = check.get('runCreatedAt')
+ if not isinstance(value, str):
+ return None
+ try:
+ created = datetime.datetime.fromisoformat(value)
+ except ValueError:
+ return None
+ return created if created.tzinfo is not None else None
+
+
+def github_effective_checks(checks, head):
+ groups = {}
+ for index, check in enumerate(checks):
+ if (isinstance(check, dict) and check.get('kind') == 'check-run'
+ and head and check.get('headSha') == head
+ and isinstance(check.get('name'), str) and check['name']
+ and all(github_check_positive_integer(check.get(key))
+ for key in ('appId', 'workflowId', 'checkRunId'))):
+ key = (check['appId'], check['workflowId'], check['name'])
+ groups.setdefault(key, []).append((index, check))
+
+ superseded_indexes = set()
+ for group in groups.values():
+ by_run = {}
+ run_order = {}
+ for index, check in group:
+ run_id = check.get('runId')
+ number = check.get('runNumber')
+ created = github_workflow_run_creation(check)
+ if (not github_check_positive_integer(run_id)
+ or not github_check_positive_integer(number) or created is None):
+ break
+ if run_order.setdefault(run_id, (number, created)) != (number, created):
+ break
+ by_run.setdefault(run_id, []).append((index, check))
+ else:
+ numbers = {number for number, _ in run_order.values()}
+ ordered = sorted(run_order, key=run_order.get)
+ dates = [run_order[run_id][1] for run_id in ordered]
+ if len(numbers) != len(run_order) or dates != sorted(dates):
+ continue
+ attempts_by_run = {
+ run_id: [check.get('runAttempt') for _, check in rows]
+ for run_id, rows in by_run.items() if len(rows) > 1
+ }
+ if any(
+ not all(github_check_positive_integer(attempt) for attempt in attempts)
+ or len(set(attempts)) != len(attempts)
+ for attempts in attempts_by_run.values()
+ ):
+ continue
+ for run_id in ordered[:-1]:
+ superseded_indexes.update(index for index, _ in by_run[run_id])
+ if ordered[-1] in attempts_by_run:
+ newest_attempt = max(attempts_by_run[ordered[-1]])
+ superseded_indexes.update(
+ index for index, check in by_run[ordered[-1]] if check['runAttempt'] < newest_attempt
+ )
+
+
+ effective, superseded = [], []
+ for index, check in enumerate(checks):
+ (superseded if index in superseded_indexes else effective).append(check)
+ return (
+ sorted(effective, key=lambda check: json.dumps(check, sort_keys=True)),
+ sorted(superseded, key=lambda check: json.dumps(check, sort_keys=True)),
+ )
+
+
+def github_required_checks(rules):
+ """Extract the name and optional provider of each observed required check."""
+ def requirement(item, provider_key):
+ if isinstance(item, str):
+ return (item, None) if item else None
+ if not isinstance(item, dict):
+ return None
+ name = item.get('context') or item.get('name')
+ if not isinstance(name, str) or not name:
+ return None
+ provider = item.get(provider_key)
+ if provider is None or (provider_key == 'app_id' and type(provider) is int and provider == -1):
+ return name, None
+ return name, provider if github_check_positive_integer(provider) else 'unproven'
+
+ required_checks = []
protection = rules.get('branchProtection') if isinstance(rules, dict) else None
required = protection.get('required_status_checks') if isinstance(protection, dict) else None
if isinstance(required, dict):
- candidates = [*(required.get('contexts') or []), *(required.get('checks') or [])]
- for item in candidates:
- if isinstance(item, str) and item:
- names.append(item)
- elif isinstance(item, dict):
- name = item.get('context') or item.get('name')
- if isinstance(name, str) and name:
- names.append(name)
+ explicit = [item for candidate in required.get('checks') or []
+ if (item := requirement(candidate, 'app_id')) is not None]
+ explicit_names = {name for name, _ in explicit}
+ required_checks.extend(explicit)
+ required_checks.extend(item for candidate in required.get('contexts') or []
+ if (item := requirement(candidate, 'app_id')) and item[0] not in explicit_names)
rulesets = rules.get('rulesets') if isinstance(rules, dict) else None
if isinstance(rulesets, dict):
rulesets = rulesets.get('rules') or rulesets.get('nodes') or []
for rule in rulesets or []:
- if not isinstance(rule, dict):
- continue
- rule_type = str(rule.get('type') or rule.get('rule_type') or '').lower()
- if rule_type != 'required_status_checks':
+ if not isinstance(rule, dict) or str(rule.get('type') or rule.get('rule_type') or '').lower() != 'required_status_checks':
continue
parameters = rule.get('parameters') or {}
- for item in parameters.get('required_status_checks') or []:
- if isinstance(item, str) and item:
- names.append(item)
- elif isinstance(item, dict):
- name = item.get('context') or item.get('name')
- if isinstance(name, str) and name:
- names.append(name)
- return list(dict.fromkeys(names))
+ required_checks.extend(item for candidate in parameters.get('required_status_checks') or []
+ if (item := requirement(candidate, 'integration_id')) is not None)
+ return list(dict.fromkeys(required_checks))
def github_rule_review_required(rules):
@@ -5802,6 +5886,7 @@ def github_pr_merge_plan_digest(plan):
unsigned = copy.deepcopy(plan)
unsigned.pop('planDigest', None)
unsigned.pop('operationId', None)
+ unsigned.pop('supersededChecks', None)
return canonical_json_digest(unsigned)
@@ -5942,6 +6027,7 @@ def build_github_pr_merge_plan(repo_root, manifest, manifest_path, stack_id, arg
permissions = repository_info.get('permissions') if isinstance(repository_info, dict) else {}
if not isinstance(permissions, dict) or permissions.get('admin') is not True:
github_blocker(blockers, 'merge_actor_not_admin', 'effective gh actor has no repository admin permission')
+ checks, superseded_checks = [], []
if isinstance(pr, dict):
if pr_number is not None and pr.get('number') != int(pr_number):
github_blocker(blockers, 'pull_request_number_mismatch', 'observed PR number differs from the stack declaration')
@@ -5990,31 +6076,39 @@ def build_github_pr_merge_plan(repo_root, manifest, manifest_path, stack_id, arg
github_blocker(blockers, 'not_mergeable', f"mergeable={pr.get('mergeable')}")
if pr.get('mergeStateStatus') in {'BEHIND', 'DIRTY', 'UNKNOWN', 'UNSTABLE'}:
github_blocker(blockers, 'base_obsolete_or_dirty', f"mergeStateStatus={pr.get('mergeStateStatus')}")
- checks = pr.get('checks') or []
+ head = pr.get('headRefOid')
+ checks, superseded_checks = github_effective_checks(pr.get('checks') or [], head)
+ required_checks = github_required_checks(rules)
+ if pr.get('checksIncomplete') is True and (policy['checks'] == 'all' or required_checks):
+ github_blocker(blockers, 'checks_observation_incomplete', 'exact-head check history could not be observed')
if policy['checks'] == 'all':
if not checks:
github_blocker(blockers, 'checks_missing', 'at least one successful check is required')
else:
for check in checks:
- if github_ci_check_result(check) is None:
+ if github_ci_check_result(check, head) is None:
github_blocker(blockers, 'check_failed_or_pending', f'check did not conclude SUCCESS/SKIPPED: {check}')
else:
warnings.append({
'code': 'checks_not_required',
'detail': 'the clone-local merge policy does not require CI checks',
})
- required_names = github_required_check_names(rules)
- if required_names:
- observed_by_name = {
- item.get('name'): item
- for item in checks
- if isinstance(item, dict) and isinstance(item.get('name'), str)
- }
- for name in required_names:
- required_check = observed_by_name.get(name)
- if required_check is None:
- github_blocker(blockers, 'required_check_missing', f'required check is absent: {name}')
- elif github_ci_check_result(required_check) is None:
+ for name, provider in required_checks:
+ named = [
+ check for check in checks if isinstance(check, dict) and check.get('name') == name
+ ]
+ if provider is not None:
+ matches = [check for check in named if github_check_positive_integer(check.get('appId'))
+ and check['appId'] == provider]
+ unverified = [check for check in named if not github_check_positive_integer(check.get('appId'))]
+ if not matches or provider == 'unproven':
+ github_blocker(blockers, 'required_check_missing', f'required check from its GitHub app is absent: {name}')
+ continue
+ named = [*matches, *unverified]
+ if not named:
+ github_blocker(blockers, 'required_check_missing', f'required check is absent: {name}')
+ for required_check in named:
+ if github_ci_check_result(required_check, head) is None:
github_blocker(
blockers,
'required_check_failed_or_pending',
@@ -6092,7 +6186,8 @@ def build_github_pr_merge_plan(repo_root, manifest, manifest_path, stack_id, arg
'commitAuthors': pr.get('commitAuthors') or [],
'headRepository': pr.get('headRepository'),
'mergeActor': actor,
- 'checks': pr.get('checks') or [],
+ 'checks': checks,
+ 'supersededChecks': superseded_checks,
'review': pr.get('review') or {},
'threads': (pr.get('review') or {}).get('threads') or [],
'rules': rules,
diff --git a/scripts/syncwheel_github.py b/scripts/syncwheel_github.py
index 91c921f..8386734 100644
--- a/scripts/syncwheel_github.py
+++ b/scripts/syncwheel_github.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Fixed GitHub adapter for Syncwheel's plan-first PR merge contract."""
+from collections import Counter
import json
import os
import re
@@ -11,6 +12,8 @@
SCHEMA_VERSION = 1
DEFAULT_TIMEOUT_SECONDS = 30
MAX_OUTPUT = 12000
+CHECK_OBSERVATION_PAGE_LIMIT = 10
+CHECK_ATTEMPT_REQUEST_LIMIT = 8
REPOSITORY_RE = re.compile(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$")
METHODS = {"squash", "merge", "rebase"}
@@ -21,12 +24,26 @@
)
PR_LIST_FIELDS = "number,url,state,isDraft,headRefName,headRefOid,baseRefName,baseRefOid"
+CHECK_CONTEXT_FIELDS = (
+ "totalCount pageInfo{hasNextPage endCursor} nodes{__typename "
+ "... on CheckRun{id name status conclusion detailsUrl} "
+ "... on StatusContext{id context state}}"
+)
THREAD_QUERY = (
"query($owner:String!,$name:String!,$number:Int!){"
"repository(owner:$owner,name:$name){"
"pullRequest(number:$number){"
"reviewThreads(first:100){nodes{isResolved isOutdated}pageInfo{hasNextPage}}"
- "}}}"
+ "commits(last:1){nodes{commit{oid statusCheckRollup{"
+ "contexts(first:100){" + CHECK_CONTEXT_FIELDS + "}"
+ "}}}}}}}"
+)
+CHECK_PAGE_QUERY = (
+ "query($owner:String!,$name:String!,$head:GitObjectID!,$cursor:String!){"
+ "repository(owner:$owner,name:$name){"
+ "object(oid:$head){... on Commit{oid statusCheckRollup{"
+ "contexts(first:100,after:$cursor){" + CHECK_CONTEXT_FIELDS + "}"
+ "}}}}}"
)
@@ -154,20 +171,298 @@ def _checks(pr):
for item in pr.get("statusCheckRollup") or []:
if not isinstance(item, dict):
continue
- name = item.get("name") or item.get("context") or item.get("app", {}).get("name")
+ legacy = item.get("__typename") == "StatusContext" or (
+ "context" in item and item.get("__typename") != "CheckRun"
+ )
+ app = item.get("app")
status = item.get("status") or item.get("state")
conclusion = item.get("conclusion")
- if not status and conclusion:
- status = conclusion
- normalized.append({
- "name": name,
- "status": status,
+ check = {
+ "name": item.get("name") or item.get("context"),
+ "status": status or conclusion,
"conclusion": conclusion,
"required": False,
- })
+ "kind": "status-context" if legacy else "check-run",
+ }
+ if isinstance(app, dict) and _positive_integer(app.get("id")):
+ check["appId"] = app["id"]
+ if isinstance(item.get("headSha"), str):
+ check["headSha"] = item["headSha"]
+ if isinstance(item.get("detailsUrl"), str) and item["detailsUrl"]:
+ check["detailsUrl"] = item["detailsUrl"]
+ normalized.append(check)
return normalized
+def _positive_integer(value):
+ return type(value) is int and value > 0
+
+
+def _paged_objects(path, key, cwd, *, max_pages=CHECK_OBSERVATION_PAGE_LIMIT):
+ rows = []
+ total = None
+ delimiter = "&" if "?" in path else "?"
+ for page in range(1, max_pages + 1):
+ endpoint = f"{path}{delimiter}per_page=100&page={page}"
+ response = run_json(["api", endpoint], cwd)["value"]
+ if not isinstance(response, dict):
+ raise AdapterError(f"incomplete GitHub {key} observation")
+ batch = response.get(key)
+ count = response.get("total_count")
+ if (type(count) is not int or count < 0 or count > max_pages * 100
+ or (total is not None and count != total)
+ or not isinstance(batch, list)
+ or len(batch) != min(100, count - len(rows))
+ or any(not isinstance(item, dict) for item in batch)):
+ raise AdapterError(f"incomplete GitHub {key} observation")
+ total = count
+ rows.extend(batch)
+ if len(rows) == total:
+ return rows
+ raise AdapterError(f"GitHub {key} observation exceeded its page limit")
+
+
+def _check_attempts(repository, head, checks, runs, cwd):
+ duplicates = {}
+ for check in checks:
+ if "runId" not in check:
+ continue
+ key = (check["runId"], check["name"])
+ duplicates.setdefault(key, []).append(check)
+ unresolved_runs = sorted({key[0] for key, rows in duplicates.items() if len(rows) > 1})
+ remaining = CHECK_ATTEMPT_REQUEST_LIMIT
+ incomplete = False
+ base = f"repos/{repository}/actions/runs"
+ expected_url = re.compile(
+ rf"https://[^/]+/repos/{re.escape(repository)}/check-runs/([1-9][0-9]*)", re.IGNORECASE,
+ )
+ for run_id in unresolved_runs:
+ last = runs[run_id].get("run_attempt")
+ if not _positive_integer(last) or last > remaining:
+ incomplete = True
+ continue
+ observed = {}
+ remaining -= last
+ try:
+ for attempt in range(1, last + 1):
+ jobs = _paged_objects(f"{base}/{run_id}/attempts/{attempt}/jobs", "jobs", cwd, max_pages=1)
+ for job in jobs:
+ url = job.get("check_run_url")
+ match = expected_url.fullmatch(url) if isinstance(url, str) else None
+ if (not match or job.get("run_id") != run_id or job.get("head_sha") != head
+ or not isinstance(job.get("name"), str)):
+ raise AdapterError("a workflow job did not match its observed attempt")
+ check_id = int(match[1])
+ if check_id in observed:
+ raise AdapterError("a workflow job appeared in multiple attempts")
+ observed[check_id] = (attempt, job["name"])
+ except AdapterError:
+ incomplete = True
+ continue
+ for key, rows in duplicates.items():
+ if key[0] != run_id:
+ continue
+ for row in rows:
+ attempt = observed.get(row["checkRunId"])
+ if attempt and attempt[1] == row["name"]:
+ row["runAttempt"] = attempt[0]
+ return incomplete
+
+
+def _graph_repository(graph):
+ if not isinstance(graph, dict) or graph.get("errors"):
+ return {}
+ data = graph.get("data")
+ repository = data.get("repository") if isinstance(data, dict) else None
+ return repository if isinstance(repository, dict) else {}
+
+
+def _graph_check_nodes(graph, head, repository, cwd):
+ pr = _graph_repository(graph).get("pullRequest")
+ commits = pr.get("commits") if isinstance(pr, dict) else None
+ nodes = commits.get("nodes") if isinstance(commits, dict) else None
+ if not isinstance(nodes, list) or len(nodes) != 1 or not isinstance(nodes[0], dict):
+ return None
+ commit = nodes[0].get("commit")
+ owner, name = _split_repository(repository)
+ observed = []
+ cursors = set()
+ ids = set()
+ total = None
+ for page_number in range(CHECK_OBSERVATION_PAGE_LIMIT):
+ if not isinstance(commit, dict) or commit.get("oid") != head:
+ return None
+ rollup = commit.get("statusCheckRollup")
+ if rollup is None and "statusCheckRollup" in commit and page_number == 0:
+ return []
+ contexts = rollup.get("contexts") if isinstance(rollup, dict) else None
+ if not isinstance(contexts, dict):
+ return None
+ rows, page, count = (contexts.get(key) for key in ("nodes", "pageInfo", "totalCount"))
+ if (not isinstance(rows, list) or len(rows) > 100 or type(count) is not int
+ or not 0 <= count <= CHECK_OBSERVATION_PAGE_LIMIT * 100
+ or (total is not None and total != count) or len(observed) + len(rows) > count
+ or not isinstance(page, dict) or type(page.get("hasNextPage")) is not bool):
+ return None
+ total = count
+ for row in rows:
+ if not isinstance(row, dict) or row.get("__typename") not in {"CheckRun", "StatusContext"}:
+ return None
+ node_id = row.get("id")
+ if not isinstance(node_id, str) or not node_id or node_id in ids:
+ return None
+ ids.add(node_id)
+ observed.append(row)
+ if not page["hasNextPage"]:
+ return observed if len(observed) == total else None
+ cursor = page.get("endCursor")
+ if (not rows or len(observed) >= total or not isinstance(cursor, str) or not cursor
+ or cursor in cursors or page_number + 1 == CHECK_OBSERVATION_PAGE_LIMIT):
+ return None
+ cursors.add(cursor)
+ try:
+ result = run_json([
+ "api", "graphql", "-f", f"query={CHECK_PAGE_QUERY}",
+ "-f", f"owner={owner}", "-f", f"name={name}", "-f", f"head={head}", "-f", f"cursor={cursor}",
+ ], cwd)["value"]
+ except AdapterError:
+ return None
+ commit = _graph_repository(result).get("object")
+ return None
+
+
+def _observed_checks(pr, graph, repository, cwd):
+ rollup = _checks(pr)
+ check_runs = [item for item in rollup if item["kind"] == "check-run"]
+ head = pr.get("headRefOid")
+ if not isinstance(head, str) or not re.fullmatch(r"[0-9a-f]{40}", head):
+ return rollup, bool(check_runs)
+ graph_rows = _graph_check_nodes(graph, head, repository, cwd)
+ base = f"repos/{repository}"
+ try:
+ raw_checks = _paged_objects(f"{base}/commits/{head}/check-runs?filter=all", "check_runs", cwd)
+ ids = [item.get("id") for item in raw_checks]
+ if (not all(_positive_integer(check_id) for check_id in ids)
+ or len(set(ids)) != len(ids)
+ or any(item.get("head_sha") != head for item in raw_checks)):
+ raise AdapterError("check runs did not match the observed PR head")
+ except AdapterError:
+ return rollup, True
+
+ actions = [
+ item for item in raw_checks
+ if isinstance(item.get("app"), dict) and item["app"].get("slug") == "github-actions"
+ ]
+ by_suite = {}
+ actions_runs = {}
+ incomplete = graph_rows is None
+ if actions:
+ try:
+ runs = _paged_objects(f"{base}/actions/runs?head_sha={head}", "workflow_runs", cwd)
+ keys = ("id", "check_suite_id", "workflow_id", "run_number")
+ if (len(runs) >= 1000 or any(run.get("head_sha") != head
+ or not all(_positive_integer(run.get(key)) for key in keys) for run in runs)):
+ raise AdapterError("workflow run history is incomplete or mismatches the PR head")
+ suite_counts = Counter(run["check_suite_id"] for run in runs)
+ run_counts = Counter(run["id"] for run in runs)
+ for run in runs:
+ suite = run["check_suite_id"]
+ if suite_counts[suite] == run_counts[run["id"]] == 1:
+ by_suite[suite] = run
+ actions_runs[run["id"]] = run
+ else:
+ incomplete = True
+ except AdapterError:
+ incomplete = True
+
+ checks = []
+ for item in raw_checks:
+ app = item.get("app")
+ suite = item.get("check_suite")
+ status = item.get("status")
+ conclusion = item.get("conclusion")
+ check = {
+ "kind": "check-run", "name": item.get("name"), "required": False,
+ "status": status.upper() if isinstance(status, str) else None,
+ "conclusion": conclusion.upper() if isinstance(conclusion, str) else None,
+ "headSha": head, "checkRunId": item["id"],
+ }
+ if isinstance(item.get("details_url"), str) and item["details_url"]:
+ check["detailsUrl"] = item["details_url"]
+ if isinstance(item.get("node_id"), str) and item["node_id"]:
+ check["checkNodeId"] = item["node_id"]
+ if isinstance(app, dict) and _positive_integer(app.get("id")):
+ check["appId"] = app["id"]
+ if app.get("slug") == "github-actions" and isinstance(suite, dict):
+ run = by_suite.get(suite.get("id")) if _positive_integer(suite.get("id")) else None
+ if run and run["id"] in actions_runs:
+ check.update(
+ workflowId=run["workflow_id"], runId=run["id"],
+ runNumber=run["run_number"], runCreatedAt=run.get("created_at"),
+ )
+ checks.append(check)
+
+ attempts_incomplete = _check_attempts(repository, head, checks, actions_runs, cwd)
+ # A disagreement between surfaces must remain visible. Only an exact
+ # identity and outcome match can replace the original rollup row.
+ def identity(check):
+ name, url = check.get("name"), check.get("detailsUrl")
+ if (not isinstance(name, str) or not name or not isinstance(url, str) or not url
+ or check.get("headSha", head) != head):
+ return None
+ return name, url
+
+ def outcome(check):
+ return tuple(str(check.get(key) or "").upper() for key in ("status", "conclusion"))
+
+ graph_by_identity = {}
+ for row in graph_rows or ():
+ if row.get("__typename") != "CheckRun" or not isinstance(row.get("id"), str) or not row["id"]:
+ continue
+ key = identity(row)
+ if key is not None:
+ graph_by_identity.setdefault(key, []).append(row)
+ rollup_counts = Counter(identity(check) for check in check_runs)
+ rest_by_node = {}
+ for check in checks:
+ if "checkNodeId" in check:
+ rest_by_node.setdefault(check["checkNodeId"], []).append(check)
+ unmatched = []
+ for check in check_runs:
+ key = identity(check)
+ graph_matches = graph_by_identity.get(key, [])
+ rest_matches = rest_by_node.get(graph_matches[0]["id"], []) if len(graph_matches) == 1 else []
+ if (key is None or rollup_counts[key] != 1 or len(rest_matches) != 1
+ or identity(rest_matches[0]) != key or outcome(graph_matches[0]) != outcome(check)
+ or outcome(rest_matches[0]) != outcome(check)
+ or ("appId" in check and check["appId"] != rest_matches[0].get("appId"))):
+ unmatched.append(check)
+ seen_graph = set()
+ for row in graph_rows or ():
+ if row.get("__typename") != "CheckRun":
+ continue
+ node = row.get("id")
+ if not isinstance(node, str) or not node or node in seen_graph:
+ incomplete = True
+ continue
+ seen_graph.add(node)
+ matching = rest_by_node.get(node, [])
+ if len(matching) != 1 or identity(matching[0]) != identity(row) or outcome(matching[0]) != outcome(row):
+ unmatched.extend(_checks({"statusCheckRollup": [{**row, "headSha": head}]}))
+ contexts = [item for item in rollup if item["kind"] == "status-context"]
+ for row in graph_rows or ():
+ if row["__typename"] != "StatusContext":
+ continue
+ if not isinstance(row.get("context"), str) or not row["context"] or not isinstance(row.get("state"), str):
+ incomplete = True
+ continue
+ observed_context, = _checks({"statusCheckRollup": [{**row, "headSha": head}]})
+ if not any(item["name"] == observed_context["name"] and item.get("headSha", head) == head
+ and outcome(item) == outcome(observed_context) for item in contexts):
+ contexts.append(observed_context)
+ return [*contexts, *checks, *unmatched], incomplete or attempts_incomplete
+
+
def _review_summary(pr, threads):
reviews = []
for item in pr.get("reviews") or []:
@@ -370,6 +665,7 @@ def observe(request, cwd):
protection = _optional_api(repo=repository, path=f"repos/{repository}/branches/{base_branch}/protection", cwd=cwd)
rulesets = _optional_api(repo=repository, path=f"repos/{repository}/rules/branches/{base_branch}", cwd=cwd)
+ checks, checks_incomplete = _observed_checks(pr, graph, repository, cwd)
allow = {
"squash": bool(repo_info.get("allow_squash_merge")),
"merge": bool(repo_info.get("allow_merge_commit")),
@@ -406,7 +702,8 @@ def observe(request, cwd):
"mergeStateStatus": pr.get("mergeStateStatus"),
"mergedAt": pr.get("mergedAt"),
"mergedBy": (pr.get("mergedBy") or {}).get("login") if isinstance(pr.get("mergedBy"), dict) else None,
- "checks": _checks(pr),
+ "checks": checks,
+ "checksIncomplete": checks_incomplete,
"mergeCommit": (pr.get("mergeCommit") or {}).get("oid") if isinstance(pr.get("mergeCommit"), dict) else None,
"threadsTruncated": threads_truncated,
},
diff --git a/tests/test_github_latest_checks.py b/tests/test_github_latest_checks.py
new file mode 100644
index 0000000..4942c97
--- /dev/null
+++ b/tests/test_github_latest_checks.py
@@ -0,0 +1,390 @@
+import json
+import unittest
+from unittest import mock
+
+import test_github_pr_merge as fixtures
+
+
+class GithubLatestChecksTest(unittest.TestCase):
+ repository = 'example/project'
+ actor = 'fixture-author'
+
+ def setUp(self):
+ self.fixture = fixtures.GithubPrMergeTest()
+ self.fixture.setUp()
+ self.addCleanup(self.fixture.tearDown)
+ self.github = fixtures.ADAPTER
+ self.syncwheel = fixtures.SYNCWHEEL
+ self.fixture.manifest['authority'] = {'mode': 'ai-managed', 'allow': ['source_change'], 'deny': []}
+ self.fixture.manifest['stacks'][0]['github'] = {'pr': 25}
+ self.fixture.manifest_path.write_text(json.dumps(self.fixture.manifest) + '\n')
+
+ def check(self, run, conclusion='SUCCESS', *, workflow='build', created='2026-01-01T00:00:00Z',
+ attempt=1, status='COMPLETED', head=None, number=None, name='ci', job_index=0):
+ head = head or self.fixture.head
+ job_id = run * 1000 + attempt * 100 + job_index
+ check_id = job_id + 100_000
+ node_id = f'CR_fixture_{check_id}'
+ url = f'https://github.com/{self.repository}/actions/runs/{run}/job/{job_id}'
+ return {
+ 'node_id': node_id,
+ 'rollup': {'__typename': 'CheckRun', 'name': name, 'workflowName': workflow,
+ 'status': status, 'conclusion': conclusion, 'startedAt': created,
+ 'completedAt': created if status == 'COMPLETED' else None, 'detailsUrl': url},
+ 'run': {'id': run, 'head_sha': head, 'check_suite_id': run + 1_000,
+ 'workflow_id': {'build': 10, 'lint': 11, 'test': 12}[workflow],
+ 'run_number': number if number is not None else run,
+ 'run_attempt': attempt, 'created_at': created},
+ 'check': {'id': check_id, 'node_id': node_id, 'name': name, 'head_sha': head, 'status': status.lower(),
+ 'conclusion': conclusion.lower() or None, 'details_url': url,
+ 'check_suite': {'id': run + 1_000}, 'app': {'id': 20, 'slug': 'github-actions'}},
+ 'job': {'id': job_id, 'name': name, 'run_id': run, 'head_sha': head,
+ 'check_run_url': f'https://api.github.com/repos/{self.repository}/check-runs/{check_id}'},
+ }
+
+ def status_context(self, name, state):
+ return {'__typename': 'StatusContext', 'id': f'SC_{name}', 'context': name, 'state': state}
+
+ def graph_commit(self, contexts, total, *, cursor=None, head=None):
+ return {
+ 'oid': head or self.fixture.head,
+ 'statusCheckRollup': {'contexts': {
+ 'nodes': contexts,
+ 'totalCount': total,
+ 'pageInfo': {'hasNextPage': cursor is not None, 'endCursor': cursor},
+ }},
+ }
+
+ def plan(self, records, *, required=False, checks='all', pages=None, graphql_head=None,
+ graphql_truncated=False, legacy=(), graph_pages=None):
+ policy = self.fixture.policy()
+ policy.update(repository=self.repository, head_repositories=[self.repository], checks=checks,
+ merge_actors=[self.actor], pr_authors=[self.actor], commit_authors=[self.actor])
+ profile = {'hooks': {'mode': 'required'}, 'github_pr_merge': policy}
+ (self.fixture.repo / '.syncwheel' / 'profile.local.json').write_text(json.dumps(profile) + '\n')
+ pull = {
+ 'number': 25, 'state': 'OPEN', 'isDraft': False,
+ 'headRefName': 'pr/feature', 'headRefOid': self.fixture.head,
+ 'baseRefName': 'main', 'baseRefOid': self.fixture.base,
+ 'headRepository': {'nameWithOwner': self.repository}, 'author': {'login': self.actor},
+ 'commits': [{'oid': self.fixture.head, 'authors': [{'login': self.actor}]}],
+ 'reviewDecision': 'APPROVED', 'mergeable': 'MERGEABLE', 'mergeStateStatus': 'CLEAN',
+ 'statusCheckRollup': [*[row['rollup'] for row in records], *legacy],
+ }
+
+ prefix = f'repos/{self.repository}'
+ runs = {}
+ for row in records:
+ run = row['run']
+ if run['id'] not in runs or run['run_attempt'] > runs[run['id']]['run_attempt']:
+ runs[run['id']] = run
+
+ def page(key, rows, number=1):
+ overrides = pages or {}
+ if (key, number) in overrides:
+ response = overrides[key, number]
+ if isinstance(response, Exception):
+ raise response
+ return response
+ self.assertEqual(number, 1, f'unexpected {key} page')
+ return {'total_count': len(rows), key: rows}
+
+ def observe(cwd, request):
+ try:
+ return self.github.observe(request, cwd)
+ except self.github.AdapterError as exc:
+ raise self.syncwheel.SyncwheelError(str(exc)) from exc
+
+ def run_json(argv, cwd):
+ if argv == ['api', f'repos/{self.repository}']:
+ value = {'full_name': self.repository, 'permissions': {'admin': True},
+ 'allow_squash_merge': True}
+ elif argv == ['api', 'user']:
+ value = {'login': self.actor}
+ elif argv[:3] == ['pr', 'view', '25']:
+ value = pull
+ elif f'query={self.github.THREAD_QUERY}' in argv:
+ if graph_pages is not None:
+ commit = graph_pages[None]
+ else:
+ contexts = [{'id': row['node_id'], **row['rollup']} for row in records]
+ contexts.extend(legacy)
+ commit = self.graph_commit(contexts, len(contexts), head=graphql_head)
+ if graphql_truncated:
+ commit['statusCheckRollup']['contexts']['pageInfo']['hasNextPage'] = True
+ value = {'data': {'repository': {'pullRequest': {
+ 'reviewThreads': {'nodes': [], 'pageInfo': {'hasNextPage': False}},
+ 'commits': {'nodes': [{'commit': commit}]},
+ }}}}
+ elif getattr(self.github, 'CHECK_PAGE_QUERY', None) and f'query={self.github.CHECK_PAGE_QUERY}' in argv:
+ self.assertIn(f'head={self.fixture.head}', argv)
+ cursor = next(arg.split('=', 1)[1] for arg in argv if arg.startswith('cursor='))
+ commit = graph_pages[cursor]
+ if isinstance(commit, Exception):
+ raise commit
+ value = {'data': {'repository': {'object': commit}}}
+ elif len(argv) == 2 and argv[1].startswith(
+ f'{prefix}/commits/{self.fixture.head}/check-runs?filter=all&per_page=100&page='
+ ):
+ value = page('check_runs', [row['check'] for row in records], int(argv[1].rsplit('=', 1)[1]))
+ elif len(argv) == 2 and argv[1].startswith(
+ f'{prefix}/actions/runs?head_sha={self.fixture.head}&per_page=100&page='
+ ):
+ value = page('workflow_runs', list(runs.values()), int(argv[1].rsplit('=', 1)[1]))
+ elif len(argv) == 2 and argv[0] == 'api' and '/attempts/' in argv[1]:
+ value = page('jobs', [
+ row['job'] for row in records if argv[1] == (
+ f"{prefix}/actions/runs/{row['run']['id']}/"
+ f"attempts/{row['run']['run_attempt']}/jobs?per_page=100&page=1"
+ )
+ ])
+ else:
+ self.fail(f'unexpected GitHub observation: {argv}')
+ return {'ok': True, 'value': value}
+
+ def observe_rule(*, repo, path, cwd):
+ value = [] if '/rules/' in path else {}
+ if required and isinstance(value, dict):
+ value['required_status_checks'] = {'contexts': ['ci']}
+ return {'status': 200, 'value': value, 'detail': None}
+
+ with (
+ mock.patch.object(self.github, 'run_json', side_effect=run_json),
+ mock.patch.object(self.github, '_optional_api', side_effect=observe_rule),
+ mock.patch.object(self.syncwheel, 'github_adapter_request', side_effect=observe),
+ mock.patch.object(self.syncwheel, 'validate_manifest', return_value={'errors': []}),
+ ):
+ return self.syncwheel.build_github_pr_merge_plan(
+ self.fixture.repo, self.fixture.manifest, self.fixture.manifest_path, 'feature',
+ self.fixture.args(),
+ )
+
+ def test_new_success_supersedes_old_cancelled_regardless_of_input_order(self):
+ old = self.check(101, 'CANCELLED')
+ new = self.check(102, created='2026-01-01T01:00:00Z')
+ new['rollup']['workflowName'] = 'updated display name'
+ effective_only = self.plan([new], required=True)
+ for records in ([old, new], [new, old]):
+ with self.subTest(old_first=records[0] is old):
+ plan = self.plan(records, required=True)
+ self.assertEqual(plan['status'], 'ready', plan['blockers'])
+ self.assertEqual([row['checkRunId'] for row in plan['checks']], [new['check']['id']])
+ self.assertEqual([row['checkRunId'] for row in plan['supersededChecks']], [old['check']['id']])
+ self.assertEqual(plan['supersededChecks'][0]['conclusion'], 'CANCELLED')
+ self.assertEqual(plan['planDigest'], effective_only['planDigest'])
+
+ def test_latest_pending_failure_or_cancellation_remains_blocking(self):
+ old = self.check(101)
+ for status, conclusion in [('QUEUED', ''), ('COMPLETED', 'FAILURE'), ('COMPLETED', 'CANCELLED')]:
+ new = self.check(102, conclusion, status=status, created='2026-01-01T01:00:00Z')
+ for checks, code in [('none', 'required_check_failed_or_pending'), ('all', 'check_failed_or_pending')]:
+ with self.subTest(status=status, conclusion=conclusion, checks=checks):
+ plan = self.plan([new, old], required=True, checks=checks)
+ self.assertEqual(plan['status'], 'blocked')
+ self.assertIn(code, {row['code'] for row in plan['blockers']})
+
+ def test_same_name_across_workflows_remains_independent_for_required_check(self):
+ failed = self.check(101, 'FAILURE', workflow='lint')
+ passed = self.check(102, workflow='test', created='2026-01-01T01:00:00Z')
+ failed['rollup']['workflowName'] = passed['rollup']['workflowName'] = 'shared display name'
+ for rollup in ([failed, passed], [passed, failed]):
+ with self.subTest(rollup=rollup):
+ plan = self.plan(rollup, required=True, checks='none')
+ self.assertEqual(plan['status'], 'blocked')
+ self.assertIn('required_check_failed_or_pending', {row['code'] for row in plan['blockers']})
+
+ def test_success_for_a_different_head_cannot_satisfy_current_required_check(self):
+ wrong_head = '7' * 40
+ stale = self.check(100, head=wrong_head)
+ plan = self.plan([stale], required=True, checks='none')
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_stale_or_truncated_graphql_check_rollup_cannot_authorize_merge(self):
+ for kwargs in [{'graphql_head': '7' * 40}, {'graphql_truncated': True}]:
+ with self.subTest(**kwargs):
+ plan = self.plan([self.check(101)], required=True, **kwargs)
+
+ self.assertEqual(plan['status'], 'blocked')
+ self.assertIn('checks_observation_incomplete', {row['code'] for row in plan['blockers']})
+
+ def test_distinct_run_numbers_resolve_equal_creation_times(self):
+ failed = self.check(101, 'FAILURE')
+ passed = self.check(102)
+
+ plan = self.plan([passed, failed], required=True)
+
+ self.assertEqual(plan['status'], 'ready', plan['blockers'])
+ self.assertEqual([row['checkRunId'] for row in plan['checks']], [passed['check']['id']])
+
+ def test_missing_creation_time_or_conflicting_run_numbers_keep_failure(self):
+ for created, number in [(None, 102), ('2026-01-01T00:00:00Z', 101)]:
+ with self.subTest(created=created, number=number):
+ failed = self.check(101, 'FAILURE')
+ passed = self.check(102, created=created, number=number)
+ plan = self.plan([failed, passed], required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_higher_attempt_of_same_run_wins_when_timestamps_are_equal(self):
+ old = self.check(101, 'CANCELLED', attempt=1)
+ new = self.check(101, attempt=2)
+ for rollup in ([old, new], [new, old]):
+ with self.subTest(rollup=rollup):
+ plan = self.plan(rollup, required=True)
+
+ self.assertEqual(plan['status'], 'ready', plan['blockers'])
+
+ def test_unmatched_rollup_failure_cannot_be_discarded(self):
+ failed = self.check(101, 'FAILURE')
+ passed = self.check(102, created='2026-01-01T01:00:00Z')
+ failed['node_id'] = 'CR_unmatched'
+
+ plan = self.plan([failed, passed], required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_incomplete_check_run_enrichment_does_not_authorize_merge(self):
+ records = [self.check(run) for run in range(1, 101)]
+ first_page = [row['check'] for row in records]
+ for count, second in [
+ (10_000, None),
+ (101, self.github.AdapterError('fixture pagination error')),
+ (101, {'total_count': 102, 'check_runs': [self.check(101)['check']]}),
+ (101, {'total_count': 101, 'check_runs': []}),
+ ]:
+ with self.subTest(count=count, second=second):
+ pages = {('check_runs', 1): {'total_count': count, 'check_runs': first_page}}
+ if second is not None:
+ pages['check_runs', 2] = second
+
+ plan = self.plan(records, required=True, pages=pages)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_actions_server_cap_cannot_authorize_merge_with_green_observed_checks(self):
+ records = [self.check(run) for run in range(1, 1001)]
+ pages = {
+ ('workflow_runs', page): {
+ 'total_count': 1000,
+ 'workflow_runs': [row['run'] for row in records[(page - 1) * 100:page * 100]],
+ }
+ for page in range(1, 11)
+ }
+
+ plan = self.plan(records[:1], required=True, pages=pages)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_ambiguous_rollup_to_rest_match_cannot_discard_rollup_failure(self):
+ first = self.check(101)
+ second = self.check(102)
+ first['rollup']['conclusion'] = 'FAILURE'
+ first['node_id'] = 'CR_unmatched'
+ second['check']['details_url'] = first['check']['details_url']
+ second['rollup']['detailsUrl'] = first['rollup']['detailsUrl']
+
+ plan = self.plan([first, second], required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_matching_check_with_conflicting_rollup_and_rest_outcomes_blocks(self):
+ record = self.check(101)
+ record['rollup']['conclusion'] = 'FAILURE'
+
+ plan = self.plan([record], required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_partial_rerun_preserves_last_successful_attempt_for_other_jobs(self):
+ existing = self.check(101, name='independent', job_index=1)
+ failed = self.check(101, 'FAILURE', attempt=1)
+ passed = self.check(101, attempt=2)
+
+ plan = self.plan([passed, existing, failed], required=True)
+
+ self.assertEqual(plan['status'], 'ready', plan['blockers'])
+ self.assertIn('independent', {row['name'] for row in plan['checks']})
+
+ def test_two_distinct_checks_in_same_attempt_remain_ambiguous(self):
+ old = self.check(101, 'CANCELLED', attempt=1)
+ first = self.check(101, attempt=2)
+ second = self.check(101, attempt=2, job_index=1)
+
+ plan = self.plan([old, first, second], required=True, checks='none')
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_attempt_job_must_prove_check_run_identity_and_exact_head(self):
+ wrong_link = f'https://api.github.com/repos/{self.repository}/check-runs/999'
+ for field, value in [('run_id', 999), ('head_sha', '7' * 40), ('check_run_url', wrong_link)]:
+ with self.subTest(field=field):
+ old = self.check(101, 'CANCELLED', attempt=1)
+ new = self.check(101, attempt=2)
+ new['job'][field] = value
+
+ plan = self.plan([old, new], required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+
+ def test_same_head_legacy_status_change_between_observations_blocks(self):
+ prior = self.status_context('ci', 'SUCCESS')
+ current = self.status_context('ci', 'FAILURE')
+ pages = {None: self.graph_commit([current], 1)}
+
+ plan = self.plan([], legacy=[prior], graph_pages=pages, required=True)
+
+ self.assertEqual(plan['status'], 'blocked')
+ codes = {row['code'] for row in plan['blockers']}
+ self.assertTrue(codes & {'checks_observation_incomplete', 'check_failed_or_pending'})
+
+ def test_complete_graphql_pagination_includes_check_beyond_first_hundred(self):
+ first = [self.status_context(f'ci-{index}', 'SUCCESS') for index in range(100)]
+ for state in ('SUCCESS', 'FAILURE'):
+ with self.subTest(state=state):
+ last = self.status_context('ci-last', state)
+ pages = {
+ None: self.graph_commit(first, 101, cursor='page-2'),
+ 'page-2': self.graph_commit([last], 101),
+ }
+
+ plan = self.plan([], legacy=first, graph_pages=pages)
+
+ self.assertEqual(plan['status'], 'ready' if state == 'SUCCESS' else 'blocked')
+ self.assertIn('ci-last', {row['name'] for row in plan['checks']})
+ self.assertNotIn('checks_observation_incomplete', {row['code'] for row in plan['blockers']})
+ if state == 'FAILURE':
+ self.assertTrue(any(row['code'] == 'check_failed_or_pending' and 'ci-last' in row['detail']
+ for row in plan['blockers']))
+
+ def test_graphql_continuation_errors_or_moves_to_other_head_fail_closed(self):
+ first = [self.status_context(f'ci-{index}', 'SUCCESS') for index in range(100)]
+ last = self.status_context('ci-last', 'SUCCESS')
+ for continuation in [
+ self.github.AdapterError('fixture continuation failed'),
+ self.graph_commit([last], 101, head='7' * 40),
+ self.graph_commit([], 101),
+ ]:
+ with self.subTest(continuation=continuation):
+ pages = {None: self.graph_commit(first, 101, cursor='page-2'), 'page-2': continuation}
+
+ plan = self.plan([], legacy=first, graph_pages=pages)
+
+ self.assertEqual(plan['status'], 'blocked')
+ self.assertIn('checks_observation_incomplete', {row['code'] for row in plan['blockers']})
+
+ def test_graphql_page_bound_fails_closed_with_green_observed_checks(self):
+ for total, page_size in [(1001, 100), (1000, 99)]:
+ with self.subTest(total=total, page_size=page_size):
+ nodes = [self.status_context(f'ci-{index}', 'SUCCESS') for index in range(10 * page_size)]
+ pages = {
+ None if index == 0 else f'page-{index + 1}': self.graph_commit(
+ nodes[index * page_size:(index + 1) * page_size], total, cursor=f'page-{index + 2}',
+ )
+ for index in range(10)
+ }
+
+ plan = self.plan([], legacy=nodes[:page_size], graph_pages=pages)
+
+ self.assertEqual(plan['status'], 'blocked')
+ self.assertIn('checks_observation_incomplete', {row['code'] for row in plan['blockers']})