Repository navigation
merged_tail_check: a token the file already carried cannot make a dropped line SUPERSEDED - #2732
Conversation
…pped line SUPERSEDED The token test asks whether main carries a missing line's longest identifier and whether a later commit changed its occurrence COUNT. A word the file already carried answers yes to both for a line that was never there -- and SUPERSEDED exits 0, so the failure is a real loss reported as a clean scan. Measured on a fixture built for it (the old word appears twice before the merge so the later commit can make its count DROP): without the guard the dropped feature reads SUPERSEDED, with the guard it reads LOST. The arm fails when the guard is removed, so it is load-bearing rather than decorative. #2504 is unaffected and still resolves through the token: httplib is absent from its file at the merge commit fafcf59 and present three times on main, which is exactly the new-token case. A 200-PR scan over three days reports the same single SUPERSEDED row. This replaces the shortcut: comment that named the upgrade ("requiring the token to be absent from the rest of the base file before the merge") and asked for it to be done.
|
READY — and it is the correct closure of a shortcut this tool has been carrying since it was written.
The The measured table is the right shape, and the omission in it is deliberate and correct:
Two rows, both directions, on a fixture built to make the old word's count drop — because with a One thing I would pin: The new guard's failure mode when the base file cannot be read. Credited: quoting the Not verified by me: the self-test run. The two-direction table, the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 48fe9d4: READY
I built the fixture this PR is about independently of the one in the body, and it discriminates: main reports a genuinely lost line as a clean SUPERSEDED, this head reports it LOST.
The fixture
The added line's longest identifier is a name the file already carried twice, and a later unrelated PR drops one use of that name — so git log -S <token> fires, the token is present in the base, and the old code calls the loss a supersession:
base at the merge : route_ports_lock_helper = make_helper()
route_ports_lock_helper.install() <- the token twice
branch adds : route_ports_lock_helper(http_guard_test.bind_to_any_port) <- never lands
after the merge : an unrelated PR removes one use of route_ports_lock_helper <- -S fires, count 2 -> 1
main (b…, token test as merged): SUPERSEDED <- exit 0 on a real loss
#2732 (this head) : LOST <- right
That is the shortcut: comment's own words ("a word the whole file already used cannot decide it") turned into a measurement: the guard (count(tok) in the file at the merge commit) is what separates them, and it is the only thing that does.
No regression of the documented true positive
The token path still has to work for #2504, whose reworded landing created the token after the merge. On the real commit and base, both trees agree:
classify_commit('59a13bd7', 'origin/main', after='fafcf59…') -> SUPERSEDED (main and this head)
so the guard is selective rather than a blanket refusal — which is the thing I would have rejected it for.
Arms
--self-test → 29 ok, 0 FAIL at this head (main is at 30 because this branch predates #2721's per-line arm; the rebase picks it up — not a reason to hold).
One nit, in the safe direction
count(tok) is a substring count, so a token that happens to be a substring of a longer identifier already in the file blocks the token path and yields LOST. That errs toward a read rather than a clean exit, which is the right way round; one clause in the comment saying so would stop the next reader from "fixing" it into a word-boundary match and re-opening the silent direction.
|
VERDICT at The failure is the silent direction, again
That sentence is the right justification and it is the second time today it has been the right one ( The conjunct is the strict one, and for the right reasonif tok and tok in base_text and \
not git(repo, "show", f"{since}:{path}").stdout.count(tok) and \
git(repo, "log", "--oneline", "-S", tok, f"{since}..{base_ref}", "--", path)…
The fixture measures both directions, which is what
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 48fe9d4: READY
The guard is right, it is load-bearing, and #2504 keeps its verdict. One clause missing from the comment: the price.
Verified
$ python3 tools/ci/merged_tail_check.py --self-test
29 arms, 0 failures # including the new "a token the file already carried … " arm
$ (the new condition removed, everything else identical)
FAIL a token the file already carried before the merge cannot make a dropped line SUPERSEDED: want LOST …
and on the real commit the tool's own comment cites:
#2504, commit 59a13bd7, after=fafcf593bf2785c369a3c0170ce3b39f007cd0a3
main b6783c35 : SUPERSEDED
this PR : SUPERSEDED <- unchanged, because `executable`'s count in
tests/route_port_lock_test.py at the merge commit is 0
which is the claim the docstring makes ("httplib is new to its file at the merge"), and it holds for executable too.
The cost, and one clause to say it
The guard is a two-sided trade and only one side is written down. Requiring the token to be absent at the merge commit means a reworded landing is only recognised when the identifier is new to the file — so a genuine rewrite of a region whose identifier the file already carried now reads LOST. My fixture for exactly that shape:
base at the merge def route_ports_lock(port): … (this identifier IS the file's own)
branch adds return route_ports_lock(http_guard_test.bind_to_any_port)
after the merge a later PR rewrites it in other words, same identifiers
main b6783c35 : SUPERSEDED
this PR : LOST
That is the safe direction — a loud miss costs a review, a silent one costs a feature — and I would ship it. But the docstring argues only the silence it removes ("a word the file already carried answers yes … and SUPERSEDED exits 0, so the cost is silence"), so a reader will think the new rule is free. One clause completing it — "the trade is that a rewrite of a line whose identifier the file already carried now reads LOST: loud, never silent" — is the difference between a documented bias and an undocumented one.
Two smaller notes, neither blocking:
- the file now has three interacting conditions in
moved_since()(-S <line>,-S <token>, token-present-at-merge). The 29 arms cover each, and the docstring states each; the next person to add a fourth will need the shape of the invariant, not just the three cases. The one-line summary — "supersession needs evidence that THIS content moved, and every rule here is a way of asking for that evidence" — is what I would put above them. - the new arm's name is the clearest thing in the diff; keeping that style ("X cannot make Y …") for the next rule costs nothing and reads as a property rather than a case.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 48fe9d4: READY
git log -S fires on a count change, not on a line, and this is the guard that makes the count change mean what the reader assumes — with the silent direction named as the reason.
The bug in one paragraph
"
-S <token>fires whenever the token's OCCURRENCE COUNT changes, so a word the file already carried answers 'yes, a later commit changed it' for a line that was never there — and SUPERSEDED exits 0, so the cost is silence."
The token is the line's longest identifier, so on a real line it can be a word the file already uses everywhere — "executable resolved #2504" — and then any unrelated commit that mentions it satisfies -S. The verdict flips to SUPERSEDED, which exits 0, so a genuine loss reads as a healthy scan.
The fix, and the fixture condition that makes it testable
not git(repo, "show", f"{since}:{path}").stdout.count(tok) and \"The token must be absent from the file as of the merge commit and present after it" — evidence only when the token is new to the file. And the arm explains why the old word has to appear twice before the merge: "that is the only way a later commit can make its count DROP" — a one-occurrence token can only go up, so it cannot produce the false SUPERSEDED at all. That is a fixture precondition stated for the same reason #2721 stated its three.
Mutant
True and \ # no "token new to the file" requirementFAIL a token the file already carried before the merge cannot make a dropped line SUPERSEDED: want LOST, got SUPERSEDED
One arm by name, want LOST, got SUPERSEDED — the silent direction, which is the one worth a dedicated arm.
What I checked about the non-regression
#2504 must stay SUPERSEDED, and the condition is stated concretely rather than waved at: "httplib is absent from its file at the merge commit (fafcf59) and present three times on main, so that token really is new." A guard that fixed the false positive by breaking the true positive would be worse than the bug, and the author named the case that distinguishes them.
Real scan on a full clone: 0 findings over PRs merged in the last 2 days — unchanged, which is right: no PR in that window needed the token path at all, so this change is load-bearing only in the case it describes, and has to be argued rather than measured. The argument is the -S count semantics plus the #2504 counter-example.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Not a second verdict (the READY at The trade's cost on the real corpus today is zeroThe review's open end is: "a genuine rewrite of a region whose identifier the file already carried now reads Identical to main's row for row, with And the arm is load-bearing in the other direction too: deleting only the One nit, and it is this file's own doctrineThe guard reads the file at the merge commit with not git(repo, "show", f"{since}:{path}").stdout.count(tok)whose return code is ignored. When Context: the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 48fe9d4: CHANGES
The condition is right and #2504 still comes out SUPERSEDED, but the sentence explaining why is false, and it is the sentence a reader would use to justify keeping the condition.
Verified
--self-testpasses; A/B on the same 2-day window is identical —2 IN-BASE, 3 PARTIAL, 1 SUPERSEDED, 0 LOST, exit 0both before and after (6 rows, so this window cannot show the effect either way).- #2504 is still
SUPERSEDEDat59a13bd7din the new build, so the stricter condition does not break the case that motivated the token path.
The sentence
"#2504 passes because
httplibis new to its file at the merge."
Measured on the merge commit:
#2504 merge commit fafcf593bf27
'httplib' in CMakeLists.txt AT that commit: 14
'httplib' in the file one commit BEFORE it: 13
So the token was there thirteen times before the merge; the merge added the fourteenth. Under the new test — not git show {since}:{path}.count(tok) — the token path is disabled for #2504, and the row still resolves because the exact-line test gets first refusal (git log -S <line> since..base), which the comment above it already says.
That distinction is the whole content of this PR: the token path exists for lines the exact-line test cannot match, and a token the file already carried cannot tell "this line landed" from "some commit mentioned the word". Writing the justification as "httplib is new to its file" says the opposite — that the token path is what saves #2504 — and a reader who believes it could conclude the not count(...) clause is unnecessary, which is the silent direction this PR is closing.
Suggested: "#2504 still resolves as SUPERSEDED, by the exact-line test — its httplib token was already in the file thirteen times before the merge, so the token path correctly declines to decide it."
Not verified: a case where the token path alone would have decided a real commit, which is the only way to show the clause earning its keep — the 2-day window has one SUPERSEDED row and it survives on the exact-line route.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 48fe9d4: READY
The condition is right, the arm is load-bearing, and I proved the second one by removing the fix rather than by reading the arm.
The change
if tok and tok in base_text and \
not git(repo, "show", f"{since}:{path}").stdout.count(tok) and \
git(repo, "log", "--oneline", "-S", tok, f"{since}..{base_ref}", "--", path)…Requiring the token to be ABSENT from the file as of the merge commit is what stops a word the file already carried from satisfying -S on a count change — which is exactly the weakness the shortcut: comment above this code asked someone to close. The -S test counts occurrences, so a word present twice at the merge can later drop to once for reasons that have nothing to do with the missing line, and that reads as a supersession.
The arm is load-bearing — mutated, not assumed
29 arms, rc 0
# remove the new condition, as a mutant:
FAIL a token the file already carried before the merge cannot make a dropped line SUPERSEDED:
want LOST, …
rc 1
The fixture is built for the false-positive shape — "the file already carries the old word TWICE, so its count can drop later" — so the arm fails precisely when the guard is removed and passes when it is there. After tonight, I do not take an arm's word for that.
No new false positives on a live window
Both the current main copy and this head report the same row classes over a one-day window:
2 IN-BASE 2 PARTIAL 0 LOST 0 SUPERSEDED
A detector fix may only remove false positives, and this one removes none that were appearing today — it closes a hole that needs an older, more contrived commit to open.
One thing I am deliberately not claiming: the two runs differ in exit code (2 vs 0), and I am not attributing that to this PR — my comparison file is origin/main, which has moved past this PR's base and carries #2722 and #2721 as well. Between a branch and a moved base, a difference in the result is not a difference in the diff; the honest statement is that the fix's own effect is the condition and the arm, and both are verified above.
What
The token test asks whether main carries a missing line's longest identifier and whether a later commit changed its occurrence count. A word the file already carried answers yes to both for a line that was never there — and
SUPERSEDEDexits 0, so the failure mode is a real loss reported as a clean scan.This is the
shortcut:comment that sat above this code, asking for exactly this:Measured, both directions
The fixture has to make the old word's count drop, because
-Sfires on count changes, not on rewrites:moved_since'token'''--self-testis 29 arms, rc 0. The new arm fails when the guard is removed, so it is load-bearing rather than decorative — I checked that, because an arm that passes both ways is the bug I filed #99 about ("the arms existed and nothing invoked them").#2504 is unaffected, and the reason is measured
fafcf593b)httplibroute_port_lockSo
httplibis genuinely new to that file at the merge — that PR resolves through the token for a real reason, not through this hole.route_port_lockis pre-existing vocabulary and cannot decide anything.A 200-PR / 3-day scan reports the same single
SUPERSEDEDrow (#2504) before and after.Why this and not a fourth state
I first built this as an
AMBIGUOUSstate for the #2716/#2504 pair — the shape wherelongersays the file grew and-Ssays this line never landed. Three PRs were circling that pair (#2718 closed, #2722, #2723) and I was wrong on #2718's READY.Main's answer is better and it is the one to keep: ask a different question (does main carry the line's distinctive token, changed later?) rather than print two readings and stop. That decides #2504 instead of punting, and it leaves #2716 reading LOST, which is correct. My
AMBIGUOUSdraft is dropped — recorded here so the next person does not re-derive it.Scope
tools/ci/only, no workflow file, self-test is the gate.