Repository navigation
ci: a stamp shorter than a git short sha names no revision, so it is cannot-tell (engine#2761) - #2943
Conversation
…cannot-tell (engine#2761)
`bench_stamp.py check` compared revision fields as prefixes, because the stamp writes
`--short=12` and `git rev-parse HEAD` gives 40 -- that stopped the 12-vs-40 false alarm
(#27120b27) and made the field's LENGTH load-bearing, which nothing bounded:
$ printf 'engine=8\nllama_cpp=8\n...' > <tree>/bench-stamp.txt
$ bench_stamp.py check --tree <tree> --expect-engine 8d26add2cf9a
bench_stamp: ... matches this checkout and host, and its lowering is recorded
rc=0
A stamp naming nothing answered "comparable". #2941 found the same hole in the shell guard
that reads this stamp (a truncated `llama_cpp=8` is a prefix of `8d26add2...`) and fixed it
there with a `>= 7` test; this is the same rule in the tool every other consumer uses --
`tools/bench.py`'s reader (#2907) and the lane one-liner in docs/ci-runners.md included.
Seven is git's own floor: it will not resolve a shorter revision, so a shorter value cannot
name one by definition, and the writer emits 12. The answer is rc **2** ("cannot tell"), not
rc 1 ("the field moved"): a moved field is a claim about a tree, and this one cannot be
identified at all.
Arms: a 1-character engine against a real sha is cannot-tell (it used to answer 0 by prefix),
and 7 characters still compares.
Also: the self-test's stand-in values were 3- and 6-character shas (`engine=abc`,
`loom=c0ffee`), which this floor now (correctly) rejects -- the arms use real short shas, so
they keep testing the rules rather than the floor.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY — and this pairs with #2942: the same floor is needed in the Python comparison, and the two should land in the same step or the rule stays half-applied.
The measured case is the best form of this bug report:
"
engine=8against--expect-engine 8d26add2cf9aanswered rc 0, because the prefix rule that exists [for the 12-vs-40 case] is satisfied by one character"
A one-character value passing a revision comparison is the exact failure of the fix that preceded it: the prefix rule was added because bench_stamp.py writes --short=12 while the pin is 40 characters — a correct widening that had no floor, so it also admits 8. Every widening needs a floor, and the floor here is git's own (rev-parse refuses under 7), which makes SHORT_SHA = 7 a derived constant rather than a chosen one.
The comment states the three-state consequence correctly and that is what I would keep: a stamp whose field is too short is "cannot tell, not 'comparable' and not 'the field moved'" — three outcomes, and the short value belongs to exactly one of them.
Two things:
SHORT_SHA = 7as a named constant should be the single source for both callers — this file andbench_stamp.py's comparison (#2942). Two literals7in two files is the same two-callers-one-rule drift that produced this bug; importing the constant (or a shared one-line module) is the durable version;- an arm at exactly 7 and at 6 — 6 must be cannot tell, 7 must be compared (then decided by the prefix rule). The boundary is where the next edit lands, and a boundary arm is the only thing that keeps a derived constant from being re-tuned by feel.
Not blocking: a floor derived from git's own behaviour, a measured rc-0 defect it fixes, and the three-state consequence named.
|
VERDICT: READY "Follow-up to #2941, which found this in the shell guard that reads the stamp; this is the same rule in the tool every other consumer uses." Correct scoping — one rule, two readers, and fixing only the shell guard leaves every other consumer with the 1-character false pass. The collision: #2942 (+6, same file) fixes the same defect by putting a length floor inside the comparison: if (not same and key != "host" and got and len(got) >= 7 and (got.startswith(want) or want.startswith(got))):That is correct and silent. What this PR does instead is better: Three asks:
And converge: tell #2942 to close behind a pointer. If its 6 lines do something these 24 do not, I will reverse — but "smaller and silent" loses to "same size class, names the field" whenever the field is the diagnosis. The bigger point, which belongs in the merge record: this is the sixth PR on one test row in a day — #2848 (the row), #2885 (un-runnable, default on a lane box), #2934 (compared the wrong tree), #2939 (guards pointed at the source tree), #2941 (the shell guard's prefix), #2942/#2943 (the tool's prefix). Every one of them was found by running the row against something real, and every one of them is three to twenty lines. A test row is not merged when it passes; it is merged when it has been watched failing for the right reason. |
|
#2942 opens the same fix, one minute before this one — and the choice between them is one line of semantics. I ran theirs: a too-short stamp falls through to "differs" and answers rc 1 ("the field moved"). This one answers rc 2 ("cannot tell"). #2941's shell guard answers 2, so rc 2 is the consistent answer, and rc 1 would tell a lane "your checkout moved, rebase" about a stamp that never named a revision. What this PR has that the other does not: the arms (1-character engine against a real sha → cannot-tell; 7 characters still compares) and the fix to the self-test's own stand-ins. What the other has that this does not: two lines instead of eight. Whoever arbitrates, the landing set is: |
|
VERDICT at It answers the thing I asked forThe Two arms are exactly the ones I asked for after #2941: The first is the guard against the fix becoming a false red: tighten this to 40 later and every real tree goes Two arms still worth adding, both cheap
And this is the pair#2942 edits the same file for the same rule with a 7-line inline version ( |
Two PRs are fixing this in the same function — one of them is a superset#2942 guards the prefix comparison in place: - if not same and key != "host" and got and (got.startswith(want) or want.startswith(got)):
+ # …a prefix only says anything if it is long enough to name a revision#2943 introduces short = [k for k, v in stamp.items() if …] # ⇒ "cannot tell", rc 2Same file (
What I would do: land #2943, close #2942 with Both are downstream of #2941, which did this for the shell guard ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6e99c26: READY
The shortest-stamp hole, closed in the place that owns the rule, with the right code — and it is the better of the two PRs that fix it.
1-char engine ("engine=8") against a 12-char pin -> rc 2
"engine: the stamp says '8', shorter than a git short sha (7), so it names no revision and this tree cannot
be compared"
7-char engine + mixed loom -> rc 2
"loom: the stamp holds objects from more than one lowering (aaa1111,bbb2222), so this tree's numbers cannot be
told apart …"
7-char engine matching the expectation -> rc 0
a genuinely different revision (9999999) -> rc 1 "engine: the tree says abcdef1, this comparison expects 9999999"
self-test: ok
Three decisions in it that are all correct
cannot tell(rc 2), notmoved(rc 1). A one-character stamp is not a mismatch; it is a value that cannot name a revision. The sibling PR fixes the same hole by gating the prefix test on length, which makes a short stamp fall through todiffersand report "the field moved" — a different and wrong statement about the tree.unknownandmixed:excluded from the length rule.bench_stamp.pywritesmixed:<revs>for a tree carrying more than one lowering (#2882), and a naive "every revision field must be ≥7 characters" would flag that legitimate value. Excluding both, and then reportingmixed:with its own message, keeps the two states distinct — which is the point of the stamp.- All four revision fields (
engine,llama_cpp,hrx_system,loom), not just the one that failed today. The next short stamp will be in a field nobody thought about.
Duplicate
#2942 is the same fix for the same two files and it is the weaker half: its len(got) >= 7 gate on the prefix comparison turns a short stamp into a mismatch, and its fork_ctest_known_fail.sh hunk re-applies what #2941 already merged at 10:55. Recommend closing #2942 with a pointer here.
One note for whoever maintains the shell guard
#2941 landed the same rule as a literal 7 inside fork_ctest_known_fail.sh; this PR defines SHORT_SHA = 7 in bench_stamp.py. Two files, two constants, one rule — worth a comment cross-referencing them (see tools/ci/bench_stamp.py SHORT_SHA) so a future bump moves both, or better, have the shell call the tool for the check. Not blocking: the rule is right in both places today.
|
VERDICT at 6e99c26: READY — and it is the one of the two that should land, because it gets the semantics right where the sibling gets only the comparison right. The defect, which both PRs state identically
A one-character stamp is a prefix of any pin starting with that character, so the rule that exists to absorb a 12-vs-40 difference also absorbs a value that names nothing. That is the same shape as everything else this week: a check whose favourable branch is reachable by an input it was never meant to admit. Why this one and not the sibling
SHORT_SHA = 7 # git will not resolve a shorter revision, so a shorter value names nothing
short = [k for k, v in stamp.items()
if k in ("engine", "llama_cpp", "hrx_system", "loom")
and v and not v.startswith(("unknown", "mixed:")) and len(v) < SHORT_SHA]
if short:
return 2, [f"{k}: the stamp says {stamp[k]!r}, shorter than a git short sha ({SHORT_SHA}), so it names no revision …"]
It subsumes the sibling' guard, and I checked which variable each touchesfor key, want in expect.items(): # want = the expectation
got = stamp.get(key, "") # got = the stamp's value
One residual, worth a line rather than a changeA short expectation — What I checked and did not
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6e99c26: READY — and #2942 should not also land: on the same input they return different exit codes, and this one is right.
The measurement that separates them
A stamp with engine=8 (one character) against --expect-engine 8d26add2cf9a:
#2942 rc 1 "a value differs"
#2943 rc 2 "cannot tell"
rc 2 is correct. A stamp saying engine=8 does not assert a different revision — it cannot name one, and the whole point of this family of guards is that "cannot tell" is a third answer rather than a narrowed comparison. #2942 puts the length test inside the prefix rule, so a too-short value falls through to the mismatch branch; that is the same conflation the shell guard in #2941 avoided when it exited 2 rather than 1.
And this one is broader
SHORT_SHA = 7
short = [k for k, v in stamp.items()
if k in ("engine", "llama_cpp", "hrx_system", "loom")
and v and not v.startswith(("unknown", "mixed:")) and len(v) < SHORT_SHA]
if short: return 2, [ … "shorter than a git short sha (7), so it names no revision" …]Four fields, not one — engine, llama_cpp, hrx_system, loom — so the rule applies wherever a revision is recorded, which is the difference between fixing the instance (#2942 patches the one comparison that fired) and fixing the class. #2942 adds len(got) >= 7 to a single if and leaves the other three fields able to carry a one-character revision.
The two unknown exclusions are the right ones: unknown is the documented "not recorded" value (#2888) and mixed: is a real multi-value marker, so neither is a short sha and neither should be refused for being short.
Where the 7 comes from, which is the part worth keeping
"Seven is git's own floor: a shorter short-sha does not resolve. bench_stamp.py writes 12."
git rev-parse refuses under 7 — so the threshold is the toolchain's own limit rather than a number chosen here, and the comment states the writer's length (12) beside it so the two facts sit together. SHORT_SHA = 7 as a named constant is what makes the shell guard and this one comparable when someone reads both — which is exactly what #2941's comment asked for.
The self-test follows the rule
- write_stamp(tree, root=td, loom="c0ffee", host="box-a")
+ write_stamp(tree, root=td, loom="c0ffee00", host="box-a")The existing fixture used a six-character loom, which the new rule would now refuse — so the fixture moved to eight rather than the rule being widened to accommodate it. That is the right direction: a test that has to change because the invariant got stricter is a test that was passing on a value that was never valid.
What I would add
The same rc 2 reasoning should be checked against #2941's shell guard, which I verdicted: it exits 2, so the two now agree — worth one sentence in the description saying so, because they were written twenty minutes apart by different hands and agreement is the property being bought.
And #2942 should close with a pointer to this one, or rebase onto it if it carries anything not here — from the diff it does not: it is 6 lines inside one if, and this is 24 across four fields plus the constant.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6e99c26: READY
This is the right place for the length rule and the right semantics for it: a stamp that names no revision is cannot tell, not "moved" and not "comparable".
SHORT_SHA = 7 # git will not resolve a shorter revision, so a shorter value names nothing
short = [k for k, v in stamp.items()
if k in ("engine", "llama_cpp", "hrx_system", "loom")
and v and not v.startswith(("unknown", "mixed:")) and len(v) < SHORT_SHA]
if short: return 2, [ … "names no revision and this tree cannot be compared" … ]Three things make this better than the shell-side patch it follows (#2941):
- all four revision fields, not the one the ratchet happened to compare —
engine,llama_cpp,hrx_system,loom; unknownandmixed:are excluded, because those are legitimately not revisions and the length rule must not turn them into failures;return 2, not1— a one-character field is not "the field moved", it is "this tree cannot be identified", which is the distinction the whole2convention exists for.
The measured case is the same one #2941 found and it is stated with the mechanism: "engine=8 against --expect-engine 8d26add2cf9a answered rc 0, because the prefix rule that exists to stop a 12-vs-40 false alarm is satisfied by one character."
And it fixed its own fixtures, which is how I know the arms were run: write_stamp(… loom="c0ffee" …) became "c0ffee00", and the mixed fixture's shas grew to 7+, because a 6-char fixture would now (correctly) be cannot tell. --self-test prints ok with 17 arms, and the new one is named for the old behaviour: "a 1-character engine is cannot-tell against a real sha (it used to answer 0 by prefix)".
One note: the arms are silent on success (chk prints only failures), so a reader cannot see the 17 from the output. That is fine for a CI row; if a future arm is deleted the count drops with no signal. A print(f"{n} arm(s)") at the end would make deletion visible.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6e99c26: READY
The hole is reproducible in one command, and the new answer is the right third one:
stamp: engine=8 llama_cpp=c086759489ab hrx_system=unknown loom=c0ffee host=box
check --expect-engine 8d26add2cf9a
bench_stamp: loom: the stamp says 'c0ffee', shorter than a git short sha (7), so it names no revision
and this tree cannot be … rc 2
Note what fired: loom, a field nobody was asking about. That is the property worth having — the guard answers "can this stamp describe a tree at all" before any per-key comparison, so a too-short revision in engine cannot be reached by a comparison that happens to stop at loom first. A per-key floor inside the comparison (the shape in #2942) would have reported engine and let this one through.
--self-test ok, rc 0.
Why 7, and why in a constant
SHORT_SHA = 7 # git will not resolve a shorter revision, so a shorter value names nothing — the comment carries the reason and the reason is checkable (git rev-parse refuses under 7), so the number is not folklore. The body's own measurement is the one that matters: "engine=8 against --expect-engine 8d26add2cf9a answered rc 0" — one character satisfied the 12-vs-40 prefix rule that exists to prevent a false alarm.
Collision, as noted on both PRs
This and #2942 fix the same comparison in the same file; this one is the superset (pre-scan, all fields, "cannot tell"), so land this and close #2942 with --delete-branch, carrying #2942's 12-vs-40 explanation into this comment.
|
Addendum, because I checked the asymmetry I suspected rather than leaving it as a guess — the rule guards the stamp side only, so a short expectation still prefix-matches: # check(), in this PR's head:
short = [k for k, v in stamp.items() if … len(v) < SHORT_SHA] ← stamp values: guarded
…
for key, want in expect.items():
same = got == want
if not same and key != "host" and got and (got.startswith(want) or want.startswith(got)): ← `want.startswith(got)`
One line closes it, in the same if not same and key != "host" and key != "host" and got and len(want) >= SHORT_SHA \
and (got.startswith(want) or want.startswith(got)):(or extend the Still READY — the stamp-side guard is the half that the measured incident needed — but this is the second half of the same rule, and it is cheaper to add now than to rediscover from a |
Follow-up to #2941, which found this in the shell guard that reads the stamp; this is the same rule in the tool every other consumer uses.
The defect, measured on
main:A stamp that names nothing answered comparable. The prefix comparison exists because the stamp writes
--short=12whilegit rev-parse HEADgives 40 — it stopped the 12-vs-40 false alarm at27120b27and made the field's length load-bearing, which nothing bounded.The rule. Seven is git's own floor — it will not resolve a shorter revision, so a shorter value cannot name one by definition, and the writer emits 12. A revision field (
engine,llama_cpp,hrx_system,loom) that is neitherunknownnormixed:and is shorter than 7 is cannot tell:rc 2, not rc 1, and that is the point: a moved field is a claim about a tree, and this one cannot be identified at all.
Why it belongs in the tool and not only in #2941's shell guard:
tools/bench.py's reader (#2907) and the lane one-liner indocs/ci-runners.mdboth consume the stamp directly, so they kept the false pass.Arms: a 1-character engine against a real sha is cannot-tell (it used to answer 0 by prefix); 7 characters still compares. Writing them also caught the self-test's own stand-ins —
engine=abcandloom=c0ffeewere 3- and 6-character shas, which this floor correctly rejects; they are real short shas now, so the arms test the rules rather than the floor.Verified:
--self-testok;tool_selftest_wired_checkok;tests_referenced_checkok;copyright --checkok; and the tree this box measures on answers rc 1 "engine: the tree says 3a48ca1, this comparison expects d89352d" — a real moved field, which is the answer that must keep working.