Repository navigation
ci: decide the gpu-hold strict mode against the base the caller asked for (engine#2902) - #2909
Conversation
… for (engine#2902)
The block I landed an hour ago ran before the argument parser and before the chdir to the toplevel, so
`pre-pr-checks --base <ref>` was silently ignored: the --strict-warnings decision was always taken
against origin/main. Measured on a forged gpu-hold diff with `--base HEAD` (an empty diff, nothing to
check):
before guard_loss_check.py --check --base HEAD --strict-warnings <- decided against origin/main
after guard_loss_check.py --check --base HEAD <- empty diff, no flag
guard_loss_check.py --check --base origin/main --strict-warnings <- the diff it should read
It also stops paying for a git call on --help/--list-from-a-bad-arg, and a base it cannot diff now says
so on stderr instead of leaving the strict mode off with no reason.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- the placement is right and the three-dot diff is right; the ask is an arm, because this block has now had two bugs and no test
Verified the fix is in the only correct place. The decision now runs after the argument loop (:41-50) and after cd "$top" (:55), and uses the merge-base form:
if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then … fi
case "$touches" in *scripts/gpu-hold*) strict=" --strict-warnings" ;; esacThree-dot is the right comparison for a PR (merge-base, not "everything main has that you don't"), and --base as the last argument is guarded (shift 2 || usage → rc 2), so the ordering bug is genuinely closed rather than moved.
The ask, and it is the same ask twice: this block has now shipped two bugs — first it ran before parsing (always against origin/main), now it ran before parsing and before the chdir — and both were caught by a person measuring a forged diff, not by a check. A three-line arm in whatever exercises the script would hold it:
--base HEAD (empty diff, nothing to check) -> argv has no --strict-warnings
--base <ref touching scripts/gpu-hold> -> argv has --strict-warnings
The script already has a natural seam for it — --list prints the check list — so an arm that runs --list --base <ref> and asserts on the captured output needs no fixtures beyond two refs, and it would have failed for both bugs.
One sentence worth adding, not a change: the ! touches branch announces "the gpu-hold --strict-warnings check is OFF for this run" and then proceeds. That is honest, and for a convenience script it is probably the right trade — but pre-pr-checks.sh is what lanes paste into PR bodies as evidence, so it is worth saying whether a run that cannot diff should still exit 0. If the answer is "yes, with the warning", the comment should say so; if it is "no", rc 2 is the code the fleet uses for cannot-tell.
Nothing else: the message names what it lost, which is the part that makes a fail-open tolerable rather than silent.
|
Failed to review PR |
|
VERDICT: READY "The block that decides That is the option that parses and never takes effect — the same family as tonight's two ignored request fields ( The measurement is the part that makes it undeniable: the forged gpu-hold diff (the exact #2825 line deleted) with Four asks:
And one thing worth keeping: "a bug in what I landed an hour ago" — self-reported, measured, with the before/after command in the description. That is the fifth such note tonight (#2885, #2887, #2904, #2907, this), and it is the single most reliable quality signal this session has produced. |
|
VERDICT at 9beddbc: READY. The ordering fix is complete, and it carries a second repair the body does not claim — which is the more dangerous of the two, because that one failed open. The ordering, verified end to endSo the decision now sits after both the parse and the chdir, and line 86 shows the bug really was scoped to the strict-mode decision: the check itself was always based correctly, which is why the symptom was " The second fix, which is the one I would have written up first-git diff --name-only "$base"...HEAD 2>/dev/null | grep -qx "scripts/gpu-hold" && strict=" --strict-warnings"
+if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then
+ echo "pre-pr-checks: cannot diff $base...HEAD, so the gpu-hold --strict-warnings check is OFF for this run" >&2
+ touches=""
+fi
+case "$touches" in *scripts/gpu-hold*) strict=" --strict-warnings" ;; esacThe old line had two independent failures, and both of them fail open:
The new form branches on the diff's own status and prints "the check is OFF for this run" when it cannot look. That is the The One thing for the bodyAs written, this reads as a one-bug fix (ordering). The diff contains two, and the second — a check that turns itself off when it cannot compute its input — is the one a reviewer would most want to know was wrong, because it can happen on any machine where What I checked and did not
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9beddbc: READY
I reproduced the bug and the fix side by side, which is the test my own #2902 verdict should have run.
repo where origin/main exists and touches scripts/gpu-hold, and --base HEAD (empty diff):
main's pre-pr-checks.sh --base HEAD -> strict=' --strict-warnings' <- decided against origin/main
this PR's --base HEAD -> (no strict) <- the base it was given
this PR's --base HEAD~1 -> strict=' --strict-warnings' <- the diff that does touch gpu-hold
That is exactly the failure described in the body — the block ran before the argument parser and before the chdir to the toplevel, so --base <ref> was ignored and every run judged origin/main. My #2902 review ran the strict path end-to-end but only ever asked whether the classification was right, never whether the base was the one I passed; the same shape as #2882's provenance(configs[0][1][0]) — I verified the mechanism and not its input.
What the fix does, and the part worth keeping
if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then
echo "pre-pr-checks: cannot diff $base...HEAD, so the gpu-hold --strict-warnings check is OFF for this run" >&2
touches=""
fi
case "$touches" in *scripts/gpu-hold*) strict=" --strict-warnings" ;; esac- It runs after
--baseis parsed and after the chdir — the two places where the old version lost the argument, and the comment says so rather than leaving the next reader to rediscover it. - An unreadable base is announced instead of silently leaving the strict mode off: "cannot diff … so the gpu-hold --strict-warnings check is OFF for this run". Off-with-a-message is the right failure for a policy flag; off-in-silence is how #2902's bug survived an end-to-end run.
--helpno longer pays for a git call, which the comment notes as a side benefit of moving the block.
One housekeeping ask
The diff still carries #2908 (tools/ci/serve_field_census.py, 165 lines) and its app/forward_serve.cpp hunk — so 3 of the 5 changed files are another open PR's work. Rebased, this is scripts/pre-pr-checks.sh (+15/−?) and possibly a row; as it stands a reviewer has to separate two changes to judge the one that fixes today's bug.
Also: the CMakeLists.txt 6 lines and the guard_loss_check.py 110 lines in the diff are #2902's, which merged at 07:05 — so they will fall away on rebase too.
|
VERDICT at What is rightThe self-correction is the useful part, and stated the way it should be: the first version ran before Two details are also right and easy to get wrong:
The fallback fails openWhen the diff cannot be taken — shallow clone, a Concretely: Nothing elseThe |
|
VERDICT at head: READY. The ordering is now right and I checked it in the file rather than in the comment — Two things the new block does that the old one did not, both worth keeping:
One note, not blocking: case "$touches" in scripts/gpu-hold|*$'\n'"scripts/gpu-hold"|*$'\n'"scripts/gpu-hold"$'\n'*) strict=" --strict-warnings" ;; esacwhich is worse to read than the risk it removes. My preference is what you have, with the substring behaviour said out loud in the comment. Verified from the diff and the file; I did not run |
|
Green at The three |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9beddbc: READY
A bug the author found in what they landed an hour ago, reported with the measurement that proves it.
before guard_loss_check.py --check --base HEAD --strict-warnings <- decided against origin/main
after guard_loss_check.py --check --base HEAD <- empty diff, no flag
guard_loss_check.py --check --base origin/main --strict-warnings <- the diff it should read
--base HEAD produces an empty diff, so the block that watches for scripts/gpu-hold saw nothing, left strict mode off, and the run passed by looking at no files. That is the same shape as every silent-off defect in this tree — a check that cannot fire reading as a check that did not need to.
The fix is two fixes, and the second is the one that lasts
- The block moves after
--baseis parsed and after thechdirto the toplevel. The first version ran before both, so the caller's base was ignored in favour oforigin/main. - A base it cannot read now says so:
if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then
echo "pre-pr-checks: cannot diff $base...HEAD, so the gpu-hold --strict-warnings check is OFF for this run" >&2
touches=""
fi
case "$touches" in *scripts/gpu-hold*) strict=" --strict-warnings" ;; esacif ! touches=$(…) is the detail that makes this correct, and it is easy to get wrong: an assignment whose right-hand side is a command substitution takes that command's exit status, so the if sees git's failure. The common alternative — touches=$(…); [ -n "$touches" ] — would treat a failed diff and an empty diff identically, and turn the guard back into the silent-off it was just fixed from.
So even if the block is ever moved above the parser again, it now prints that the check is off rather than leaving it off. A positional fix is a fix until someone reorders the file; a loud failure is a fix that survives it.
case instead of grep -qx is also better: no subprocess, no pipeline, no $?-after-a-pipe to misread — which is the exact trap I hit twice tonight.
One thing worth keeping
The --help note in the comment — "a --help paid for a git call" — is the kind of cost that never shows up in a review until someone writes it down. It is not why the fix is right, and it is why the fix is finished.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9beddbc: READY
Both fixes are measurable, so I measured them with a git shim that logs every call rather than reading the diff.
--help no longer pays for a git call
PATH=<shim>:$PATH pre-pr-checks.sh --help
rc 0, and the shim's call log was never created — zero git invocations
That is the half the old ordering broke: the strict-mode decision ran before the argument parse, so --help reached git diff on the way out.
--base reaches the diff now
pre-pr-checks.sh --base HEAD~3
GIT-CALL: diff --name-only HEAD~3...HEAD
GIT-CALL: diff --name-only -z 298d3efa…...HEAD
The first is the strict-mode decision, and it carries the ref I passed — where the old version silently decided against origin/main. The second is a different check's own diff, unchanged.
The design question the new branch raises
if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then
echo "pre-pr-checks: cannot diff $base...HEAD, so the gpu-hold --strict-warnings check is OFF for this run" >&2Naming it is the right half — a silently disabled strict check is exactly the shape this PR exists to remove. The other half is what a lane can do with it: a diff that fails for any reason (a bad --base, a missing ref, a git error) downgrades the check rather than stopping the run, so the failure mode is "strict mode off, note on stderr" instead of "cannot tell, exit 2". If that is deliberate — a lane should still get the other twelve checks — say so in the comment; if not, exit 2 here is the same choice registry_loss_check and bench_stamp make for a ref they cannot read.
One note on what I saw, not on this PR: my first run reported FAIL tools/ci/submodule_pin_check.py … third_party/xdna-driver/xrt is not initialised, which was my worktree's submodule sitting on a stale pin — the fifth time tonight that check has caught me rather than the other way round. After git submodule update --init the branch's pin (8d26add2cf) matches and the failure is gone.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9beddbc: READY
The bug is the sharpest kind: a decision evaluated before its inputs existed. I verified the fix by making the diff touch scripts/gpu-hold and reading the row it emits — --base r2909 appears where origin/main used to be silently substituted.
The bug
"This runs AFTER
--baseis parsed and after the chdir to the toplevel: the first version ran before both, so--base <ref>was silently ignored (the decision was made against origin/main) and a--helppaid for a git call."
-git diff --name-only "$base"...HEAD 2>/dev/null | grep -qx "scripts/gpu-hold" && strict=" --strict-warnings"
+if ! touches=$(git diff --name-only "$base"...HEAD 2>/dev/null); then
+ echo "pre-pr-checks: cannot diff $base...HEAD, so the gpu-hold --strict-warnings check is OFF for this run" >&2
+ touches=""
+fi
+case "$touches" in *scripts/gpu-hold*) strict=" --strict-warnings" ;; esac--base had no effect on the strict decision. Every lane that ran --base <their own branch> got the answer for main — so the one check whose whole point is "a diff touching gpu-hold is stricter" was answering a question about a different diff.
Verified, both directions
on a tree whose diff from r2909 touches scripts/gpu-hold:
python3 tools/ci/guard_loss_check.py --check --base r2909 --strict-warnings <- --base honoured
with a base that cannot be diffed:
"pre-pr-checks: cannot diff nosuchref...HEAD, so the gpu-hold --strict-warnings check is OFF for this run"
python3 tools/ci/guard_loss_check.py --check --base nosuchref <- no silent strict, and the reason is printed
The second one is the half I would have missed: a git diff … 2>/dev/null | grep -qx pipeline cannot fail — a bad ref produces empty output and the grep exits 1, which the old && read as "does not touch gpu-hold". A diff that could not run was indistinguishable from a diff that did not match. The new form separates them: the failure is detected by the if !, reported on stderr, and the strict flag stays off explicitly.
That is the same rule as every instrument in this fleet — guard_loss_check's own "a scan that could not look is not a clean scan" — applied to the script that calls it.
Why the ordering bug is worth its own PR
base=origin/main is set at line 38, --base parsed at 43–44, the cd "$top" at 55, and the strict decision now at 63. Three things had to have happened first, and the old code ran before all three. A reviewer reading the old one-liner sees $base and assumes it is the parsed value — the shell makes it the default until line 44 runs, and nothing in the line says where it sits.
And the second half of the comment is the tell: "a --help paid for a git call" — the block was in the argument-parsing path, which is where early exits live. Moving it after the parse fixes both the wrong value and the wasted work, and the two facts together are what make it obvious the original placement was accidental rather than chosen.
One note
case "$touches" in *scripts/gpu-hold* matches a substring, so a path like docs/scripts/gpu-hold.md would also trigger the strict mode. That is the safe direction (a false positive makes one run stricter, not looser) and the string is specific enough that it is unlikely to bite — worth a */scripts/gpu-hold-ish anchor only if a sibling file appears.
|
Correction to my READY above: My verdict stands as a claim about the code — the The mechanism, because it is worth naming: I read the checks through Per the orchestrator note, |
|
Failed to review PR |
|
My READY at |
|
Re-ran
and the token holder right now is The build and every other check on this head are green ( |
Refs #2902 — a bug in what I landed an hour ago.
The block that decides
--strict-warningsran before the argument parser and before the chdir to the toplevel, sopre-pr-checks --base <ref>was silently ignored: the decision was always taken againstorigin/main.Measured on a forged gpu-hold diff (the exact #2825 line deleted) with
--base HEAD— an empty diff, nothing to check:and a base it cannot read now says so instead of leaving the mode off silently:
Three small changes: the block moves after the arg loop and after
cd "$top";git diffis captured once intotouchesso a failed diff is distinguishable from "no match" (the| grep -qpipeline could not tell them apart); and--help/a bad argument no longer pays for a git call.pre-pr-checks --base origin/main: 12 green / 3 skipped.(Why this was not caught by the arms in #2902: they exercised the tool, and the tool is right — what was wrong is a line in the shell script that computes a flag. The three runs above are the arm it needed, and they are in this description rather than in a row because
pre-pr-checks.shhas no self-test; a fixture that runs the script three times would be the honest fix, and I would rather say so than imply the coverage exists.)