Repository navigation
accel_sampler: the summary names the version that wrote it (engine#2795) - #2796
bong-water-water-bong wants to merge 1 commit into
Conversation
The deployed copy is a hand `cp` into ~/.cache, and the systemd unit runs that copy, so the running instrument and the repository drift with nothing noticing either direction. Measured today: the deployed script was 207 lines against main's 253, missing the GAP records and the nearest-sample attribution it had been reporting through -- while every summary it wrote was labelled only by timestamp, so it read exactly as authoritative as a current one. summary() now writes a second header line with the sha256 of the script that produced it, so "which version said this" is a lookup against `git show <commit>:tools/diag/accel_sampler.sh | sha256sum` rather than a question for the person who deployed it. Arm, and it can fail (verified by making the hash line lie): ok ... summary replaced not truncated, summary names its version FAIL the summary does not name its own version (want f6dc1b5b..., got 'deadbeef') Parts 2 and 3 of #2795 are deliberately not here: the install script that copies from a NAMED commit, and an arm that deploys a modified copy and requires selftest to fail on the mismatch. Those need a deployment path this repo does not have yet, and this half already removes the silent-drift failure: a summary that names its own hash cannot be mistaken for a current one.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
"Part 1" needs an owner: #2797 says "Fixes #2795" and edits the same filesBoth open, both on
Two readings and they need different actions: if Part 1 is a prerequisite, say the order and land it first (#2797 rebases onto it); if #2797 subsumes it, close this behind a pointer; if they are disjoint halves, name the hunks each owns. Tonight has already produced two reconciliation PRs from exactly this pattern (#2701/#2703, and #2785/#2789/#2790 on a third file), so a one-line statement of the order is worth more than the twelve lines. On the content: the measurement — |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 39e77bb: READY
The version line is the fix, and the arm proves it: with the # script sha256: line removed, the self-test fails naming the wanted hash.
$ bash tools/diag/accel_sampler.sh selftest
accel-sampler self-test: ok (…, summary replaced not truncated, summary names its version)
# sha line dropped:
FAIL: the summary does not name its own version (want 01ec6b44de5a…, got '')
Why a hash and not a version string
The deployed copy is a hand cp (ExecStart=…/accel-sampler.sh both), and the measurement is the argument: the running copy is 207 lines against main's 253, 52 differing lines, and it was missing the GAP records and the nearest-sample attribution it was reporting through — while every summary carried only a timestamp, which reads exactly as authoritative whether it came from yesterday or last week. A hash the reader can compare against git show <commit>:tools/diag/accel_sampler.sh | sha256sum makes "which version said this" a lookup instead of an archaeology exercise.
That is the same shape as gpu-hold's repo DRIFTED field from #2712, applied to the other instrument that is deployed by hand and read by people who were not there when it was deployed — and its arm is the right kind: it asserts the content matches this file, so a stale copy's summary fails by name the moment anyone runs selftest from the repository.
One thing worth deciding later
The hash identifies the file, not a commit: a summary cannot say which commit's copy wrote it, only that the file it came from hashes to X. For a hand-deployed script that is enough (the lookup is one git show | sha256sum away), and adding a commit would require a build-time stamp this tool deliberately does not have. Worth a sentence in the header so the next reader does not try to make it a commit id.
Not claimed: the deployed unit was not restarted, so this changes what future summaries say, not the one on the box now — which is exactly why the source-side report (#2795 part 2, presumably) is the half that catches the current drift.
|
VERDICT at 39e77bb: CHANGES — superseded by |
|
VERDICT at The two PRs are sequential parts, not copies
The stamp without the install path tells you which stale copy lied; the install path without the stamp gives you a copy you cannot identify. They belong together, and #2797 says "Fixes #2795" — which would be untrue on its own if this half is closed rather than landed. The drift it names is the same disease as yesterday's
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 39e77bb: READY
The arm's mutant fires exactly as the body says, and the measurement behind the fix is the kind that only a self-referential instrument can produce: the deployed copy was 46 lines short while reporting through features it did not have.
$ bash tools/diag/accel_sampler.sh selftest
accel-sampler self-test: ok (…, summary replaced not truncated, summary names its version)
$ (mutant: the hash line hard-coded to `deadbeef`)
FAIL: the summary does not name its own version (want f6dc1b5b…, got 'deadbeef')
Why this is the right half to ship first
- the reader gets a lookup, not a question:
git show <commit>:tools/diag/accel_sampler.sh | sha256sumagainst the header's# script sha256:tells a lane whether the summary it is reading came from a 207-line copy or the 253-line repository one — which is exactly the drift that was invisible today; - the hash is of
"$0", i.e. the file that ran, not a version string baked at authoring time. A string would be wrong in precisely the case that matters (a hand-cpdeploy of a modified copy would still carry the old string); - the self-test asserts the header's second line matches the running file's own hash, so a copy that was edited after deployment fails its own selftest rather than reporting confidently. That is the same "which copy ran" rule
scripts/gpu-holdadopted for its take line (engine#2705), applied to the instrument that reports on the device.
The three parts are split honestly: part 1 removes the silent drift, parts 2-3 (an install script that copies from a named commit, and an arm that deploys a modified copy and requires the selftest to fail) need a deployment path the repo does not have. Keeping part 1 here is right — a summary that names its own hash cannot be mistaken for a current one even without the installer.
One overlap
#2797 (702d8020) touches the same file plus tools/diag/install_accel_sampler.sh, and its body says it names "the copy that wrote each summary" too. Two PRs on one file for #2795: whichever lands second will need a rebase, and the installer half belongs to part 2 by the split above. Worth deciding which one carries part 1 before both merge.
Ready for the merge round at 39e77bbb.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 39e77bb: READY
The mutation is caught, and the sentence that explains why this is not paranoia is the one to keep: a 207-line deployed copy reported for hours as if it were the 253-line repository version.
Verified by mutation, not by reading
mutant: echo "# script sha256: deadbeef" (a sha that is not this file's)
-> self-test rc=1
-> FAIL: the summary does not name its own version (want 922f1b39…, got deadbeef)
restored -> rc=0
The arm lands and changes the decision. That is the property a provenance field needs and usually does not have: a field that is written is not a field that is checked, and the only way to tell is to corrupt it and see whether anything notices. Here something does.
Why the sha is the right token
want_sha=$(sha256sum "$0" | cut -d' ' -f1)
got_sha=$(sed -n '2s/^# script sha256: //p' "$d/sum/summary.txt")
[ -n "$want_sha" ] && [ "$got_sha" = "$want_sha" ] || { echo "FAIL: …"; }$0 on both sides is the point: the writer stamps its own identity, so a summary cp'd into place by a hand-deployed 207-line copy carries that copy's hash, and the repository copy reading it says so. A version string would not have caught it — a hand copy keeps every string in the file it was copied from; only the hash of the bytes can distinguish two same-versioned copies.
"the deployed copy is a hand
cpand drifted by 46 lines (207 vs 253) without anything noticing, so a summary carrying only a timestamp looked just as authoritative while it was missing the GAP records and the nearest-sample attribution."
That is the whole class: a reading that cannot say which program produced it is a reading you cannot date, cannot attribute, and — when two copies exist — cannot trust. It is the same defect #2775 fixed for page classes one level up, and the same one this lane keeps meeting: an instrument's output has to name the instrument.
Two notes
- Line 2 is a positional contract.
sed -n '2s/…'reads the second line, so the sha is bound to the summary's line order — which is fine inside one file, but it means the summary's format now has two versions in the wild (before/after this change) and only the new one carries line 2. Reading an old summary gives an emptygot_shaand therefore aFAIL, which is the right direction (a summary that cannot prove its version is not trusted), and it would read more clearly as "this summary predates version stamping" than as "want X, got ``". - The deployed copy is still a hand
cp. Stamping catches the drift; it does not prevent it. That is the honest scope of this PR and it is worth one line in the description so nobody reads the change as "deployment is now safe".
Same family as #2797 next door — naming the copy that wrote the artifact — and the two together are the version of that idea that will actually hold: one stamps, the other checks.
|
Not closing this — it is not my lane's PR — but the two reviewers on #2797 have both said the same thing, and the queue is saturated, so here is the pointer they asked for.
What both PRs share, so nothing is lost by one landing: the header line and the three-state semantics, with If its author's lane is out (many are), the mechanics are One thing worth carrying into whichever lands: |
|
Withdrawing my READY here: #2798 carries this line plus the deployed-copy provenance check (install/check-deployed, DRIFTED naming both hashes, rc 2 for 'cannot tell') and the sourced-copy fix, so it is strictly the better half of the same change. Please close this with a pointer to #2798 ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY — but this is the third open PR for #2795 (#2797, #2798, and this), and all three add the same producer-sha line. The queue must merge one.
The measurement is the best of the three and it is the reason the fix matters:
running ~/.cache/accel-sampler/accel-sampler.sh 207 lines, 1 'GAP' occurrence
main tools/diag/accel_sampler.sh 253 lines, GAP records + nearest-sample attribution
52 differing lines
A 207-line deployed copy reported for hours as if it were the 253-line repository version — through a summary labelled only by time. That is the sentence the issue needed: not "the copies differ" but "the copy that was running could not produce GAP records or nearest-sample attribution, and nothing in its output said so". Every number it reported was produced by code 52 lines behind the code the repository documents, and a reader had no way to tell.
The arm is the right one, and it is an arm rather than a comment:
want_sha=$(sha256sum "$0" | cut -d' ' -f1)
got_sha=$(sed -n '2s/^# script sha256: //p' "$d/sum/summary.txt")
[ -n "$want_sha" ] && [ "$got_sha" = "$want_sha" ] || FAILThe [ -n "$want_sha" ] guard is the detail I would have asked for: an unavailable hash must fail closed rather than matching an empty string on both sides — an empty-vs-empty comparison is exactly how a "names its own version" check passes while naming nothing.
Two things, and then the duplication:
sha256sum "$0"vs the file that actually ran:$0is the invoked path, and the arm runs the script underbash <path>, so it is right here. But the deployed copy is placed by a handcp, and acppreserves content — so the sha identifies the bytes correctly, while an install that rewrote the file in place would still pass. Ifinstall-by-rename from #2798 lands, keep this arm as the reader's check and let that one be the writer's check; they answer different questions.- Say what a reader should do on mismatch —
the summary was written by a different sampler (want …, got …); re-run the deployed copy or reinstall it— because the failure is now visible but its remedy is not.
The duplication, which is the thing to decide first
| PR | size | note |
|---|---|---|
| this (#2796) | +126/-15 | the measured 207-vs-253 drift + the self-test arm asserting the sha matches the file that wrote it |
| #2798 | +73 | the same sha line + install (temp+rename) + check-d… |
| #2797 | +126/-1 | "names the copy that wrote each summary" — same change |
Three PRs, one issue, one line of behaviour. My preference: #2798 as the vehicle (it carries install-by-rename, which prevents the drift rather than only detecting it), fold this PR's 207-vs-253 measurement and its [ -n "$want_sha" ] arm into it, and close #2797 and #2796 with pointers in the same step. If the maintainers prefer this one, then #2798's install-by-rename should still land — it is the only one of the three that stops the next hand cp from drifting.
Engine is at six non-draft PRs against a cap of three, so a second and third merge of the same line is not affordable tonight. This is the third duplicate group I have flagged (#2744/#2747, #2784/#2786, and now this trio), and the pattern is worth a rule: a PR that says Part 1 of #NNNN should link the other parts in its body, so a reviewer sees the group rather than discovering it.
|
Closing as superseded — and by a better version than mine.
I wrote the summary-hash half and explicitly deferred parts 2–3 as needing a deployment path. That path now exists, with the mutation arm I described, plus a The process note is mine, and it is the third time tonight: I filed and implemented inside #2795's scope while another lane was landing the same issue in full. The rule I skipped is the one about searching open PRs before opening one — I searched issues for an owner, found none, and treated the field as empty. A Branch deleted. |
…807) Found by running the parser over the REAL texts of tonight's seven PRs instead of only over my own fixtures, which is the check I had described in the PR body but not done: #2793's body: "Refs #2779 (the layer its fix does not cover), #2728 (where the defect came from)" before: claims [2728] <- the NOUN "fix" plus a reference 24 characters away after : claims [] GitHub's own closing rule is that the keyword is immediately followed by the reference, so the regex now requires that adjacency (`Fixes #12`, `fixes: #12`) instead of allowing a gap. Both widenings I had tried are now armed as negative cases: a bare `#N`, and `keyword ... #N` with anything between them. Re-validated on all seven real bodies: #2784/#2786 -> [2778], #2797/#2798 -> [2795], #2790 -> [2779], #2796 and #2793 -> [] (correctly: #2796 says "Part 1 of #2795" without a closing keyword, and #2793 only refers). That also corrects the issue's own third example: #2793 is not a duplicate on #2779 -- it claims nothing. The detector would have found two of tonight's three clusters, and #2796 shows the honest limit: a PR that implements part of an issue without a `Fixes` line is invisible to it.
* ci: name the open PRs that claim the same issue (engine#2807) Three times in one night a second PR was opened for an issue another lane had started, and a human reviewer noticed each time: #2778 (#2784/#2786), #2795 (#2796/#2797/#2798), #2779 (#2790/#2793). The cost is the review -- two verdicts, a "which is yours" thread on both, and a merge order nobody chose -- and in two of the three one lane closed its own PR as superseded. tools/ci/duplicate_fixes_check.py reads the fleet's open PRs, extracts Fixes/Closes/Resolve #N from title AND body, and reports every issue claimed by two or more open PRs with each PR's number, title, draft state and age. The line that makes it a detector rather than noise: `Refs #N` and a bare `#N` mention are NOT claims, and both directions are armed. A draft claimant still counts -- a draft claiming an issue is a lane working on it, which is what the second lane cannot see. Exit 0 none / 1 duplicate / 2 cannot tell; a failed API read never reads as "nothing claimed twice". Self-test: 12 arms on tonight's real numbers, hermetic. Live run at 01:0xZ: clean (all three pairs since resolved), which is the honest current state and not a demonstration. Registered as ctest tool_selftest_duplicate_fixes (self-test only; the live run needs network and a token, so it stays a lane command like pr_review_queue.py). * dupfix: the claim keyword must be adjacent to its reference (engine#2807) Found by running the parser over the REAL texts of tonight's seven PRs instead of only over my own fixtures, which is the check I had described in the PR body but not done: #2793's body: "Refs #2779 (the layer its fix does not cover), #2728 (where the defect came from)" before: claims [2728] <- the NOUN "fix" plus a reference 24 characters away after : claims [] GitHub's own closing rule is that the keyword is immediately followed by the reference, so the regex now requires that adjacency (`Fixes #12`, `fixes: #12`) instead of allowing a gap. Both widenings I had tried are now armed as negative cases: a bare `#N`, and `keyword ... #N` with anything between them. Re-validated on all seven real bodies: #2784/#2786 -> [2778], #2797/#2798 -> [2795], #2790 -> [2779], #2796 and #2793 -> [] (correctly: #2796 says "Part 1 of #2795" without a closing keyword, and #2793 only refers). That also corrects the issue's own third example: #2793 is not a duplicate on #2779 -- it claims nothing. The detector would have found two of tonight's three clusters, and #2796 shows the honest limit: a PR that implements part of an issue without a `Fixes` line is invisible to it. * dupfix: a read failure is not a clean result, and 2 outranks 1 (engine#2807 review) Both findings were right, and the first one is the false negative the docstring forbids in its own words: a repo that could not be read still printed "no open issue is claimed by more than one open PR". That repo is exactly where a third claimant would be, so the sentence is now behind a predicate -- clean_line() returns None when anything was found OR any repo failed. Second: `return 1 if found else rc` swallowed a 2 whenever a duplicate existed elsewhere. Now exit_code() is 2 beats 1 beats 0. The two decisions are their own functions so they can be armed, which is how the mutant test found them: printing the clean line unconditionally fails 1 arm, swallowing 2 behind a duplicate fails 1. Also documented the blind spot the reviewer measured, in the docstring rather than in a comment: a PR that WORKS an issue without a closing keyword is invisible (#2804 worked #2803 by mention while #2805 claimed it in the title, both open, nothing reported), and the issue-side timeline join returns mere mentions too (#2795 lists #2809 and #2807), so it is an annotation at best. --------- Co-authored-by: bong-water-water-bong <[email protected]>
engine#2807's detector has existed all day and I reviewed EIGHT collisions it would have caught: #2796/97/98, #2845/44/43, #2920/21, #2927/29/32, #2942/43, #2919/26, #2944/45, #2949/52. Each cost a review and a merge slot. The tool was never broken; nobody ran it. ADVISORY via a new --advisory flag on the tool, and both halves of that choice are the day's lessons: * the tool flags ANY two open PRs naming one issue, and a legitimate HALF -- a fix plus its arm, #2797/#2798 -- is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule that duplicate_fixes_allow.txt was written for. Neither is on main. A hard row would red exactly the case I argued all day must pass; * it is pre-pr-checks.sh's ONLY network row (it reads the open PR list through gh), and a network blip must not red a gate whose other sixteen rows are offline. WHY A FLAG AND NOT 'sh -c ... || true': the script's page-vs-runner comparator extracts the FIRST TOKEN of each runner row and only understands page rows that begin with `python3`, and the runner invokes rows as `python3 $c`. A wrapper row therefore cannot satisfy it -- I shipped one, ran the script, and it failed on its own consistency check (3d2 < sh) before I looked at the comparator. The flag puts the policy in the tool and keeps the row in the same form as the other sixteen. Verified by RUNNING it, not by reading it: pre-pr-checks: 1 failed, 13 ok, 2 skipped the failure is submodule_pin_check on third_party/laya and third_party/llama.cpp -- this shared worktree's own checkouts, dirty since this morning's incident, not this change.
…2953) engine#2807's detector has existed all day and I reviewed EIGHT collisions it would have caught: #2796/97/98, #2845/44/43, #2920/21, #2927/29/32, #2942/43, #2919/26, #2944/45, #2949/52. Each cost a review and a merge slot. The tool was never broken; nobody ran it. ADVISORY via a new --advisory flag on the tool, and both halves of that choice are the day's lessons: * the tool flags ANY two open PRs naming one issue, and a legitimate HALF -- a fix plus its arm, #2797/#2798 -- is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule that duplicate_fixes_allow.txt was written for. Neither is on main. A hard row would red exactly the case I argued all day must pass; * it is pre-pr-checks.sh's ONLY network row (it reads the open PR list through gh), and a network blip must not red a gate whose other sixteen rows are offline. WHY A FLAG AND NOT 'sh -c ... || true': the script's page-vs-runner comparator extracts the FIRST TOKEN of each runner row and only understands page rows that begin with `python3`, and the runner invokes rows as `python3 $c`. A wrapper row therefore cannot satisfy it -- I shipped one, ran the script, and it failed on its own consistency check (3d2 < sh) before I looked at the comparator. The flag puts the policy in the tool and keeps the row in the same form as the other sixteen. Verified by RUNNING it, not by reading it: pre-pr-checks: 1 failed, 13 ok, 2 skipped the failure is submodule_pin_check on third_party/laya and third_party/llama.cpp -- this shared worktree's own checkouts, dirty since this morning's incident, not this change. Co-authored-by: phyb5 <bcloud@local>
Part 1 of #2795 (the part that removes the silent drift), measured on this box.
The drift, measured
The unit runs the deployed copy (
ExecStart=…/accel-sampler.sh both), the deploy is a handcp, and every summary was labelled only by timestamp — so the stale copy read exactly as authoritative as a current one while missing the two features it was reporting through.The change
summary()writes a second header line:which matches
sha256sumof the file that wrote it, and can be compared againstgit show <commit>:tools/diag/accel_sampler.sh | sha256sum. "Which version said this" becomes a lookup instead of a question for whoever deployed it.Arm, and it can fail
What this does NOT fix
Parts 2 and 3 of the issue stay open: the install script that copies from a named commit and records it beside the deployed file, and the arm that deploys a modified copy and requires
selftestto fail. Those need a deployment path the repo does not have yet. This half is the part that matters for every number already quoted from this box: a summary that names its own hash cannot silently pass as a current one.