
Land
- 122 installs
- 26.4k repo stars
- Updated July 24, 2026
- openai/symphony
Symphony land skill monitoring conflicts CI and squash-merging PRs to completion.
About
Symphony land skill for shepherding PRs to squash-merge completion. Goals: conflict-free with main, green CI with failure fixes, squash-merge when checks pass, and continuous watcher loop until merged unless blocked. Preconditions require gh CLI auth and clean working tree on PR branch. Steps: locate PR, confirm local gauntlet green, commit and push uncommitted changes, check mergeability, pull skill for conflicts, address Codex review comments, watch checks, fix failures with commit and push cycles, squash-merge with PR title and body. Includes context guard for review feedback conflicting with user intent and ambiguity gate before implementing reviewer suggestions.
- Continuous watcher loop until PR squash-merged unless blocked
- Conflict resolution via pull skill then push skill publish
- CI failure fix cycle with commit push and re-run checks
- Codex review comment acknowledgment before merge
- Context guard and ambiguity gate for reviewer feedback
Land by the numbers
- 122 all-time installs (skills.sh)
- +5 installs in the week ending Jul 26, 2026 (Skillselion tracking)
- Ranked #205 of 733 Git & Pull Requests skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
land capabilities & compatibility
- Capabilities
- monitor pr checks · resolve conflicts · fix ci failures · squash merge pr
- Works with
- github
- Use cases
- ci cd · code review
What land says it does
Do not yield to the user until the PR is merged; keep the watcher loop running unless blocked.
Squash-merge the PR once checks pass.
npx skills add https://github.com/openai/symphony --skill landAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 122 |
|---|---|
| repo stars | ★ 26.4k |
| Last updated | July 24, 2026 |
| Repository | openai/symphony ↗ |
How do I land this PR through conflicts and CI to squash-merge?
Land a PR by monitoring conflicts, keeping CI green, and squash-merging when checks pass using Symphony orchestration.
Who is it for?
Symphony users shepherding PRs through land merge workflow.
Skip if: Creating new PRs or draft-only work without merge intent.
When should I use this skill?
User asks to land, merge, or shepherd a PR to completion.
What you get
PR squash-merged to main with conflicts resolved and all checks green.
Files
Land
Goals
- Ensure the PR is conflict-free with main.
- Keep CI green and fix failures when they occur.
- Squash-merge the PR once checks pass.
- Do not yield to the user until the PR is merged; keep the watcher loop running
unless blocked.
- No need to delete remote branches after merge; the repo auto-deletes head
branches.
Preconditions
ghCLI is authenticated.- You are on the PR branch with a clean working tree.
Steps
1. Locate the PR for the current branch. 2. Confirm the full gauntlet is green locally before any push. 3. If the working tree has uncommitted changes, commit with the commit skill and push with the push skill before proceeding. 4. Check mergeability and conflicts against main. 5. If conflicts exist, use the pull skill to fetch/merge origin/main and resolve conflicts, then use the push skill to publish the updated branch. 6. Ensure Codex review comments (if present) are acknowledged and any required fixes are handled before merging. 7. Watch checks until complete. 8. If checks fail, pull logs, fix the issue, commit with the commit skill, push with the push skill, and re-run checks. 9. When all checks are green and review feedback is addressed, squash-merge and delete the branch using the PR title/body for the merge subject/body. 10. Context guard: Before implementing review feedback, confirm it does not conflict with the user’s stated intent or task context. If it conflicts, respond inline with a justification and ask the user before changing code. 11. Pushback template: When disagreeing, reply inline with: acknowledge + rationale + offer alternative. 12. Ambiguity gate: When ambiguity blocks progress, use the clarification flow (assign PR to current GH user, mention them, wait for response). Do not implement until ambiguity is resolved.
- If you are confident you know better than the reviewer, you may proceed
without asking the user, but reply inline with your rationale. 13. Per-comment mode: For each review comment, choose one of: accept, clarify, or push back. Reply inline (or in the issue thread for Codex reviews) stating the mode before changing code. 14. Reply before change: Always respond with intended action before pushing code changes (inline for review comments, issue thread for Codex reviews).
Commands
# Ensure branch and PR context
branch=$(git branch --show-current)
pr_number=$(gh pr view --json number -q .number)
pr_title=$(gh pr view --json title -q .title)
pr_body=$(gh pr view --json body -q .body)
# Check mergeability and conflicts
mergeable=$(gh pr view --json mergeable -q .mergeable)
if [ "$mergeable" = "CONFLICTING" ]; then
# Run the `pull` skill to handle fetch + merge + conflict resolution.
# Then run the `push` skill to publish the updated branch.
fi
# Preferred: use the Async Watch Helper below. The manual loop is a fallback
# when Python cannot run or the helper script is unavailable.
# Wait for review feedback: Codex reviews arrive as issue comments that start
# with "## Codex Review — <persona>". Treat them like reviewer feedback: reply
# with a `[codex]` issue comment acknowledging the findings and whether you're
# addressing or deferring them.
while true; do
gh api repos/{owner}/{repo}/issues/"$pr_number"/comments \
--jq '.[] | select(.body | startswith("## Codex Review")) | .id' | rg -q '.' \
&& break
sleep 10
done
# Watch checks
if ! gh pr checks --watch; then
gh pr checks
# Identify failing run and inspect logs
# gh run list --branch "$branch"
# gh run view <run-id> --log
exit 1
fi
# Squash-merge (remote branches auto-delete on merge in this repo)
gh pr merge --squash --subject "$pr_title" --body "$pr_body"Async Watch Helper
Preferred: use the asyncio watcher to monitor review comments, CI, and head updates in parallel:
python3 .codex/skills/land/land_watch.pyExit codes:
- 2: Review comments detected (address feedback)
- 3: CI checks failed
- 4: PR head updated (autofix commit detected)
Failure Handling
- If checks fail, pull details with
gh pr checksandgh run view --log, then
fix locally, commit with the commit skill, push with the push skill, and re-run the watch.
- Use judgment to identify flaky failures. If a failure is a flake (e.g., a
timeout on only one platform), you may proceed without fixing it.
- If CI pushes an auto-fix commit (authored by GitHub Actions), it does not
trigger a fresh CI run. Detect the updated PR head, pull locally, merge origin/main if needed, add a real author commit, and force-push to retrigger CI, then restart the checks loop.
- If all jobs fail with corrupted pnpm lockfile errors on the merge commit, the
remediation is to fetch latest origin/main, merge, force-push, and rerun CI.
- If mergeability is
UNKNOWN, wait and re-check. - Do not merge while review comments (human or Codex review) are outstanding.
- Codex review jobs retry on failure and are non-blocking; use the presence of
## Codex Review — <persona> issue comments (not job status) as the signal that review feedback is available.
- Do not enable auto-merge; this repo has no required checks so auto-merge can
skip tests.
- If the remote PR branch advanced due to your own prior force-push or merge,
avoid redundant merges; re-run the formatter locally if needed and git push --force-with-lease.
Review Handling
- Codex reviews now arrive as issue comments posted by GitHub Actions. They
start with ## Codex Review — <persona> and include the reviewer’s methodology + guardrails used. Treat these as feedback that must be acknowledged before merge.
- Human review comments are blocking and must be addressed (responded to and
resolved) before requesting a new review or merging.
- If multiple reviewers comment in the same thread, respond to each comment
(batching is fine) before closing the thread.
- Fetch review comments via
gh apiand reply with a prefixed comment. - Use review comment endpoints (not issue comments) to find inline feedback:
- List PR review comments:
gh api repos/{owner}/{repo}/pulls/<pr_number>/comments- PR issue comments (top-level discussion):
gh api repos/{owner}/{repo}/issues/<pr_number>/comments- Reply to a specific review comment:
gh api -X POST /repos/{owner}/{repo}/pulls/<pr_number>/comments \
-f body='[codex] <response>' -F in_reply_to=<comment_id>in_reply_tomust be the numeric review comment id (e.g.,2710521800), not
the GraphQL node id (e.g., PRRC_...), and the endpoint must include the PR number (/pulls/<pr_number>/comments).
- If GraphQL review reply mutation is forbidden, use REST.
- A 404 on reply typically means the wrong endpoint (missing PR number) or
insufficient scope; verify by listing comments first.
- All GitHub comments generated by this agent must be prefixed with
[codex]. - For Codex review issue comments, reply in the issue thread (not a review
thread) with [codex] and state whether you will address the feedback now or defer it (include rationale).
- If feedback requires changes:
- For inline review comments (human), reply with intended fixes
([codex] ...) as an inline reply to the original review comment using the review comment endpoint and in_reply_to (do not use issue comments for this).
- Implement fixes, commit, push.
- Reply with the fix details and commit sha (
[codex] ...) in the same place
you acknowledged the feedback (issue comment for Codex reviews, inline reply for review comments).
- The land watcher treats Codex review issue comments as unresolved until a
newer [codex] issue comment is posted acknowledging the findings.
- Only request a new Codex review when you need a rerun (e.g., after new
commits). Do not request one without changes since the last review.
- Before requesting a new Codex review, re-run the land watcher and ensure
there are zero outstanding review comments (all have [codex] inline replies).
- After pushing new commits, the Codex review workflow will rerun on PR
synchronization (or you can re-run the workflow manually). Post a concise root-level summary comment so reviewers have the latest delta:
[codex] Changes since last review:
- <short bullets of deltas>
Commits: <sha>, <sha>
Tests: <commands run>- Only request a new review if there is at least one new commit since the
previous request.
- Wait for the next Codex review comment before merging.
Scope + PR Metadata
- The PR title and description should reflect the full scope of the change, not
just the most recent fix.
- If review feedback expands scope, decide whether to include it now or defer
it. You can accept, defer, or decline feedback. If deferring or declining, call it out in the root-level [codex] update with a brief reason (e.g., out-of-scope, conflicts with intent, unnecessary).
- Correctness issues raised in review comments should be addressed. If you plan
to defer or decline a correctness concern, validate first and explain why the concern does not apply.
- Classify each review comment as one of: correctness, design, style,
clarification, scope.
- For correctness feedback, provide concrete validation (test, log, or
reasoning) before closing it.
- When accepting feedback, include a one-line rationale in the root-level
update.
- When declining feedback, offer a brief alternative or follow-up trigger.
- Prefer a single consolidated "review addressed" root-level comment after a
batch of fixes instead of many small updates.
- For doc feedback, confirm the doc change matches behavior (no doc-only edits
to appease review).
#!/usr/bin/env python3
import asyncio
import json
import random
import re
from dataclasses import dataclass
from datetime import datetime
from typing import Any
POLL_SECONDS = 10
CHECKS_APPEAR_TIMEOUT_SECONDS = 120
CODEX_BOTS = {
"chatgpt-codex-connector[bot]",
"github-actions[bot]",
"codex-gc-app[bot]",
"app/codex-gc-app",
}
MAX_GH_RETRIES = 5
BASE_GH_BACKOFF_SECONDS = 2
@dataclass
class PrInfo:
number: int
url: str
head_sha: str
mergeable: str | None
merge_state: str | None
class RateLimitError(RuntimeError):
pass
def is_rate_limit_error(error: str) -> bool:
return "HTTP 429" in error or "rate limit" in error.lower()
async def run_gh(*args: str) -> str:
max_delay = BASE_GH_BACKOFF_SECONDS * (2 ** (MAX_GH_RETRIES - 1))
delay_seconds = BASE_GH_BACKOFF_SECONDS
last_error = "gh command failed"
for attempt in range(1, MAX_GH_RETRIES + 1):
proc = await asyncio.create_subprocess_exec(
"gh",
*args,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
if proc.returncode == 0:
return stdout.decode()
error = stderr.decode().strip() or "gh command failed"
if not is_rate_limit_error(error):
raise RuntimeError(error)
last_error = error
if attempt >= MAX_GH_RETRIES:
break
jitter = random.uniform(0, delay_seconds)
await asyncio.sleep(min(delay_seconds + jitter, max_delay))
delay_seconds = min(delay_seconds * 2, max_delay)
raise RateLimitError(last_error)
async def get_pr_info() -> PrInfo:
data = await run_gh(
"pr",
"view",
"--json",
"number,url,headRefOid,mergeable,mergeStateStatus",
)
parsed = json.loads(data)
return PrInfo(
number=parsed["number"],
url=parsed["url"],
head_sha=parsed["headRefOid"],
mergeable=parsed.get("mergeable"),
merge_state=parsed.get("mergeStateStatus"),
)
async def get_paginated_list(endpoint: str) -> list[dict[str, Any]]:
page = 1
items: list[dict[str, Any]] = []
while True:
data = await run_gh(
"api",
"--method",
"GET",
endpoint,
"-f",
"per_page=100",
"-f",
f"page={page}",
)
batch = json.loads(data)
if not batch:
break
items.extend(batch)
page += 1
return items
async def get_issue_comments(pr_number: int) -> list[dict[str, Any]]:
return await get_paginated_list(
f"repos/{{owner}}/{{repo}}/issues/{pr_number}/comments",
)
async def get_review_comments(pr_number: int) -> list[dict[str, Any]]:
return await get_paginated_list(
f"repos/{{owner}}/{{repo}}/pulls/{pr_number}/comments",
)
async def get_reviews(pr_number: int) -> list[dict[str, Any]]:
page = 1
reviews: list[dict[str, Any]] = []
while True:
data = await run_gh(
"api",
"--method",
"GET",
f"repos/{{owner}}/{{repo}}/pulls/{pr_number}/reviews",
"-f",
"per_page=100",
"-f",
f"page={page}",
)
batch = json.loads(data)
if not batch:
break
reviews.extend(batch)
page += 1
return reviews
async def get_check_runs(head_sha: str) -> list[dict[str, Any]]:
page = 1
check_runs: list[dict[str, Any]] = []
while True:
data = await run_gh(
"api",
"--method",
"GET",
f"repos/{{owner}}/{{repo}}/commits/{head_sha}/check-runs",
"-f",
"per_page=100",
"-f",
f"page={page}",
)
payload = json.loads(data)
batch = payload.get("check_runs", [])
if not batch:
break
check_runs.extend(batch)
total_count = payload.get("total_count")
if total_count is not None and len(check_runs) >= total_count:
break
page += 1
return check_runs
def parse_time(value: str) -> datetime:
normalized = value.replace("Z", "+00:00")
return datetime.fromisoformat(normalized)
CONTROL_CHARS_RE = re.compile(r"[\x00-\x08\x0b-\x1f\x7f-\x9f]")
def sanitize_terminal_output(value: str) -> str:
return CONTROL_CHARS_RE.sub("", value)
def check_timestamp(check: dict[str, Any]) -> datetime | None:
for key in ("completed_at", "started_at", "run_started_at", "created_at"):
value = check.get(key)
if value:
return parse_time(value)
return None
def dedupe_check_runs(check_runs: list[dict[str, Any]]) -> list[dict[str, Any]]:
latest_by_name: dict[str, dict[str, Any]] = {}
for check in check_runs:
name = check.get("name", "unknown")
timestamp = check_timestamp(check)
if name not in latest_by_name:
latest_by_name[name] = check
continue
existing = latest_by_name[name]
existing_timestamp = check_timestamp(existing)
if timestamp is None:
continue
if existing_timestamp is None or timestamp > existing_timestamp:
latest_by_name[name] = check
return list(latest_by_name.values())
def summarize_checks(check_runs: list[dict[str, Any]]) -> tuple[bool, bool, list[str]]:
if not check_runs:
return True, False, ["no checks reported"]
check_runs = dedupe_check_runs(check_runs)
pending = False
failed = False
failures: list[str] = []
for check in check_runs:
status = check.get("status")
conclusion = check.get("conclusion")
name = check.get("name", "unknown")
if status != "completed":
pending = True
continue
if conclusion not in ("success", "skipped", "neutral"):
failed = True
failures.append(f"{name}: {conclusion}")
return pending, failed, failures
def latest_review_request_at(comments: list[dict[str, Any]]) -> datetime | None:
latest: datetime | None = None
for comment in comments:
if is_codex_bot_user(comment.get("user", {})):
continue
body = comment.get("body") or ""
if "@codex review" not in body:
continue
timestamp = comment_time(comment)
if timestamp is None:
continue
if latest is None or timestamp > latest:
latest = timestamp
return latest
def filter_codex_comments(
comments: list[dict[str, Any]],
review_requested_at: datetime | None,
) -> list[dict[str, Any]]:
latest_codex_reply = latest_codex_reply_by_thread(comments)
latest_issue_ack = latest_codex_issue_reply_time(comments)
codex_comments = [c for c in comments if is_codex_bot_user(c.get("user", {}))]
filtered: list[dict[str, Any]] = []
for comment in codex_comments:
created_time = comment_time(comment)
if created_time is None:
continue
if review_requested_at is not None and created_time <= review_requested_at:
continue
is_threaded = bool(
comment.get("in_reply_to_id") or comment.get("pull_request_review_id")
)
if not is_threaded:
if latest_issue_ack is not None and created_time <= latest_issue_ack:
continue
else:
thread_root = thread_root_id(comment)
last_reply = None
if thread_root is not None:
last_reply = latest_codex_reply.get(thread_root)
if last_reply and last_reply > created_time:
continue
filtered.append(comment)
return filtered
def is_codex_bot_user(user: dict[str, Any]) -> bool:
login = user.get("login") or ""
return login in CODEX_BOTS
def is_bot_user(user: dict[str, Any]) -> bool:
login = user.get("login") or ""
if is_codex_bot_user(user):
return True
if user.get("type") == "Bot":
return True
return login.endswith("[bot]")
def is_codex_reply_body(body: str) -> bool:
return body.startswith("[codex]")
def is_codex_review_body(body: str) -> bool:
return body.startswith("## Codex Review")
def latest_codex_issue_reply_time(
comments: list[dict[str, Any]],
) -> datetime | None:
latest: datetime | None = None
for comment in comments:
body = (comment.get("body") or "").strip()
if not is_codex_reply_body(body):
continue
created_time = comment_time(comment)
if created_time is None:
continue
if latest is None or created_time > latest:
latest = created_time
return latest
def filter_human_issue_comments(comments: list[dict[str, Any]]) -> list[dict[str, Any]]:
latest_ack = latest_codex_issue_reply_time(comments)
filtered: list[dict[str, Any]] = []
for comment in comments:
if is_bot_user(comment.get("user", {})):
continue
body = (comment.get("body") or "").strip()
if is_codex_reply_body(body):
continue
if is_codex_review_body(body):
continue
if "@codex review" in body:
continue
created_time = comment_time(comment)
if (
latest_ack is not None
and created_time is not None
and created_time <= latest_ack
):
continue
filtered.append(comment)
return filtered
def filter_codex_review_issue_comments(
comments: list[dict[str, Any]],
) -> list[dict[str, Any]]:
latest_ack = latest_codex_issue_reply_time(comments)
filtered: list[dict[str, Any]] = []
for comment in comments:
body = (comment.get("body") or "").strip()
if not is_codex_review_body(body):
continue
created_time = comment_time(comment)
if (
latest_ack is not None
and created_time is not None
and created_time <= latest_ack
):
continue
filtered.append(comment)
return filtered
def thread_root_id(comment: dict[str, Any]) -> int | None:
return comment.get("in_reply_to_id") or comment.get("id")
def comment_time(comment: dict[str, Any]) -> datetime | None:
timestamp = comment.get("updated_at") or comment.get("created_at")
if not timestamp:
return None
return parse_time(timestamp)
def latest_codex_reply_by_thread(
comments: list[dict[str, Any]],
) -> dict[int, datetime]:
latest: dict[int, datetime] = {}
for comment in comments:
body = (comment.get("body") or "").strip()
if not is_codex_reply_body(body):
continue
thread_root = thread_root_id(comment)
created_time = comment_time(comment)
if thread_root is None or created_time is None:
continue
existing = latest.get(thread_root)
if existing is None or created_time > existing:
latest[thread_root] = created_time
return latest
def filter_human_review_comments(
comments: list[dict[str, Any]],
) -> list[dict[str, Any]]:
latest_codex_reply = latest_codex_reply_by_thread(comments)
filtered: list[dict[str, Any]] = []
for comment in comments:
if is_bot_user(comment.get("user", {})):
continue
body = (comment.get("body") or "").strip()
if is_codex_reply_body(body):
continue
thread_root = thread_root_id(comment)
created_time = comment_time(comment)
last_codex_reply = None
if thread_root is not None:
last_codex_reply = latest_codex_reply.get(thread_root)
if last_codex_reply and created_time and created_time <= last_codex_reply:
continue
filtered.append(comment)
return filtered
def is_blocking_review(
review: dict[str, Any],
review_requested_at: datetime | None,
) -> bool:
created_at = review.get("submitted_at") or review.get("created_at")
if not created_at:
return False
user_login = review.get("user", {}).get("login")
created_time = parse_time(created_at)
if (
user_login in CODEX_BOTS
and review_requested_at is not None
and created_time <= review_requested_at
):
return False
body = (review.get("body") or "").strip()
state = review.get("state")
if user_login in CODEX_BOTS:
return state == "CHANGES_REQUESTED"
if body.startswith("[codex]") or state in ("APPROVED", "DISMISSED"):
return False
blocking = False
if body or state == "CHANGES_REQUESTED":
blocking = True
elif state == "COMMENTED":
blocking = False
elif state:
blocking = state not in ("APPROVED", "DISMISSED")
return blocking
def review_timestamp(review: dict[str, Any]) -> datetime | None:
created_at = review.get("submitted_at") or review.get("created_at")
if not created_at:
return None
return parse_time(created_at)
def dedupe_reviews(reviews: list[dict[str, Any]]) -> list[dict[str, Any]]:
latest_by_user: dict[str, dict[str, Any]] = {}
for review in reviews:
user_login = review.get("user", {}).get("login")
if not user_login:
continue
timestamp = review_timestamp(review)
if user_login not in latest_by_user:
latest_by_user[user_login] = review
continue
existing = latest_by_user[user_login]
existing_timestamp = review_timestamp(existing)
if timestamp is None:
continue
if existing_timestamp is None or timestamp > existing_timestamp:
latest_by_user[user_login] = review
return list(latest_by_user.values())
def filter_blocking_reviews(
reviews: list[dict[str, Any]],
review_requested_at: datetime | None,
) -> list[dict[str, Any]]:
return [
review
for review in dedupe_reviews(reviews)
if is_blocking_review(review, review_requested_at)
]
def is_merge_conflicting(pr: PrInfo) -> bool:
return pr.mergeable == "CONFLICTING" or pr.merge_state == "DIRTY"
async def fetch_review_context(
pr_number: int,
) -> tuple[
list[dict[str, Any]],
list[dict[str, Any]],
list[dict[str, Any]],
datetime | None,
]:
issue_comments = await get_issue_comments(pr_number)
review_request_at = latest_review_request_at(issue_comments)
review_comments = await get_review_comments(pr_number)
reviews = await get_reviews(pr_number)
return issue_comments, review_comments, reviews, review_request_at
def raise_on_human_feedback(
issue_comments: list[dict[str, Any]],
review_comments: list[dict[str, Any]],
reviews: list[dict[str, Any]],
review_request_at: datetime | None,
) -> None:
human_issue_comments = filter_human_issue_comments(issue_comments)
codex_review_comments = filter_codex_review_issue_comments(issue_comments)
human_review_comments = filter_human_review_comments(review_comments)
if human_issue_comments or human_review_comments or codex_review_comments:
print("Review comments detected. Address before merge.")
print(
"Reminder: decide whether feedback stays in scope; defer if needed "
"and note in your root-level update.",
)
raise SystemExit(2)
blocking_reviews = filter_blocking_reviews(reviews, review_request_at)
if blocking_reviews:
print("Review states/comments detected. Address before merge.")
print(
"Reminder: keep PR title/description aligned with the full scope "
"when changes expand.",
)
raise SystemExit(2)
async def wait_for_codex(pr_number: int, checks_done: asyncio.Event) -> None:
print("Waiting for review feedback...", flush=True)
while True:
(
issue_comments,
review_comments,
reviews,
review_request_at,
) = await fetch_review_context(pr_number)
bot_issue_comments = filter_codex_comments(issue_comments, review_request_at)
bot_review_comments = filter_codex_comments(review_comments, review_request_at)
bot_comments = bot_issue_comments + bot_review_comments
raise_on_human_feedback(
issue_comments,
review_comments,
reviews,
review_request_at,
)
if bot_comments:
latest = max(
bot_comments,
key=lambda comment: parse_time(comment["created_at"]),
)
body = sanitize_terminal_output(latest.get("body") or "").strip()
if body:
print("Codex left comments. Address feedback before merge.")
print(body)
raise SystemExit(2)
if checks_done.is_set():
return
await asyncio.sleep(POLL_SECONDS)
async def wait_for_checks(head_sha: str, checks_done: asyncio.Event) -> None:
print("Waiting for CI checks...", flush=True)
empty_seconds = 0
while True:
check_runs = await get_check_runs(head_sha)
if not check_runs:
empty_seconds += POLL_SECONDS
if empty_seconds >= CHECKS_APPEAR_TIMEOUT_SECONDS:
print(
"No checks detected after 120s; check CI configuration",
)
raise SystemExit(3)
await asyncio.sleep(POLL_SECONDS)
continue
empty_seconds = 0
pending, failed, failures = summarize_checks(check_runs)
if failed:
print("Checks failed:")
for failure in failures:
print(f"- {failure}")
raise SystemExit(3)
if not pending:
print("Checks passed")
checks_done.set()
return
await asyncio.sleep(POLL_SECONDS)
async def watch_pr() -> None:
pr = await get_pr_info()
if is_merge_conflicting(pr):
print(
"PR has merge conflicts. Resolve/rebase against main and push before "
"running land_watch again.",
)
raise SystemExit(5)
head_sha = pr.head_sha
checks_done = asyncio.Event()
codex_task = asyncio.create_task(wait_for_codex(pr.number, checks_done))
checks_task = asyncio.create_task(wait_for_checks(head_sha, checks_done))
async def head_monitor() -> None:
while True:
current = await get_pr_info()
if is_merge_conflicting(current):
print(
"PR has merge conflicts. Resolve/rebase against main and push "
"before running land_watch again.",
)
raise SystemExit(5)
if current.head_sha != head_sha:
print("PR head updated; pull/amend/force-push to retrigger CI")
raise SystemExit(4)
await asyncio.sleep(POLL_SECONDS)
monitor_task = asyncio.create_task(head_monitor())
success_task = asyncio.gather(codex_task, checks_task)
done, pending = await asyncio.wait(
[monitor_task, success_task],
return_when=asyncio.FIRST_COMPLETED,
)
for task in pending:
task.cancel()
for task in done:
exc = task.exception()
if exc:
raise exc
if __name__ == "__main__":
try:
asyncio.run(watch_pr())
except SystemExit as exc:
raise SystemExit(exc.code) from None
Related skills
FAQ
When does land stop?
Only when blocked; otherwise keep the watcher loop until the PR is merged.
How are conflicts handled?
Use the pull skill to fetch/merge origin/main, resolve, then push skill to publish.
What about reviewer feedback?
Confirm feedback does not conflict with user intent; use ambiguity gate before implementing.