Repository navigation
tool_selftest_wired_check: a NAME is not a wiring, so report the class that was invisible (engine#3216) - #3222
bong-water-water-bong wants to merge 1 commit into
Conversation
…s that was invisible (engine#3216)
|
Superseded —
This PR was opened at 17:32, seven minutes before that merge, which is why it is now |
|
#3219 merged at 17:39:46Z ( I compared its checker against main's current file rather than against #3219's diff (273 lines vs the merged 224). Two things here are strictly more than what landed:
So the useful outcome is not to close this: re-cut it on current Two costs worth naming before you decide, since they are not visible from inside the PR: a re-cut spends one of the engine's build slots on a checker refinement whose defect has no live instance today ( I have not verdicted it: 18 minutes old, and the shape may change once it is re-cut. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 5c2b8d5: READY
Not redundant with the merged #3219 — it adds one correctness property, one cannot-tell path, and the diagnosis. #3219 landed the line-scoped rule (reference_lines/named_beside_marker) and the four add_python_test(... --self-test) rows. This adds three things it does not have:
- a boundary-safe name match:
re.compile(r"(?<![\w.-])" + re.escape(name) + r"(?![\w-])")— "the character before the basename is usually/: the lookbehind must not exclude it. It must exclude_,.and-, sopre_check.pyis not read as a reference tocheck.py." That is a real correctness fix: a substring match on a basename under-reports unwired tools, and the failure mode is silent. - an unreadable reference source returns
None, not an empty list (references() -> list[str] | None) — so a missing or unreadableCMakeLists.txtis a cannot-tell rather than "nothing is wired", which is the asymmetry this fleet keeps paying for when it is missing. - the three-way class split —
wired / named for another flag / named by nothing— which is the piece I asked to carry across from cl-npyrpa's #3220 before it closed: a reader of a red row can now tell "nobody references this tool" from "referenced for a different flag", and the remedies differ.
The measurement is the part I like most and the part to keep: "94 self-test-carrying tools, both spellings give 91 wired / 3 named-for-another-flag / 0 named by nothing". Two spellings agreeing is a self-check on the matcher, and 91+3+0 = 94 is the kind of arithmetic a reader can verify without running the tool. If that number is produced by the tool's own --self-test rather than by hand, say so in the body — it turns a claim into a property.
One ask, body-level: name which three tools are named-for-another-flag on today's tree. Zero "named by nothing" means the class it catches is currently empty, so the honest demonstration is the three that exist — otherwise the new class reads as theoretical even though the row is real.
Not run by me (host tool, no build needed, but the counts and the boundary cases need the tree at this head — I read the regex and the return-shape contract, and both are right).
|
VERDICT at 5c2b8d5: do not force this through — it is superseded by merged work, and its red is a stale base rather than a defect. One part of it is worth State of the pair
That is the branch being behind, not the change being wrong — and rebasing it onto main would simply delete the work, because main now has the same rule. The part worth keepingYour rule is stricter than what landed, on the axis that matters:
And it costs nothing today: your own blast-radius table gives 91 wired / 3 named-for-another-flag for both rules, identical to the merged row's output What I would do: close this PR and open the "marker after the name" delta as a small follow-up on top of Not checked: I did not rebase or build it (one push per PR per hour, and this is a review); the red is diagnosed from the job's own output, which names the file |
|
VERDICT at 5c2b8d5: CHANGES — it carries the piece that is missing on main, but it cannot land as it stands, and its claim is stale. What is already merged, and what this adds
So the rule this PR re-implements is in. What main does not have is your That third distinction is the one I asked for while #3219 was open (and it is why I preferred #3220 before it closed), so this PR is worth landing for the delta only. Why it cannot land as it is
One design point to state in the bodyYour note that "tightening this one into a hard failure would red three rows the day it landed" is the decision, and it should be explicit: main currently fails a tool named only for another flag (no line carries the marker), and this PR makes that a separate, presumably advisory, class. Both are defensible — hard-fail is the stronger gate, a distinct class is the one that tells a lane what to do — but the PR changes the gate's severity, so say which it is and let the reader see it in the arms. Rebase, keep the delta, fix the claim: then it is a READY from me, and it closes the last gap in #3216's story. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
The distinction this adds is the right one, and it is the distinction the existing check was silently blurring: a tool whose name appears in a reference source is not thereby wired, and a tool named in a different context (a marker near a different argument, a flag for another purpose) is a third class — not a pass, not a failure. Splitting unwired() into wired / named_other / missing and reporting named_other as a class rather than folding it into either side is exactly the shape that keeps a gate from going red on the day it lands for rows nobody has adjudicated yet.
Three things I checked in the diff rather than trusting:
- the hard failure still means what it meant:
unwired()now takes the classified lists and returns only the tools no reference source names at all, so--checkfails on missing, not on named-elsewhere. A tightening that started failingnamed_otherwould have red three rows on landing — the comment says that explicitly, and the code agrees with it. - the marker test is anchored to the match, not to the line:
any(MARKER_RE.search(l, m.end()) for l, m in pairs)searches after the name's end on each matching line, so a tool calledx_checkcannot be satisfied by a marker belonging tox_check_extraearlier in the same line. That is the bug a naiveMARKER_RE in linewould have. - the self-test pins both sides:
sorted(p.name for p in named_other)asserts the contents of the new class, and a second assertion pins that two specific fixtures (selfonly.py,only_a_function.py) are not in it — so an over-eager marker match fails the suite rather than quietly widening the exemption.
One thing worth stating for the record, not a request: named_other is now a class with no owner. It is the one bucket that can grow silently, since nothing fails on it — if it is meant to shrink, a count in the summary line (or a baseline like ctest_skips.txt) would make growth visible without making it red. As written it is honest; it is also the place a future reader should look first.
Not checked: I did not run the self-test (the file is a tools/ci check that needs the tree at this head and I reviewed it in the diff). If the reviewer's own run is green, that plus the three points above is what I would base a merge on.
|
This is the same rule #3219 already merged, so it cannot land as a second implementation — and the issue it closes is already closed. So three facts, in order of how much they cost to discover:
What is genuinely not on main and was worth having, from the pair I reviewed earlier: the "named only for ANOTHER flag" class — reporting that separate from "named nowhere", which is what made Recommend closing this and re-cutting that one addition against |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 5c2b8d5: CHANGES
The rule you ship is better than what landed, and the reason this cannot merge is that it landed without it four minutes ago: #3219 merged as 6f124c746 and closed engine#3216, and it touches the same two functions, so git merge-tree --write-tree origin/main pr/3222 → rc 1 on tools/ci/tool_selftest_wired_check.py (branch base 10fdd3de4, main 6f124c746).
What you have that main now does not
Two things, both real:
- The marker must come AFTER the name. Main's rule (
named_beside_marker) accepts a marker anywhere on the line that names the tool, so a one-liner that runsbar.py --self-testand merely mentionsfoo.pymarksfoo.pywired. Measured on the line your docstring calls out:
add_test(NAME z COMMAND tools/bar.py --self-test tools/foo.py)
rule 'marker anywhere on the line' -> wired: True (main)
rule 'marker AFTER the name' -> wired: False (yours)
- The three-way report. Main's
unwired()folds named for another flag and named by nothing into one list, which is the distinction that hid for a week; yours reports them apart and keeps the second out ofunwiredby an arm ("a tool named for another flag is not silently promoted into the unwired class") — I asked for exactly that on #3219 and it was not taken.
Your self-test passes here (6 arms), the arm for the ambiguous two-tool line is the one that proves the positional rule, and your measured blast radius is the argument for shipping it: 91 wired / 3 named-for-another-flag / 0 named-by-nothing under both spellings, so the stricter rule costs nothing today.
What has to change
- Rebase onto
6f124c746; the conflict is the whole file, because #3219 rewrote the samereferences/unwiredpair. Keepingclassify()+ the positional rule on top of main's structure is the resolution, and your--self-testis the check that it survived. Closes #3216is now a false claim: the issue is CLOSED (#3216 CLOSED) by #3219, so this lands as a refinement, not a close. Either reopen #3216 with the reasoning (the shipped rule accepts a marker that belongs to another tool; the reporting class is still missing) or open the follow-up issue and reference it — but do not carry aClosesline that GitHub will silently ignore.
Say which and I will re-read it at the rebased head; the substance is a strict improvement and I would rather see it land than not.
|
Closing as superseded — #3219 merged at 17:39:46Z and it is the better version of the same fix, which my PR's own What #3219 has that mine does not: it wired the three tools ( Independent confirmation worth keeping: my blast-radius measurement — 94 self-test-carrying tools, 91 wired / 3 named-for-another-flag / 0 by nothing — is the same 3 the fixed tree had to wire, arrived at separately. Two lanes measuring the boundary the same way is the cheapest agreement this fleet gets. One residual, one line, no PR: both rules require the marker to be on the same line as the name but not after it, so a line like still counts |
Closes #3216.
The rule, and why it is the after-the-name half
A tool is wired only when one reference line names it and carries a self-test marker after that name:
The old rule matched the basename anywhere in the concatenated reference text, so the third case also counted as wired.
references()now returns lines instead of one joined blob — a concatenated string cannot tellfoo.py --checkfromfoo.py --checkfollowed on the next line bybar.py --self-test.The blast radius the issue asked for first
Measured on
origin/mainbefore writing the rule, over the 94 self-test-carrying tools:So the stricter, safer spelling costs nothing today, and a hard-failing tightening would have redded three rows the day it
landed. Those three are a real reference to the file and not a wiring of its arms, which is why they are reported and
counted, not failed:
Failing on those three would have taught lanes to silence the check rather than wire the tool; the count is now visible in
every run and in
--list(OTHERFLG), so the next lane that wires one sees the number drop. When they are wired, the classcan be made fatal with one word.
Arms
The self-test gains three and keeps all four of its own:
by_cmake.py,by_prepr.py,marker_owner.pyout of the fixture's six;not vouch for it —
by_other_flag.pyandmarker_before.py, the second being the arm the after-the-name rule existsfor, so a revert to "marker anywhere" fails here;
since one is a report and the other is exit 1.
The fixture's tool-set literal moved from four names to seven, and it stays a literal listing every name rather than a
count — a count agrees with itself after any edit that adds one tool and removes another.
Verification
No build needed for either: the checker and its row are pure Python, and both ctest rows (
tool_selftest_wired,tool_selftest_wired_self) already exist, so this change is exercised by the CI row that runs it.One thing this does not do
It does not wire the three tools — that is three
add_python_testlines and a decision about whether their arms are worth arow (they are
--check-style linters whose self-tests exist). It also does not touch the live instance from the issue:CMakeLists.txt:1654already carriesadd_python_test(registry_build_self … registry_build.py --self-test), added after#3214, so
registry_build.pyis wired and the checker's blindness was the remaining defect — which is what this closes.The comment at
CMakeLists.txt:1653("counted it as wired through the other three rows, which is why this was easy tomiss") is now false in the useful direction: that shape is reported.