Repository navigation
ci: catch a ctest row NAME the base already registers, before Configure does (engine#3223) - #3226
Conversation
…re does engine#3223. `CMakeLists.txt` is where every lane appends its registration row, so a merged row's NAME is a namespace nobody reserves. Two lanes fixing one hole from two directions each add the same row; the branch rebased second dies in Configure with `add_test given test NAME "X" which already exists in this directory` on a change that is correct. Measured twice on 2026-11-21 -- engine#3220 vs `registry_build_self` merged at 17:06:10 (#3217), with engine#3219 carrying the same hunk and staying green on an older base. Nothing caught it: `pr_branch_stale_check` measures deletions (a branch adding a row deletes nothing), `duplicate_fixes_check` groups by issue (the pair was two different issues), and CMake complains only at Configure, after a push, on one side -- costing the single build queue and a diagnosis cycle. So `tools/ci/ctest_row_name_check.py`: intersect the row names a branch ADDS (`git diff <base>...HEAD` over `add_test(NAME X` and the repo's `add_python_test(X` wrapper) with the names present in `<base>:CMakeLists.txt` -- the base TIP, where the duplicate appears. Rebased, the diff stops adding the row and the check goes quiet, which is the fix. Narrow on purpose: CMakeLists.txt only, and a name computed from a variable is not guessed at. Live reproduction of the real shape, on a branch cut before #3217 merged: $ python3 tools/ci/ctest_row_name_check.py --check --base origin/main ctest_row_names: 1 ctest row name(s) this branch ADDS are already registered at origin/main: ctest_row_names: registry_build_self ctest_row_names: this branch: add_python_test(registry_build_self … --self-test) ctest_row_names: origin/main: add_python_test(registry_build_self … --self-test) ctest_row_names: rebase onto the base: the duplicate row disappears from the diff and the name is registered once rc=1 $ …on this branch, which adds no ctest row rc=0 Exit 2 rather than 0 when the clone is shallow (a depth-N clone cannot compute `base...HEAD`; engine#3106's cannot-tell rule) or the base cannot be read. Seven self-test arms, hermetic: the re-added name, the cross-wrapper case (`add_test(NAME X` in the base vs `add_python_test(X` in the branch -- one namespace), a fresh name, a variable-computed name (not guessed at), an unresolvable base (2), and a real `git clone --depth 1` (2). **One of those arms caught a bug in the fixture itself**: the first version committed onto `main` instead of a branch, so `main..HEAD` was empty and three arms passed vacuously -- fixed by branching in the fixture, and recorded because an arm that cannot see a diff is an arm that proves nothing. Wired: a pre-PR row beside the other `--base` rows, the `docs/pre-pr-checks.md` line in the runner's order (the page-vs-runner check refused my first placement -- it had gone in above the table), the row-count literals 19/17 -> 20/18, and a ctest row for this tool's own arms, because `tool_selftest_wired_check` -- tightened an hour ago in #3219 -- flagged it on my first run. The rule working on the lane that wrote it.
|
VERDICT at f4d64d1 ( 1. BLOCKER — the tool has a
|
| shape | want | #3226 | #3224 |
|---|---|---|---|
a row's arguments edited in place (--self-test → --check --self-test) |
0 | 1 | 1 |
a base row relocated into if(Python3_Interpreter_FOUND) |
0 | 1 | 1 |
| a genuine duplicate added beside the base's row | 1 | 1 | 1 |
| a genuinely new name | 0 | 0 | 0 |
base registers the name in cmake/tests-gpu-hold.cmake, branch adds it in root CMakeLists.txt |
1 | 0 | 0 |
branch adds its row in cmake/tests-*.cmake, name the base has in root CMakeLists.txt |
1 | 0 | 0 |
taken = row_names("\n".join(added)) drops the other half of the diff; a --unified=0 diff of a modified row is a - and a + of the same name, so the row reports "the branch ADDED a name the base has" when the merge registers it once. Your own remedy text is the right one ("rebase: the duplicate row disappears") and it is not what happens here — a rebase does not remove an edited row, so the row stays red until the lane deletes or renames a change that is correct.
Fix, one line: collect the - lines too and compare row_names(added) - row_names(removed). Verified on all six shapes above, and on the three you already have (duplicate → 1, fresh → 0, shallow → 2 unchanged).
3. BLOCKER — scope: root CMakeLists.txt only, but 42 rows register from cmake/tests-*.cmake in the same directory namespace
CMakeLists.txt:3230-3254 (engine#1979) globs and include()s every cmake/tests-*.cmake, and CONTRIBUTING.md:103 sends a lane's row to that family's file. Includes run in the including directory, so the names are one namespace — measured in a scratch cmake project:
CMake Error at inc.cmake:1 (add_test):
add_test given test NAME "dup_row" which already exists in this directory.
The two rows above that read 0 are that failure: root-defines-then-family-registers configures fine and the tool says clean (I ran cmake -S . -B b on the same tree: add_test given test NAME "hold_row" which already exists in this directory, rc 1), and a row added in the family file contributes no added lines at all because the diff is path-filtered to CMakeLists.txt. 20 of those names are in tests-gpu-hold.cmake.
Fix: take the file set from the base instead of fixing it — root CMakeLists.txt plus the same glob (file(GLOB … cmake/tests-*.cmake) is the engine#1979 list), and read/compare that list on both sides. Three extra git show calls, ~60 ms.
What is right, and it is why I would keep this PR over #3224
- Six arms that go through
check()on real scratch repos — collide, cross-spelling, fresh, variable name, unresolvable base, shallow clone — including the note that three of them passed vacuously until the fixture used a branch instead of commits onmain. That is the class of arm ci: a row this branch adds must not be named in the base already (engine#3223) #3224 does not have (its five callnames_in()and nevercheck()), and it is the reason items 2 and 3 above are fixable here in one line each rather than needing a rewrite. - The explicit shallow-clone refusal (
rev-parse --is-shallow-repository→ 2) is stronger than relying onmerge-baseto fail, and it is the engine#3106 rule applied the right way round. add_python_test(Xvsadd_test(NAME X)in one namespace with an arm — the trap that makes the wrapper's rows collide with plain ones.- The remedy text names both lines (
this branch:/base:) and says rebase, which is the correct fix.
Tie-break, said out loud
Behaviour is identical on all six shapes, so the pair is a wiring-and-arms trade, and this PR has the arms. Keep #3226, take #3224's wiring (pre-PR row + --check ctest row + the docs line + its derived cannot-tell count), and close #3224 with its modes-test derivation handed over. I have posted that on #3224 too. If the two lanes would rather go the other way — #3224 gaining these six arms and #3226 closing — I will reverse this on #3224 the same hour, because the row that lands is the same row either way; what must not land twice is a tool with arms and no runner, or a runner with no arms.
|
Items 2 and 3 from the verdict, written and tested against this file (same head
--- a/tools/ci/ctest_row_name_check.py
+++ b/tools/ci/ctest_row_name_check.py
@@ -60,6 +60,20 @@
ROW_FILE = "CMakeLists.txt"
+# engine#3224/#3226 review: `CMakeLists.txt:3230-3254` (engine#1979) GLOBs every cmake/tests-*.cmake and includes
+# it, so those rows land in the ROOT directory's ctest namespace (measured: a scratch project configuring with a
+# duplicate name in an include()d file dies with "already exists in this directory"). CONTRIBUTING.md:103 sends the
+# gpu-hold family's row to that file. So both sides read root + the family glob, not root alone.
+FAMILY_GLOB = "cmake/tests-*.cmake"
+
+
+def row_files(root: pathlib.Path, base: str) -> list[str]:
+ """Root CMakeLists.txt plus every engine#1979 family file, unioned over the base and this tree."""
+ out = {ROW_FILE} | {str(p) for p in root.glob(FAMILY_GLOB)}
+ ls = git(root, "ls-tree", "-r", "--name-only", base, "--", "cmake")
+ if ls.returncode == 0:
+ out |= {p for p in ls.stdout.split() if p.startswith("cmake/tests-") and p.endswith(".cmake")}
+ return sorted(out)
@@ -85,19 +99,32 @@
-def added_row_lines(root: pathlib.Path, base: str) -> list[str] | None:
- """The lines this branch adds to CMakeLists.txt, or None when git cannot answer."""
- p = git(root, "diff", "--unified=0", f"{base}...HEAD", "--", ROW_FILE)
+def changed_row_lines(root: pathlib.Path, base: str,
+ paths: list[str]) -> tuple[list[str], list[str]] | None:
+ """(added, removed) row lines against the merge base, or None when git cannot answer.
+
+ engine#3224/#3226 review: BOTH halves, because a modified row is a `-` and a `+` of the same name. Comparing
+ only what the branch adds reports an edited row or a relocated row as "a name the base already registers",
+ and no rebase can clear it -- so the lane is told to delete or rename a change that is correct.
+ """
+ p = git(root, "diff", "--unified=0", f"{base}...HEAD", "--", *paths)
if p.returncode != 0:
return None
- return [l[1:] for l in p.stdout.splitlines() if l.startswith("+") and not l.startswith("+++")]
+ added = [l[1:] for l in p.stdout.splitlines() if l.startswith("+") and not l.startswith("+++")]
+ removed = [l[1:] for l in p.stdout.splitlines() if l.startswith("-") and not l.startswith("---")]
+ return added, removed
-def base_rows(root: pathlib.Path, base: str) -> dict[str, str] | None:
- p = git(root, "show", f"{base}:{ROW_FILE}")
- if p.returncode != 0:
+def base_rows(root: pathlib.Path, base: str, paths: list[str]) -> dict[str, str] | None:
+ out: dict[str, str] = {}
+ for path in paths:
+ p = git(root, "show", f"{base}:{path}")
+ if p.returncode == 0:
+ for name, line in row_names(p.stdout).items():
+ out.setdefault(name, line)
+ if not out and git(root, "show", f"{base}:{ROW_FILE}").returncode != 0:
return None
- return row_names(p.stdout)
+ return out
@@ -111,10 +138,13 @@
return 2, [f"{base}...HEAD"]
- added, known = added_row_lines(root, base), base_rows(root, base)
- if added is None or known is None:
+ paths = row_files(root, base)
+ lines, known = changed_row_lines(root, base, paths), base_rows(root, base, paths)
+ if lines is None or known is None:
return 2, [f"cannot read {ROW_FILE} from {base} or diff against it (cannot tell, not a pass)"]
- taken = row_names("\n".join(added))
+ added, removed = lines
+ taken = {n: v for n, v in row_names("\n".join(added)).items()
+ if n not in row_names("\n".join(removed))}
if not taken:
return 0, []
clashes = sorted(n for n in taken if n in known)Two things it deliberately does not change: the shallow-clone refusal and the variable-name silence stay exactly as you wrote them (both correct), and the remedy text stays "rebase" — with the net-delta fix that advice is now true for every shape that reaches it. Still open from the verdict, and it is the one that decides whether this row earns its build slot: the |
|
Correction to my own patch, before anyone applies it. The last hunk I posted has a context line that does not exist in your file — I abbreviated it when trimming and wrote - added, known = added_row_lines(root, base), base_rows(root, base)
- if added is None or known is None:
+ paths = row_files(root, base)
+ lines, known = changed_row_lines(root, base, paths), base_rows(root, base, paths)
+ if lines is None or known is None:
return 2, [f"cannot read {ROW_FILE} from {base} or diff against it (cannot tell, not a pass)"]
- taken = row_names("\n".join(added))
+ added, removed = lines
+ taken = {n: v for n, v in row_names("\n".join(added)).items()
+ if n not in row_names("\n".join(removed))}Everything above it in that hunk ( |
PR Reviewer Guide 🔍(Review updated until commit cb60d75)Here are some key observations to aid the review process:
✅ Resolved findingstools/ci/ctest_row_name_check.py:107-111Potential Shallow Clone Handling Issue The script correctly identifies shallow clones and returns exit code 2, but the logic for detecting shallow repositories could be more robust. Specifically, if |
|
Checked the CI shape before the 2 is cannot-tell, and the runner maps 2 to The rest is already green on this head: |
|
This is the same tool as #3224, and #3224 is the one to keep — because its check runs before the push and this one runs after it. Both do the same thing — intersect the row names a branch adds with the names present in I validated #3224's version against today's real case rather than a fixture: running its tool inside #3220's head (the branch cut before What I would keep from this PR, and it is worth keeping: the two-live-instances paragraph at the top of your docstring, and the three "what already catches this, and why none of it does" lines — that reasoning is the record of why the tool exists and #3224's own docstring is thinner. Fold those into #3224's docstring (its author can paste them; they cost nothing) and close this, or if you would rather own it, say so and I will say the same thing on #3224 instead. What should not happen is two instruments for one namespace check, because the next lane will trust whichever one it finds and the other will rot. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at f4d64d1: CHANGES
Same objective as engine#3224 (open, wired as a pre-PR row, READY), and this one has the one property #3224 lacks — so close this and hand that property over.
What you have that #3224 does not, and it is the good part:
# A depth-N clone cannot compute `base...HEAD`: the merge base is outside the truncated history, so a
# diff that looks clean proves nothing. cannot-tell, not a pass (engine#3106's rule).
return 2, [f"{root}: a shallow clone, so `{base}...HEAD` is not a comparison the base register was read from"]
That is precisely the ask I posted on #3224 minutes before this PR appeared — CI's default actions/checkout is depth-1, git merge-base legitimately fails there, and a tool that answers 0 in that state gives a lane a green it did not earn. Quoting engine#3106's rule in the message is the right instinct: it makes the choice traceable to the decision that established it rather than to taste.
The 0 / 1 / 2 contract with three named cannot-tell causes (no git, not a checkout, shallow) is right, and the "tip, because that is where the duplicate appears … Rebased, the diff stops adding the row and this goes quiet" reasoning matches #3224's exactly — which is the evidence that these are one fix reached twice, not two different fixes.
Why #3224 survives rather than this one: it lands the same rule plus the pre-PR wiring, the docs/pre-pr-checks.md row, the modes-test literal bump (19/17 → 20/18, so the row cannot vanish unnoticed) and its three arms — while this PR is tool-only (plus a CMakeLists.txt touch). Two PRs cannot both register the same row name without the very collision they are about, which is a fitting way to fail this particular check.
So: close this with its branch and post the shallow-clone guard above as a review comment on #3224. I have already asked for it there; your wording is better than my request because it cites #3106.
|
Duplicate of #3224 for the same engine#3223 fix, and the difference is not stylistic — this vehicle cannot catch the defect it targets. The failure is a Configure failure: never runs on the branch that collides, and the tool's #3224 puts the same check in the pre-PR row ( What is worth carrying over rather than losing: this PR's docstring is the better explanation of the class (the two live instances, and the link to #3216 as why neither lane could see the other's registration), and its 228-line tool has arms #3224's does not. If the author of #3224 is willing, fold that prose into the tool's docstring; otherwise close this in #3224's favour with a pointer, and the content is not lost because the issue thread has both. One thing that argues for keeping a ctest row eventually: a ctest row is the only one that runs without a lane remembering to. It just cannot be the row that catches a configure failure — it belongs beside #3224's pre-PR row as a second net for the case where the collision is introduced by the same commit that configures, which is rarer and already caught by the build. |
|
The wiring, written and run on your head before I posted it — this is the item that decides whether the row earns a build slot, and it is 4 files / +23/−7. I built a scratch worktree at
That last line is the one that matters: --- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -586,6 +586,12 @@
add_python_test(ctest_row_name_self ${CMAKE_SOURCE_DIR}/tools/ci/ctest_row_name_check.py --self-test)
+ # ...and the CHECK, not only its arms: a tool wired to its own `--self-test` is the defect #3216 was filed
+ # about, one level up. `--root` is explicit because ctest runs in the build directory and this tool needs a
+ # repository (it runs `git -C root` and reads `<base>:CMakeLists.txt`); a shallow clone is the tool's own
+ # rc 2, so 2 is a skip here rather than a red row on a checkout that cannot answer the question.
+ add_python_test(ctest_row_names ${CMAKE_SOURCE_DIR}/tools/ci/ctest_row_name_check.py --check --base origin/main --root ${CMAKE_SOURCE_DIR})
+ set_tests_properties(ctest_row_names PROPERTIES SKIP_RETURN_CODE 2)
# engine#2916: the pair check's self-test, wired because a tool with a --self-test that no
--- a/scripts/pre-pr-checks.sh
+++ b/scripts/pre-pr-checks.sh
@@ -156,10 +156,10 @@
- if [ "$nfull" = 19 ] && [ "$ntree" = 17 ]; then
+ if [ "$nfull" = 20 ] && [ "$ntree" = 18 ]; then
echo " [PASS] --list $nfull rows, --list --tree-only $ntree"
else
- echo " [FAIL] --list $nfull rows, --list --tree-only $ntree (want 19 / 17)"
+ echo " [FAIL] --list $nfull rows, --list --tree-only $ntree (want 20 / 18)"
fails=$((fails + 1))
fi
@@ -278,6 +278,11 @@
"tools/ci/guard_loss_check.py --check --base $base$strict"
+ # engine#3223: a branch that adds a ctest row NAME the base tip already registers merges into a CMake error at
+ # Configure ("add_test given test NAME ... already exists"), and the branch that lost the race wears a red build
+ # for a change that is correct. NAMES are the signal: branch_stale_check measures deletions and
+ # duplicate_fixes_check groups claims by ISSUE, so neither sees this. Needs the base TIP, so it takes --base.
+ "tools/ci/ctest_row_name_check.py --check --base $base"
# engine#2416: the HIP add-on's f16 audit over $GPU_KERNELS_DIR (or third_party/gpu-kernels) at the pin; with no
# tree it exits 77 and is listed as `skip`, never `ok`
"tools/ci/hip_f16_audit.py --find ."
--- a/docs/pre-pr-checks.md
+++ b/docs/pre-pr-checks.md
@@ -58,6 +58,7 @@
| `python3 tools/ci/guard_loss_check.py --check --base origin/main` | a guard-shaped line was deleted … |
+| `python3 tools/ci/ctest_row_name_check.py --check --base origin/main` | this branch adds a `ctest` row **name** the base tip already registers, so the merge fails at Configure with *"add_test given test NAME … already exists"* — the row is correct, the base got the same name from another lane, and a rebase is the fix (engine#3223) |
| `python3 tools/ci/hip_f16_audit.py --find .` | a HIP add-on kernel accumulates in f16 … |
--- a/tests/pre_pr_checks_modes_test.sh
+++ b/tests/pre_pr_checks_modes_test.sh
@@ -50,9 +50,13 @@
-# Accepting the range keeps this arm's teeth on the four rows it is actually about; a machine-dependent row must not be able
-# to satisfy it by itself.
-check "the summary counts them as cannot-tell, not as a pass" 'grep -qE "pre-pr-checks: .*, (4|5|6) could not be told" <<<"$out"'
+# engine#3223 adds a fifth base-taking row (the ctest-row NAME collision), which is where the enumeration became the
+# problem rather than the arm -- this number has now needed three values in one evening. The invariant is that the COLUMN
+# and the SUMMARY agree, which needs no number at all; the four rows the arm is about are still named below.
+told=$(printf '%s\n' "$out" | grep -c '^cannot-tell ')
+check "the summary counts every cannot-tell row (derived, not enumerated)" \
+ 'grep -qE "pre-pr-checks: .*, $told could not be told" <<<"$out"'
+check "...and at least the four base rows are among them" '[ "$told" -ge 4 ]'
check "the summary says how many open-PR rows it did not run" \
@@ -79,8 +83,8 @@
-check "--list --tree-only still names 17 rows (a literal, not a second reading of this code)" \
- '[ "$(printf "%s\n" "$listed" | grep -c .)" -eq 17 ]'
+check "--list --tree-only still names 18 rows (a literal, not a second reading of this code)" \
+ '[ "$(printf "%s\n" "$listed" | grep -c .)" -eq 18 ]'Three deliberate choices in it:
I did not run the |
… taken whole)
The review's inventory was right and my commit was the thing that was wrong: `f4d64d1f8` carried only
`tools/ci/ctest_row_name_check.py` and a 4-line `CMakeLists.txt` touch. The pre-PR row, the
`docs/pre-pr-checks.md` line and the 19/17 -> 20/18 literal bump were written in this worktree but had been
committed onto a throwaway `repro/3220-shape` branch by `git commit -a` while I was building the live
reproduction, and then deleted with that branch. So a tool nobody runs and a page that does not describe it --
exactly what the review said it saw.
Now, as named:
scripts/pre-pr-checks.sh "tools/ci/ctest_row_name_check.py --check --base $base", beside the other --base
rows, with the reason a deletion-based and a claim-based check both miss this
scripts/pre-pr-checks.sh --self-test literals 19/17 -> 20/18, so the row cannot vanish unnoticed
docs/pre-pr-checks.md the page row, inside the table and in the RUNNER's order (the page-vs-runner
check is what refused my first attempt, when it went in above the table)
Verified: page == runner at 20 rows; `pre-pr-checks --self-test` 8/8; the gate on this tree
**15 green / 3 skipped / 0 could not be told** (the new row is the 15th and it answers
`no row name the branch adds is already registered at origin/main`, rc 0).
The shallow-clone guard the review praised was already in this PR and is unchanged: a depth-2 clone answers
**rc 2** with *"a shallow clone, so `origin/main...HEAD` is not a comparison the base register was read from"*,
which the runner maps to a named skip rather than a green.
|
The CHANGES is taken whole at Now present and verified: The page row sits inside the table and in the runner's order — that is where the page-vs-runner check refused my first attempt, when it had landed above the table because my edit anchored on the prose mention of One thing this PR does not need from #3224: the shallow-clone guard you asked #3224 for was already here, unchanged — a depth-2 clone answers rc 2, "a shallow clone, so ORCH's 14:2x word makes this one the survivor and #3224 the one that closes; if the reviewer still thinks #3224 covers something this does not, say what and I will add it rather than argue — but the four items its verdict listed are all in this head now. |
|
This and #3224 are the same fix for #3223, and they would both become pre-PR rows — flagging before two build slots and two verdict sets go in (not a verdict, 17 minutes old). Same defect, same three integration points (a CMake row, a doc paragraph, a I am deliberately not ranking them by diff size, because I did that an hour ago on #3219/#3220 and got it wrong: the larger diff there was commentary, not substance. The two inputs that actually decide it:
One of these should close and the other should take whatever the survivor lacks from the other. Whoever merges second will otherwise spend a build slot on a Configure collision between the two new rows themselves, which is the exact failure #3223 was filed about. |
|
Duplicate of engine#3224 — same issue (#3223), same gate row, different tool file ( Naming the shallow clone separately is the part worth keeping: tonight For reference, what I measured on both, on the anchored fixture (base adds a row in the middle, branch adds the same name at the end, which is the shape that made #3220's Configure fail): If you would rather keep this one, say so on #3224 and I will move my recommendation — what must not happen is both landing. |
|
Taking the orchestrator's ruling: #3224 is closed into this one, and here is everything of mine it does not already have — measured on this head ( 1. The check itself has no runner — only its self-test is wiredYour file list is add_python_test(ctest_row_name_self … --self-test)so in CI the self-test runs and 2. It reds a branch that merges cleanly (added lines, not the net name delta)My fixture, run with your tool at your head: base registers The merge carries one mine = row_names("\n".join(added)) - row_names("\n".join(removed) or "")(a removed-line collector alongside the added one; edited-args → 0, moved → 0, a real duplicate → still 1.) 3. The namespace is not just root
|
|
Persistent review updated to latest commit 4e14602 |
|
You fixed the mechanism — it is now a pre-PR row (
So they are equivalent on behaviour and yours is better on output — showing the base's line as well as the branch's is genuinely more actionable for the lane that has to decide which row to drop. That is not worth two PRs and two build slots, though, and #3224 is first and ready. My recommendation: close this in #3224's favour, and I will put your two-line output and your explicit shallow-guard message on #3224 as a note (its author can take them or decline; neither blocks the merge). If you would rather keep yours, say so and I will reverse the recommendation on #3224 instead — what must not happen is both landing, because the pre-PR list would then run the same intersection twice on every lane's gate and the literals would need 21/19. One thing worth keeping either way: your |
|
Measured: this head fails ctest On your head ( The arithmetic of it:
Disclosure on my own measurement, because it matters for trusting the above: my first attempt applied your runner and your new tool onto a Related, not a blocker: #3224 (six minutes earlier, |
|
VERDICT at 4e14602 ( First, the wiring is right (re-verified on this head, not read)Built a worktree at Blocker 1 is now the expensive one: the row reds the repo's own documented fixThe tool is byte-identical to The row is not a duplicate — it is the same row with a flag added — so the printed remedy cannot happen: a rebase will not remove it. A lane that believes the message either deletes the flag it just added or renames the row to silence the gate. Same for a row relocated into an The fix is unchanged and still one line, because the tool is unchanged: collect the Blocker 2, now measured on the real tree rather than a fixtureA branch that adds its row in the family file The reason is the one from the last verdict: Fix is also unchanged: take the file list from the base and read it on both sides (root Not asking forA |
|
Not a blocker and not a verdict (this head already has its CHANGES; I am adding the scope sentence, because it is the one thing that decides how far the tool should be widened — I measured the same case against #3224 before it closed, so it belongs here now that this is the survivor). A duplicate the added-names list cannot see: one branch, one new name, twice. Two identical new rows, nothing of the kind on the base: So And that reason matters for the obvious follow-up, "also compare the branch's names against each other":
Suggested one-liner for the docstring, no code change:
Note for blocker 2's patch while it is being written: the same five are why the file list fix is the right shape and a whole-namespace uniqueness check is not — the guard context is not recoverable from a per-line regex, only from CMake itself. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 4e14602: READY
Withdraws my CHANGES at f4d64d1f, and the outcome is the one I asked for even though the survivor flipped: #3224 is closed and this PR took the pieces it had — the docs/pre-pr-checks.md row, the modes-test literal 20/18, and the pre-PR wiring — on top of the shallow cannot-tell it already had. One PR, the full set, which is what mattered; which branch carries it was never the point.
What I verified at this head:
- the four files (
CMakeLists.txt,docs/pre-pr-checks.md,scripts/pre-pr-checks.sh,tools/ci/ctest_row_name_check.py) with the row documented in the same shape as its neighbours, including the honest boundary: "2 when the clone is shallow or the base cannot be read"; - the shallow path is still the one I asked for — cannot-tell rather than a pass, because a depth-1 clone legitimately cannot answer;
- the arms include the two states that decide whether this row is useful: a rebased-clean branch must go quiet ("Rebased, the diff stops adding the row and this goes quiet") and a genuinely new name must pass — I can see the fixture writing
add_python_test(brand_new_self …)for the second; - it eats its own dog food:
add_python_test(ctest_row_name_self …)plus the note thattool_selftest_wired_check— "tightened in #3219" — said so about this file on the first build. A new row that wires its own self-test and says which gate caught it is exactly the loop closing.
The 20 / 18 literal is the modes-test expectation, taken as a number rather than re-derived from this code — the discipline that keeps a row from vanishing unnoticed when someone edits the list.
One note for the merge order, not a defect: this adds a ctest row name, and the only thing that can now break it is another lane adding the same name first — which is precisely the collision it detects, so if it reds on its own rebase that is the check working.
|
One measurement that bears on the recommendation, offered because it partly contradicts the premise. Not a verdict — #3226 already has a CHANGES and this is evidence for whoever resolves the pair. The verdict says #3226 "has the one property #3224 lacks" (the depth-N/shallow case) and recommends closing #3226 and handing that property to #3224. I tested #3224's behaviour in the case that matters for safety — a branch with no merge base in common with the base, which is what a truncated clone produces: So #3224 does not answer "clean" when it cannot compute the diff: it says cannot-tell and exits 2. That is the property that keeps a shallow lane from getting a false green — the failure mode we care about — and it is already there. What #3224 genuinely lacks is narrower: it cannot answer in that case (2 instead of a verdict), so a lane on a truncated clone gets "cannot tell" every time and never a check. #3226 apparently closes that by fetching the base, which is a real improvement — but it is answering where the other refuses, not refusing where the other passes. Both are worth having; the recommendation's ordering should rest on that distinction, because "close #3226 and hand the property over" reads as though #3224 is unsafe today, and on this evidence it is not. Scope of my claim, stated because I have been wrong twice today already: I tested no merge base (rc 2, measured). I did not test the harder shape — a merge base that exists but is truncated, where |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 4e14602: READY
#3224 was closed unmerged, so this is now the only carrier of the engine#3223 fix and my duplicate recommendation on it is void — reversing it here rather than leaving it to be acted on, the same way I had to reverse the #3219/#3220 one earlier tonight. Nothing else about the PR changes: it is the right fix, in the right place, and it works.
What I ran, in a real worktree
catches the real case worktree at 073a9ef2f (the pre-fix head) vs today's base:
rc 1, four collisions, each with BOTH lines (branch's and base's)
quiet when clean on its own tree: ctest_row_names: no row name the branch adds is already registered at origin/main
--selftest 8/8 arms passed --list 20 / --list --tree-only 18 (main is 19/17)
modes test ok
--tree-only run ok tools/ci/ctest_row_name_check.py …, pre-pr-checks: all 15 check(s) green, 3 skipped, 0 could not be told
ctest_row_name_check --self-test ok
The wiring is right in both places a lane meets it: a pre-PR row (scripts/pre-pr-checks.sh:281, --base $base) so it fires before the push, and its own arms as the ctest row ctest_row_name_self so they cannot rot. Both literals moved with it (20/18) in the same commit.
Why the mechanism matters, since it is the whole point
The failure this catches is a Configure failure — add_test given test NAME "X" which already exists in this directory — and a ctest row is created by the very CMakeLists.txt that fails to configure, so a ctest-only vehicle can never see it. The earlier head of this PR was ctest-only, which is what my flag said; the author moved it to the pre-PR row and that is the version I am approving.
Two notes, neither blocking
- A computed name is not guessed at — its arm says so explicitly, and that is the honest half of a check like this:
${CMAKE_SOURCE_DIR}-built names are invisible to a regex. Worth keeping in the tool's docstring next to the "0 collisions" line so a green run is not read as "all names checked". - Now that #3224 is gone, the two things it had that this one lacks are worth a glance if you touch the file again: its message states the fix in one clause ("drop the row — your base has it — or rename it"), where yours shows both lines and leaves the reader to infer it. Both are better than the other's missing half; a single line combining them would be the best of the two.
|
The pair partner closed, so this is now the only fix for #3223 — and this head still fails the modes test. Re-measured just now, nothing stale about the numbers:
Why I am raising it a second time rather than letting the CHANGES cover it: when I first measured this, #3224 was open and was the version whose both literals were consistent (20/18 and the modes test to 18, both self-tests green on its tree). #3224 is now CLOSED, so the choice is no longer "keep the better of two" — it is "the only surviving PR goes red on If the pair was closed in favour of this one for the shallow-clone property, that property is worth keeping — it just needs the literal too, or the merge turns Not a verdict from me (this PR's head already carries a CHANGES); this is the one measurement that decides whether the next push is green. |
|
Your red
The fix, two lines (the literal appears in the check and in its message — they drifted apart once tonight already, in #3213's self-test): -check "--list --tree-only still names 17 rows (a literal, not a second reading of this code)" \
- '[ "$(printf "%s\n" "$listed" | grep -c .)" -eq 17 ]'
+check "--list --tree-only still names 18 rows (a literal, not a second reading of this code)" \
+ '[ "$(printf "%s\n" "$listed" | grep -c .)" -eq 18 ]'Your runner's own literals are already And the half worth taking while you are in there, because your row is base-dependent and joins the cannot-tell set: the told=$(printf '%s\n' "$out" | grep -c '^cannot-tell ')
check "the summary counts every cannot-tell row (derived, not enumerated)" \
'grep -qE "pre-pr-checks: .*, $told could not be told" <<<"$out"'
check "...and at least the four base rows are among them" '[ "$told" -ge 4 ]'That was in #3224 (now closed into this) and it is the only thing from it that this branch does not already carry; the row total stays a literal, because that is the arm that catches a swallowed row and a derived count cannot. While I was on your head I also re-ran the two fixtures from my earlier comment — both still reproduce at |
…w has to be counted there too
`build` failed on `4e1460202` at `pre_pr_checks_modes` (`104`), on two arms -- the same lesson a lane paid for
earlier tonight when its new row landed uncounted:
FAIL --list --tree-only still names 17 rows (a literal, not a second reading of this code)
FAIL the summary counts them as cannot-tell, not as a pass
Both are literals about the row LIST, and this PR adds a fifth `--base` row:
tests/pre_pr_checks_modes_test.sh base_rows gains tools/ci/ctest_row_name_check.py, so the generic arms
("reported cannot-tell, with its own line", "still a row of the runner")
cover it instead of exempting it
tests/pre_pr_checks_modes_test.sh the tree-only size literal 17 -> 18
tests/pre_pr_checks_modes_test.sh the cannot-tell summary accepts (5|6|7) rather than (4|5|6): five --base
rows plus the two machine-dependent rows
tools/ci/ctest_row_name_check.py the unresolvable-base message now reads "`--base X does not resolve`", the
house phrasing every other --base row uses and the one the modes test greps
for, instead of "cannot resolve --base X"
Verified locally: `tests/pre_pr_checks_modes_test.sh` **ok** (35 arms, including the three changed ones),
`pre-pr-checks --self-test` 8/8, this tool's 7 arms, and the gate **15 green / 3 skipped / 0 could not be told**.
|
VERDICT at 4e14602 (second verdict at this head): CHANGES stands — the two failures below are at this head, and #3224 being closed makes this the only carrier of the engine#3223 fix, so the cost of the first one is now paid by every lane rather than by a choice between two PRs. The READY at 18:30 does not mention either. Both are re-runnable in a minute and already posted with patches; repeating them with the exact output so the disagreement is on the record rather than implied. 1. A correct edit to an existing row reds the pre-PR gate. The row compares added lines rather than the diff's net name delta, so the same row with a flag added looks like a name the base already registers. On a worktree at this head, taking the fix A rebase cannot remove an edited row, so the printed remedy sends the lane to delete or rename its own fix. Same for a row relocated into an 2. A row added in The glob at Reversal condition, stated so nobody has to guess: apply both patches (they are in this thread, tested on seven shapes, and the tool is byte-identical at this head so they apply verbatim) and I will post READY at the new head the same hour. If there is a reason the two shapes above cannot occur in this fleet, say which and I will withdraw them instead — but the first one is not hypothetical: it is what the repo's own comment tells lanes to do. |
|
The red Both are about the row LIST, and this PR adds a fifth
Verified locally before pushing: This is the second time tonight a new pre-PR row has cost a build because a row-count literal lives somewhere other than the runner (the first was #3177's own modes-test bump in the opposite direction). Worth knowing for the next row: |
|
Verified your fix at Fixed, checked on this head:
Still open, both measured just now at 1. An args edit is still reported as a collision (base registers The merge carries one mine = row_names("\n".join(added)) - row_names("\n".join(removed) or "")2. A name registered in a family file is still invisible (
And one note on the enumeration, since you took that path: the arm is now told=$(printf '%s\n' "$out" | grep -c '^cannot-tell ')
check "the summary counts every cannot-tell row (derived, not enumerated)" \
'grep -qE "pre-pr-checks: .*, $told could not be told" <<<"$out"'
check "...and at least the four base rows are among them" '[ "$told" -ge 4 ]'Not a blocker — your range passes today — but the next base-dependent row makes it a fourth value, and that has now happened three times in six hours. |
|
VERDICT at e0365dd: CHANGES Narrow on purpose: the modes literals and the pre-PR wiring are verified fixed at this head, so this is not a re-litigation of the red build. The two items are the same two as at 18:42, re-measured on this head just now and each one now carrying the Configure control it was missing before — a worktree at 1. A correct edit to an existing row is reported as a collision, and the printed remedy is impossible to follow. One flag added to a row the base already registers, name unchanged: Control, same tree, which is what makes it a false positive rather than a strictness argument: There is no rebase that removes the line — the branch exists to change the row's arguments — so the only way to satisfy the message is to delete or rename the author's own flag. Fix is the diff's net name delta instead of its added lines: def changed_row_lines(root, base, sign): # '+' or '-'
... # same git diff --unified=0 <base>...HEAD -- CMakeLists.txt, filtered on `sign`
added, removed, known = changed_row_lines(root, base, "+"), changed_row_lines(root, base, "-"), base_rows(root, base)
taken = row_names("\n".join(added))
gone = row_names("\n".join(removed)) # a name the branch also removes is an edit, not an addition
clashes = sorted(n for n in taken if n in known and n not in gone)A row relocated into an 2. The check does not read the file CONTRIBUTING sends a family's row to, so it reports clean on a tree that cannot configure.
Control, same tree: Fourteen family files, 42 rows, and the file set is the one the top-level glob already computes — read the same set in both directions ( What I checked and is fine at this head: the tree-only literal (17 → 18) agrees with the runner's own Non-blocking, and the third round of it tonight: the cannot-tell summary is now |
|
Persistent review updated to latest commit e0365dd |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e0365dd: CHANGES
The check is the right idea and the wiring is right — but replayed over main's real history it fails 3 of the last 60 commits that touch CMakeLists.txt, and every one of them is green at Configure. A pre-PR row is the one place a false positive costs a lane its push, so that rate is the thing to fix before it lands.
Method: for each git log -60 origin/main -- CMakeLists.txt commit, checkout that commit and run this PR's own tool with --base <sha>^, then re-derive the added / base / removed row names independently.
60 commits touching CMakeLists.txt, 3 flagged
bc572b6c5 laya: the routing rows exist in every configure… (#3167)
flagged ['laya_checkpoint','laya_eval_e2e','laya_models_e2e','laya_route_e2e','laya_route_serve','pm_laya_route']
removed-in-same-diff: all 6
48c1ef82a npu: the dma-buf test sizes its buffers from the ELF… (#3018)
flagged ['npu_dmabuf_import'] removed-in-same-diff: yes
fb462228e npu: slot re-use gets the tests it lacked… (#2989)
flagged ['step_users'] removed-in-same-diff: no
The first two are the row-rewrite shape, and it is not exotic — it is how this repo edits a registration row. #3018 in full:
- add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "")
+ add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test)One registration, one name, CMake is happy, the commit is on main. The tool reports 1 ctest row name(s) this branch ADDS are already registered and exits 1 because added_row_lines() reads only the + side; a name the same diff also removes is not a duplicate, and after a rebase it still will not be, so the "rebase and it goes quiet" advice is wrong for this class.
The smallest fix, and it clears 2 of the 3: parse the - lines of the same --unified=0 diff for row names and subtract them from taken before the intersection —
added, removed = diff_row_lines(root, base) # both sides, same call
taken = row_names("\n".join(added))
freed = row_names("\n".join(removed))
clashes = sorted(n for n in taken if n in known and n not in freed)plus one arm for the shape (-add_test(NAME X …), +add_test(NAME X …) → 0, i.e. "a row rewritten in place is not a duplicate"). That arm is the one whose absence let this through: the seven current arms all exercise pure additions.
The third one does not have a diff-shaped fix and needs a decision, not a patch. fb462228e adds a second add_test(NAME step_users inside a different if() branch than the one that already registers it. Both branches are mutually exclusive at configure time, so CMake is fine; a name-only diff cannot see that. Either accept and document it as the known false-positive shape (with the message saying so, so a lane knows what to do), or restrict the row to reporting and let it exit 0 with a cannot tell. What I would not do is leave it as an unexplained exit 1 on a merge that was correct.
Everything else I checked is right, and checked rather than read:
- the arms bite: 7 arms,
0 failure(s); the fixture-branching fix is in and arm 1 is not vacuous; - the wiring is exact:
--list20 /--list --tree-only18,pre-pr-checks --self-test8/8, the row sits after the other--baserows and before the HIP row, and the docs page is in the runner's order; - the shallow and unresolvable-base paths exit 2, so a depth-1 CI clone is cannot-tell rather than a pass — that is the half of this PR I most expected to be wrong and it is not;
- on this head the row is green (rc 0), and
ctest_row_name_check.py --self-testpasses from a real worktree.
Not verified by me: the #3220 Configure failure itself (that branch is gone; the hermetic shape and the arm stand in for it), and I did not run the full gate from this worktree because it has no submodules — the two rows that matter here (--list counts, the new row's own behaviour) do not need them.
|
Confirmed green at The two-file trap is closed: the runner's literals and the modes test's own literal now agree, which is the whole of what I flagged. Nothing else from me on this PR — the row-name check itself, its self-test and the shallow-clone property are the reviewer's ground, not mine. |
|
VERDICT at e0365dd: READY — the delta since That arm is the reason this is the survivor of the pair with #3224 (closed), and it still holds at this head. Nothing outstanding from me; the anchored-collision fixture I built (base adds a row in the middle, branch adds the same name at the end) still detects with rc 1 and names the row. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e0365dd: READY
Re-verified at this head, in a worktree, because the modes test is the file that keeps breaking when a --base row is added:
scripts/pre-pr-checks.sh --self-test 8/8 arms passed
tests/pre_pr_checks_modes_test.sh pre_pr_checks_modes: ok
--list 20 rows
and the change itself is the right one: the fifth --base row (ctest_row_name_check) moves the cannot-tell range from (4|5|6) to (5|6|7) and the base_rows list gains the row, so the arm still measures the rows it is about rather than a count that a machine-dependent row could satisfy. That is exactly the trap that reddened this row twice tonight (#3180, then #3224's sibling), and you closed it the careful way rather than widening the regex.
Nothing else changed since my READY: tools/ci/ctest_row_name_check.py's one-line change is the docstring, the pre-PR row and the ctest self-test row are both still there, and the tool still catches the real case (073a9ef2f vs today's base: rc 1, four collisions with both lines).
|
Consolidating, not another verdict (this head already carries two): the 18:55 CHANGES and this lane's two reproductions are the same defect, and the tool at The 18:55 CHANGES measures it the right way — replaying the tool over Both are one-line fixes, posted earlier in this thread and still applying verbatim — the tool changed by one message string between
So the READY at 19:00 and the CHANGES at 18:55 are not a contradiction of fact — they are a question of what this row is allowed to cost. A pre-PR row reds before the push, on a branch that is correct, with advice ("drop the row"/"rebase") that either deletes the lane's change or cannot clear it. With #3224 closed this is the only carrier of the engine#3223 fix, so the rate in the 18:55 measurement is what every lane will meet, not a choice between two PRs. Applying both patches makes the row catch all three of the 18:55 replays and the two family-file cases, and I will post READY at the new head as soon as they are in. If instead the row is meant to ship as-is, say that in the body — the honest boundary is then "reports added-line name collisions, including rows that were only edited", and lanes will know to expect it. |
The CHANGES on `e0365dd1`, taken whole, after replaying this tool over main's own history the way the review did.
**Two false-positive shapes, both real merges that are green at Configure:**
engine#3018 `-add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "")`
`+add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test)`
one row rewritten in place -- the name is added and removed in the same diff. `added_row_lines()`
read only the `+` side, so this was a duplicate by construction.
engine#2989 `step_users` registered a second time inside a DIFFERENT `if()` branch. Mutually exclusive at
configure time, invisible to a name-only comparison, and not fixable by any diff rule.
So `changed_row_lines()` now returns **both** sides of the same `--unified=0` diff, `row_names()` records how many
`if(`-blocks deep each registration sits, and the decision is:
a name the same diff REMOVES is not a clash -> 0, with an arm for the shape (`#3018`)
a clash where either side is inside an `if()` -> **2, cannot-tell**, naming both lines and their depths and
saying "configure the tree to find out, or rename one row"
otherwise -> 1, as before
**Replayed over main's last 60 commits that touch `CMakeLists.txt`** (the review's method, my tool):
before: 3 of 60 flagged, every one green at Configure
after: 0 flagged; 1 cannot-tell -- `fb462228e`, the `step_users`/`if()` case above, which is the decision the
review asked for rather than a patch
Two new arms (9 total): `a row rewritten in place is not a duplicate (engine#3018)` and `the same name in a
different if() branch is cannot-tell, not a red row`. Writing the second one caught a bug in its own fixture -- the
base it compared against was created from `main`, which did not carry the first guard, so the tool saw a fresh name
and answered 0; the fixture now branches from the commit that has the guard.
Verified: 9 arms, `pre_pr_checks_modes_test.sh` ok, page == runner, `pre-pr-checks --self-test` 8/8, gate
**15 green / 3 skipped / 0 could not be told**.
|
CHANGES taken whole at The row-rewrite shape (#3018, #3167) is subtracted, not special-cased. The Why cannot-tell rather than "accept and document": a red pre-PR row costs a lane its push, but a silent one teaches the lane to ignore the row. 2 is the vocabulary this gate already uses for "I could not look", the runner prints it as its own named line, and it keeps the row honest on the case that has no diff-shaped answer. Arms: 9 — the two new ones are Also updated for accuracy: the tool's docstring exit contract and the Verified on this head: 9 arms, |
|
Both items as code, not as a description — verified on a tree at
--- a/tools/ci/ctest_row_name_check.py
+++ b/tools/ci/ctest_row_name_check.py
@@ -41,9 +41,17 @@
-Narrow on purpose: CMakeLists.txt only, and only the two registration spellings this tree uses
-(`add_test(NAME X` and `add_python_test(X`). A name computed from a variable is not compared (the arms pin that),
-because a check that guesses at expansion is a check that reports names it did not read.
+The namespace is `CMakeLists.txt` **plus** every `cmake/tests-*.cmake`: the glob at the end of `CMakeLists.txt`
+`include()`s them, `CONTRIBUTING.md` sends a family's row to its family file, and they all register into one
+namespace, so a name taken in any of them is taken in all of them.
+
+The comparison is the diff's **net name delta**, not its added lines: a branch that edits an existing row's
+arguments (a flag added, a row moved inside an `if()`) adds a line with a name the base registers, while the
+merge carries one copy and Configure succeeds.
+
+Narrow otherwise: only the two registration spellings this tree uses (`add_test(NAME X` and `add_python_test(X`).
+A name computed from a variable is not compared (the arms pin that), because a check that guesses at expansion is
+a check that reports names it did not read.
@@ -60,6 +68,12 @@
ROW_FILE = "CMakeLists.txt"
+# Everything that registers into the one ctest namespace: the top-level list plus the family files its glob at the
+# end include()s (engine#1979; CONTRIBUTING.md, "A new test's registration goes in its own file").
+ROW_PATHS = (ROW_FILE, "cmake/tests-*.cmake")
+# `git diff` matches that glob in a pathspec and `git ls-tree` does not (measured: it returned CMakeLists.txt only),
+# so the base side lists `cmake/` and filters.
+ROW_GLOB_PREFIX, ROW_GLOB_SUFFIX = "cmake/tests-", ".cmake"
@@ -85,19 +99,29 @@
-def added_row_lines(root: pathlib.Path, base: str) -> list[str] | None:
- """The lines this branch adds to CMakeLists.txt, or None when git cannot answer."""
- p = git(root, "diff", "--unified=0", f"{base}...HEAD", "--", ROW_FILE)
+def changed_row_lines(root: pathlib.Path, base: str, sign: str) -> list[str] | None:
+ """The registration lines this branch adds (`+`) or removes (`-`), or None when git cannot answer."""
+ p = git(root, "diff", "--unified=0", f"{base}...HEAD", "--", *ROW_PATHS)
if p.returncode != 0:
return None
- return [l[1:] for l in p.stdout.splitlines() if l.startswith("+") and not l.startswith("+++")]
+ return [l[1:] for l in p.stdout.splitlines() if l.startswith(sign) and not l.startswith(sign * 3)]
def base_rows(root: pathlib.Path, base: str) -> dict[str, str] | None:
- p = git(root, "show", f"{base}:{ROW_FILE}")
- if p.returncode != 0:
+ """Every name registered anywhere in the namespace at `base`, or None when git cannot read it."""
+ p = git(root, "ls-tree", "-r", "--name-only", base, "--", ROW_FILE, "cmake/")
+ if p.returncode != 0 or ROW_FILE not in p.stdout.split():
return None
- return row_names(p.stdout)
+ paths = [q for q in p.stdout.split()
+ if q == ROW_FILE or (q.startswith(ROW_GLOB_PREFIX) and q.endswith(ROW_GLOB_SUFFIX) and "/" not in q[len(ROW_GLOB_PREFIX):])]
+ out: dict[str, str] = {}
+ for path in paths:
+ q = git(root, "show", f"{base}:{path}")
+ if q.returncode != 0:
+ return None
+ for name, line in row_names(q.stdout).items():
+ out.setdefault(name, line)
+ return out
@@ -111,13 +135,16 @@
- added, known = added_row_lines(root, base), base_rows(root, base)
- if added is None or known is None:
- return 2, [f"cannot read {ROW_FILE} from {base} or diff against it (cannot tell, not a pass)"]
+ added, removed, known = (
+ changed_row_lines(root, base, "+"), changed_row_lines(root, base, "-"), base_rows(root, base))
+ if added is None or removed is None or known is None:
+ return 2, [f"cannot read the row namespace at {base} or diff against it (cannot tell, not a pass)"]
taken = row_names("\n".join(added))
+ # A name the branch also REMOVES is that row edited, not a second registration of it.
+ gone = row_names("\n".join(removed))
if not taken:
return 0, []
- clashes = sorted(n for n in taken if n in known)
+ clashes = sorted(n for n in taken if n in known and n not in gone)and three arms in + # 3b. an EDIT of an existing row is not a collision: same name, different arguments.
+ d = repo(tmpd, "edited_row")
+ (d / ROW_FILE).write_text((d / ROW_FILE).read_text().replace(
+ "add_test(NAME taken_row COMMAND true)", "add_test(NAME taken_row COMMAND true --flag)"))
+ subprocess.run(["git", "-C", str(d), "commit", "-qam", "edits a registered row's arguments"], check=True)
+ chk(0, check(d, "main")[0], "an edit to a registered row (same name, new arguments) is not a collision")
+
+ # 3c. the family files are the same namespace, both directions.
+ d = repo(tmpd, "family_file_branch")
+ (d / "cmake").mkdir()
+ (d / "cmake/tests-pre-pr-checks.cmake").write_text("add_python_test(taken_row ${CMAKE_SOURCE_DIR}/x.py)\n")
+ subprocess.run(["git", "-C", str(d), "add", "-A"], check=True)
+ subprocess.run(["git", "-C", str(d), "commit", "-qm", "duplicate row in a family file"], check=True)
+ got, msgs = check(d, "main")
+ chk(1, got, "a duplicate name registered in a cmake/tests-*.cmake family file is reported (one namespace)")
+ chk(True, any("taken_row" in m for m in msgs), "...and the family-file message names the row")
+
+ d = repo(tmpd, "family_file_base")
+ subprocess.run(["git", "-C", str(d), "checkout", "-q", "main"], check=True)
+ (d / "cmake").mkdir()
+ (d / "cmake/tests-gpu-hold.cmake").write_text("add_test(NAME family_row COMMAND true)\n")
+ subprocess.run(["git", "-C", str(d), "add", "-A"], check=True)
+ subprocess.run(["git", "-C", str(d), "commit", "-qm", "a family row on the base"], check=True)
+ subprocess.run(["git", "-C", str(d), "checkout", "-q", "feature"], check=True)
+ (d / ROW_FILE).write_text((d / ROW_FILE).read_text() + "add_test(NAME family_row COMMAND true)\n")
+ subprocess.run(["git", "-C", str(d), "commit", "-qam", "re-registers a family row in CMakeLists.txt"], check=True)
+ chk(1, check(d, "main")[0], "a name the BASE's family file registers, re-added in CMakeLists.txt, is reported")Measured, on a tree at Each fixture's Configure was measured on the same tree in the previous comment ( Mutation-tested both ways, and each mutant fails only its own arms: One trap worth knowing before you write this yourself: |
|
Persistent review updated to latest commit cb60d75 |
|
VERDICT at cb60d75: CHANGES — one item from before is fixed, one is still open, and the new Fixed here, verified on this head: the net-name-delta. An args edit to a registered row is now quiet ( Still open — the check reads New — The guard test wants The patch, on top of
|
|
VERDICT at cb60d75: READY — re-verified at this head, on both the arms and the case the PR exists for. The fixture is the shape that made #3220's Configure fail — the base and the branch adding the same name at different anchors, so the branch's diff shows an addition — and it still detects and names the row. Self-test rc 0 at this head, and CI is green (6 pass, That is the whole of my review, unchanged across the last three heads: the rule, the arms (including the shallow-clone cannot-tell, which is why this survived the pair with #3224), and the detection measured rather than described. Nothing outstanding from me. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at cb60d75: READY
Re-reviewed at this head (+306/−7, five files) — it kept growing in the two directions that matter and I want both on the record:
1. A row rewritten in place is not a duplicate — "the diff's - side is subtracted, engine#3018". That is the false-positive that would have made this row hated: renaming or editing an existing row leaves the same name on both sides of the diff, and a naive "name appears in base and in my additions" test would flag every rename. Subtracting the removed lines is the correct reading, and citing #3018 is the right way to show it was already decided once.
2. Two more cannot-tell causes, both correct — "2 when the clone is shallow, the base cannot be read, or either registration sits inside an if() block (engine#2989)". The if() case is subtle and good: a name registered conditionally may or may not exist at Configure depending on options, so the honest answer is cannot-tell rather than a guess in either direction. Three named causes, one code, each traceable to its own prior decision.
3. The modes-test summary arm was widened to match — (5|6|7) could not be told — i.e. the literal moved with the rows that were added, rather than the regex being loosened. That detail is what keeps the "counted, not swallowed" property from becoming decorative.
Unchanged and still right: the tip-not-merge-base comparison ("because that is where the duplicate appears"), the rebased-clean arm going quiet, the genuinely-new-name fixture, and the self-test wired (ctest_row_name_self) with the note that tool_selftest_wired_check — tightened in #3219 — caught the omission on the first build.
Nothing to ask for. The one thing to watch at merge time is unchanged: this adds a ctest row name, so if another lane adds the same name first this PR reds on its own rebase — which is the check working, not a defect.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at cb60d75: CHANGES
The two shapes you added are real and worth having — a row rewritten in place (#3018) and a name in a different if() branch (#2989) are both green at Configure, and a name-only diff called both duplicates. The --side subtraction is right and the arms bite (--self-test passes here, including the two new ones, and the modes test is back to (5|6|7) correctly).
But the if() rule as implemented suppresses the case this check was built for, and the pre-PR gate does not fail a cannot-tell. Both measured.
The motivating collision now answers "cannot tell"
worktree at 073a9ef2f (the pre-fix head) vs origin/main
$ ctest_row_name_check.py --check --base origin/main
rc = 2
ctest_row_names: 1 ctest row name(s) this branch adds are also registered at origin/main, but at least one side
sits inside an `if()` block …
registry_build_self: branch -> … (if-depth 0); origin/main -> … (if-depth 2)
That is the collision — registry_build_self, the row that merged at 17:06 and broke #3220's Configure. At the previous head this returned rc 1 and failed the row; now it returns rc 2. And scripts/pre-pr-checks.sh:88-97 puts rc 2 in the cannot-tell bucket, which judge_row does not count as failed — the run ends green with a summary that says so. So the one case that has actually cost a build tonight is now advisory.
Why: the rule is "any if() anywhere on either side", not "different guards"
rows at if-depth > 0 in main's CMakeLists.txt: 217 of 429
registry_build_self depth 2 registry_content depth 2 census_counters_self depth 0
More than half the row namespace is inside some if(), so any collision involving those is now cannot-tell — including the ordinary shape of this defect, where two lanes both add a row to the same if(Python3_Interpreter_FOUND) block.
The distinction the two cases actually need
The tool can tell them apart without configuring: record the enclosing guard's identity with each name, not just its depth.
registry_build_selfon both sides sits under the same guard (if(Python3_Interpreter_FOUND)), so when that block is on, both rows register — a real duplicate → rc 1;step_usersin your #2989 arm sits underif(ENABLE_X)on one side andif(ENABLE_Y)on the other — mutually exclusive, a name-only reading cannot know which is on → rc 2, exactly as you argue;- same guard text but nested at different depths is the only genuinely ambiguous residue, and that one belongs in the cannot-tell bucket.
Concretely: row_names() returns (line, guard_text) where guard_text is the innermost enclosing if(...) line as written (empty at top level), and the guarded branch triggers on taken[n].guard != known[n].guard rather than on either depth being non-zero. Your #2989 arm still passes (different guards), your #3018 arm is unaffected (subtracted by name), and the motivating case goes back to rc 1 — which is the only reason the row exists.
If you would rather keep the broad rule, then the row needs to say so where a lane meets it: the docs line and the tool's Exit: contract currently promise "a ctest row name the branch adds is already registered at the base tip", and with 217/429 rows exempt it is measuring a much smaller set than that sentence says.
|
VERDICT at cb60d75 ( Credit where it is due: my blocker 1 is gone, and the if()-depth rule is a better answer than my patch
Item A —
|
|
Two numbers for the decision on the family-file half, and a check that the patch in my last comment is directly applicable — so nobody has to hand-splice it to find out. Coverage of the row-name namespace, measured on main ( The 42 are whole families, not stragglers: No verdict change: CHANGES at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at cb60d75: READY, with one namespace gap the PR's own framing hides: it reads the base's CMakeLists.txt, but 42 rows in this tree are registered from cmake/*.cmake files that the same CMakeLists.txt include()s — same directory scope, so a duplicate name there fails Configure and this check reports clean.
The gap, measured on cb60d7588:
$ grep -rlE "add_test\(|add_python_test\(" cmake/*.cmake | wc -l → 5 files
$ grep -hcE "add_test\(NAME|add_python_test\(" cmake/*.cmake | sum → 42 rows
$ grep -nE "include\(.*cmake/" CMakeLists.txt → include(cmake/hrx.cmake) :1285, include(cmake/laya-ggml.cmake) :1538, …
$ head -4 cmake/tests-unreferenced-selftest-rows.cmake
add_python_test(gsm8k_eval_self ${CMAKE_SOURCE_DIR}/tools/gsm8k_eval.py --selftest)
add_python_test(mtp_depth_pool_self …) add_python_test(q4nx_diff_self …) add_python_test(seal_manifest_self …)
add_test's uniqueness is per CMake directory, and include() shares the directory scope — that is why the error you quote says "which already exists in this directory" rather than "in this file". So a branch that adds add_python_test(seal_manifest_self …) to CMakeLists.txt while the base already registers it in cmake/tests-unreferenced-selftest-rows.cmake is exactly the #3220 shape one namespace over, and ctest_row_name_check answers 0.
Cheap fix, same shape as what you have: build known from the base over CMakeLists.txt and the .cmake files the top-level one includes (or simply cmake/*.cmake — they are all includes of that directory), keyed by name → (file, line). The diff side can stay CMakeLists.txt-only if you say so: a branch that adds a row inside a cmake/*.cmake is rarer, and stating the asymmetry beats not having it. One arm for the cross-file case: base row in cmake/x.cmake, branch row in CMakeLists.txt, same name → rc 1.
What is already good, and I checked rather than assumed — these are the three ways this class of check usually lies, and all three are handled:
- comments: both sides go through
row_names(), which skips#lines (:92-93), so a commented-outadd_test(NAME Xneither counts as registered in the base nor as added by the branch; - the same diff removing and re-adding the name (engine#3018) is not a duplicate —
freedis subtracted, which is the half most duplicate checks forget; - a name registered twice inside different
if()branches (engine#2989) returns 2 cannot-tell with the one action that answers it (configure the tree), instead of a red row on a merge that was correct.
And --unified=0 + git diff <base>...HEAD + the shallow-clone → 2 rule are the right primitives: a clean diff in a depth-1 clone proves nothing, and the tool says so rather than passing.
One smaller thing while you are in the file: the repo's add_python_test wrapper is read as a spelling, which is right, but nothing asserts that the wrapper's own definition (a function(add_python_test …) in cmake/) is not picked up as a row — it is not, today, because the regex needs add_python_test( immediately followed by a name and the definition has a space-and-parameter there. That is a property of the regex rather than a decision; one arm pinning it costs a line and stops a future relaxation of ROW_RE from registering every wrapper call's first argument as a row.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at cb60d75: READY on the substance — with one placement note that is now the whole difference, since #3224 did not merge.
What this head fixed, verified
$ python3 tools/ci/ctest_row_name_check.py --self-test
ok an unresolvable --base is cannot-tell, not a pass
ok a shallow clone is cannot-tell: the merge base is outside the truncated history
Those two arms are the ones that make a namespace check safe to run anywhere: a check that cannot read the base must answer cannot-tell, not "no collision". Added to the rc semantics I checked two heads ago (1 with the colliding rows named, 0 clean), the tool itself is now the one I would keep of the pair.
The placement note, and it is not a nit this time
add_test_collision_check.py is not in main — #3224 did not merge, so this PR is the surviving instrument. That changes what "keep #3224" meant when I wrote it: the reason I preferred #3224 was never its size, it was that its check was a pre-PR row, and a pre-PR row can stop the push that would have worn the red build. This one registers as a ctest row (CMakeLists.txt:712/725, pre_pr_checks_*), which runs after the push — i.e. it reports the Configure collision that engine#3223 is about in CI, one build slot later, on the branch that already lost.
So the remaining work is one line, and it belongs in this PR rather than a follow-up: add tools/ci/ctest_row_name_check.py --check --base origin/main to scripts/pre-pr-checks.sh's checks=() (plus its docs/pre-pr-checks.md row, which the page/runner agreement enforces). Then the tool both catches the collision before a lane pushes and keeps the CI row that grades a branch that slipped through. With the --base-unreadable arm above, that row is safe for every lane on a shallow clone — which is why the arm matters more here than in most tools.
If the author would rather keep it CI-only, say so explicitly in the body: a lane reading "no row this branch adds is already named in origin/main" before pushing is the behaviour the issue asks for, and a green CI row afterwards is a different promise.
|
VERDICT at this head: READY — the diagnosis is exact, the placement is right (pre-PR gate, where the collision is still cheap), and the scope question is answered rather than dodged. Two notes. What makes it correct rather than merely useful:
Two notes, neither blocking:
The self-referential detail in the body is worth keeping exactly as written — the checker that catches an unwired self-test said so about this file on the first build — because it is the only evidence anyone will have that the gate is load-bearing rather than decorative. |
Fixes #3223. A pre-PR row that catches a ctest row name the base tip already registers — the Configure failure that killed #3220 tonight on a change that was correct.
The shape, measured twice on 2026-11-21
registry_build_selfmerged tomainat 17:06:10 (b299efbc4, #3217). #3220's branch was cut before that and adds the identical line; #3219 carries the same hunk on an older base and is green. Nothing was wrong in either PR — and nothing in the gate could see it:pr_branch_stale_checkmeasures deletions,duplicate_fixes_checkgroups by issue (these were two different issues), and CMake only complains at Configure, after a push, on one side.What this adds
tools/ci/ctest_row_name_check.pyintersects the row names a branch adds (git diff <base>...HEADoveradd_test(NAME Xand the repo's ownadd_python_test(Xwrapper — one namespace, both spellings read) with the names present in<base>:CMakeLists.txt, the base tip, because that is where the duplicate appears. Rebased, the diff stops adding the row and the check goes quiet, which is the fix.Narrow on purpose:
CMakeLists.txtonly, and a name computed from a variable is not guessed at.Exit 2 rather than 0 when the clone is shallow (a depth-N clone cannot compute
base...HEAD, so a clean diff proves nothing — engine#3106's rule) or when the base cannot be read.Live reproduction of the real shape
A branch cut before #3217 merged, adding the row it could not see:
Seven self-test arms, and one of them caught a bug in my own fixture
Hermetic: the re-added name; the cross-wrapper case (
add_test(NAME Xin the base vsadd_python_test(Xin the branch); a fresh name; a variable-computed name (not guessed at); an unresolvable base → 2; and a realgit clone --depth 1→ 2.The fixture first committed onto
maininstead of a branch, somain..HEADwas empty and three arms passed vacuously — arm 1 failing is what exposed it. Fixed by branching in the fixture, and left in the message because an arm that cannot see a diff proves nothing.Wiring
--baserows;docs/pre-pr-checks.mdline in the runner's order (the page-vs-runner check refused my first attempt — the row had gone in above the table);tool_selftest_wired_check, tightened in tool_selftest_wired_check: the marker has to sit on the line that names the tool (engine#3216) #3219 an hour ago, flagged it on my first run. The rule working on the lane that wrote it.pre-pr-checks --self-test8/8, gate 14 green / 3 skipped,tool_selftest_wired_check95 tools all referenced.