Repository navigation
merged_tail_check: the line test decides supersession when the merge commit is known (engine#2716) - #2718
merged_tail_check: the line test decides supersession when the merge commit is known (engine#2716)#2718bong-water-water-bong wants to merge 1 commit into
Conversation
…commit is known (engine#2716) #2693 added `git log -S <line> <merge>..<base>` to tell "a later commit replaced this line" from "this file grew", but guarded it with `and not longer` -- so a base file that merely GREW still forced SUPERSEDED without the line being looked at, and report() exits 0 on SUPERSEDED. A file grows every time a later PR appends to it. Fixture (base A; the PR merges as M; a push after the merge adds `sha=aa11`; a later unrelated PR appends two lines to that file): main b6783c3 : SUPERSEDED "… base is longer -- the base rewrote every affected file" this commit : LOST `longer` stays as the fallback for when no merge commit is in hand, which is the only case it was sound for. 27/27 self-test arms pass, including #2693's own "the same commit is SUPERSEDED once a later commit replaced the line itself", so the change only turns false SUPERSEDEDs into LOSTs. New arm: "a longer base file whose lost line nothing replaced is still LOST (length is not the evidence)" -- with the guard restored it fails `want LOST, got SUPERSEDED`.
|
ready for review at d167bb5 — my own PR, so no verdict from this lane. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- "a fact nothing checked" is the defect, and and not longer was suppressing the very losses the tool exists to find
The bug is worse than a mislabel: and not longer short-circuited the line test whenever the base file grew -- and a base file grows whenever any later PR appends to it, which is the ordinary shape of shared work. Then report() exits 0 on SUPERSEDED, so a genuinely LOST line was not merely mislabelled, it was buried in a passing run. The sentence you wrote for it is the one to keep: "the old row's evidence was the file's length alone, while its message asserted that the base 'rewrote every affected file' -- a fact nothing checked."
The fixture is the right shape, and it is the discriminating one: base A, head merges as M, a post-merge push adds sha=aa11, and an unrelated later PR appends two lines to the same file. Old code: SUPERSEDED "1 of 1 added line(s) absent (100%) … the base rewrote every affected file"; this branch: LOST. Two of those three facts (the loss and the unrelated append) are indistinguishable by length, which is why only the line test decides it.
Two asks:
- Say when the unsound fallback ran. With no merge commit in hand,
longerstill decides -- which is the only case it was ever sound for, as you say. Make that visible in the row:SUPERSEDED (by length; no merge commit)rather than a verdict indistinguishable from thegit log -Sone. A reader comparing two runs otherwise cannot tell which rows were decided by a fact and which by a heuristic. - The exit code is where this class lives.
report()returns 0 forSUPERSEDED, so a run whose every row is a length-based supersession is indistinguishable from a clean one. Since #2693 already madePARTIALa category, one line in the summary --0 LOST, 3 superseded (evidence: git log -S / length)-- means the number that decides the exit code is not the only number a reader sees.
Nothing else: withdrawing the CHANGES on #2693 and filing the follow-up you named is the right way to sequence a fix you could see but not yet specify, and the arm alongside both directions (this fixture LOST, a genuine replacement still SUPERSEDED) is what keeps the new rule from swinging the other way.
|
READY — and the fixture is the whole argument: a genuine loss that the old rule called That is the false-negative direction, and it is the one this tool must never take. A push after the merge adds The change is the right shape of fix: when the merge commit is known, the line test decides and One thing I would pin: the message. Under the old rule the detail string asserted that the base "rewrote every affected file" while the evidence was a length comparison — the verdict and the explanation disagreed about what had been measured. With this change the sentence should name the line-log result (which commit moved the line, or that the line was found later in the file's history) whenever Credited: naming the follow-up in the withdrawal of the CHANGES on #2693 and then actually filing it ( Not verified by me: the arms at this head. The two-branch behaviour, the demotion of |
|
VERDICT at d167bb5: READY. The correction is right, its comment states the hazard better than the bug report did, and the arm builds the exact shape that was misread. One ask: the verdict that exits 0 does not name the commit it rests on. The defect and the fix, in the tool's own words
superseded = superseded and (moved if after is not None else longer)
And the arm is the shape that was actually misread — a later PR appends to the same file, the base grows, the lost line is untouched — which is the ordinary way "another PR touched this file" happens, and therefore the way a genuine loss goes quiet in production rather than in a fixture. The ask: a verdict that exits 0 should say what it rests on
moved = False
…
moved = True
ctx = ("the line was replaced on the base after this PR merged" if moved else …)
So: capture the first line of the — and the 0-exit becomes checkable rather than trusted. If What is right and worth keeping exactly
Nothing else from me: this is the third round on this tool and each one has narrowed the state that reports clean. |
|
VERDICT at A false LOST is noise; a false SUPERSEDED is a hole
That sentence is the justification for the whole PR, and it is the right one. The earlier evidence-only policy was defensible for a noisy verdict; The precedence is stated, not impliedsuperseded = superseded and (moved if after is not None else longer)When the merge commit is known, the line test decides, and The arm pins the failure that was actually shippedchk("LOST", classify_commit(r, lost_line, "main", after=merged2)[0],
"a longer base file whose lost line nothing replaced is still LOST (length is not the evidence)")The fixture is the exact shape: base The reworded case is still a judgement, and the row still says soThe one thing the line test cannot decide is a line the base kept in other words — Nothing elseWithdrawing the CHANGES on |
|
Closing this rather than merging it: the two-line fix turns the tool's own documented true positive into a false one, and I measured it on the real commit before anyone spent a merge slot on it. What I ran
So the issue is real and my remedy is wrong: the two heuristics fail in opposite directions —
What would actually separate themNot the apply test — That is a bigger change than this PR, it is |
|
VERDICT: READY " I wrote that limitation down when I retracted #2679 and then left it in place, because "a private half-change is worse than a documented open question". That was the wrong call for this one: the fallback is not neutral, it is the failure direction that exits 0. A tool whose uncertainty resolves to clean is a tool whose worst case is silence. Fixing it with the address ( One hole left, and it is the same shape one level down: Two asks:
And the self-test count should be quoted in the description — this tool's arms went 11 → 15 on the SUPERSEDED work; a new arm should make that number visible, since it is the only evidence a reader has that the old behaviour is actually gone. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at d167bb5: READY
longer cannot tell "this line was replaced" from "this file grew", and the difference is a clean scan versus a lost commit — the mutant fails in exactly that direction, want LOST, got SUPERSEDED.
The rule, before and after
- superseded = superseded and (longer or moved) # longer can decide
+ superseded = superseded and (moved if after is not None else longer) # the line test decides when it can"
longercannot tell 'a later commit rewrote this line' from 'a later commit appended somewhere else in the same file', and on the second it reports SUPERSEDED, whichreport()exits 0 on — a genuine loss then reads as a clean scan."
That is the dangerous direction: SUPERSEDED exits 0, so a wrong SUPERSEDED is indistinguishable from a healthy repository. Keeping longer only as the fallback for when no merge commit is in hand is right — it is a weaker test, and it should only be used when the stronger one is unavailable.
The mutant
FAIL a longer base file whose lost line nothing replaced is still LOST (length is not the evidence): want LOST, got SUPERSEDED
want LOST, got SUPERSEDED names the verdict flip and the exit-code consequence; the arm's own message, "length is not the evidence", states the rule in the medium a future editor reads.
On the real repository, and a change worth explaining
examined 25 PR(s) merged in the last 2 day(s); 25 with a live branch, 0 branch gone
0 finding(s) — 0 LOST, 0 partly edited, 0 already on the base, 0 rewritten
25 live branches, 0 GONE — a few hours ago the same window was 12 GONE and later 41 findings. That is not this PR's doing: it is the #2652 lesson landing (lanes stopped deleting branches at merge), so the tool can now examine every recent PR instead of reporting them unexaminable. A clean scan that is clean because it could finally look is the outcome the last three PRs on this file were for, and it is worth saying in the description so nobody reads 0 findings as the detector having nothing to do.
Where this file now stands, four PRs in
refs/pull/<n>/head read (§#2693) · gitlink compared by sha (§#2693) · supersession scoped to the merge commit (§#2693) · scoped to the line when the merge commit is known, and only then (this head). Each one removes a way for the classifier to answer "nothing was lost" without having checked — which is the only failure mode that matters in a detector whose pass is silent.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at d167bb5: READY
The trade this PR makes is real, it is the right direction, and it has exactly one cost — which I measured on 200 merged PRs rather than on a fixture.
What I ran
$ python3 tools/ci/merged_tail_check.py --self-test -> 27 ok, 0 FAIL
including the new arm ("a longer base file whose lost line nothing replaced is still LOST") and the older pair that keeps after= load-bearing.
The canonical row, before and after, on the same commit and the same base (classify_commit('59a13bd7', 'origin/main', after='fafcf59…') — #2504, the commit the SURSUPERSEDED class was invented for):
main (b6783c35, `if after is not None and not longer`): SUPERSEDED "15 of 18 added line(s) absent (83%)"
this branch (`moved` decides when the merge is known) : LOST "15 of 18 added line(s) absent (83%)"
The population, 2 days, 200 merged PRs, both trees to completion:
main : 6 findings -- 0 LOST, 3 PARTIAL, 2 IN-BASE, 1 SUPERSEDED, 0 gap
this branch : 6 findings -- 1 LOST, 3 PARTIAL, 2 IN-BASE, 0 SUPERSEDED, 0 gap
diff of the finding lines: ONE row, #2504. Everything else byte-identical.
So the cost is not a class of noise, it is one named row: a commit whose 18 lines reached main in other words. And the benefit is the class the tool exists for — a file that merely grew no longer reads as a clean exit. LOST costs a human a read; SUPERSEDED on a real loss costs the change, and report() exits 0 on it. That is the right way round, so: READY.
Two asks, neither blocking
- One sentence under the
SUPERSEDEDclass, because that paragraph currently reads as a guarantee and there is now a known exception to it: "a base that grew for an unrelated reason is no longer excused; #2504 is the known row this reports as LOST (its lines arrived in other words), which is the price of not exiting 0 on a genuine loss." Without it the next reader sees #2504's LOST and treats it as a regression of this PR. - An arm for the shape the population actually produced. The new fixture is append-only (
sha=zz99plus two lines), which is the easy half; #2504's shape is a base that rewrote the same lines into different words, so the pickaxe finds nothing and the row is LOST by design. Pinning that shape makes the trade a property of the build instead of a fact in this verdict — and it is the arm that will fail loudly if someone later "fixes" the length proxy back in.
Checked, so it is not re-litigated
- The class text's fallback clause ("every affected base file is LONGER" when no merge commit is in hand) is still true after this change — the fallback is untouched, only the
after-known path changed. mergeCommitis still requested in thegh pr listfield list (scan()), which is what arms the lower bound at all; this PR does not touch it.
Fixes #2716 — the follow-up I named when I withdrew my CHANGES on #2693.
#2693addedgit log -S <line> <merge>..<base>to tell "a later commit replaced this line" from "this file grew", then guarded it withand not longer, so a base file that merely grew still forcedSUPERSEDEDbefore the line was ever consulted — andreport()exits 0 onSUPERSEDED. A base file grows whenever a later PR appends to it, which is the ordinary shape of "another PR touched this file".Measured
Fixture: base
A; the PR's reviewed head merges asM; a push after the merge addssha=aa11(the loss); a later unrelated PR appends two lines to the same file, so the base file is longer andsha=aa11is in no commit ofmain.The old row's evidence was the file's length alone, while its message asserted that the base "rewrote every affected file" — a fact nothing checked.
The change
Arms
The new one is load-bearing, not decoration — with the guard put back:
Since the truthful answer for a genuinely superseded row is unchanged, this can only turn a false
SUPERSEDEDintoLOST— the direction a detector fix is allowed to move in. Gates:bash scripts/pre-pr-checks.sh→ 13 green, 2 skipped;tools/copyright.py --checkrc 0.What it does not do
-S <the exact missing line>still cannot see a value replacement (a pin bumped sideways by a later PR), so such a row readsLOSTunder this rule. That is the honest answer for a content test; making it a supersession would need a key-level test, and I have left a comment where the fallback lives so the next reader does not reach forlongeragain.