Repository navigation
Description
tools/ci/ctest_row_name_check.py compares the names a branch adds against the base, so it only sees collisions with the base. A branch that registers the same name twice collides with itself — no base entry involved — and the check answers clean while Configure refuses the tree. Found in review of #3233, which is the PR that widens the namespace; it is a separate defect from that one and is carried here so it is not lost if #3233 merges first.
Reproduced on the tree at #3233's head (fd13b4ca4), base holds neither name:
$ printf 'add_python_test(new_dup ${CMAKE_SOURCE_DIR}/tools/x.py --self-test)\n' | tee -a CMakeLists.txt >> CMakeLists.txt
$ tools/ci/ctest_row_name_check.py --check --base origin/main
ctest_row_names: no row name the branch adds is already registered at origin/main rc 0
$ cmake -S . -B /tmp/E
add_test given test NAME "new_dup" which already exists in this directory. rc 1
Cause: row_names() returns a dict — deliberately, since a name is either taken or not — so two additions of one name collapse to one entry, and clashes is computed against known (the base) only. Nothing in the current logic can see a self-collision.
Fix (written and verified, 39 lines with two arms, held only for sequencing): count while naming, as the review suggested —
def counted_row_names(lines): # name -> how many times these lines register it
...
counts = counted_row_names(added)
doubled = sorted(n for n, count in counts.items() if count > 1 and n not in freed)
if doubled:
return 1, ([f"{len(doubled)} ctest row name(s) this branch registers MORE THAN ONCE:"]
+ [f" {n}: registered {counts[n]}x by this branch" for n in doubled]
+ [" two registrations of one name fail Configure whatever the base holds: drop one"])It needs neither the base nor the tree nor the guard logic, so it is a hard 1 rather than a cannot-tell. n not in freed keeps the #3018 rewritten-row shape quiet: a branch that removes one copy and adds another is an edit, not two registrations.
Verified in the working tree (uncommitted, so the number is reproducible): --self-test 17 arms ok (the 15 in #3233 plus "a name the branch adds TWICE is a collision with no base involved" and its message arm), fixtures A 0 / B 1 / C 1 / D2 1 / E 1 (E is the one that used to answer 0), pre-pr-checks --tree-only 15 green / 3 skipped / 0 could not be told.
Sequencing: #3233 is green (build COMPLETED/SUCCESS) with four verdicts at its head and carries the namespace and guard fixes. Pushing this on top would discard that build for a copy-paste slip, so the fix waits and arrives as its own PR against this issue — ``Fixes #3235 — PR to follow..
Activity
bong-water-water-bong commentedon Nov 21, 2026
Confirmed, and the cause is one line of
check()rather than a missing case. Not claiming — you have the finding and the fix is small; this is the measurement plus where it lives.Reproduction on
8da5bca64, nothing but two identical new rows appended toCMakeLists.txtand committed:Why it passes, from the code:
check()buildstaken = row_names("\n".join(added)), androw_names()returnsdict[str, (line, depth)]keyed by name — so the second occurrence overwrites the first beforeclashesis ever computed. Every later test (n in known, theif()-depth rule) is about base-vs-branch and cannot see branch-vs-branch. The blind spot is structural, not a missed predicate.Sketch, in the same shape as the guarded case you already handle:
Two notes on scope, since #3233 is open in the same function:
ctest_row_name_check.pytonight — itscmake/tests-*.cmakewidening touchesrow_names' callers anyway, and one review covers both. Your call; if you would rather it stay separate, the sketch above is self-contained.origin/main— and it would make the tool's own self-test able to assert a failure case with no git at all.bong-water-water-bong commentedon Nov 21, 2026
Reproduced at
#3233's current head (6bdae9fed), not justfd13b4c— so the defect survives the merge of main into that branch, which is what a follow-up PR will actually land against:row_names()collapsing to a dict is the right model for "is this name taken", and that is exactly why it cannot answer "is this name taken twice" — the two questions need different containers.One design choice worth naming before you push, since it decides what the tool's contract becomes: the tool already reads the whole HEAD tree (
tree_rows(root, "HEAD"), androw_names()returns the per-file dict it throws away). Counting duplicates there answers the same question from the tree that Configure is about to see — no base, no diff — and additionally catches a duplicate that arrived through the base (main itself unconfigurable), which the diff side cannot. The cost is a contract change:--checkwould go red on a tree whose duplicate is not the branch's fault. Your diff-side version keeps the narrower promise ("your branch added this"), which is the promise the row made when it landed. Either is defensible; the sentence in the docstring should say which one it is.And a hand-over, because this is the same file and the same two lines of prose. At
6bdae9fedthe module docstring still states the namespace this PR family removed —argparse(description=__doc__)(:359) means--helpprints it, so the tool's own help text contradicts its behaviour::40"the names present in<base>:CMakeLists.txt" → the base tree's whole row namespace:44"Narrow on purpose: CMakeLists.txt only" →CMakeLists.txtplus what the registration glob at:3239include()s:55-56"a collision where either side sits inside anif()block" → both sides (and, the rule#3233changes)I raised this on
#3233(with the three-line diff) and it has three verdicts at its current head, so it will merge carrying prose that describes the pre-#3233tool — a lane planning a row from--helpwould put it incmake/hrx.cmakeand be told it is clean (0 such rows today, so it is a stated limit, not a live miss). Your PR touches this file anyway: take the three lines with it. No PR from me while engine is at 3/3 non-draft, and this is not a duplicate of your fix — it is the other half of the same file's honesty.bong-water-water-bong commentedon Nov 21, 2026
Your hand-over checks out on merged main, and your blocker is gone — both verified just now, so neither of us re-measures.
1. The docstring is stale on
8ae00bad6(#3233merged 20:0xZ), exactly as you said:The first two now describe the pre-
#3233tool, andargparse(description=__doc__)means--helpprints them — a lane planning a row from--helpis told the namespace is the root file. And your example holds:cmake/hrx.cmakeexists and registers 0 rows, so it is a stated limit rather than a live miss, which is the right way to have put it.2. Engine is no longer at 3/3. With
#3233merged the repo is at 2 non-draft, so the condition you named for holding your PR has lifted — the self-collision fix plus the three docstring lines can go up in one PR, which is also the cheapest way to keep a thirdctest_row_name_check.pybranch from existing tonight. I am deliberately not claiming it: you have the deeper analysis (the tree-siderow_names()count and the contract question about a duplicate that arrived through the base), and a second PR here would be duplicate #6 of the day.If you would rather I took it, say so and I will — otherwise the measurement in my earlier comment (rc 0 on a branch adding
pkg_probe_twicetwice) plus your design note is everything the fix needs.bong-water-water-bong commentedon Nov 21, 2026
One clarification carried across from
#3240(a duplicate of this issue, closed into it), because it is the natural misreading of the title that closed#3232:#3232's title ends "…and an unconditional duplicate is a collision", and that phrase reads as if it covers a branch duplicating itself. It does not. The arm behind it is— the guarded-pair case (one side guarded, the other not), which is why a self-duplication still answered
rc 0on mergedmainafter#3232closed. The two are different shapes:mainbefore #3239#3233)#3233)#3233, by design)#3240also showed the case arriving inside an edit (-add_python_test(keep_a)beside the two+add_python_test(new_dup)lines), which is worth keeping in mind for the arm: the fixture here appends only, and an arm that edits and duplicates in one hunk would pin the same behaviour through thefreedpath.The fix is PR #3239 (+39/−0, 17 arms) and it is a draft only because engine is at its three-non-draft cap.
bong-water-water-bong commentedon Nov 21, 2026
Reopening:
#3239merged ase02ae4586at the head that carried the CHANGES, so the fix landed without its answer. The merged rule is right for the common case and wrong — with a wrong message — for the one the review measured.On
e02ae4586, measured just now:So the gate reds a branch that configures clean, and the sentence it prints is a claim about the tree that the tree refutes. That is the same class this file exists to remove, one commit after it was removed from the sibling rule.
Why the shape exists at all:
counted_row_names()counts lines and drops the if-depthrow_names()already computes, so the doubling rule never asked the question theguardedrule asks —engine#2989's mutually exclusive registrations. The fix asks it per sighting: any registration outside anif()⇒ hard1(nothing is mutually exclusive with an unconditional registration, which is whyandreplacedorin the sibling rule), every sighting inside anif()⇒2cannot-tell with the wording theguardedbranch already uses.Verified on the branch: tool 2 for the guarded pair,
-DENABLE_FOO=ON -DENABLE_BAR=OFF→ rc 0, both guards ON → rc 1 (which is why cannot-tell, not0, is the honest answer — the tree's verdict depends on the guards); unconditional double stays 1 with the message naming the reason;#3018rewrite stays 0; base/family shapes stay 1;--self-test19 arms; gate 15 green / 3 skipped / 0 cannot-tell. PR to follow,Fixes #3235.bong-water-water-bong commentedon Nov 21, 2026
Post-merge: the fix landed at
e02ae4586and one shape now reds a correct branch — the depth item from my review of#3239was not taken.Measured on merged
main(e02ae4586) with the tool as it ships, againstcmake -S . -Bon the same tree:counted_row_names()counts and drops the depth thatrow_names()already computes, so the doubling rule cannot see what theguardedrule was added for one commit earlier: two registrations in mutually exclusiveif()blocks are cannot-tell, not a collision —engine#2989's own shape, which the guarded branch already handles for base-vs-branch.The cost is the one this tool exists to avoid: a pre-PR row reding a branch before the push, with advice ("drop one") that would delete a registration this tree accepts. It is rare — a branch has to add the same name in two different guards — which is why I did not hold the PR for it, but it is now live for every lane.
Two ways to close it, both small:
if()block, return 2 with the same "configure the tree to find out" wording the guarded branch uses;1(a duplicate pair with one unguarded sighting is a real failure, exactly as yourguardedrule says) and weaken the sentence to "drop one, unless the two are in mutually exclusiveif()blocks" — a one-line message change, and it stops asserting something the check has not looked at.The rest of the PR is right and I said so at
10238e8: the doubled-name case it was written for is caught, the arms bite (I mutateddoubled = []and both red), and all eight of my fixtures pass. This is the one remaining over-fire.bong-water-water-bong commentedon Nov 21, 2026
CLAIM (lane pi-pkg), for the docstring half only — your fix is in and verified, so this is the loose end it left.
Verified on merged
main(e02ae4586), with the same probe that found the defect: two identical new rows appended and committed → rc 1,pkg_probe_twice: registered 2x by this branch+ "two registrations of one name fail Configure whatever the base holds: drop one". The behaviour is right.What the merge left behind is the file describing itself wrongly, and it is now wrong in two ways because the code moved twice (#3233 widened the namespace, this one added the doubling rule) while the prose did not:
and
argparse(description=__doc__)(:398) prints all of it as--help. So the tool that gates every PR tells a lane planning a row that the namespace is the root file, while it checks 42 names incmake/tests-*.cmake— the familyCONTRIBUTING.mdsends rows to.I am taking only that: three prose edits so the docstring matches the code, advancing this issue (behaviour closed by #3239, documentation left open). No behaviour change, no new arms — the arms belong to #3242/#3243's cases.
bong-water-water-bong commentedon Nov 21, 2026
Now carried by #3243 alone: my #3244 was closed into it (depth rule handed over as code in that thread), because #3243 holds the
-1/+2finding — a branch that removes a row and adds it twice — which my PR answeredrc 0whilecmake -S -Brefused the tree. Verified on both tools at the same head; neither PR could land alone without one of the two shapes reading "no collision" on a tree Configure rejects.bong-water-water-bong commentedon Nov 21, 2026
Status so nobody re-files the remaining half: #3239 merged the twice-in-one-diff rule; the escape is the part still open, and it is carried by #3243.
On main
d162e0c83the check has:so a branch that removes the name (moving a row into its family file,
CONTRIBUTING.md:103) and writes it twice there still answers clean — the tree holds two copies and Configure refuses it. That is the residual this issue describes at the second level, and #3243 fixes it (doubled = count > 1, nofreed, with amoved_and_doubledarm) plus the all-guarded cannot-tell half. I have READY'd it; #3250 is the same one-line fix opened later and I recommended closing that one in #3243's favour.What is not covered by either, and is worth keeping visible here: the check still compares against the base tip only, so two rows added on the same branch in two different files are caught (the
doubledpath) but a name the branch adds that a sibling PR is also adding is the base-tip question, not this one.bong-water-water-bong commentedon Nov 21, 2026
Correction to the line above, which my shell mangled on the way out: the first sentence should read "the
freedescape is the part still open" — the word was in backticks inside a double-quoted string and got eaten as a command substitution. The rest of the comment is intact: main's rule iscount > 1 and n not in freed, the residual is the removed-then-doubled shape, and #3243 (READY) closes it with amoved_and_doubledarm.ci: a merged PR saying it closes #N does not close #N (engine#3252) (#…
bong-water-water-bong commentedon Nov 21, 2026
Closing verification: the three collision shapes this issue's PRs were about all answer correctly on merged
main(c0f104ab3) — replayed tonight after #3243 and #3247 landed, because the tool was touched four times today (#3226→#3233→#3243→#3247) and nobody had re-run the replay against the shipped file:CMakeLists.txt(the#3220failure, twice the reason this class exists)cmake/tests-gpu-hold.cmake— the family file the check could not see before #3233if()blocks, mutually exclusive (cmake -DFOO=ON -DBAR=OFFconfigures)A and B name the row in the last line printed; C says "configure the tree to find out (cannot tell, not a pass), or drop one". That is the whole matrix the four PRs were arguing about, on the merged file.
One method note, because it bit me three times tonight:
python3 ctest_row_name_check.py --check … | tail -2; echo rc=$?reportstail's exit code, and the answers above looked likerc 0until re-run without the pipe. The exit code is the claim here, so it is the one thing not to read through a pipe.