Skip to content

Abort PR pushes when Git cannot determine ancestry - #1239

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1177-ancestry-probe-v2
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1177-ancestry-probe-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Context and goal

  • Context: Loop-zero uses Git ancestry to decide whether an existing PR needs a history rewrite.
  • Problem: A failed ancestry probe can select a force-with-lease push.
  • Goal: Abort before publication when Git cannot establish ancestry.

Closes #1177

Acceptance

  • A signaled or fatal ancestry probe fails the PR command with a diagnostic and no push or PR mutation.
  • An ancestor uses a normal push. A known divergent head keeps the exact lease.
  • A missing remote head still advises fetching and integrating it.

Supersedes #1202, whose conflict resolution requires a fresh review.

Validation

Recorded for 4eb0f7d5c02e

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Seven focused CLI tests pass on the current head. They cover SIGTERM, fatal Git errors, unknown remote heads, regular pushes, and the exact force-with-lease path.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 4eb0f7d, approve

Architecture-Review: unchanged; Git still owns ancestry and a known divergent PR head still requires the exact lease.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca marked this pull request as draft November 26, 2026 00:43

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero primary review by claude on 4eb0f7d5c02eba6019b3ef9e4322f55738054a4c, 30.5s: approve (0 critical, 0 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/cli.py
["git", "merge-base", "--is-ancestor", sha, head],
cwd=wt, env_allowlist=worktree.GIT_ENV, timeout=GIT_TIMEOUT,
)
if done.exit_code not in (0, 1):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Stricter _is_ancestor also changes the delta-review message when the reviewed commit is missing

_is_ancestor now raises on any exit other than 0 or 1. That change also reaches _run_review (cli.py:984) and _delta_merge_recovery (cli.py:971). Before this change, a delta review whose reviewed SHA was missing from the local repo made git merge-base exit 128, which _is_ancestor read as 'not an ancestor'. The user then got the specific recovery guidance ("reviewed head … is not an ancestor of this branch. Find the original branch tip with git reflog …"). For example, this happens when another clone force-pushed the reviewed head and this repo never fetched it. Now the same case shows the generic "git merge-base --is-ancestor failed (exit 128): fatal: Not a valid commit name …". Failing closed is the right call, and both paths still abort. The cost is the actionable advice on that path, and no test covers the new review-side behaviour. Smallest fix: in _run_review, run the same cat-file -e <sha>^{commit} check used in cmd_pr before the ancestry probe and give a 'fetch it first' hint. Or add a test that pins the new message so the change is deliberate.

@eowca
eowca marked this pull request as ready for review November 26, 2026 01:08
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as fa78ebb at 01:14 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 01:09 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1270
  • ✅ Merged 01:14 · fa78ebb · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit fa78ebb into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1177-ancestry-probe-v2 branch November 26, 2026 01:15
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.

Abort PR pushes when Git cannot determine ancestry

1 participant