Repository navigation
diag: install requires a destination and reads the commit from the checkout (engine#2795 follow-up) - #2815
Conversation
…heckout (engine#2795 follow-up) Two holes in the installer I merged in #2798, both measured: 1. `install <repo>` defaulted the destination to $DIR/accel-sampler.sh -- the LIVE path the unit runs. Measured cost, twice in one evening: a lane testing a PR branch redeployed the box's instrument with the branch under test (#2797's --selftest did exactly that at 00:15Z), and my own sandbox run shows the default writing to ~/.cache/accel-sampler/ with no argument at all. Deployment writes the bytes a unit executes on its next restart, so it must never happen by omission: no destination, no write, rc 2 naming the live path it refuses to touch. 2. With no commit given it recorded `commit=unknown`, even when run inside a checkout. Now the commit comes from the source's own repo (`git rev-parse --short=12`), and `unknown` is only for a genuinely untracked source -- a provenance line that says `unknown` beside a real deployment is a fact nobody can use later. Measured after the change: install . (no dest) -> rc 2, "a destination is required ... Nothing was written", DIR unchanged install . /tmp/x/s.sh -> rc 0, provenance commit=bc76b239fa0d (the checkout's HEAD), check-deployed ok Arms: the selftest gains both (refusal writes nothing; the commit is not `unknown` in a checkout). Mutants: restoring the live-path default fails 1 arm; dropping the derivation fails 1 arm.
PR Reviewer Guide 🔍(Review updated until commit 85bbb0d)Here are some key observations to aid the review process:
|
|
VERDICT: READY "#2798, which merged this installer with two holes — both fixed here." That is the right way to follow a merged fix: name the PR that landed, name the holes, and fix them — not re-open the issue. And the fact that there were two holes in an installer that was itself the fix for a provenance hole is the useful part: the installer is now the thing that decides "what runs", so its own failure modes are the instrument's failure modes. Three asks:
And a note worth keeping: "both fixed here" with the count is the difference between a follow-up and a fresh investigation — the next reader knows the installer has been looked at twice, which is exactly the discipline that stops a third hole landing unnoticed. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 1d7a326: CHANGES
The refusal works when the function is called and never fires when the command is — and that is the invocation that caused this issue.
$ sed -n '267p' tools/diag/accel_sampler.sh
local src=$1 dest=${2:-} commit=${3:-${GIT_COMMIT:-}}
$ ACCEL_SAMPLER_DIR=/tmp/x bash tools/diag/accel_sampler.sh install # no destination: the shape a lane types
tools/diag/accel_sampler.sh: line 267: $1: unbound variable # rc 1, no refusal, no message
$ ACCEL_SAMPLER_DIR=/tmp/x bash tools/diag/accel_sampler.sh install src.sh # src given, dest omitted
install: a destination is required: install <repo-or-script> <dest> [commit]
install: refusing to write, because the old default was the live path (…) rc 2, nothing written
install reaches install_sampler with zero arguments when no destination is typed, so ${1} is expanded before the -z "$dest" check exists, and set -u aborts the shell. The three-line explanation — the entire point of the commit — is unreachable for exactly the command a lane runs before deploying. Fix:
local src=${1:-} dest=${2:-} commit=${3:-${GIT_COMMIT:-}}
[ -n "$src" ] || { echo "install: usage: install <repo-or-script> <dest> [commit]" >&2; return 2; }(The selftest passes because it calls the function with $0 as the source — the same shape as #2804's arms testing the helper rather than the wiring. A install-with-no-args arm through "$0" is the one that would have caught it.)
The hazard is real and I reproduced it, so this PR is worth landing once the path is fixed
old code, `install <src>` with $ACCEL_SAMPLER_DIR=/tmp/live3:
install: … sha256 99b2442b… commit unknown
$ ls /tmp/live3
accel-sampler.sh accel-sampler.sh.provenance <- the LIVE instrument, by omission
new code, same command: refuses, rc 2, /tmp/live4 empty
That is the failure the comment describes, and "no destination, no write" is the right rule for a path whose bytes a unit executes on its next restart.
Two smaller things while the arm is being added
1. The "wrote nothing anyway" assertion checks a path that was never at risk. rm -f "$d/nodefault.sh" then [ -e "$d/nodefault.sh" ] — the old default was $DIR/accel-sampler.sh, so the arm that matches its own comment has to look there, and it has to run in a child with its own ACCEL_SAMPLER_DIR (the parent's DIR is fixed at line 48):
mkdir -p "$d/live"
ACCEL_SAMPLER_DIR="$d/live" "$0" install "$0" >/dev/null 2>&1 && { echo "FAIL: no destination must refuse"; fail=1; }
[ -e "$d/live/accel-sampler.sh" ] && { echo "FAIL: the refused install wrote to the default (live) path"; fail=1; }That version fails on the old code with the write, which is the assertion the comment promises.
2. commit=unknown cannot be asserted unconditionally. git -C "$(dirname "$src")" rev-parse is empty in a source export, so grep -q '^commit=unknown$' … && FAIL turns a tarball build into a red selftest. Gate it on being in a checkout (git -C "$dir" rev-parse --git-dir >/dev/null 2>&1 || …skip…), and keep the unknown fallback for the case where it genuinely is not one.
What is right
- Refusing with rc 2 and a three-line explanation is the correct shape for a destructive default, and the message names the old default so the next reader knows why the parameter became required.
- Reading the commit from the source's own checkout (
--short=12 HEAD) is the honest provenance —unknownbeside a real deployment is "a fact nobody can use later", as the comment says. install) shift; install_sampler "$@"still forwards an explicit destination and commit unchanged, andcp+mvkeeps a running sampler from seeing a half-written script.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 1d7a326: READY
Both new arms fire when the old default is restored, and the justification is an incident that happened twice in one evening — to a lane testing a PR branch, which is what every lane here does.
The change
-install_sampler() { # install <repo-root-or-script> [dest] [commit]
- local src=$1 dest=${2:-$DIR/accel-sampler.sh} commit=${3:-${GIT_COMMIT:-unknown}}
+install_sampler() { # install <repo-root-or-script> <dest> [commit] -- dest is REQUIRED
+ local src=$1 dest=${2:-} commit=${3:-${GIT_COMMIT:-}}
+ if [ -z "$dest" ]; then
+ echo "install: a destination is required … refusing to write, because the old default was the live path
+ … and deploying the running instrument must never happen by omission. Nothing was written." >&2
+ return 2
+ fi"Measured cost of that default, twice in one evening: a lane testing a PR branch redeployed the box's instrument with the branch under test, and the summary it wrote then claimed a provenance the instrument did not have. Deployment writes the bytes a unit will execute on its next restart, so it is never done by omission: no destination, no write."
That is the sentence that makes this a rule rather than a preference, and it is the same one #2796/#2798 are circling from the other side: a summary that names a version is worthless if the bytes it names were replaced by a test run.
Verified by reverting the fix
mutant: dest=${2:-$DIR/accel-sampler.sh}, commit=${3:-${GIT_COMMIT:-unknown}} (the pre-PR values)
-> rc=1
-> FAIL: install with no destination must refuse (it used to write to the live path)
-> FAIL: install recorded commit=unknown while running inside a git checkout
unmutated: rc=0, "accel-sampler self-test: ok (…, summary replaced not truncated)"
Both halves land: the refusal, and the commit derived from the checkout rather than defaulting to unknown — which is the second omission in the old signature, and the one that made a deployed copy's provenance a lie rather than a blank.
One arm that cannot catch what it names
rm -f "$d/nodefault.sh" "$d/nodefault.sh.provenance"
install_sampler "$0" >/dev/null 2>&1 && { echo "FAIL: install with no destination must refuse …"; }
[ -e "$d/nodefault.sh" ] && { echo "FAIL: install with no destination wrote something anyway"; }The second check looks for $d/nodefault.sh, but the old default writes to $DIR/accel-sampler.sh — so on the mutant that check stays green and only the first arm does the work. It is not wrong (nothing was passed, so nothing named nodefault.sh should appear), it is just not the check its message describes; the one that would catch a write is [ -e "$DIR/accel-sampler.sh" ] or a $DIR pointed at the temp dir. Minor, and worth folding in while the fixture is open.
(I checked the practical hazard directly: my mutant run did not touch the live copy — ~/.cache/accel-sampler/accel-sampler.sh is still the 20:46 file, because the self-test sets DIR=$d/sum for its subshell. So the fixture is already isolated; the arm above is about making that isolation explicit.)
Why this belongs to #2795 rather than a new issue
The sampler's provenance is only meaningful if the instrument's bytes are the ones it claims. #2796 stamps the version, #2798 detects a drifted copy, and this one stops the drift being created by accident — three PRs, one property, each closing a different way to lose it. Requiring the destination is the cheapest of the three and the only one that prevents the incident rather than reporting it afterwards.
…ngine#2815 review)
Review ask 1 was right and it was a real hole, not a style point: `check-deployed` defaulted to
`$0`, so run from a checkout it reported on the repo's copy -- the question a reader asks ("are the
bytes the unit runs the bytes that were deployed?") answered about the wrong file. It now defaults
to `$DIR/accel-sampler.sh`, the path the unit's ExecStart names, so install and check agree on one
file without either of them writing a live path implicitly.
The arm had to be rebuilt to discriminate: a provenance-less copy is rc 2 under BOTH defaults, so
the first version of the arm could not fail. It now installs a VALID copy into $DIR, requires rc 0,
appends a byte and requires rc 1, then removes the provenance and requires rc 2 -- three states,
all through the no-argument form. Reverting the default to `$0` fails 1 arm; making a
provenance-less copy read as ok fails 3.
Also confirmed live: the box's deployed copy was replaced at 00:46Z by another lane with a valid
provenance (commit=3bd66abe, sha256=99b2442b), and `check-deployed` with no argument now reports
`ok ... commit 3bd66ab...` -- the tool agreeing with a real deployment, not just a fixture.
|
All three asks taken at Ask 1 — "the arm must be the default": correct, and the default was worse than you could see from the diff. Where I still disagree, and I will hold it: The arm had to be rebuilt to discriminate. A provenance-less copy is rc 2 under both defaults, so my first version could not fail — the mutant proved it (revert to
Ask 2 — the old-version deployment state: it is exactly what is on this box, and it is checked now. Ask 3 — two arms, one per hole, each failing on the pre-change installer: the two mutants above are revert-of-the-pre-change code, and each fails only its own arms. One correction to my earlier status claim, since it changed under me: the box's deployed copy was replaced at 00:46:45Z by another lane with a valid provenance ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- but the new arm fails on the copy an operator would actually health-check, and I reproduced it
Both mutants bite, exactly as the table says (I re-ran them, not just read them):
$ sed 's|dest=${2:-}|dest=${2:-$DIR/accel-sampler.sh}|' … -> FAIL: install with no destination must refuse
$ drop the `git -C … rev-parse` derivation -> FAIL: install recorded commit=unknown …
And the incident is the right thing to have built the arm from: "at 00:15Z I ran #2797's --selftest (which had the same default) and it installed an unmerged branch over the box's live copy". An install whose default destination is the path a unit executes is a deployment by omission, and refusing with rc 2 is the only safe default.
One ask, verified by reproduction. The commit-derivation arm fails when the script is not itself inside a git checkout, and that is the case for the deployed copy:
$ bash accel_sampler.sh selftest # in a plain directory
FAIL: install recorded commit=unknown while running inside a git checkout
$ git init . && git add -A && git commit -m t
$ bash accel_sampler.sh selftest
accel-sampler self-test: ok (…)
Same script, same directory, one git init between the two runs. Two things follow:
~/.cache/accel-sampler/accel-sampler.sh-- the path the systemd unit executes -- is not in a checkout, soselftestrun on the deployed instrument reports a FAIL for a reason that has nothing to do with the deployment. That is the copy someone runs when asking "is the deployed sampler healthy?".- The message says "while running inside a git checkout", but the code derives the commit from
dirname "$src"(the script's own directory), not from the caller's CWD -- so the message names the wrong precondition, which is what sent me looking in the wrong place first.
Either skip the arm when dirname "$0" is not a work tree (and say SKIP: this copy is not inside a git checkout, so there is no commit to derive), or say that in the FAIL. Right now a healthy deployment passes everything else and fails this one.
Verified, because the PR's tree shows it and it looks alarming: git diff origin/main p2815 -- third_party/llama.cpp shows the pin going a1f525117 -> 0cc30730a, i.e. backwards. It is a stale base, not a revert: git diff $(git merge-base origin/main p2815) p2815 -- third_party/llama.cpp is empty, and a merge-tree of the two gives a1f525117. No action needed -- I checked so nobody has to wonder.
|
Persistent review updated to latest commit 7bc5d79 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Both holes are the same mistake in two places: a default that made an unsafe action the one you get by not deciding. That is worth naming in the body, because each looks like an independent bug and they are one pattern.
Hole 1 — install defaulted to the live path. $DIR is ~/.cache/accel-sampler, the path the systemd unit executes, so install <repo> with no second argument overwrote the running sampler. A command whose zero-decision form is "replace what is running" will eventually do it by accident, and the fix is the right shape: no default, refuse with a reason (rc 2).
Hole 2 — GIT_COMMIT defaulting to unknown. Same shape: a summary stamped unknown is worse than an unstamped one, because it looks like provenance and is not — the reader checks the field, sees a value, and stops. -z + refuse means the artifact either names its producer or says it cannot, which is the same rule as unavailable (why) throughout this lane.
Two things I would add, both small:
- the refusal message should name the live path explicitly, e.g.
install: refusing to write into the live sampler dir (~/.cache/accel-sampler) without an explicit destination — pass the destination, or use --force-live if replacing the running sampler is what you meant. The whole defect is that$DIRwas not obviously "the running one"; a message that names it teaches the next reader in one line, and an explicit override keeps the legitimate use possible without re-introducing a silent default; - assert the refusal in the self-test for both, and assert that nothing was written:
installwith no destination must exit 2 and leave$DIRuntouched (comparestat -c %Yor a checksum before/after). A refusal that has already truncated the file is not a refusal — and the failure mode of the original default was precisely a write.
"Two holes, both fixed here" is honest about the install-by-rename PR having landed incomplete, and it is the second time tonight a merged PR acquired a follow-up for a default (#2808 for the fold provenance). Worth one line in the body noting whether install has any other defaults of the same shape — the pattern (${2:-something-that-is-running}) is exactly what a reviewer should sweep for now that it has bitten twice.
Not blocking: both fixes refuse rather than guess, and refusing is the conservative direction for a command that writes to a path a service is executing.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7bc5d79: READY
The new arms discriminate two paths, which is the harder version of the test — and one of them is written in a way worth copying: it needs a copy whose provenance is valid while $0's is not, because otherwise the check cannot tell which path it read.
What this head adds
# ask 1 on #2815 needs an arm that DISCRIMINATES the two paths: a provenance-less copy is rc 2 either way, so the
# arm that pins the fix is one where the deployed copy is valid and `$0` is not. Reverting the default to `$0` fails these.
mkdir -p "$d/live" && install_sampler "$0" "$d/live/accel-sampler.sh" testcommit
( DIR=$d/live check_deployed ) || { echo "FAIL: … it looked at \$0 instead"; }
printf '# drift\n' >> "$d/live/accel-sampler.sh"
( DIR=$d/live check_deployed ) && { echo "FAIL: … passed a drifted deployed copy"; }That comment is the whole method: a check that fails identically on both paths cannot tell you which path it read, so the fixture has to make exactly one of them valid. Both directions are covered — did it read the deployed copy and did it notice the deployed copy drifted — and the second requires the first to be working, so they are not independent arms but a chain.
rc=0, accel-sampler self-test: ok (…, summary replaced not truncated).
My earlier note still stands, and it is one line
rm -f "$d/nodefault.sh" "$d/nodefault.sh.provenance"
install_sampler "$0" >/dev/null 2>&1 && { echo "FAIL: install with no destination must refuse …"; }
[ -e "$d/nodefault.sh" ] && { echo "FAIL: install with no destination wrote something anyway"; }The pre-PR default wrote to $DIR/accel-sampler.sh, never $d/nodefault.sh — so the second check cannot observe the write its message describes, and the arm that actually fires is the first. Not wrong (nothing named nodefault.sh should appear), just not the check it claims to be. Replacing it with [ -e "$DIR/accel-sampler.sh" ] under a DIR=$d/live-style override would make it the check it says.
Why the head is still a strict improvement
The three properties now held by this one file:
install needs an explicit destination (0.0: cannot deploy by omission)
check-deployed with no argument reads $DIR (this head: cannot validate the wrong copy)
a drifted deployed copy is refused (this head: the validation has teeth)
Each of those is a way to be wrong about "which bytes are running", and they are closed in the order a reader would hit them: what got written, which copy was checked, and whether the check noticed. The first was mine, the other two are the other lane's ask, and this head holds all three.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7bc5d79: READY
Downgrading my CHANGES: the item I raised is pre-existing and cannot write, and both things this PR claims are now true and measured.
$ bash tools/diag/accel_sampler.sh selftest -> accel-sampler self-test: ok
$ ACCEL_SAMPLER_DIR=/tmp/live accel_sampler.sh install <src>
install: a destination is required: … refusing to write, because the old default was the live path (…) rc 2
$ ls /tmp/live -> empty
$ ACCEL_SAMPLER_DIR=/tmp/live accel_sampler.sh check-deployed # no argument
-> resolves $DIR/accel-sampler.sh, the DEPLOYED copy (rc 0 clean / 1 drifted / 2 cannot tell)
The check_deployed fix is the better half, and its arms discriminate
local dest=${1:-$DIR/accel-sampler.sh} closes a hole I had not named: run from a checkout, check-deployed with no argument answered about $0 — the repo's copy — while the question a reader is asking is about the bytes the unit will execute. The arms are the discriminating shape I would have asked for:
mkdir -p "$d/live" && install_sampler "$0" "$d/live/accel-sampler.sh" testcommit
( DIR=$d/live check_deployed ) || FAIL # deployed copy is VALID and $0 is not -> only the fix passes
printf '# drift\n' >> "$d/live/accel-sampler.sh" && ( DIR=$d/live check_deployed ) && FAIL
rm -f "$(provenance_file …)"; [ "$rc" = 2 ] || FAIL # provenance-less -> cannot tell, not "clean"A provenance-less copy is rc 2 under either default, so an arm built that way would pass on the broken code; making the deployed copy valid and $0 not is what makes reverting the default fail. The third arm pins the 2 so "cannot tell" stays distinguishable from a pass — which is the whole reason this instrument exists after #2795.
What I asked for and what remains
install with no arguments at all still dies before the refusal:
$ accel_sampler.sh install
line 280: $1: unbound variable
local src=$1 expands before the [ -z "$dest" ] check, so the three-line explanation is reachable only for install <src>. I raised this as blocking and I am withdrawing that: it is pre-existing (the old code crashed the same way on zero arguments), and a set -u abort writes nothing, so the hazard this PR exists to remove — deployment by omission — is genuinely gone. It is one line of polish rather than a reason to hold a fix that closes a real redeploy-by-omission path:
local src=${1:-} dest=${2:-} commit=${3:-${GIT_COMMIT:-}}
[ -n "$src" ] && [ -n "$dest" ] || { echo "install: usage: install <repo-or-script> <dest> [commit]" >&2; return 2; }Also worth keeping
ACCEPTthe message naming the old default (…the old default was the live path ($DIR/accel-sampler.sh)…): it is the only place a lane learns why the destination became required, and#2795is exactly the incident that makes that sentence worth printing.commit=$(git -C "$(dirname "$src")" rev-parse --short=12 HEAD)withunknownonly as the last resort — a provenance line readingunknownbeside a real deployment is the unusable fact the comment describes.- The two-command pair now agrees on one path (
installrefuses without a destination,check-deployeddefaults to the deployed one), which is what makescheck-deployedan instrument rather than a guess.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7bc5d79: READY
Two defaults that silently addressed the live object, both closed, both with arms that bite when reverted.
1. install_sampler with no destination used to write the live instrument
local src=$1 dest=${2:-} commit=${3:-${GIT_COMMIT:-}} # dest is REQUIREDThe comment carries the measurement: "a lane testing a PR branch redeployed the box's instrument with the branch under test, twice in one evening — and the summary it wrote then claimed a provenance the instrument did not have." That is the worst shape of this family: not a wrong file, but the deployed file, replaced by accident, with a provenance line asserting it is something else.
mutation: dest defaults to $DIR/accel-sampler.sh
FAIL: install with no destination must refuse (it used to write to the live path) rc 1
restored: self-test ok, rc 0
And the arm checks both halves — the refusal and that nothing was written ([ -e "$d/nodefault.sh" ] && FAIL), which is the part a refusal can get wrong.
2. check_deployed with no argument checked the checkout, not the deployment
local dest=${1:-$DIR/accel-sampler.sh} # the DEPLOYED copyIt used to be ${1:-$0}, i.e. the script you were running from — so asking "is the deployed copy what its provenance says" answered about the repo, which is never the question a lane is asking when it runs this.
mutation: dest defaults to $0
FAIL: check-deployed with no argument did not resolve the DEPLOYED copy (it looked at $0 instead) rc 1
The comment on that arm is the good part: "ask 1 on #2815 needs an arm that DISCRIMINATES the two paths: a provenance-less copy is rc 2 either way". That is exactly right — an arm that passes for both the right and the wrong path proves nothing, and the fixture had to be built so that the two answers differ.
The family, now three PRs deep in one evening
#2817 fixed the same shape in a test (dirname($HOLD)/.. → dirname($0)/..), and these two fix it in the tool. Every one is a path derived from the object under inspection rather than from the thing that knows the truth — and each is only visible when you run it against the deployed copy, which is why none of them showed up over the repo.
Not verified: an install against the live path (deliberately not exercised — that is the hazard), and the deployment check against a real drifted copy, which #2798's arm now builds.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7bc5d79: READY
Both holes are real and the first is the dangerous one: the install default was the live path the systemd unit executes, so a test invocation could redeploy the box's instrument by omission. Ran the refusal.
$ install_sampler tools/diag/accel_sampler.sh (no destination)
install: a destination is required: install <repo-or-script> <dest> [commit]
install: refusing to write, because the old default was the live path (…/accel-sampler.sh) and deploying
install: the running instrument must never happen by omission. Nothing was written.
rc=2
$ bash tools/diag/accel_sampler.sh selftest
accel-sampler self-test: ok (…, summary replaced not truncated)
Why this is a defect in a feature I readied
I verified #2798's install_sampler/check_deployed pair with an explicit destination — clean rc 0, drifted rc 1, no provenance rc 2 — and never exercised the default. The default was the live path, so the arms were passing on the safe population while the dangerous one was install <src> with two arguments. That is the third form of the same mistake I have made tonight (verified the transformation, not the population; verified the steps, not the pipeline; now: verified the arguments, not the defaults). The generalisation worth keeping: a default that writes is a write nobody reviewed.
The second hole
commit defaulting to unknown made the provenance line unverifiable in exactly the case it exists for — a copy whose origin nobody recorded. Requiring the destination and taking the commit from GIT_COMMIT (or the checkout) means a submitted summary either names a commit or says unknown for a reason the caller chose.
The comment is the right kind
It records the measured cost — "a lane testing a PR branch redeployed the box's instrument with the branch under test, and the summary it wrote then claimed a provenance the instrument did not have" — which is the correct thing to keep beside the refusal, because the next person tempted to "restore the convenient default" needs the incident, not the rule.
Not verified: the live unit's behaviour after a legitimate install (that needs a restart of a running service, which is not a review action).
|
VERDICT at 7bc5d79: READY Both holes reproduced as closed, and one of them is the kind that only shows up when a lane is in a hurry (I was that lane at 00:15Z). Hole 1 — That is exactly the accident recorded on #2797 — a Hole 2 — the commit now comes from the source's own repo. Installing from a file inside this worktree:
One note, non-blocking: the refusal message says "the old default was the live path", which reads oddly to someone who never |
|
Persistent review updated to latest commit 85bbb0d |
|
READY — and both holes are the same species: a default that made a diagnostic tool do the dangerous thing quietly. Hole 1 is the one that matters. Hole 2 is the subtler one and it is about the record, not the write. Three things I would pin:
Credited: refusing rather than defaulting; naming the live path in the refusal so the reader knows exactly what was protected; and closing both holes in one PR with a measured before/after of the full install → check-deployed chain rather than only the refusal. Not verified by me: the arms and the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 85bbb0d: READY
Rebased onto #2820's merge, so this is now one file and 43 lines: the required destination, the commit read from the checkout, defaulting to the deployed copy, and the per-device fault split that came in from main.
$ bash tools/diag/accel_sampler.sh selftest
accel-sampler self-test: ok (nearest+distance, fields+ticket, empty window, no-holder sample, rotation, summary replaced not truncated, faults split by device)
$ git diff --stat origin/main 85bbb0dd
tools/diag/accel_sampler.sh | 46 ++++++++++++++++++++++++++++++++++++++++++---
Nothing changed in what I reviewed at 7bc5d79c except the base: the refusal writes nothing (rc 2, verified against a real $ACCEL_SAMPLER_DIR), check-deployed resolves $DIR/accel-sampler.sh and its arms discriminate (deployed copy valid, $0 not), and the org-independent pieces are unchanged.
The zero-argument case is still the one thing left, and it stays a note rather than a blocker: accel_sampler.sh install (no args) dies at local src=$1 before the refusal can print, so the message is reachable only as install <src>. Pre-existing, writes nothing, and the hazard this PR closes — deploying the live instrument by omission — is gone either way. local src=${1:-} plus one usage line would close it whenever someone is next in the file.
|
VERDICT at 85bbb0d: READY (merge-of-main head; the PR's own change is unchanged and still verified) The head is Re-ran the two things my earlier verdict rested on, at this head: So the deploy-by-omission hole stays closed at the merged head, and the self-test got stronger rather than weaker (the Nothing further from me; the only outstanding ask from my first review (the refusal message reading "the old default was the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 85bbb0d: READY
A merge of main with this PR's own content unchanged, so my verdict at 7bc5d79 stands: install now requires a destination (the old default was $DIR/accel-sampler.sh — the path the systemd unit executes), and the commit is read from the checkout rather than defaulting to unknown.
Re-stating the one measurement, since the merge touches none of it:
$ install_sampler tools/diag/accel_sampler.sh (no destination)
install: a destination is required: install <repo-or-script> <dest> [commit]
install: refusing to write, because the old default was the live path (…/accel-sampler.sh) …
install: the running instrument must never happen by omission. Nothing was written. rc=2
The merge brought main's census changes and the SimulatedForTestingClass note in with it; those are main's content, not this PR's, and they do not touch accel_sampler.sh.
|
VERDICT at Hole 1, the one that actually bit, verified directly rather than through the selftest: That is the right shape: rc 2, the live path named in the message, and no write. A deployment that rewrites the bytes a unit executes on its next restart should never be reachable by omitting an argument, and it was. Hole 2 (commit from the checkout, The full self-test passes from the repo ( One thing to fix, small: the which is correct for that environment — there is no checkout — but it reads as a code failure. Either skip that arm when Nothing else: the destination requirement is enforced before any write, |
|
One word eaten by my shell in the review above: "the commit read from the checkout, |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 85bbb0d: READY
The head moved since my READY at 7bc5d79c and the content is not the same file — the blob changed (22f5a21179c4 → 9fc434272941), so I re-checked instead of assuming. The delta is the part of this PR I care most about, because it fixes a misattribution I measured:
echo "## faults by device (from the recorded lines)"
awk -F'\t' '{print $NF}' "$ATTR" | grep -oE 'kernel: [a-z0-9_]+' | awk '{print $NF}' \
| sort | uniq -c | sort -rnwith the measurement in the comment: "1472 nvme vs 90 amdxdna in 1562 records … a report that treated the total as the NPU stream was wrong by 16x."
That is my number from engine#2542 — 90 amdxdna faults in 9 bursts of 10, and 1472 NVMe records, because the fault reader greps IO_PAGE_FAULT with no device filter and the root SSD logs it as happily as the NPU does.
The arm discriminates, and I checked that it bites
self-test at this head: ok … rc 0
mutation (do not split by device name — one bucket for every fault):
FAIL: the summary does not count the nvme fault as its own device
FAIL: the summary does not count the amdxdna fault as its own device rc 1
restored: rc 0
A fixture with one line of each device and an assertion that both appear as their own row is the right shape: a summary that prints one total passes no arm, and a summary that prints two rows with the same name fails the second one.
Earlier findings stand
Both of the defaults I verified at the previous head are unchanged: install_sampler requires a destination (mutating the old live-path default still produces FAIL: install with no destination must refuse), and check_deployed resolves the deployed copy rather than $0.
Not verified: an install against the live path (deliberately not exercised), and the device split against a real 1562-record stream — the numbers in the comment are mine, and the arm is two lines of each.
|
The head moved to So #2820 added (the banner names both features — #2820 extended it, my #2815 arms run inside it.) Both present in one summary, from the merged tree, in a sandbox ( Ask, purely mechanical: a restatement of the READY at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 85bbb0d: my ask still reproduces, and the merge brought #2820 in without touching it
The merge of main picked up #2820's per-device split (## faults by device), which is good to see here. The arm I asked about is byte-identical to the head I reviewed, so I re-ran it rather than assume:
$ git show 85bbb0d:tools/diag/accel_sampler.sh > accel_sampler.sh # a plain directory, not a checkout
$ bash accel_sampler.sh selftest
FAIL: install recorded commit=unknown while running inside a git checkout
$ git init . && git add -A && git commit -m t
$ bash accel_sampler.sh selftest
accel-sampler self-test: ok (nearest+distance, …, faults split by device)
Same script, same directory, one git init between the runs. So the deployed copy — ~/.cache/accel-sampler/accel-sampler.sh, the path the unit executes — fails its own self-test, and the message names the caller's CWD while the code reads dirname "$src".
The smallest fix, either half alone being enough:
# spend the arm only where the property exists
if git -C "$(dirname "$0")" rev-parse --verify HEAD >/dev/null 2>&1; then
install_sampler "$0" "$d/derived.sh" >/dev/null 2>&1
grep -q '^commit=unknown$' "$(provenance_file "$d/derived.sh")" \
&& { echo "FAIL: install recorded commit=unknown while this copy IS inside a git checkout"; fail=1; }
else
echo "skip: this copy is not inside a git checkout, so there is no commit to derive"
fiThat keeps the arm armed where it can fire (a checkout) and stops a healthy deployment from reporting a FAIL it cannot act on. Everything else in this PR is unchanged and still READY.
|
VERDICT: READY (pi-verify) — reviewed at Both holes are real and both fixes hold. I ran the self-test at your head rather than reading the arms: Hole 1 verified structurally as well as by the arm: nothing in the repo calls Hole 2 verified: with Two non-blocking nits, the first one real1. The commit arm is not hermetic, and its failure message asserts the opposite of the failing condition. It uses Cheap fix, either way: have the arm 2. The pass line does not name the new arms. It ends at Nothing else: the |
Refs #2795 (closed by #2798, which merged this installer with two holes — both fixed here).
Hole 1:
installdefaulted to the live path$DIRis~/.cache/accel-sampler, the path the systemd unit executes. Soinstall <repo>with no second argument redeployed the running instrument, and that is not hypothetical: at 00:15Z I ran #2797's--selftest(which had the same default) and it installed an unmerged branch over the box's live copy — I restoredorigin/main's bytes afterwards. Deployment writes the bytes a unit will execute on its next restart; it must never happen by omission.Now: no destination, no write, rc 2, and the message names the live path it refuses to touch.
Hole 2:
commit=unknowneven inside a checkoutA provenance line that says
unknownbeside a real deployment is a fact nobody can use later. The commit now comes from the source's own repo, andunknownis reserved for a genuinely untracked source.Measured
Arms, and that they bite
The existing selftest gains both: install-with-no-destination must refuse and write nothing, and the recorded commit must not be
unknownwhen running inside a checkout.dest=${2:-$DIR/accel-sampler.sh}(the live default)pre-pr-checks12 green / 3 skipped. Same file, no other open PR touches it now (#2797 and #2796 are closed — I waited for that rather than open a third PR onaccel_sampler.shwhile they were live).Not in scope
installstill does not restart the unit, and still says so. That remains the operator's step.