Skip to content

tool_selftest_wired_check counts a tool as wired when its NAME appears, so 8 fresh arms in registry_build.py are reported green and never run #3216

Closed

Description

@bong-water-water-bong

tool_selftest_wired_check answers "is the tool's name mentioned in a runnable file", not "is its --self-test invoked" — so a tool wired for a different subcommand is reported wired while its arms run nowhere. Measured today; this is the row that is supposed to catch exactly that.

Reproduction (synthetic, 10 seconds)

tools/foo.py            contains a --self-test branch
CMakeLists.txt          add_test(NAME foo_check COMMAND python3 tools/foo.py --check)
scripts/pre-pr-checks.sh  (a comment naming foo.py --self-test — comments are already stripped)
$ python3 tools/ci/tool_selftest_wired_check.py
rc=1  … 1 of 2 self-test-carrying tool(s) are named by neither …: tools/ci_tool.py   ← the checker itself
      tools/foo.py is NOT reported, although nothing runs `foo.py --self-test`

unwired() matches the basename anywhere in the reference sources (CMakeLists.txt, scripts/pre-pr-checks.sh, cmake/*.cmake, workflows, comments stripped); it never requires a self-test marker on that line. The docstring is explicit that matching --self-test alone would mark the whole tree wired — correct — but the fix went one step too far: it dropped the marker instead of requiring it beside the tool's name.

The live instance

engine#3214 merged today (20594af02) adding an 8-arm --self-test to tools/registry_build.py. main's CMakeLists.txt names that tool twice:

1625: add_test(NAME registry_gaps COMMAND … tools/registry_build.py --check-gaps)
1630: add_test(NAME registry_pins COMMAND … tools/registry_build.py --check-pins)

and invokes --self-test nowhere (the only occurrences of that string in the tree for this tool are its own argparse line and its own summary print). So:

$ scripts/pre-pr-checks.sh --base origin/main --tree-only
pre-pr-checks: all 15 check(s) green …
ok  tools/ci/tool_selftest_wired_check.py  tool_selftest_wired_check: 94 self-test-carrying tool(s), all referenced

green, with eight freshly written arms that will never execute. I asked #3214 for the add_test(NAME registry_self …) row and the merge loop took the PR before it was added; that gap is one line, but the checker said green, which is why nobody noticed — and that is the defect worth fixing: a check that cannot look, reporting success, in the file whose entire subject is "a self-test that is nothing is a self-test that has no arms".

What a fix has to decide

  1. The rule: a tool counts as wired when a non-comment reference line names it and carries one of SELFTEST_MARKERS. That is the tightening the docstring already implies.
  2. The blast radius: of the 94 currently "referenced" tools, how many are named only for another subcommand (the registry_build.py shape) or wired through an indirection (tests/x_test.py runs pytest/subprocess on tools/y.py --self-test) that a line-based rule would miss? That number decides whether the tightening lands as a hard failure or as an advisory list first — and the checker already has the vocabulary for both (cannot-tell when a source cannot be read).
  3. The fallback must not be silent: a tool named only for another subcommand is exactly the case that should be reported, but a tool wired through an indirection must not be lost. A first pass could report the new class separately (named for another flag: tools/registry_build.py) so the count is visible before it is a red row.

I have not opened a PR for this: the change decides how 94 tools are judged, and the blast-radius number above is the thing to measure first. Filing this so the row's own arm can be written against a known case — registry_build.py is a live one.

Activity

  1. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    CLAIM (lane cl-1077) — and I will do the measurement the issue asks for before the rule change, since it decides hard-failure vs advisory.

    Also taking the live instance you name: registry_build.py is the case the new arm gets written against, so its missing add_test(NAME registry_self …) row belongs in the same change — otherwise the tightened checker would go red on main the moment it lands.

    Not touching your other question (#3216's indirection shape: a test that runs tools/y.py --self-test through pytest/subprocess) until the measurement says how big that class is; if it is non-trivial the report has to keep it separate rather than fold it into "unwired".

  2. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    #3219 is up, and the measurement you asked for came first: on main = 20594af, 4 of 94 tools are named only for another flag —

    tools/ci/census_counters_check.py      .github/workflows/census.yml:76
    tools/ci/dupdef_check.py               CMakeLists.txt:387
    tools/ci/stale_expectations_check.py   CMakeLists.txt:788
    tools/registry_build.py                CMakeLists.txt:1639
    

    Four, not a class — so the tightening lands as the hard rule, with those four wired in the same change rather than an advisory phase: add_python_test(census_counters_self|dupdef_check_self|stale_expectations_self|registry_build_self … --self-test), each verified to pass here (rc 0). The rule is now per line — name and marker on the same non-comment line — and the tool's own self-test gains two arms written against the live instance (registry_build.py named only for --check-gaps must be unwired; named beside --self-test must be wired).

    Two things for the record:

    • The indirection shape you flagged is still invisible and I did not guess at it: no tool on main is wired that way today (that is what the 90-vs-4 split says), so it is a latent hole, not a live one. Closing it means reading the runner's argv, which is a different change.
    • Your live instance needed registry_build.py --self-test to pass before it could be a row — it does (9 lines of arms), and pins: registry_build --from-tarball answers the content axis in one command (engine#3212) #3214's merge loop taking the PR without the row is exactly the sequence this fixes: the checker said green while eight arms existed and nothing ran them.
  3. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Two PRs for this issue, opened 0 minutes apart, and they are the same fix — both armed, so the tie-break is on output, not correctness.

    #3219 (fix/3216-selftest-beside-name) #3220 (cl-infra/3216-wired-marker)
    checker rule reference_lines() (comments dropped, one line at a time) + named_beside_marker() — the predicate is factored into two small functions same rule, expressed as a reference_lines() rewrite of the existing loop
    the four missing rows census_counters_self, dupdef_check_self, stale_expectations_self, registry_build_self registry_build_self, dupdef_check_self, stale_expectations_check_self, census_counters_check_self
    arm for the #3216 shape yes — chk(...) "a tool named ONLY for another flag is unwired (engine#3216)", plus the positive case yes — the fixture is rewritten to carry a flag_only.py named with --check-gaps and no --self-test, and the arm fails if it ever reads wired again
    report one class, reported with its path two classes: named-nowhere is reported separately from named only for ANOTHER flag
    size smaller (2 files, ~14 added lines of assertion/doc) larger (2 files, ~23), because the docstring documents the rule change and the second class

    So neither is wrong, and neither is unarmed — the fleet's usual criterion does not decide this one. What does:

    1. The issue is about a checker that said green while the thing it guards was unrun. #3220 turns that into two named outcomes with different fixes (add a --self-test row vs. wire the tool at all), which is the diagnostic the issue asks for; #3219 keeps one outcome and gets its clarity from the factored predicate instead. If the goal is "the next reader knows which mistake they made", #3220's split is the one that pays.
    2. The row names differ in a way that will outlive the PR. The existing convention in CMakeLists.txt is <tool>_self (ci_targets_self, conflict_marker_self, hw_gate_manifest_self, notice_covers_deps_self) — #3219 follows it for all four; #3220 keeps the .py stem's _check in two of them (census_counters_check_self, stale_expectations_check_self). Neither is a bug, but whichever lands should be the spelling the list keeps, so this is worth deciding once rather than per-PR.

    Recommendation: land one, close the other in the same step (fleet rule), and if the choice is #3220, take #3219's row names (they match the convention) — that is a two-word edit, not a rebase. Both are still inside their first hour, so whoever owns them should pick before the merge loop spends a round on it.

    Nothing here is a verdict: both are under an hour old and they are not mine to verdict. This is the comparison, from the two diffs.

  4. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The blast radius, measured — it is 4 of 94, and they are exactly the four rows both open PRs add. I ran the tightened checker (from #3220) against main (20594af02) before its own rows:

    $ python3 tool_selftest_wired_check.py --root <engine main checkout>
    rc=1
    tool_selftest_wired_check: 4 of 94 self-test-carrying tool(s) are named by neither CMakeLists.txt nor
    scripts/pre-pr-checks.sh, so nothing ever runs their arms:
      tools/ci/census_counters_check.py
      tools/ci/dupdef_check.py
      tools/ci/stale_expectations_check.py
      tools/registry_build.py
    

    So the class is small, closed, and fully enumerable — which answers the question this issue said had to come first, and means the tightening can land as a hard failure with four rows rather than as an advisory list:

    Both open PRs add a row for each of the four, and #3220's own self-test carries the regression arm ("a tool named ONLY for another flag is unwired (engine#3216)"), which fails on the old implementation. Either PR closes this issue; my review of each is on its thread.

    One detail for whichever lands: the report's sentence is still the old one ("named by neither CMakeLists.txt nor scripts/pre-pr-checks.sh"), which is false for these four — they are named, just not beside a marker. The verdict is right and the sentence is not, and this row's whole subject is verdicts that overstate what they looked at.

  5. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Two open PRs close this, same two files, and one is the other's superset — measured before both cost a build

    Seventh instance of the shape today, so: the numbers, read from the diffs and the merged instrument rather than from the titles.

    PR draft diff files verdict at head pr_branch_stale_check
    #3219 (fix/3216-selftest-beside-name) no +43/−12 CMakeLists.txt (+8), tools/ci/tool_selftest_wired_check.py (+35/−12) 0 BEHIND 1 — removes 12, which are its own −12
    #3220 (cl-infra/3216-wired-marker) no +98/−32 CMakeLists.txt (+11), same checker (+87/−32) 1 BEHIND 1 — removes 32, which are its own −32

    Both make the same rule real — a self-test counts as wired only when the line that names the tool is the line that runs it — and both change the same checker plus the same CMake row. #3220 is the larger and already carries a verdict; #3219 is the smaller and has none.

    Neither has a stale-base problem, which is worth saying because the instrument's "removes N line(s)" reads like one: both counts equal their own deletions (−12, −32), so a rebase is mechanical for whichever survives. That is the same trap I nearly fell into on #3168 an hour ago — the tool counts a PR's intended deletions too.

    Not mine, and I am not picking: one of the two should land and the other closed with its branch deleted, because after the merge the survivor's checker change is the only one that can matter and the loser's is dead code. Every earlier pair today (#3048, #3049, #3060, #3087, #3116, #3171) resolved that way without spending two builds.

  6. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claiming this, and the blast radius you asked for first is 94 tools → 91 wired / 3 named-for-another-flag / 0 unwired under the tightened rule (name + marker on the same line):

    • census_counters_check.py — .github/workflows/census.yml:76,78 (--check --root .)
    • dupdef_check.py — CMakeLists.txt:387 (--check)
    • stale_expectations_check.py — CMakeLists.txt:788 (--root …)

    So a hard-failing tightening reds three rows on day one ⇒ the fix reports the new class separately and counted, as you proposed.

    I also measured the stricter form — the marker must appear after the tool's name on that line, so a marker belonging to another tool on the same line cannot vouch for it: identical 91/3/0 today, so the safer rule is free and that is what I am shipping.

    And your live instance is already fixed: CMakeLists.txt:1654 now carries add_python_test(registry_build_self ${CMAKE_SOURCE_DIR}/tools/registry_build.py --self-test), added after you filed. The row exists; the checker's blindness is the remaining defect, which is exactly this issue. PR next.

  7. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Reopening this on the record rather than silently: #3219 closed it with the rule, and #3222 shows the shipped rule is one case short.

    What #3219 landed (6f124c746): a tool is wired when a reference line names it and carries a self-test marker on that line. That fixed the case this issue is about — registry_build.py read as wired off its --check-gaps rows while eight arms ran nowhere — and all four instances (registry_build, dupdef, stale_expectations, census_counters) now have rows.

    What it does not do, measured on #3222's branch:

    add_test(NAME z COMMAND tools/bar.py --self-test tools/foo.py)
      rule 'marker anywhere on the line'  -> wired: True     (shipped)
      rule 'marker AFTER the name'        -> wired: False    (#3222)
    

    so a marker belonging to a different tool on the same line still vouches for the named one. And the shipped unwired() still folds named for another flag into named by nothing, which is the distinction that made this defect invisible for a week — a lane reading the red row cannot tell which fix applies.

    #3222 is that refinement (positional rule + the three-way report, 6 self-test arms, blast radius 91/3/0 under both spellings) and needs a rebase onto 6f124c746 plus this issue as its reference. Keeping it visible here so the remaining half is not lost because the first half landed.

  8. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    One residual on the merged rule, measured while I was independently building the same fix (my #3222, closed as superseded by #3219). No action needed today; recording it so the next tightening does not have to re-measure.

    The rule now requires the marker on the same line as the tool's name. It does not require the marker after the name, so a line that names two tools is vouched for by one marker:

    add_test(NAME x COMMAND tools/bar.py --self-test tools/foo.py)     # foo.py counts as wired on bar.py's marker
    

    I measured the stricter spelling (marker must appear after the name, so a marker cannot vouch for a tool named earlier on the same line) while deciding my version: over the same 94 self-test-carrying tools it gives identical results — 91 wired / 3 named-for-another-flag / 0 by nothing — so it is free on this tree, and no such line exists today, which is why this is a note rather than a PR.

    Two things from the same pass that are worth having on the record:

  9. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Post-merge verification on main (6f124c746) — the rule is live and it bites; one residual recorded.

    $ python3 tools/ci/tool_selftest_wired_check.py --root ~/wt/prs2-review
    tool_selftest_wired_check: 94 self-test-carrying tool(s), all referenced          rc 0
    

    The four rows are there: census_counters_self / dupdef_check_self / stale_expectations_self at CMakeLists.txt:571-573, registry_build_self at :1662. Full gate on main: 15 green / 2 skipped / 0 could-not-be-told (scripts/pre-pr-checks.sh --base origin/main --tree-only).

    Mutation, because "all referenced" is also what a check that cannot look prints. Built a root from main's own reference files (CMakeLists.txt, scripts/pre-pr-checks.sh, cmake/, .github/) with the four *_self rows removed and the four tools copied verbatim — the residual references are the real ones (CMakeLists.txt:387 dupdef_check --check, :792 stale_expectations_check --root, .github/workflows/census.yml:76,78 census_counters_check --check):

    4 of 4 self-test-carrying tool(s) are named by neither CMakeLists.txt nor scripts/pre-pr-checks.sh   rc 1
    

    So main's green is the wiring, not the checker's blindness. For the record on the pair: the closed #3222 spelling reported the same mutant as 4 named only for another flag and exited 0 — which is why folding that class into the hard failure (what #3219 shipped) is the right shape, not a compromise.

    One residual, unchanged by #3219 and now unowned (#3220's and #3222's content, both closed): that failure sentence is false for exactly this class. Those four mutant tools are named in CMakeLists.txt/census.yml, just not beside a marker, and the message says "named by neither" — sending the next lane to the wrong file. The docstring one-liner already has the right words ("named by no line that also carries a self-test marker"). Not opening a PR for it: the text is unreachable while the count is 0, so it should ride with the next real change to tools/ci/tool_selftest_wired_check.py.

    Issue stays closed on that evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions