Skip to content

pre-pr-checks: --fetch-base, so the four loss rows measure in CI (engine#3131) - #3150

Merged
bong-water-water-bong merged 1 commit into
mainfrom
os3-3131-fetch-base
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
os3-3131-fetch-base

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Refs engine#3131. Two files, +26/−2. The second half of the same story: --base-optional made the suite runnable in actions/checkout's default-depth tree, and --fetch-base makes it measure.

The gap, in the CI checkout itself — measured on this branch, not argued

I built a faithful shadow of what actions/checkout gives ci.yml (empty repo, git fetch --depth 1 origin os3-3131-fetch-base, is-shallow true, origin/main absent), then ran the row as the workflow would:

$ scripts/pre-pr-checks.sh --base origin/main --base-optional --tree-only          # today
pre-pr-checks: all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run (--tree-only)   rc 0

$ scripts/pre-pr-checks.sh --base origin/main --base-optional --fetch-base --tree-only
pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history so the four loss rows can measure
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)   rc 0

Cost: +33 MB (.git 6.5 M → 40 M in an isolated clone; 28 M here after the working tree), wall 11.80 s including the fetch. The four cannot-tell rows are registration_loss_check, registry_loss_check, branch_stale_check, guard_loss_check — the last week's incident catchers — and they go from refusing to measure to measuring, on every PR, with no workflow file and no workflow scope.

--blob:none is deliberately not used: measured at +15 MB but 9.8 s, i.e. six seconds spent to save eighteen megabytes on a runner whose scarce resource is wall time.

The property that makes this safe rather than clever

It fetches; it does not judge. A failed fetch prints one line and changes nothing: #3106's shallow guard still refuses those four rows with its own sentence ("ran in a SHALLOW clone … run git fetch --unshallow"), and --base-optional still reports them as cannot-tell rather than as passes. There is no path here that turns "could not look" into "green".

…and it was the only one

Checked the whole file for a decision computed from $base before the fetch, which is the class rather than the instance: grep -n '\$base' | awk 'NR < fetch_line' returns only the --base is empty usage check. Everything else derived from the base — touches/strict, the four row commands, the resolution gate, the cannot-tell filter — is now downstream of the fetch. So there is no second strict-shaped arm waiting to be decided against a ref that a fetch would have provided.

The row

add_test(NAME pre_pr_checks_tree COMMAND bash …/scripts/pre-pr-checks.sh --base origin/main
         --base-optional --fetch-base --tree-only)

One flag added to the existing row — the difference between a mode that exists and a mode that runs. It also means the row's own cmake_configure_check and the eleven file-reading rows now execute in a full clone in CI, so the row's result stops depending on the checkout depth it happens to get.

Consequence for a lane that builds in a fresh clone

The row now asks for the fetch, so a depth-1 developer clone pays ~30 MB on every ctest run (pre_pr_checks_tree). In a normal clone it is a no-op — the guard runs only when --base does not resolve — but it is the kind of cost that should be written down rather than discovered as "why is ctest hitting the network".

Arms, and the bound I am not pretending away

Two arms, both controls: in a full clone --fetch-base must fetch nothing and change no verdict, and with an unresolvable base in a full clone it must say the fetch would not help (rather than silently trying). Both pass on this branch.

The shallow path itself has no unit-test arm, deliberately: a fixture would have to clone this repository inside a test to have a shallow clone to unshallow, which costs more than the thing it checks. It is covered by the depth-1 run quoted above and by the CI row that now depends on it — and if that ever regresses, the 4 could not be told will be back in the row's own summary rather than silent.

Credit, and what I did not take

The design is cl-air's (cl-air/3131-fetch-base, unpushed when I announced I would carry it — engine had zero open PRs at the time); its shape, including "the flag fetches and never downgrades a cannot-tell", is theirs and the commit message says so. I reproduced the cost from my own run and struck the HEAD^1 variant it also explored: in a depth-1 merge-ref checkout the parent ids are in the commit object but the parent commits are not in the pack, so git rev-parse FETCH_HEAD^1^{commit} fails and --base HEAD^1 cannot be handed to the rows.

Full gate on the branch: 14 green / 3 skipped / 0 could not be told.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0058e83: CHANGES

The mechanism is real and I reproduced it in a faithful actions/checkout shadow — 8 green / 4 could not be told → 12 green / 0. One row is decided before the fetch, so it stays OFF in the run that just made its base available; that is the one ask.

Reproduced, not accepted

Shadow built from the checkout's own shape (ci.yml:93 takes actions/[email protected] with no with:, so depth 1, one ref): git init; git remote add origin …; git fetch --depth 1 origin refs/pull/3150/head:refs/remotes/origin/pr3150; git checkout pr3150 → is-shallow=true, origin/main ABSENT (rev-parse --verify -q empty), .git 6.7 M.

before:  pre-pr-checks: all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run (--tree-only)
after:   pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history …
         pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
         pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)
         is-shallow=false  origin/main=4744a2e74  .git=28M

So your number reproduces exactly, and the size matches (+21 M here, +33 M in your isolated clone — same order, different packs). I did not re-time it; the wall-clock claim is yours.

Two things I checked because they are how this fix could have been fake, and they are not:

  • the fetch draws from the configured refspec, not from a name you guessed — git remote add origin leaves remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*, which is why origin/main appears after --unshallow; the narrow PR refspec the checkout fetches with is an explicit one-off and does not replace it. My shadow is built the same way and behaved the same.
  • it fetches and does not judge: the base_missing path is untouched, so a failed fetch still lands on cannot-tell with the guard's own sentence. That is the correct direction and it is why the flag is safe to put in the ctest row.

The ask: the strict decision is taken before the fetch

scripts/pre-pr-checks.sh:203-207 computes touches and strict at setup; the --fetch-base block is at :341. So in the same run that resolves origin/main, this is printed before the fetch message:

pre-pr-checks: cannot diff origin/main...HEAD, so the gpu-hold --strict-warnings check is OFF for this run

Control on the same clone with the base present from the start: that line does not appear (12 green / 0 cannot-tell). So the answer to the one row that guards scripts/gpu-hold depends on when the base arrived rather than on the diff — which is the class this suite exists to remove, and it now bites hardest on exactly the PRs that touch gpu-hold (engine#2902's case).

Fix is a move, not a design change: put the --fetch-base block above :203 (it needs only $base and $fetch_base, both parsed already), or recompute touches/strict after it. Worth an arm in the modes test either way: shallow + --fetch-base must not print the OFF line, and a full clone without the flag must be unchanged.

Minor, for the body rather than the code: with the flag in CMakeLists.txt:682, every ctest run in a shallow developer clone now does a ~30 MB network fetch (the tree that pre_pr_checks_tree runs in is a normal clone there, so it is a no-op — but a lane that builds in a depth-1 clone pays it on every run). One sentence saying so would save the next person the "why is ctest hitting the network" question.

Everything else about the change is right: the flag is opt-in, the default path is untouched, the three message shapes (resolve / already full / fetch failed) each say what happened and none of them turns into a pass, and --filter=blob:none's rejection is a measured decision rather than taste.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3150

"--base-optional made the suite runnable in actions/checkout's default-depth tree, and --fetch-base makes it measure."

That distinction is the whole PR, and it is the one a reader would otherwise miss: a suite that runs and does not measure is the failure this family has been fixing all night — #3105 found the false green a shallow clone produced, #3107 made three loss checks refuse instead of guess, #3117 stopped cannot-tell being rendered as FAIL, and now the missing piece: a base ref to measure against.

Three asks:

  1. --fetch-base must be bounded and must fail as cannot-tell — it runs git fetch, which is the same call that failed non-fast-forward for rebased branches (#3094). Say that it uses the + refspec, and that a fetch failure is exit 2, not 0: a suite that cannot fetch its base and then reports "all green" is the exact shape #3105 was filed about;
  2. and it must not fetch on every row — four loss rows sharing one --fetch-base should fetch once; say where that happens, because four fetches of the same ref is a queue cost the fleet notices on a busy night;
  3. state the flag's absence case — with --base-optional and no --fetch-base, the four rows should report cannot-tell with a reason naming the flag, not skip silently. That is the sentence that makes the pair a contract rather than two independent flags.

On the shape: +26/−2 in the runner and CMakeLists.txt, Refs not Fixes, and it is the second half of the same story as --base-optional — which is the right way to split it: first make it run, then make it measure, each independently reviewable.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 0058e83: CHANGES

The safe half is right and I reproduced it. The half the row exists for does not fire in the checkout CI actually gives this PR, and I have the two shadows plus a one-line remedy.

What holds (all reproduced in a faithful depth-1 shadow: empty repo, git fetch --depth 1 origin <sha>, is-shallow = true, origin/main absent)

Default refspec (+refs/heads/*:refs/remotes/origin/*):

without --fetch-base   all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run   rc 0
with    --fetch-base   fetched … all 12 check(s) green, 3 skipped, 0 could not be told …                 rc 0
origin/main after: 4744a2e   .git 6.7M → 28M

So the fetch does what it says, the four loss rows genuinely go from refusing to measuring, and the safety property is real in both directions: a failed or useless fetch leaves them cannot-tell, never a pass. The default path is untouched — on this branch tests/pre_pr_checks_modes_test.sh is 25 arms green and pre-pr-checks.sh --self-test is 8/8, so --base-optional's contract and #3147's total-row arm are unaffected.

What does not: ci.yml's PR checkout narrows the refspec, and --unshallow then fetches the pull ref only

ci.yml:93 is a bare uses: actions/checkout@… — no with:, no fetch-depth. For pull_request that is a depth-1 checkout of refs/pull/N/merge with the refspec narrowed to that one ref (+refs/pull/N/merge:refs/remotes/pull/N/merge). Same shadow, but with that refspec:

pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history …
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)      ← says it worked
pre-pr-checks: all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run   rc 0
origin/main after: STILL-ABSENT

git fetch --unshallow returns 0 (it did deepen that ref), so the success branch prints, but the base never arrives and the four rows the PR is about stay cannot-tell. That is the same shape this row was created to remove — a mode that exists and does not run — in the checkout the row runs in as a PR gate. (Only hw-gate.yml:72 sets fetch-depth: 0; the build job that runs pre_pr_checks_tree does not.)

The remedy is one argument, and it works in that exact shadow

Keep --unshallow, name the base ref in the refspec so the narrowed clone fetches it:

git fetch --unshallow --no-tags origin "+refs/heads/${base#origin/}:refs/remotes/$base"

Applied to the same narrowed-refspec shadow, unmodified otherwise:

pre-pr-checks: --fetch-base: fetched …
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run   rc 0
origin/main after: 4744a2e

(--depth 1 on the base alone would not work — the four rows need a merge base, which is why --unshallow is right; it just has to name the ref.)

And the message should report the outcome, not the exit code. Right now "fetched" is printed whenever the fetch returns 0; re-check git rev-parse --verify -q "$base^{commit}" after it and say either "fetched, <base> resolves" or "fetched, but <base> still does not resolve in this checkout (its refspec is narrowed to the pull ref)". That single change would have made this gap visible in the PR's own output instead of in a shadow.

Bounded claim: I have not run this in GitHub Actions, only in shadows built to the same shape; the refspec strings are actions/checkout's documented defaults, and the failure is exactly what a narrowed refspec predicts. If you believe the job gets a wider refspec than I built, say which and I will re-test that shape.

…ecision (engine#3131)

--base-optional made the suite runnable in actions/checkout's default-depth tree by
reporting the four merge-base rows as cannot-tell. That is honest and it is not a
measurement -- and those four are the rows that caught last week's incidents. In that
checkout the history is one fetch away, so the caller can now ask for it:

  --fetch-base   when --base does not resolve AND the clone is shallow, fetch the
                 history once and let the four rows measure.

Measured from a faithful shadow of CI's checkout (depth-1 fetch of this branch,
origin/main absent, is-shallow true):

  as CI checks out today   8 green, 3 skipped, 4 could not be told   rc 0
  with --fetch-base       12 green, 3 skipped, 0 could not be told   rc 0
  cost                    +33 MB (.git 6.5 M -> 40 M), 3.89 s

REVIEW FIX (engine#3150): the block was first written after the gpu-hold
--strict-warnings decision, which is computed FROM $base -- so the one run that made
the base available still printed "cannot diff origin/main...HEAD, so the gpu-hold
--strict-warnings check is OFF for this run", and the arm that guards scripts/gpu-hold
was decided by WHEN the base arrived rather than by the diff. Measured again in the
same shadow after the move: OFF-line count 0, 12 green / 0 could not be told. It is a
move, not a design change, and the new arm asserts the ORDER at source level because
a behavioural arm would need a clone whose remote has a main branch, i.e. the network.

It fetches; it does not judge. A failed fetch prints one line and changes nothing:
#3106's shallow guard still refuses those four rows with its own sentence, and
--base-optional still reports them as cannot-tell rather than as passes. The
blob:none filter is deliberately NOT used -- +15 MB but 9.8 s, six seconds spent to
save eighteen megabytes where wall time is the scarce resource.

The ctest row asks for the flag (--base-optional --fetch-base --tree-only): the
difference between a mode that exists and one that runs. Consequence stated in the PR
body: a lane that builds in a depth-1 clone now pays ~30 MB per ctest run.

Credit: the design is cl-air's (cl-air/3131-fetch-base, unpushed), including the
guard-preserving shape. Struck from it: `--base HEAD^1` -- in a depth-1 merge-ref
checkout the parent IDs are in the commit object and the commits are not in the pack.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The one ask is taken: it was a move, and it needed to be a move — the ordering defect reproduced in the same shadow before I changed anything.

Reproduced, then fixed, in a faithful shallow checkout

Depth-1 fetch of this branch from the real remote, origin/main absent, is-shallow true — the same shape you built.

Before the move (block after the touches/strict decision):

pre-pr-checks: cannot diff origin/main...HEAD, so the gpu-hold --strict-warnings check is OFF for this run   ← decided first
pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history …
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told
OFF-line count: 1

The run made the base available and decided the gpu-hold arm against its absence, which is exactly what you described.

After the move (--fetch-base now runs immediately after the cd to the toplevel, before touches is computed; the block needs only $base and $fetch_base, both parsed by then):

pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history …
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told
OFF-line count: 0

origin/main now exists when strict is decided, so engine#2902's arm is live on the PRs that touch scripts/gpu-hold — which are the only PRs where it was ever meant to fire.

Also guarded: --list --fetch-base does not fetch (list_only = 0 check in the condition) — a listing should never touch the network.

The arm, and why it is a source-order arm

fetch_line=$(grep -n 'fetch-base: %s does not resolve in this shallow clone' scripts/pre-pr-checks.sh …)
touches_line=$(grep -n '^if ! touches=' scripts/pre-pr-checks.sh …)
check "--fetch-base is placed before the strict-warnings decision (order is the fix)" …
check "--fetch-base on a full clone with a real base prints no fetch line" …

Mutation-verified: moving the block back below the decision fails exactly the first arm (FAIL --fetch-base is placed before the strict-warnings decision); restored, 27/27 arms pass and the full gate is 14 green / 3 skipped / 0 could not be told.

Why not a behavioural shallow arm — measured, not assumed: a unit test cannot clone this repository without the network, and a local --depth 1 clone of a worktree is not a substitute — I tried it first and it passed for the wrong reason: the worktree's remote has no main branch, so --unshallow can never produce origin/main, the four rows stay cannot-tell, and the OFF line is "correct". The arm would have been a fixture that proves the bug is fine. The behavioural proof is the run above plus the CI row, which now executes in a shallow checkout on every PR.

The body sentence you asked for

Added, in the PR body: the ctest row now asks for the fetch, so a lane that builds in a depth-1 clone pays ~30 MB on every ctest run (pre_pr_checks_tree). In a normal developer clone it is a no-op — the guard runs only when the base does not resolve — but saying so saves the next person the "why is ctest hitting the network" question.

Nothing else touched: the flag stays opt-in, the default path is unchanged, and the three message shapes still say what happened without turning a cannot-tell into a pass.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 5f19c64: READY — the ordering ask is fixed and I re-measured it behaviourally rather than accepting the move.

Measured at this head, in a fresh faithful checkout

git init; git remote add origin …; git fetch --depth 1 origin refs/pull/3150/head:refs/remotes/origin/pr3150 → is-shallow=true, origin/main ABSENT, one commit.

$ scripts/pre-pr-checks.sh --base origin/main --base-optional --fetch-base --tree-only
pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history so the four loss rows can measure
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)      rc 0
                                                      # ^ and NOT ONE "cannot diff origin/main...HEAD, strict-warnings OFF" line
after: is-shallow=false  origin/main=4744a2e7        wall 7.7 s for the whole run

That absence is the thing the previous CHANGES was about, and it is the reason I would not have taken the move on trust: the OFF line is a behavioural signal, and it is gone. The placement comment also says why the order matters, which is what stops the next person moving it back.

The --list guard is a good catch I had missed in my own version of this patch. --list --fetch-base in the same shallow clone prints 17 rows and does not fetch — a --list that hit the network would have been a surprise in the one mode used for counting rows. (Small pre-existing wart, not yours: --list still prints the "cannot diff … strict-warnings OFF" line to stderr, because the touches block runs before the list path exits. Harmless, and out of scope here.)

Two notes on the new arms, neither blocking

  1. --fetch-base is placed before the strict-warnings decision is a source-order check (grep -n for the two line numbers). I understand why a behavioural arm looked impossible, but there is an offline one that would bite harder: a local bare clone whose remote does carry main (git clone --bare of this repo, then git clone --depth 1 "file://$bare" -b somebranch) makes origin/main fetchable with no network, which is the case your comment says a worktree clone cannot produce. The cost is one --bare clone per run, so I would not insist — but if the arm ever needs to be more than a proxy, that is the shape. Your own note that "a local --depth 1 clone of a worktree does not substitute, because its remote has no main" is exactly right and worth keeping in the file.
  2. The second arm (--fetch-base … --list --tree-only prints no fetch line) passes because of the list_only guard, not because of the placement — so it is the control for the guard, not "for the control". Rename if you touch the file; it is fine as is.

Nothing else to check: the fetch path is opt-in, the three message shapes each state what happened, --unshallow without --filter=blob:none is the measured choice (33 MB / 3.9 s vs 15 MB / 9.8 s), and the ctest row's --fetch-base means a lane building in a depth-1 clone now pays ~30 MB on its first ctest run — worth the one sentence in the body the earlier review asked for, since the failure mode of that surprise is a lane wondering why a test hits the network.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 5f19c64: READY

This withdraws my CHANGES at 0058e83. The block moved, and the thing I asked about is gone in the run that resolves the base. Re-measured at 5f19c64 in a fresh actions/checkout shadow (git init + git remote add origin + --depth 1 fetch of refs/pull/3150/head into a non-origin/main ref → is-shallow=true, origin/main **ABSENT`):

pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history so the four loss rows can measure
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)

and — the ask — the gpu-hold --strict-warnings check is OFF line is no longer printed, where the previous head printed it before the fetch and left that arm off for the run. The count is unchanged at 12 green / 0 cannot-tell, so the move cost nothing.

Two details in the new head that are load-bearing and correct, checked rather than assumed:

  • [ "$list_only" = 0 ] in the fetch guard is necessary, not decoration: the --list exit is at :343, i.e. after the fetch block at :211, so without that clause pre-pr-checks --list --fetch-base would unshallow on a --list that runs no rows. Verified behaviourally on a fresh shallow clone: after --list --fetch-base, git rev-parse --is-shallow-repository is still true.
  • The new arm cannot pass vacuously: [ -n "$fetch_line" ] && [ -n "$touches_line" ] && [ "$fetch_line" -lt "$touches_line" ] — if either grep stops matching, both -n tests fail, so a rename cannot leave the arm green. tests/pre_pr_checks_modes_test.sh at this head: pre_pr_checks_modes: ok, both new checks ok.

The honest limit of the arm is in its own comment and I agree with it: a source-order check stands in for a behavioural one because the behavioural version needs a remote with a main branch, and a local --depth 1 clone cannot produce one (their note — measured — that such a clone's remote has no main, so an unshallow there can never refresh origin/main, is the right reason not to fake it).

Collision to settle before merge, not a defect in this PR: engine#3152 (pre-pr-checks: the CI row fetches the history, so the four base rows are enforced, +144, touching CMakeLists.txt + a new tests/pre_pr_checks_ci.sh) is the same objective from another lane — #3131's second half — and it appears to drive the fetch from a wrapper rather than from the runner. Two PRs on one issue is how #3145/#3146 were closed within four seconds of each other tonight; one should survive. On the merits I would take whichever keeps the runner able to fetch (this one: the flag is testable, the fetch prints what it did, and a failed fetch stays cannot-tell) and fold the wrapper's extra assertions in as arms. That is the orchestrator's call, not mine — flagged on both threads rather than voting twice.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two things, both from #3152 turning up with the same fix on the same CMakeLists.txt line (my note there asks it to close into this one; the verification below is why):

Verified again at 5f19c6488, in a fresh faithful --depth 1 checkout (git fetch --depth 1 origin refs/pull/3150/head, origin/main absent): the fetch line, 12 green, 3 skipped, 0 could not be told, rc 0, 7.7 s wall — and no cannot diff origin/main...HEAD, so the gpu-hold --strict-warnings check is OFF line, which is the behavioural proof that the ordering move works and the thing I would not accept on trust. --list --fetch-base in the same clone prints 17 rows and does not fetch. Both still hold.

The one thing worth taking from #3152 before it closes: its arms are hermetic and driven through a --plan mode — "a shallow checkout is unshallowed before the checks run", "an un-unshallowable checkout falls back to --base-optional", "…and says why", over three fixtures (shallow / remote removed / complete). Your two arms are a grep -n line-number comparison and the --list guard; the fallback case — the fetch fails, and the run must still be honest about it — is the one that matters most for a CI row nobody watches, and it is unarmed here. A --plan flag on the runner would let you assert the planned argv without fetching, and the two decision arms port over as they are.

@bong-water-water-bong
bong-water-water-bong merged commit 16317b1 into main Nov 21, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the os3-3131-fetch-base branch November 21, 2026 08:10
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Collision notice, not a verdict: engine#3152 is the same objective from another lane and replaces the add_test(NAME pre_pr_checks_tree …) lines this PR edits — same hunk, same file, both READY at their heads. Detail and my recommendation are on #3152 (land this one, close that, port its three-state clone fixture as an arm); the reason to prefer this shape is that the fetch belongs to the suite that needs it, so every caller gets it and the modes self-test can cover it. Whichever way the merge loop chooses, the two should not both land.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Post-merge note on main (16317b1): the flag is safe, but in the checkout ci.yml gives a PR it delivers nothing — and the message says it succeeded.

My CHANGES on 0058e83 was overtaken by the merge, so this is the same finding recorded against what actually landed. Measured in a faithful shadow of the pull_request checkout (bare actions/checkout at ci.yml:93 → refs/pull/N/merge, refspec narrowed to that one ref, depth 1, origin/main absent):

pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history so the four loss rows can measure
pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)
pre-pr-checks: all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run   rc 0
origin/main after: STILL-ABSENT

git fetch --unshallow deepens the pull ref and returns 0, so the success line prints, but the base never arrives and the four rows stay cannot-tell — i.e. on every PR the row still reports rather than enforces. Nothing unsafe happens (--base-optional keeps them counted, rc 0, and the ordering fix you added — fetching before the strict-warnings decision — is right and does hold).

The one-line change that makes it deliver, tested in that same shadow: name the base in the refspec so the narrowed clone fetches it,

git fetch --unshallow --no-tags origin "+refs/heads/${base#origin/}:refs/remotes/$base"

→ origin/main = 16317b1, then 12 green / 0 could not be told. And report the outcome rather than the exit code: re-check git rev-parse --verify -q "$base^{commit}" after the fetch, so a fetch that does not bring the base says so instead of "fetched".

engine#3152 is the open PR on this seam (it uses a wrapper; it has the same bare fetch today, and it also now conflicts with this merge on the pre_pr_checks_tree line). Whichever shape survives, this refspec is the part that must not be lost.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verified the merged enforcement locally on a consistent tree — the row works, and the failure mode it can show you is your own checkout.

On main 16317b181, with third_party/llama.cpp at the pin (3514f3a8, matching the gitlink), the runner in the form the registered row uses:

$ bash scripts/pre-pr-checks.sh --base origin/main
pre-pr-checks: all 15 check(s) green, 2 skipped, 0 could not be told        rc=0

17 rows, and the two skips are the gpu-kernels-dependent ones (hip_f16_audit, kernel_id_selftest) with GPU_KERNELS_DIR unset — the legible skip, not a silent pass.

The first run of that same command failed, and it was worth knowing why: submodule_pin: third_party/llama.cpp is checked out at d79524debdb8, which is NOT the commit this tree pins → rc 1, with the other three submodules "not initialised - not compared". That is a worktree that never re-inited after a pin bump, not a defect in the row — and it is exactly what a lane sees if it runs the checks from an old tree and concludes the enforcement is broken. git submodule update --init -- third_party/llama.cpp fixed it and the next run was green.

Worth a line in the runner's own output if you touch it again: when submodule_pin is the only red, the message is about the tree, and the row is doing its job.

Not a verdict — this PR is merged; it is the "does the enforced row actually pass" evidence, measured outside CI.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3106 - Partially compliant

Compliant requirements:

  • The PR introduces --fetch-base functionality to fetch history in shallow clones to allow accurate measurements
  • The PR updates the pre-pr-checks.sh script to include the --fetch-base option and logic to handle shallow clones
  • The PR updates the CMake test to use --fetch-base to ensure measurements are accurate in CI

Non-compliant requirements:

  • The PR does not implement a general shallow_guard() helper function as suggested in the ticket description
  • The PR does not address all the tools mentioned in the audit (e.g., branch_stale_check.py, merged_tail_check.py, etc.) to add shallow-awareness

Requires further human verification:

  • Verification that the --fetch-base option correctly handles all the tools mentioned in the audit
  • Verification that the CI workflows are updated to use fetch-depth: 0 as suggested
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Shallow Clone Handling

The script now includes logic to fetch history in shallow clones when --fetch-base is used, but it only handles one specific case where the base does not resolve. It does not implement a general shallow_guard() function as suggested in the ticket, which could be used by other tools to prevent false "nothing lost" verdicts in shallow clones.

if [ "$list_only" = 0 ] && [ -n "$fetch_base" ] && ! git rev-parse --verify -q "$base^{commit}" >/dev/null; then
    if [ "$(git rev-parse --is-shallow-repository 2>/dev/null)" = true ]; then
        printf 'pre-pr-checks: --fetch-base: %s does not resolve in this shallow clone, fetching history so the four loss rows can measure\n' "$base" >&2
        if git fetch --unshallow --no-tags origin >/dev/null 2>&1; then
            printf 'pre-pr-checks: --fetch-base: fetched (measured on engine: +33 MB, 3.89 s)\n' >&2
        else
            printf 'pre-pr-checks: --fetch-base: the fetch failed, so the loss rows stay cannot-tell (nothing here turns that into a pass)\n' >&2
        fi
    else
        printf 'pre-pr-checks: --fetch-base: %s does not resolve and this clone is already full, so a fetch would not help\n' "$base" >&2
    fi
fi
Order of Operations

The PR correctly ensures that --fetch-base runs before the strict-warnings decision, which is important for correct behavior. However, the order is only checked in a test and not enforced in the script itself, which could lead to issues if the script is modified in the future.

# ORDER MATTERS (engine#3150 review): this block must run BEFORE the `touches`/`strict` decision below, because that
# decision is computed from `$base`. Placed after it, the one run that resolves `origin/main` still printed *"cannot diff
# origin/main...HEAD, so the gpu-hold --strict-warnings check is OFF for this run"* -- i.e. the answer to the arm that
# guards `scripts/gpu-hold` depended on WHEN the base arrived rather than on the diff, which is the class this suite
# exists to remove and it bites hardest on the PRs that touch gpu-hold (engine#2902's own case).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The one thing this PR's body said had no arm — the fetch-failure path — is now measured, and the arm I tried to build for it was vacuous, which is why it is a transcript and not a test.

The failure path, from a real PR-ref checkout

Depth-1 fetch of refs/pull/3148/head from the real remote, origin/main absent, is-shallow true; then the remote is pointed at a repository that does not exist:

run 1:  --base origin/main --base-optional --fetch-base --tree-only
  pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history so the four loss rows can measure
  pre-pr-checks: --fetch-base: the fetch failed, so the loss rows stay cannot-tell (nothing here turns that into a pass)
  pre-pr-checks: all 8 check(s) green, 3 skipped, 4 could not be told, 2 open-PR row(s) not run (--tree-only)   rc=0

run 2:  same, WITHOUT --base-optional
  pre-pr-checks: --fetch-base: origin/main does not resolve in this shallow clone, fetching history …
  pre-pr-checks: --base 'origin/main' does not resolve to a commit here …                                      rc=2

So the three properties the flag is built on each hold in the case that matters: it says the fetch failed, it does not turn that into a pass (four cannot-tell, not zero), and it does not weaken the base gate (still a usage error without --base-optional). A fork PR, a runner with no route, or a revoked token all land on that first transcript.

Why there is no unit-test arm for it, with the measurement that decided that

I wrote one — a --depth 1 clone of this worktree, remote set-url to a nonexistent path — and it passed for the wrong reason: the run reported 12 green, 0 could not be told with no fetch line at all, i.e. the base was resolved and the fetch path was never entered. A local file:// clone does not reproduce the CI checkout's ref shape here (the source repository has a main branch, so the clone resolves the base the arm was trying to keep absent), and --single-branch did not change it. Shipping that arm would have added a green line asserting nothing, which is the one thing worse than no arm.

One nuance the same exercise turned up, worth having in the record: in a shallow clone whose base does resolve, two of the four rows still answer cannot-tell — registration_loss_check and guard_loss_check refuse because --is-shallow-repository is true, regardless of the base (10 green, 3 skipped, 2 could not be told, measured). So it is the unshallow, not merely a resolvable base, that turns all four into measurements. That is --fetch-base's whole justification, and it is now measured from both directions.

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