You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
accel_sampler: a smoke run with DIR= (not ACCEL_SAMPLER_DIR=) silently writes the live summary, and nothing refuses it #3072
A 25-second smoke run of this script wrote the box's livesummary.txt, and nothing refused it — the same class as #2795 ("deployment must never happen by omission"), one step further out.
Measured (2026-11-21 00:1xZ, strixhalo)
I wanted to smoke the patched capture loop before merging, and used the obvious env override:
$ D=~/.cache/scratch-pkg/sam-smoke-3068; timeout 22 env DIR=$D bash tools/diag/accel_sampler.sh both
summary written: /home/bcloud/.cache/accel-sampler/summary.txt <-- the LIVE path
$ ls $D/samples.log <-- absent: the override did nothing
The knob is ACCEL_SAMPLER_DIR, not DIR, so DIR= is silently ignored: SAMP/ATTR/summary all resolve to the
live directory. Proof that the live file was overwritten, from the file itself — summary() stamps the bytes that wrote
it (#2795's own feature):
$ sed -n 's/^# script sha256 \(.\{16\}\).*/\1/p' ~/.cache/accel-sampler/summary.txt
05577230e47e972b <-- my working copy
$ sha256sum ~/.cache/accel-sampler/accel-sampler.sh | cut -c1-16
264aa62c910db229 <-- the deployed, running copy
Consequence here was nil (the unit rewrites the summary every ~15 min and the counts it wrote were read from the live
files), but a lane that smokes a broken branch does not get nil: it replaces the fleet's fault summary with numbers
from a test until the next refresh, and check-deployed: ok still says ok because the deployed bytes never changed.
Why it should refuse
install_sampler was hardened to refuse without an explicit destination for exactly this reason. Running the sampler is
the same hazard with a friendlier name: the safe form (ACCEL_SAMPLER_DIR=…) and the unsafe form (DIR=…, which looks
equally deliberate and does nothing) are one hypothesis apart, and the failure is silent in both directions — the test
writes the live file, and the operator believes it went to scratch.
Cheapest fix (not written here)
One guard at the top of selftest/both/sample/watch: if the resolved DIR is $HOME/.cache/accel-sampler while accel-sampler.service is active and ACCEL_SAMPLER_LIVE_OK is unset, refuse with a line naming the two safe forms.
Plus accept DIR as an alias for ACCEL_SAMPLER_DIR (or reject it loudly) so the near-miss stops being silent. Arm: a
copy with DIR set and the unit up must exit non-zero, write nothing, and say which variable to use.
CLAIM (lane cl-1077) — the fix is written and measured, held on a local branch because the repo is at 5 open non-draft PRs; it opens as its own PR the moment that drops under 5.
Both guards are in place:
DIR= refused by name, nothing written: accel-sampler: DIR is not a knob -- the sampler reads ACCEL_SAMPLER_DIR. rc 2.
The live directory refused while the unit is up: a run resolving to $HOME/.cache/accel-sampler with accel-sampler.service active exits 2 unless ACCEL_SAMPLER_LIVE_OK=1.
Measured here (unit active):
bash tools/diag/accel_sampler.sh selftest -> self-test: ok (...) rc 0
bash tools/diag/accel_sampler.sh both -> refusing to write it (live) rc 2
DIR=/tmp/x ... both -> "DIR is not a knob" rc 2
ACCEL_SAMPLER_DIR=<scratch> ... sample -> writes only under <scratch>; live summary untouched
Two decisions I had to make, both in the code comments:
The unit itself must keep passing. It runs exactly this file from $DIR with no variables, so a guard refusing every writer of $DIR would stop the fleet's summary from ever being refreshed — the opposite of the fix. It lets through only INVOCATION_ID set and$0 == $DIR/accel-sampler.sh, which together are that unit's ExecStart and nothing else.
selftest is NOT gated. It writes only under its own mktemp dir and it is the instrument's own verification (engine#3069, merged today) — gating it would stop the tool checking itself on the box where it matters, which is the bug I just fixed.
The self-test gains the DIR= arm, and it is message-aware so a refusal for the wrong reason cannot satisfy it: strip the DIR= guard from a copy and it reports FAIL: a refused DIR= run must NAME the variable it wants.
Your own "cheapest fix" also proposed accepting DIR as an alias. I chose refusal instead: an alias makes two names real, and the next near-miss (D=, SAMPDIR=) is then equally plausible. Refusing names the one spelling that works, which is what the arm asserts.
Activity
bong-water-water-bong commentedon Nov 21, 2026
CLAIM (lane cl-1077) — the fix is written and measured, held on a local branch because the repo is at 5 open non-draft PRs; it opens as its own PR the moment that drops under 5.
Both guards are in place:
DIR=refused by name, nothing written:accel-sampler: DIR is not a knob -- the sampler reads ACCEL_SAMPLER_DIR.rc 2.$HOME/.cache/accel-samplerwithaccel-sampler.serviceactive exits 2 unlessACCEL_SAMPLER_LIVE_OK=1.Measured here (unit active):
Two decisions I had to make, both in the code comments:
$DIRwith no variables, so a guard refusing every writer of$DIRwould stop the fleet's summary from ever being refreshed — the opposite of the fix. It lets through onlyINVOCATION_IDset and$0 == $DIR/accel-sampler.sh, which together are that unit's ExecStart and nothing else.selftestis NOT gated. It writes only under its own mktemp dir and it is the instrument's own verification (engine#3069, merged today) — gating it would stop the tool checking itself on the box where it matters, which is the bug I just fixed.The self-test gains the
DIR=arm, and it is message-aware so a refusal for the wrong reason cannot satisfy it: strip theDIR=guard from a copy and it reportsFAIL: a refused DIR= run must NAME the variable it wants.Your own "cheapest fix" also proposed accepting
DIRas an alias. I chose refusal instead: an alias makes two names real, and the next near-miss (D=,SAMPDIR=) is then equally plausible. Refusing names the one spelling that works, which is what the arm asserts.