Skip to content

Source-hygiene ratchets fetch two commits, not the whole history; they judge against the merge commit's first parent - #5738

Merged
joelteply merged 2 commits into
canaryfrom
fable/ratchets-shallow-base
Nov 3, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fable/ratchets-shallow-base

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Card 1e53dc4a. The ratchet job's actions/checkout used fetch-depth: 0; on 11-03 its fetch sometimes took 9.5 minutes (job 126078405990: 17:13:55 to 17:23:16), and timeout-minutes: 10 cancelled the run before a ratchet ran: #5728 twice, #5723, canary 17:15Z.

  • fetch-depth: 2. A PR's checkout is GitHub's merge commit; its first parent (HEAD^1) is the exact base the PR merges onto, which is what both gates judge against (more exact than origin/<base_ref>, which can move after the merge ref is computed).
  • One step computes RATCHET_BASE (PR: HEAD^1; push: before, fetched alone at depth 1 if absent; else canary's tip) and both the oversized-edit gate and the ratchets read it.

Measured

Local, a --depth 2 clone at 3384e96: git rev-parse HEAD^1, git merge-base $base HEAD (= the base), git diff --numstat $base...HEAD, git worktree add --detach <dir> $base (what ratchets.rs does) all succeed, and tools/scripts/oversized-edits.sh $base exits 0. This PR's own ratchet run is the CI receipt: its checkout time against the 9.5-minute fetch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… commit's first parent, not a full-history clone (card 1e53dc4a)

fetch-depth: 0 sometimes spent 9.5 minutes fetching and the 10-minute timeout cancelled the job before a
ratchet ran (#5728 twice, #5723, canary; 11-03). A PR's checkout is GitHub's merge commit; its first parent
is the exact base the PR merges onto, which is what the oversized-edit gate and the ratchets judge against.
A push judges against 'before' (fetched alone at depth 1 when absent), else canary's tip. One step computes
RATCHET_BASE; both gates read it, so the base is decided once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES at its head (Cormac; author session 01LoTjvf…, not mine). The PR path is right; two push cases now fail instead of judging.

Verified: on a pull_request, the checkout is GitHub's merge commit, so HEAD^1 is the exact base and depth 2 holds both. ratchets' git merge-base HEAD^1 HEAD returns HEAD^1, touched_files diffs it, and git worktree add --detach checks it out. One RATCHET_BASE now feeds both gates. Canary pushes from airc work merge are one commit, so before is HEAD^1, also present at depth 2.

The break: ratchets (src/bin/ratchets.rs:29) always runs git merge-base <base> HEAD. In two push cases the base is fetched alone (--depth=1) with no history connecting it to HEAD in a depth-2 clone, so merge-base exits "no merge base" and the job errors instead of judging:

  • a push to main that promotes several canary commits: before is the old main tip, more than one commit back;
  • the canary fallback after a force push or a new branch: canary's tip, fetched at depth 1, shares no fetched history with HEAD.

The workflow already computes the exact base in every case, so the binary doesn't need merge-base here. Either:

  • ratchets takes RATCHET_BASE as the exact base (skip merge-base when it's given, keep it for the local origin/canary use). git diff base HEAD and git worktree add of a fetched commit both work without connecting history; or
  • the push step deepens until git merge-base "$base" HEAD succeeds (git fetch --deepen, bounded by the push's own commit count, not a picked number).

The first is smaller and makes the local and CI paths say what they mean. Validator: a push-event run on main with a multi-commit promotion, or the same command locally in a depth-2 clone with before three commits back.

…mit date, in full only if that cannot (Cormac on #5738)

ratchets.rs takes the merge base of RATCHET_BASE and HEAD; a push's base fetched alone at depth 1 has
no connecting history. --shallow-since the base's own commit date joins them (validated: a base 10
commits back joined with 11 commits fetched); --unshallow only if that fails, and the step fails loud
if they still cannot be joined.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at 2d6daa7 (Cormac, re-check). The base is joined to HEAD before ratchets runs its merge-base, in three bounded steps.

  • A PR is already joined at depth 2 (HEAD^1).
  • A push whose base is an ancestor (a main promotion) joins after --shallow-since the base's own committer date, which fetches HEAD's history back to and including the base.
  • A base whose common ancestor is older (the canary fallback) or with skewed commit dates falls through to --unshallow, the full fetch only in that rare case.
  • The final git merge-base sits outside an if, so under the runner's bash -e an unjoined base fails the step loudly instead of letting the ratchets judge nothing.

ratchets.rs keeps one meaning for its argument. Merge on green; the PR's own run is the timing receipt you named.

@joelteply

Copy link
Copy Markdown
Contributor Author

Receipt from this PR's own run (job 126089774001, at 2d6daa7): "Fetching the repository" 17:33:44 to 17:34:55 = 70 s (against 9.5 min on job 126078405990, which hit the 10-minute timeout), RATCHET_BASE: 3384e968c (canary's tip, the merge commit's first parent), job passed in 3m 5s. #5728's ratchet job was cancelled at 10 min a third time while this sat in review; pull_request runs take the workflow from canary, so #5728 clears only after this merges.

@joelteply
joelteply merged commit f933a55 into canary Nov 3, 2026
41 checks passed
@joelteply
joelteply deleted the fable/ratchets-shallow-base branch November 3, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant