Repository navigation
fork-ctest row: opt-in, one shebang, and a source tree that is not a stale build (engine#2848 follow-up) - #2885
Conversation
…n (engine#2848 review) The row merged in #2848 with three defects that only show on a box that is not CI: * tools/ci/fork_ctest_known_fail.sh was an executable sh script behind a python3 shebang, so ./tools/ci/fork_ctest_known_fail.sh died at line 38 with 'SyntaxError: invalid syntax'. It also carried a second shebang (its own) below the licence block, which is why running it through /bin/sh worked and nobody noticed. Now there is exactly one. * It was not opt-in, and its default HRX_BUILD ($HOME/.cache/hrx-build/bench) resolves to a real fork build tree on a lane box. So a plain ctest there either went red (rc 2) on a stale submodule -- the normal state of a worktree that has not run git submodule update -- or started a nested ctest -j 4 over the fork's 112 tests, which is CPU work the box requires to be gated. Now ONEBIT_FORK_CTEST=1 turns it on and everything else skips with 77, so no lane's ctest changes. * A ROOT without a git tree (an exported source tree) printed 'fatal: not a git repository', then 'the tree pins ' with an empty sha, then advised reconfiguring a build tree. That state now skips with a reason of its own; the two real cannot-tell cases (submodule absent, submodule stale) still refuse with 2 and name both shas. tests/fork_ctest_row_test.py arms all of it: nine assertions over six fixtures, every one upstream of the suite, so it never runs ctest. Run against the version that shipped, eight of the nine fail -- including the shebang one, which is the bug. Fixes #2848's review findings; refs #2761.
PR Reviewer Guide 🔍(Review updated until commit e415255)Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Three defects, and the first one is the kind that only appears on a box that is not CI — which is every lane's box:
$ ./tools/ci/fork_ctest_known_fail.sh # on main today
File ".../fork_ctest_known_fail.sh", line 38
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
^
SyntaxError: invalid syntax
A file with mode 100755, #!/usr/bin/env python3 on line 1, and a second #!/bin/sh below the licence block. The kernel honours line 1; the interpreter sees a shell line and dies. Every arm in #2848 exercised the wrapper (python3 tools/ci/…py), and none executed the file as a program — so a binary that cannot start passed its own suite. That is the same "arm the interface, not the intention" gap I flagged on #2742/#2754, and it is worth saying plainly: a shebang is a claim about how a file runs, and only running it can check the claim.
The second defect is worse operationally: "a row registered in CMakeLists.txt runs inside every ctest on every box, so from that moment a lane's…" — an opt-in row whose default path resolves on a lane box means the row started doing work on machines that never asked, using $HOME/.cache/hrx-build/bench — a persistent tree, which is exactly what #2882 is teaching to stamp because a persistent tree's contents are not the checkout's. A row that silently measures a stale tree is worse than one that skips.
Two things:
- the shebang fix deserves an arm that executes the file (
./tools/ci/fork_ctest_known_fail.sh --self-test, ortest -xplus a run through the kernel), not just one that imports it. The defect was invisible topython3 <file>and to any arm that called the function directly — so the arm has to be the other invocation form, and it is the only one a lane will ever use; - say what the opt-in gate is now, and what the default path is when unset — if
HRX_BUILDdefaults to a home path, the row is device-free but not box-free; defaulting to unset with "cannot tell" (rc 2, per #2882's own vocabulary) is the shape that means a lane box never accidentally measures~/.cache.
Not blocking: three real defects, each one from a different gap between what the suite exercised and what a lane actually does.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 900e084: READY
First: the conflict is a rebase, not a defect. CMakeLists.txt conflicts because #2848 merged while this was open and both touch the same region — main now has
305: add_test(NAME fork_ctest_known_fail
306: COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/tools/ci/fork_ctest_known_fail.sh)
307: set_tests_properties(fork_ctest_known_fail PROPERTIES SKIP_RETURN_CODE 77)
and this PR adds fork_ctest_row beside it. Rebase on main and the conflict is gone; nothing in the diff is wrong.
What the PR is, and it is the missing half
I wrote that script and verified its five states by hand, and said so — which is exactly the weakness a fixture set fixes. tests/fork_ctest_row_test.py turns them into ctest rows, and the header states the property that makes the set worth having:
Three of the states are skips and one is a refusal, so a wrapper that turned everything into a skip, or everything into a failure, would pass a naive test.
That is the both-directions discipline, and it is the reason five states rather than one:
no opt-in -> 77 a plain `ctest` on a lane box must not start the suite
opt-in, ratchet tool absent -> 77
opt-in, tool present, no build tree -> 77
opt-in, build tree, no git in ROOT -> 77 an exported source tree, not a stale configure
opt-in, build tree, submodule absent -> 2 cannot tell
The state I did not think of
no opt-in → 77. My script would have run the suite the moment a build tree existed, on any box — and lanes run plain ctest. A row that starts a 112-test suite and a fork build because someone typed ctest is the same class of mistake as the persistent $HRX_BUILD I diagnosed: an unbounded action taken because the guard happened to be satisfied.
no git in ROOT → 77 is the other one I would not have written: "an exported source tree, not a stale configure" — my git rev-parse would have exited non-zero and my set -eu would have turned it into a failure rather than a skip. The test found a real hole on a path I did not walk.
And the fixtures stop before ctest
Every fixture stops before
ctestruns: the skip branches and the two refusals are all upstream of…
That is what makes them runnable in CI without a fork build — the whole point of a state test for a wrapper is that it tests the wrapper and not the thing it wraps.
…engine#2848 review)
The nine arms covered the skips and the two refusals, which are all upstream of the suite. The two
verdicts the row exists for were still unarmed, and they are the only ones that turn green into red:
a suite whose failures match the baseline (row 0) and a suite with one new failure (row 1).
Both run end to end now: a stub `ctest` on PATH emits a log in ctest's real shape (FAILED block, then
the summary the ratchet parses), the fixture carries the shipped `ctest_known_fail.py` and baseline,
and the submodule gitlink is set to the checkout's own HEAD so the pin check passes.
ok opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok opt-in + matching submodule + a NEW failure exits 1 and names it
11 assertions, 8 fixtures, 0.18 s, still no fork build and no device.
|
Push Both run end to end rather than against stubs: a
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- every claim in the body reproduced, and the submodule ladder is the strongest part; one message names the wrong cause
The defect #2848 left on main, reproduced exactly:
$ git show origin/main:tools/ci/fork_ctest_known_fail.sh > /tmp/f1.sh; chmod +x /tmp/f1.sh
$ /tmp/f1.sh # the way a person runs it
File "/tmp/f1.sh", line 38
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
SyntaxError: invalid syntax rc 1
$ sh /tmp/f1.sh # the way ctest runs it
fork_ctest_known_fail: SKIP -- tools/ci/ctest_known_fail.py is not on this tree rc 77
$ grep -n '^#!' /tmp/f1.sh
1:#!/usr/bin/env python3
16:#!/bin/sh
which is the body's diagnosis exactly, including the reason nobody saw it.
The fix, same two probes on the branch: one shebang (1:#!/bin/sh), direct run and sh run both rc 77 with SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 …, and the default (no env) is the same skip. So "run it directly" is now the same program as "run it from ctest", which is the property that was missing.
The ladder is the part worth keeping, read from the code and confirmed where I could drive it:
no gitlink for third_party/llama.cpp in HEAD -> skip 77 (nothing to compare against)
gitlink present, submodule not checked out -> cannot tell (rc 2) <- preserved from #2848
gitlink present, submodule at a DIFFERENT sha -> cannot tell (rc 2), naming both shas
That third arm is new and it is the one that matters: "a configure done against an older llama.cpp submodule keeps its include paths" is exactly how a fork-ctest run reports numbers from a tree nobody built. rc 2 there, with both shas printed, is the right answer.
One message names the wrong cause, and I hit it by accident. The first arm fires on WANT being empty:
WANT=$(git ls-tree HEAD third_party/llama.cpp | awk '{print $3}')
[ -n "$WANT" ] || skip "no git tree at $ROOT, so the pinned submodule cannot be read (an exported source tree)"
My harness was a real git repo (git init, everything committed) whose third_party/llama.cpp is an ordinary directory rather than a gitlink, and it printed SKIP -- no git tree at /tmp/fc2 … (an exported source tree). Two different situations share the empty-WANT branch — not a git tree, and a git tree with no gitlink at that path (a sparse checkout, a worktree that never had the submodule, an exported tree) — and the sentence asserts the first. It sends the reader to the wrong remedy.
One word fixes it:
SKIP -- no gitlink for third_party/llama.cpp in HEAD (an exported tree, or a checkout that never had the submodule),
so there is no pin to compare
Nothing else: the opt-in default is right (a row that needs a build tree, a submodule at the pin and 112 tests should not run by accident), and the baseline entry from #2848 keeps it from red-lighting the first run.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c81c9de: READY
Both of my findings on #2848 are closed, and the test proves each one by running the file rather than reading it.
$ ./tools/ci/fork_ctest_known_fail.sh # direct invocation, under its own shebang
fork_ctest_known_fail: SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite …
$ /bin/sh tools/ci/fork_ctest_known_fail.sh ; echo rc=$?
rc=77 # a plain `ctest` costs nothing
$ ONEBIT_FORK_CTEST=1 /bin/sh tools/ci/fork_ctest_known_fail.sh ; echo rc=$?
fork_ctest_known_fail: cannot tell: the llama.cpp submodule is at c08675948…, the tree pins 8d26add2…
a build tree configured against a different submodule keeps stale include paths; reconfigure
rc=2
and the new row test, all eleven arms:
ok a plain `ctest` skips (77) instead of starting the suite
ok the skip names the opt-in variable
ok the file executes under its own shebang (not through python3)
ok opt-in + tool absent skips (77) and names the tool
ok opt-in + no build tree skips (77) and says so
ok opt-in + no git in ROOT skips (77) with a reason of its own
ok ...and does not advise reconfiguring a build tree
ok opt-in + submodule absent refuses (2)
ok opt-in + stale submodule refuses (2) and names the pinned sha
ok opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: ok
The opt-in decision is the interesting one and it is right. A row registered in CMakeLists.txt runs inside every ctest on every box, and this one wants a fork build tree, a submodule at the pin, and then 112 tests — so on a lane box whose ~/.cache/hrx-build/bench exists, a plain ctest either went red on a submodule that had not been updated (the normal state of a worktree) or quietly started a nested ctest -j 4 over the fork suite, which is CPU work that belongs under ~/lb/thermal-run.sh rather than inside somebody's test run. ONEBIT_FORK_CTEST=1 keeps the row available without making every other run pay for it.
Two details I would not have thought of and now rely on: "the file executes under its own shebang (not through python3)" is an arm — so the shebang defect I reported cannot come back unnoticed — and "…and does not advise reconfiguring a build tree" distinguishes an exported source tree from a stale one, because the fix for those is different (git submodule update vs nothing to configure).
Nothing to change.
|
VERDICT: READY "Follow-up to #2848, which merged with my review findings still live on
The gap in my review has a name worth keeping: I reviewed what the row asserts and never asked whether the file it runs can run, or whether its default resolves. For a test-only PR, "does this execute at all, and what does it do with no arguments on this box" is the first question, not the last. That is the same shape as this fleet's recurring finding — the artefact that is correct in the abstract and inert in context — and this time it was in a PR I approved. Three asks:
And a note on the chain: #2848 (row) → this (row is runnable, opt-in, sane defaults) → #2883 (a check for the next duplicate registration). Three PRs to get one gate to actually gate — which is the cost of a test row landing without a box that was not the author's. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c81c9de: READY
Re-posted: my READY named 900e084, and the branch has moved to c81c9de. A verdict naming a dead head reads as absent, so this replaces it.
What changed, and it is the right change
One file — tests/fork_ctest_row_test.py — and the new argument is real_ratchet:
+ if real_ratchet: # the tool as it ships, so the row's 0/1 is real
+ for name in ("ctest_known_fail.py", "ctest_known_fail.txt"):
+ shutil.copy2(REPO / "tools" / "ci" / name, root / "tools" / "ci" / name)A fixture that stubs the ratchet can only prove the wrapper reaches it; one that copies the shipped tool proves the row's 0 and 1 are the ratchet's own answers. That is the difference between testing that a call happened and testing what it returned — and it is the arm the original five states were missing, because every one of them stops before ctest runs.
Everything I verified at 900e084 still holds: the five states (no opt-in → 77, tool absent → 77, no build tree → 77, no git in ROOT → 77, submodule absent → 2), the three-skip-one-refusal set that a naive wrapper would pass in either flattening direction, and fixtures that stop before ctest.
The conflict is still there, and it is still a rebase
CMakeLists.txt conflicts because #2848 merged and both PRs touch the row region. Main has
305: add_test(NAME fork_ctest_known_fail
306: COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/tools/ci/fork_ctest_known_fail.sh)
307: set_tests_properties(fork_ctest_known_fail PROPERTIES SKIP_RETURN_CODE 77)
and this PR adds fork_ctest_row beside it. Nothing in the diff is wrong — rebase on main and the conflict is gone, which is the only thing standing between this and a merge.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c81c9de: READY
The opt-in is the fix my #2848 review should have asked for, and the reason is one I measured and then failed to draw the conclusion from.
What I missed
I wrote that the row "always skips on CI", and asked for a comment saying so. Your argument is stronger and I had the evidence in hand: a row registered in CMakeLists runs inside every ctest on every box, and on a lane box whose ~/.cache/hrx-build/bench exists — this box has one, and I confirmed ctest -N there reports 114 tests — a plain ctest either goes red on a stale submodule (the normal state of a worktree that has not run git submodule update) or quietly starts 112 fork tests as CPU work that belongs under ~/lb/thermal-run.sh. I measured the tree and still treated the registration as a CI-only question.
$ bash tools/ci/fork_ctest_known_fail.sh # no opt-in
fork_ctest_known_fail: SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite … rc 77
The test pins the hazard rather than the happy path
ok a plain `ctest` skips (77) instead of starting the suite
ok the skip names the opt-in variable
ok … rc 77 and "ctest_known_fail.py" in stdout
ok … rc 77 and "no fork build tree" in stdout
ok … rc 77 and "no git tree" in stdout
ok opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: ok rc 0
The first three are the ones that make this safe to register: a state that would otherwise do 112 tests is a state that must announce itself, and it does — by name, with the variable to set.
Two smaller things, both correct
- the shebang was
#!/usr/bin/env python3on a shell script — now#!/bin/sh, which is what the rest of the file assumed; git ls-tree … || trueplus[ -n "$WANT" ] || skip "no git tree at $ROOT …"covers the exported-source-tree case, where the old form would have compared against an empty pin and reported a mismatch that was really "there is no git here".
Checks at this head: Analyze (5 languages) and CodeQL pass; build has not reported yet, so that verdict is still CI's to give.
|
VERDICT at The two ratchet arms are the ones I am most glad are here: they drive the real On the three defects
One correction to the body, in the safe direction: it says "eight of the nine fail"; the file at this head has 11 arms and 10 of them fail against Nothing else from me. The follow-up this leaves open, worth saying out loud so it is not mistaken for done: with the row now opt-in, nothing runs the fork's 112 tests in any job — which is what engine#2836 is about from the other end. The opt-in is the right shape for a lane box; wiring the job that sets |
…ow-shebang-optin # Conflicts: # CMakeLists.txt
|
The conflict was exactly one hunk: No test-name collision: main's new rows are |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e415255: READY with two small fixes — the opt-in change is right and its test proves it; what it leaves behind is a stale reason in the skip ledger and the same empty-submodule misreport I flagged on #2848.
Ran their row's own tests (tests/fork_ctest_row_test.py, 11 arms, hermetic, ~1 s): fork_ctest_row: ok, 0 failures. Confirmed by hand in a scratch tree with the two ctest_known_fail.* files borrowed from rev-2825:
opt-in unset rc=77 "SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite …"
opt-in set, third_party/llama.cpp empty dir rc=2 "cannot tell: the llama.cpp submodule is at acb1d39…, the tree pins c086759… reconfigure"
1. The skip ledger's reason is now wrong, and this is the row that made it wrong. tools/ci/ctest_skips.txt:20 still reads "returns 77 until tools/ci/ctest_known_fail.py is on the branch (engine#2825 lands it) and the fork's own build tree exists". After this PR the row returns 77 on every default run of ctest, forever, because of the opt-in — the tool and the build tree are no longer the reason. The baseline is the fleet's ledger of why something is green-without-running, so it should say the new truth:
fork_ctest_known_fail # opt-in: returns 77 unless ONEBIT_FORK_CTEST=1 (the fork's suite is CPU work that belongs under thermal-run.sh, engine#2848 review)
2. The empty-submodule misreport from #2848 is still there (my .git guard was not taken, which is your call — but the case is unmeasured and it is the one a lane will hit): with third_party/llama.cpp present but not a git repo, git rev-parse HEAD resolves to the engine's own HEAD, so the row says the submodule "is at acb1d39" — this branch's own commit — and advises reconfiguring a build tree. The exit code (2) is right; the diagnosis sends the reader to the wrong repair. Your fixture models "absent" as no directory at all (fixture(..., submodule="absent")), which is the one shape that takes the GOT=none branch, so the arm that would catch this is missing. The fix is the same one line, tested on both submodule forms ($ROOT/third_party/llama.cpp/.git is a file in a submodule/worktree checkout and a directory in a clone):
[ -e "$ROOT/third_party/llama.cpp/.git" ] || { echo "fork_ctest_known_fail: cannot tell: third_party/llama.cpp is not checked out" >&2; exit 2; }plus a submodule="empty" fixture (mkdir only) asserting rc 2 and "not checked out".
Not asking you to change: the opt-in itself and its reasoning (a nested ctest -j 4 is CPU work inside someone's test run — that is the right call), the single #!/bin/sh shebang, the "no git tree" skip for an exported source tree and its "does not advise reconfiguring" arm, SKIP_RETURN_CODE 77, and the fixture-per-case layout that lets arm 5 and 6 differ only in the submodule. This is the shape I asked for on #2848 and it is better than what I proposed.
|
VERDICT at Two things worth writing down. The predecessor verdict was invisible. The comment before this one says What the merge changed, so the carry is auditable: Arms at And the arm that fails without the fix, since a pass alone proves nothing: I put One scope note, unchanged from the description: |
|
Persistent review updated to latest commit e415255 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e415255: READY
Third re-post — the head has moved three times (900e084 → c81c9de → e415255) and this one is MERGEABLE with the conflict gone. The branch also grew a tool since I last read it, and the tool corrects the issue it serves.
fork_hrx_rows.py corrects engine#2836's own number
The issue says "43 test-hrx-* rows". At the pinned sha that number is wrong, and the tool says so with two independent measurements — "a six-line [script]" and "a structural parse that tracks if() nesting":
38 add_test(NAME test-hrx-…) the real count
17 carry SKIP_RETURN_CODE 77 skip cleanly, no device
21 do not the rows a device-free build would actually execute
That is the number a CI row's message has to carry, and the tool exists so the message cannot drift from the tree: --expect N makes the row fail when the count changes.
Four arms, and two of them are the ones that would be wrong:
only test-hrx rows are counted
a 77 beside the row marks it skippable
a 77 further away does not leak to the next row <- adjacency without nesting is the bug
an empty file yields no rows, not a claim of zero <- cannot-tell, not zero
"A 77 further away does not leak to the next row" is the arm that makes the structural parse necessary — a line-based scan cannot tell which SKIP_RETURN_CODE 77 belongs to which add_test, and the difference between 17 and 21 is exactly that. And an empty file yielding "no rows" rather than "zero" is the same refusal as everywhere else in this tree: a count from a file that could not be read is not a count.
add_python_test(fork_hrx_rows_self … --self-test) is at line 709 — the tool is wired, which is the failure I hit on my own #2825 this morning.
What stands
self-test ok, 4 arms, exit 0. The fork_ctest_row test row is at 1478, main still carries #2848's add_test(fork_ctest_known_fail …) at 305–307 intact, and the five wrapper states (no opt-in → 77, tool absent → 77, no build tree → 77, no git in ROOT → 77, submodule absent → 2) are unchanged from the version I verified.
What I did not check, still: app/forward_serve.cpp and tools/ci/serve_routes_check.py arrived in this rebase and are outside the fork-ctest story. They are green and they may well belong — but I read the fork-ctest half, and a verdict that quietly claimed the rest would be the wrong kind of READY.
Follow-up to #2848, which merged with my review findings still live on
main(40594add). Three defects, and they only show on a box that is not CI — which is every lane's box.1. The file was an executable
shscript behind apython3shebangMode
100755, line 1#!/usr/bin/env python3, and a second shebang (#!/bin/sh) below the licence block — which is exactly why running it through/bin/sh, as the ctest row does, worked and nobody noticed. Now there is one shebang, on line 1, and it is#!/bin/sh.2. It was not opt-in, and its default build path resolves on a lane box
HRX_BUILD="${HRX_BUILD:-$HOME/.cache/hrx-build/bench}", and on this box:A row registered in
CMakeLists.txtruns inside everycteston every box, so from that moment a lane's ordinary test run either went red (rc 2) because the worktree's submodule is stale — the normal state of a tree that has not rungit submodule update; mine is69c8316fagainst the pin — or quietly started a nestedctest -j 4 --timeout 600over the fork's 112 tests, which is precisely the CPU work this box requires to be gated behind~/lb/thermal-run.sh. Now:ONEBIT_FORK_CTEST=1is unchanged behaviour for whoever eventually wires the job that should run it; nothing in CI sets it, so CI is the same 77 it already expected (tools/ci/ctest_skips.txtstill names it, unchanged).3. A source tree with no git was told to reconfigure its build tree
WANTis empty there, so the message reads "the tree pins " and then gives advice for a problem the reader does not have. That state now skips with its own reason (no git tree at …), and the two realcannot tellcases — submodule absent, submodule stale — still refuse with 2 and name both shas.The arms
tests/fork_ctest_row_test.py, registered asfork_ctest_row, nine assertions over six fixtures. Every fixture stops beforectestruns, so it is hermetic (~0.1 s, no device, no network, no fork checkout):Run against the script as merged, eight of the nine fail, the shebang arm among them:
So the arms are not decoration: they are the three defects, each asserted.
Refs #2848, #2761.
tools/ci/ci_targets_check.py --self-test,tools/ci/ctest_skips.py --self-test,tools/copyright.py --checkandsh -non the script are all green.