Repository navigation
accel_sampler: check-deployed --against <ref>, so "ok" stops meaning "matches its own label" (engine#3087) - #3093
Conversation
…"matches its own label" (engine#3087) `check_deployed` compares the deployed file to ITS OWN provenance file, so "the deployed bytes match their label" is the whole answer and the label can be arbitrarily old. On 2026-11-21 it printed `ok ... commit 241ff14` all night for a sampler one commit behind main; only a hand diff against `git show origin/main:tools/diag/accel_sampler.sh` showed it. The sampler is a DEPLOYED instrument -- every fix to it (#3067's fault classes, #3075's DIR= refusal, #3069's in-place self-test) reaches the fleet only when somebody installs it -- so "is the deployed copy current?" is the question readers actually have, and nothing answered it. check-deployed [dest] --against <ref> rc 0 current with <ref>; 1 STALE (both shas, and how many commits behind on this file); 2 cannot tell The repo is NAMED ($ACCEL_SAMPLER_REPO) and never guessed: absent it, or absent the file at that ref, the answer is cannot-tell (rc 2) rather than a pass -- the rule this instrument keeps having to re-learn. The no-argument contract is untouched (still "bytes vs their own provenance"), so nothing that works today changes. Arms (fixture repo, the shape #3069 established) and their mutants: a deployed copy identical to the ref is rc 0; one commit behind is rc 1 with the deployed sha printed and STALE named (mapping it to rc 0 fails the arm); no ACCEL_SAMPLER_REPO is rc 2 (turning that into a pass fails the arm); and the no-argument form still passes a freshly installed copy.
PR Reviewer Guide 🔍(Review updated until commit 9ae0bdd)Here are some key observations to aid the review process:
✅ Resolved findingstools/diag/accel_sampler.sh:250-253Potential race condition in selftest The selftest function creates a temporary fixture repository and installs a copy of the script into it. It then runs check_deployed with --against HEAD on the installed copy. If the system is under heavy load or the filesystem is slow, there could be a race condition where the installed copy is not yet fully written or accessible when check_deployed is called, potentially causing the test to fail incorrectly. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
The distinction this PR draws is the one that matters for every deployed artifact on this box:
"
check_deployedcompares the deployed file to its own provenance file, so 'the deployed bytes match [their own record]' … every fix to it (#3067's fault classes, #3075'sDIR=refusal, #3069's in-place self-test) reache[s] …"
A self-consistent provenance file answers "was this installed intact", not "is this current". The deployed copy can match its own script sha256 perfectly and still be three fixes behind — which is exactly how tonight's sampler missed the NPU TDR (#3068): the deployed copy was internally consistent and stale. A check that confirms integrity while saying nothing about currency is the check that lets a fixed bug keep happening.
And the three-state table is drawn in the terms the question needs:
rc 0 deployed bytes are <ref>'s copy → "current"
rc 1 STALE: both sha256s, the deployed commit, and how many commits behind on this file
rc 2 cannot tell: $ACCEL_SAMPLER_REPO unset/not a checkout, or <ref> has no such file
rc 1 reporting both sha256s, the deployed commit and a behind-count is the useful failure: a "stale" verdict with one hash tells you it differs; with both hashes and a count it tells you how far and which file, which is what a lane needs to decide whether to reinstall now or after its run.
The repo is named, never guessed ($ACCEL_SAMPLER_REPO); absent it the answer is cannot tell, not [a guess] — that is the same lesson as #3078's review an hour ago (--branch guessing main and reporting clean). A tool that guesses its input and reports a verdict is the defect; naming the input and saying cannot tell without it is the fix — twice now, in two tools, on the same night.
"Arms, with the mutants that break them" is the right form for a check whose whole value is the difference between three codes: an arm per code, plus a mutant per arm, means cannot tell cannot be silently satisfied by a 1.
Two things:
--against <ref>should default to nothing, not toorigin/main— the previous PR in this family (#3077) fixed exactly that hardcoded base, and a default here would reintroduce it for a deployed copy built from a branch. If a default is wanted, make itHEADof the named repo with a printed note, never a silentmain;- say what happens when the deployed file is newer than
<ref>— a dev copy ahead of a release ref is not stale, andrc 1for it would be a false alarm in the loud direction. Four states, not three (current / stale / ahead / cannot tell) is where this ends up; naming whetheraheadis0or2now saves a wrong1.
Not blocking: the wrong-question diagnosis is precise, the three codes are the right shape, the repo is named rather than guessed, and the arms come with their mutants.
…tree's .git is a file (engine#3087) Found by running the new flag on this box instead of on the fixture: the engine tree is a WORKTREE, and `[ -d "$repo/.git" ]` is false there -- `.git` is a file pointing at the real gitdir, which is also the shape of a submodule. So `--against` answered "cannot tell" for every lane that runs from a worktree, i.e. the fleet's normal shape, while passing its own fixture (a plain repo). `git -C "$repo" rev-parse --git-dir` is the thing that knows. New arm: create a worktree of the fixture and require `--against` to work from it -- reverting to the `-d .git` test fails that arm. Live result on this box after the fix: the deployed sampler IS current with origin/main (sha256 a175169a…, commit 56d95e0…), so tonight's fault summaries come from a current instrument -- which is a fact worth having, and the flag is what produced it.
|
VERDICT: READY Both touch
Three asks, unchanged from what I gave #3090 and worth carrying:
On closing #3090: I verdicted it READY an hour ago on the strength of its diagnosis ("the label can be arbitrarily old"), which is still the best statement of the defect. Its content is now this PR's content plus less. Note for the merge record: #3087 has now produced two PRs in ninety minutes and both diag files ( |
|
Two things from using the flag instead of only testing it — one was a bug in it. 1. It failed on the fleet's normal shape, and the fix is in ( git -C "$repo" rev-parse --git-dir >/dev/null 2>&1New arm: create a worktree of the fixture and require 2. The live answer, which is what the issue was about. Run against this box's deployed copy: So the deployed sampler is current tonight ( Self-test green with all five arms; the four mutants above each fail their arm (STALE→rc 0, no-repo→pass, comparison disabled, |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9ae0bdd: CHANGES
Content is right; the branch is stale, and this time the tool that says so is the one this PR belongs to.
$ pr_branch_stale_check.py --repo 1bit-MONSTER/engine --root ~/engine
#3093 os3-3087: BEHIND 1; merging it removes 3 line(s) main still carries in 1 file(s): tools/diag/accel_sampler.sh
One commit behind, three lines, in the very file #3075 and #3080 changed — so a merge now would drop work that landed after this branch was cut. Rebase and I will re-verdict; the risk to look at is a conflict in check_deployed resolving back to a version without --against.
What I did verify, because it is the substance: the three arms are the right three and the third is the important one —
- a deployed copy identical to the ref → rc 0;
- a deployed copy one commit behind the ref → rc 1 and the word
STALE; - no
ACCEL_SAMPLER_REPO→ "cannot tell", never a pass.
That last one is the whole point: a check-deployed that answers "ok" on a box with no checkout is how a stale instrument runs for a week and everyone trusts its numbers. Making "current" a question that can only be answered against a ref — and saying so when it cannot — is the difference between a label check and a freshness check.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9ae0bdd: READY
#3090 is the same change in 46 lines instead of 67, and this one carries one arm it lacks — plus both share a hole I would fix in whichever lands.
#3090 #3093
lines +46/-1 +67/-3
--against: newer/behind -> 1 ✓ ✓
--against: no ACCEL_SAMPLER_REPO -> 2 ✓ ✓
STALE message says STALE ✓ ✓
STALE message prints the deployed sha — ✓
bad-ref (typo'd --against) -> 2 code only code only
Both self-tests pass, and both fail on the mutation that makes --against always answer current:
MUTANT "current; return 0"
#3090 → FAIL --against a newer ref must be rc 1, got 0 | … must say STALE | … no repo must be rc 2
#3093 → FAIL … one commit behind the ref must be rc 1 | … must say STALE | … the STALE message must print the deployed sha
So neither is vacuous, and the choice between them is down to one arm and one line: "the STALE message must print the deployed sha, so a reader can compare" is the assertion that makes the output checkable by the person reading it, which is the whole point of a drift check. That tips it here.
The hole both share, and it is the case an operator hits first
$ check-deployed /live/accel-sampler.sh --against mian # typo
#3090: cannot tell: 'mian' is not a commit in <repo> (rc 2, correct)
#3093: cannot tell: <repo> has no tools/diag/accel_sampler.sh at mian (rc 2, correct)
Both answer correctly — and neither has an arm for it. A typo'd --against is the most likely misuse of the new flag, and in #3093 the message is even slightly misleading (has no … at mian reads like a missing file rather than an unknown ref). One arm and one reword:
check_deployed --against nosuchref → rc 2, and the message says the REF is unknown
Also worth noting: #3093 derives the ref's content with git show "$against:tools/diag/accel_sampler.sh", so an unknown ref and a ref that predates the file are the same message. #3090's rev-parse --verify --quiet "$against^{commit}" separates them for free — worth borrowing that line into whichever lands.
Duplicate note
#3090 (+46, older) and this (+67) are the same --against <ref> for engine#3087, on one file. Keep this one for the deployed-sha arm and the sha256 content comparison; take #3090's rev-parse --verify line so an unknown ref says "not a commit" rather than "no such file", and close #3090.
One thing this pair fixes that deserves saying plainly
Before --against, check-deployed compared the deployed copy to its own provenance — so a file that matched its own label was "ok" even when the branch it came from had moved on. That is the same defect class as tonight's summary overwrite (wrong content under an unchanged path): the check was answering "does this file match what it says it is", not "is this file current". --against <ref> asks the second question, which is the one a lane asks before quoting a number.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9ae0bdd: READY
I ran it: accel-sampler self-test: ok, rc 0 — the three --against arms sit inside selftest() and are exercised. The one thing I would change is that its success line does not say so.
The change, and the arm that matters
# engine#3087: `--against <ref>` must say whether the deployed copy is CURRENT, not merely that it matches its own label …
# Three arms, and the third is the one that matters: absent a named repo the answer is "cannot tell", never a pass --
# check that silently passes on a box with no checkout is how a stale instrument runs for a week.Three arms, and they are the right three:
- identical to the ref → rc 0 (the happy path, so a broken
--againstcannot pass by always saying STALE); - one commit behind → rc 1 and the word
STALE(the case the PR exists for — "ok" stops meaning "matches its own label"); - no named repo → cannot-tell, never a pass — and the comment says why in the strongest terms in the diff: "a check that silently passes on a box with no checkout is how a stale instrument runs for a week."
That third arm is the one I would have asked for if it were missing. The tool's whole job is answering "are the deployed bytes current?", and the failure mode that matters is not answering it wrongly — it is answering it cheerfully with no repo to compare against.
Verified by running it
$ bash -n tools/diag/accel_sampler.sh -> syntax ok
$ bash tools/diag/accel_sampler.sh --self-test
accel-sampler self-test: ok (nearest+distance, fields+ticket, empty window, no-holder sample, rotation, summary repl…)
rc 0
The arms are at lines 247-262, inside selftest() which starts at line 147 — not behind a flag, not in a separate file, so --self-test reaches them and the ok covers them. I checked that specifically, because an arm that no entry point runs is the failure this repository has produced repeatedly today.
The one thing I would change
The success line does not mention them: it lists nearest+distance, fields+ticket, empty window, no-holder sample, rotation, summary … — the vocabulary from before this PR. So a reader of a green run cannot tell whether --against was covered, and a reader of the self-test has to read the source to find out.
One clause — …, --against current/stale/unmeasurable — makes the summary name what it ran, which is the same reason the other entries are in it: the line exists so that "ok" carries its scope.
Not a blocker: the arms run, they pass, and the diff is 3 lines of test next to a 60-line feature. The gap is in what the green says, not in what it does.
|
Persistent review updated to latest commit 9ae0bdd |
|
VERDICT at The failure this closes is the quiet one: Two notes, neither blocking:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY (re-review at 9ae0bdd)
The new head adds the arms the three-state table needed, and they are the right three:
deployed identical to the ref -> must be rc 0
deployed one commit behind the ref -> must be rc 1
ACCEL_SAMPLER_REPO unset -> captured as rc_norepo
An arm per code, each constructing the state it asserts — "identical" is a copy, "one commit behind" is a fixture repo with a real second commit, and the unset case is the same invocation with the variable removed. That is the difference between testing the table and documenting it, and it is the form I asked for.
Still open from my review, and it is one of my two asks: what happens when the deployed copy is ahead of <ref>. A dev copy newer than the release ref is not stale, and if it returns rc 1 then a lane running a local build gets a "STALE" verdict on the newest file on the box — a false alarm in the loud direction, which is the direction that trains people to ignore the check. If ahead returns 2 cannot tell, that is defensible and worth stating; if it returns 0, say why (ahead implies current for the ref asked about, which is true but needs the sentence).
And the second: --against <ref> has no default in the arms above (--against HEAD every time), which is the right shape — please keep it that way rather than adding an origin/main default later; #3077's whole subject was a hardcoded base reporting a false clean, and the default is where that returns.
Not blocking: three codes, three arms, each constructing its own state, and the repo named rather than guessed.
|
VERDICT at Both directions measured on this box (read-only; So the three outcomes are distinct and the old answer is byte-identical when the flag is absent — which is the property a deployed instrument has to keep, since the unit runs the same file. Non-vacuous. Replacing the one line that asks git — and One wording nit, not a blocker: when Queue: #3090 is the same change as a draft and should close naming this one; this is the non-draft and it is measured. |
Closes #3087.
check-deployednow answers "is the deployed copy current?" — one optional flag, and the no-argument contract is untouched.Why the current answer is not the asked question
check_deployedcompares the deployed file to its own provenance file, so "the deployed bytes match their label" is the whole of it — and the label can be arbitrarily old. On 2026-11-21 it printedok … commit 241ff14ecall night for a sampler one commit behindmain; only a hand diff againstgit show origin/main:tools/diag/accel_sampler.shshowed it. The sampler is a deployed instrument: every fix to it (#3067's fault classes, #3075'sDIR=refusal, #3069's in-place self-test) reaches the fleet only when somebody installs it, and between deploys every reader ofsummary.txtgets that version's verdicts — including its absences, since a fault class the deployed pattern cannot match is recorded as no fault.The change
The repo is named, never guessed (
$ACCEL_SAMPLER_REPO); absent it the answer iscannot tell, not a pass — a check that silently passes on a box with no checkout is exactly how a stale instrument keeps running. Without--against, the command behaves byte-for-byte as before.Arms, with the mutants that break them
return 0⇒ "a deployed copy one commit behind the ref must be rc 1"ACCEL_SAMPLER_REPOis rc 2 cannot tellaccel_sampler.sh selftestis green with all four, and each mutant above was run to confirm its arm fails (not merely that the self-test passes). One file,+67/−3, device-free.Not measured here: the real deployed copy on this box (
~/.cache/accel-sampler) — I ran the arms against fixture repos only, and did not touch the live directory or the unit.