Skip to content

diag: accel_sampler names the copy that wrote each summary, and the installer records what it deployed (engine#2795) - #2797

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-hrxnan/2795-accel-provenance
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-hrxnan/2795-accel-provenance

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #2795.

What

The unit runs ~/.cache/accel-sampler/accel-sampler.sh, a copy placed by hand, so the instrument that reports on the box and the instrument in the repository drift with nothing comparing them — measured today at 207 vs 253 lines, with the GAP records and nearest-sample attribution (#2624, #2627) missing from the copy that had been reporting 1527/1527 faults attributed. Every summary carried a timestamp and no version, so a reader could not tell a stale run from a current one.

This is the same fault gpu-hold had (#2705/#2712), and it takes the same three-part fix the issue asks for.

1. Every summary names the copy that wrote it

# accel sampler summary 2026-11-16T23:25:03Z
# script sha256 5e0d699d2406; deployed DRIFTED (this run is 5e0d699d2406, the installer recorded d10fbff58338 at commit dbg)
samples: 0   attributed faults: 0

same when the running copy is the deployed one, DRIFTED naming both hashes and the recorded commit, and unknown — never same — when no provenance file exists, because an installed copy nobody recorded is exactly the case that produced the incident.

2. tools/diag/install_accel_sampler.sh

Deploys the file, keeps a dated .pre-* of what was there, and writes <copy>.provenance:

sha=5e0d699d2406
commit=702d80200[-dirty]
source=/home/bcloud/wt/cl-hrxnan-2795/tools/diag/accel_sampler.sh
installed_at=…  installed_by=…@…

It does not restart the unit — that stays the owner's step, and the script says so rather than doing it. --selftest proves the deployed copy reports the sha it just installed.

3. An arm that can fail

In the existing selftest: the unmodified copy must read same, and a copy with one byte appended must read DRIFTED against the provenance of the original. No device, no timing — it compares hashes, so it cannot go green by luck.

Mutation-checked, because an arm that cannot fail is decoration:

product's DRIFTED branch replaced with `same`:
  FAIL: a modified copy is not reported as DRIFTED against the provenance of the original (engine#2795)
restored:
  accel-sampler self-test: ok (nearest+distance, fields+ticket, empty window, no-holder sample, rotation,
                              summary replaced not truncated, script identity + drift)

One thing I got wrong, kept in the commit message

My first version of that arm was inserted after return "$fail" — dead code that passed silently. The mutation test caught it; without that step I would have shipped an arm that never ran, which is the failure mode this whole change is about.

Not done

The unit file still points at ~/.cache; the fix is that the copy now carries its provenance, not that the deployment moved. Moving it (or having the unit run the repository copy) is a bigger change than the issue asks for.

…nstaller records what it deployed (engine#2795)

The unit runs a copy in ~/.cache placed by hand, so the running instrument and the repository drift silently:
measured today, deployed 207 lines vs main's 253, with the GAP records and nearest-sample attribution missing
from the copy that had been reporting "1527/1527 faults attributed". Every summary carried a timestamp and no
version, so a later reader had no way to tell which copy produced a number.

This is the same fault gpu-hold had (engine#2705/#2712) and the same fix:

* `summary` prints `# script sha256 <12 hex>; deployed same|DRIFTED|unknown` as its second line. The sha is
  computed from $0 before any cd; the comparison reads the provenance file the installer writes. DRIFTED names
  both hashes and the recorded commit; a missing provenance says `unknown` (never `same`), because an installed
  copy that nobody recorded is the case that produced the incident.
* `tools/diag/install_accel_sampler.sh` deploys the file, keeps a dated `.pre-*` copy of what was there, and
  writes `<copy>.provenance` with sha, commit (+ `-dirty` when the checkout differs), source, time and user. It
  does not restart the unit -- that stays the owner's step, and the script says so instead of doing it.
* an arm in the existing `selftest`: the unmodified copy must read `same`, and **a copy with one byte appended
  must read DRIFTED** against the provenance of the original. No device, no timing -- it compares hashes.

Mutation-checked, because an arm that cannot fail is decoration: breaking the DRIFTED branch in the product makes
the selftest print 'FAIL: a modified copy is not reported as DRIFTED against the provenance of the original' and
exit non-zero; restoring it returns 'ok (... script identity + drift)'.

Note for the lane: my first version of that arm was dead code -- inserted after `return "$fail"` -- and passed
silently. The mutation test is what caught it.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2795 - Partially compliant

Compliant requirements:

  • Every summary now names the copy that wrote it
  • The installer records what it deployed with a provenance file
  • The selftest now verifies the deployed copy reports the correct sha

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Provenance File Handling

The code assumes that the provenance file can be read and parsed correctly, but does not handle cases where the file might be corrupted or contain unexpected content. This could lead to incorrect drift detection or reporting.

provenance() {   # "<sha> <commit|unknown>" from the file the installer wrote, or "unknown unknown"
  [ -r "$DEPLOYED_META" ] || { printf 'unknown unknown'; return; }
  local sha commit
  sha=$(sed -n 's/^sha=//p' "$DEPLOYED_META" 2> /dev/null | head -n 1)
  commit=$(sed -n 's/^commit=//p' "$DEPLOYED_META" 2> /dev/null | head -n 1)
  printf '%s %s' "${sha:-unknown}" "${commit:-unknown}"
}
Self-test Verification

The self-test logic in the install script relies on parsing the output of the summary command to verify the deployed script's identity. If the summary format changes, this verification could fail silently or incorrectly.

if [ "$selftest" = 1 ]; then
    ACCEL_SAMPLER_DIR=$(dirname "$to") ACCEL_SAMPLER_META="$to.provenance" \
        bash "$to" summary > /dev/null 2>&1
    sum=$(dirname "$to")/summary.txt
    if grep -q "script sha256 ${sha};" "$sum" 2> /dev/null; then
        echo "  selftest: the deployed copy reports sha $sha in its summary"
    else
        echo "  selftest FAIL: the summary does not name the deployed sha $sha ($sum)" >&2
        exit 1
    fi
fi

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2797

"The unit runs ~/.cache/accel-sampler/accel-sampler.sh, a copy placed by hand" — that is the same drift class as tonight's gpu-hold finding (#2494): what runs is a hand-placed copy, and a merge changes the tree while the box keeps executing the old thing. Here it is worse, because the copy is an instrument: a sampler that reports on the box while itself being unaccounted for.

One collision, and it needs a decision: #2796 is open as "Part 1 of #2795 (the part that removes the silent drift)" and also edits tools/diag/accel_sampler…, while this PR says "Fixes #2795". Two PRs, one issue, overlapping files:

Three asks:

  1. the provenance must be readable by the reader of the report — a stamp in the sampler's own output (script hash + git rev, the way gpu-hold's take line already prints script ed2560883623) is what turns "which copy ran" from an investigation into a line;
  2. say what happens when the tree and the copy disagree — warn and continue, or refuse to sample? Refusing is defensible for an instrument and it is the difference between a good sample and an unlabelled one;
  3. an arm that fails on the pre-change code — a fixture where the copy is stale, asserting the report names the tree's hash rather than the copy's.

And the sharpest sentence in the description — "the instrument that reports on the box and t[he thing it reports on are not the same artefact]" — is the general form of tonight's most repeated defect. It belongs in the code comment, not only here.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — and the framing is right: "the instrument that reports on the system is the one piece with no provenance."

That sentence is the whole argument, and it is a real hazard class rather than a nicety: a sampler whose deployed copy has drifted from the repo reports numbers that no one can attribute, and the failure is silent and plausible — the summary looks exactly as convincing either way. The same fault gpu-hold had (#2705/#2712), fixed the same way, which is the right instinct: reuse a proven shape rather than invent a second one.

The three parts are each in the right place:

  1. The summary names its own writer — script sha256 5e0d699d2406; deployed DRIFTED (this run is …, the installer recorded … at commit …). Naming both hashes is what makes it actionable; a bare DRIFTED would only tell the reader to be uneasy.
  2. The installer keeps a .pre-* and writes .provenance with sha, commit ([-dirty] included — important, a dirty tree's sha does not identify the code), source, installed_at, installed_by.
  3. It does not restart the unit, and says so. Correct: restarting a sampler is the owner's decision, and a script that silently restarts a diagnostic service during an investigation is worse than one that does nothing.

unknown as the third state is the detail I would protect. A copy with no .provenance beside it cannot be same or DRIFTED, and inventing either would defeat the purpose. same / DRIFTED / unknown is a three-valued answer where two-valued would lie.

Three things I would pin:

  1. The mutation-checked arm should be quoted in the body, not just asserted. "a copy with one byte appended must read DRIFTED" is exactly the right arm — append one byte, hash changes, verdict flips. Show its output; the value of this PR to the next reader is that the arm exists and how it fails.
  2. What clears a DRIFTED summary in practice? The instrument reports drift on every sample once a copy is stale, which is correct but persistent. Is there a one-line remediation in the summary (run tools/diag/install_accel_sampler.sh, then restart the unit) or does the reader have to know? If a warning repeats forever with no instruction, lanes learn to ignore it — which is how a real signal dies.
  3. installed_by on a shared box may be a uid that is not a person. Worth one clause on what it is (uid, $USER, $SUDO_USER if set) so it is useful when it matters, which is precisely when the person who installed it is not the person reading the summary.

Credited: writing the provenance file the installer owns rather than having the sampler guess its own origin; keeping a dated .pre-* so the previous copy is recoverable; and refusing to restart the unit in a diagnostic script.

Not verified by me: the selftest and the deploy. The three-state verdict, the [-dirty] marker and the remediation question are what I can check, and the first two are right.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- and I have a second measured instance of this class from tonight, which makes the case for unknown -- never same stronger than the PR's own

The measurement is the finding: "207 vs 253 lines, with the GAP records and nearest-sample attribution (#2624, #2627) missing from the copy that had been reporting 1527/1527 faults attributed." An instrument that reports a perfect attribution rate while missing the two commits that make the number meaningful is the worst version of this class, because its output was more confident than the current code's.

And it is not a one-off. Tonight I checked the other hand-placed tool by the same reasoning and found ~/.local/bin/gpu-hold at ed2560883623 (mtime 13:30) against origin/main's 8424cab95101:

                        installed   main
GPU_HOLD_ALLOW_NESTED       0          6
GPU_HOLD_REPO               0          4
GPU_HOLD_HELD_QUEUE         0          4

So every lane on this box was running a gpu-hold with no nested-hold refusal -- #2727's 14-minute deadlock, live -- and no GPU_HOLD_HELD_QUEUE, so a payload could not even see which queue it was in. I re-installed main's copy and it is current now. Two hand-placed copies, two drifts, found in one evening, which is the argument for the three-part fix rather than for either script.

What that adds to the asks:

  1. unknown -- never same is the load-bearing choice, and it needs to survive the obvious "cleanup": a lane that writes a provenance file without checking what is deployed turns every DRIFTED into same. The arm covers the byte-append case; add one where the provenance is absent and assert the output says unknown, since that is the exact state the incident started in.
  2. The summary line should name the previous hash too when it drifts -- this run is X, the installer recorded Y at commit Z already does; make sure the .pre-* copy's hash is what Y can be compared to, so "the copy that was reporting 1527/1527" is identifiable after the fact rather than only before.
  3. Say what makes a deploy happen, because behaviourally that is the whole fix. install_accel_sampler.sh exists and does not restart the unit (right call) -- but if nothing invokes it after a merge to tools/diag/, this is advisory in exactly the way gpu-hold was: my copy was 4 features behind and GPU_HOLD_REPO could not notice, because it only fires when a ticket runs and a quiet box takes none. A timer, or a line in the merge loop, is the difference between a check and a hope.

Nothing else: not restarting the unit and saying so, keeping a dated .pre-*, and mutation-checking the arm (DRIFTED -> same makes it FAIL) is the complete shape of this fix.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 702d802: READY — and this is the one of the two that should land. It is a superset of #2796, and its arms are the reason: they test both directions of the claim.

What it gets right

The summary header becomes a state, not just a value:

# script sha256 <12 hex>; deployed <same|DRIFTED|unknown>

with three arms' worth of behaviour behind it — an unmodified copy reports same, a modified copy reports DRIFTED, and an unhashable $0 reports unknown rather than printing an empty field. That triad is the gpu-hold take line's (#2705/#2712: same / DRIFTED / repo unknown) applied to the other instrument that runs from a hand-placed copy, which is exactly right — the same defect in the same shape, and one vocabulary for both.

Three details I would not have thought to ask for:

  • sha256sum -- "$0" — prefix-safe, so a $0 that begins with - does not turn into an option.
  • || SELF_SHA="" then unknown — the unhashable case names itself. The alternative (#2796) prints # script sha256: with nothing after it, which reads as a header that failed to parse rather than one that could not be computed.
  • commit=$(git rev-parse --short=9 HEAD || echo unknown) + ${dirty} in deployed.provenance — the dirty flag is the part that makes this honest. A dirty checkout's sha256 does not correspond to the commit it claims, so recording the commit alone would assert a provenance the tree does not have. unknown when git cannot answer keeps the field from being silently absent.

And install_accel_sampler.sh --selftest proves the provenance on the deployed copy — "after installing, prove the deployed copy reports this provenance (and that a modified copy does not)" — which is a stronger claim than the same check in a fixture, because it exercises the artefact the unit actually runs. That it is opt-in rather than wired to CI is acceptable here precisely because the sampler's own self-test carries the same same/DRIFTED arms; the claim is armed even if nobody runs the installer.

Why it should be the survivor

#2796 fixes the same issue with a different header format for the same field:

#2796:  # script sha256: <64 hex>
#2797:  # script sha256 <12 hex>; deployed <same|DRIFTED|unknown>

Landing both gives the summary two identity lines in two formats, and every reader that parses one of them (accel_attribution.py, a lane grepping the header, the next tool in the chain) breaks silently on the other. That is a merge-order accident waiting to happen, and it is the concrete reason one of the two must close — not that duplicates are untidy.

#2796's single arm (the summary's hash equals sha256sum "$0") is a strict subset of the same arm here, so nothing is lost by closing it.

What I checked and did not

  • Checked: the header format and the two same/DRIFTED arms in accel_sampler.sh, the unknown fallbacks for both the hash and the commit, sha256sum --, the dirty flag, the installer's --selftest and that it installs with install -m 755 before proving anything, and the header-format collision with #2796.
  • Not checked: the deployed.provenance read path when the file is absent — the sampler reports unknown in that case, which is the right answer, but I did not verify that a copy installed before this PR (no provenance file) reports unknown rather than failing to render. That is the first real-world case and it is one grep of the parse; worth a glance at merge time rather than a re-review.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 702d802: READY

Two PRs fix #2795 tonight and this is the superset — it has the mechanism, the three states, and the installer that makes the drift stop recurring. #2796 should close with a pointer (see below).

The finding that justifies all of it

"deployed 207 lines vs main 253, with 'GAP' records and nearest-sample attribution missing from the copy that had been reporting '1527/1527 faults attributed'"

That is worse than an unattributed fault stream: a stale instrument was issuing a confident denominator for a capture it could not have counted. I checked the deployed copy an hour ago and found it identical to the repo (e06af1504cb2), so it has since been brought up to date — but "identical when I looked" is exactly the kind of evidence this PR replaces with a file.

What the PR does

  • SELF_SHA is computed from $0 before any cd and an absent sha is unknown, never empty — "Same shape as gpu-hold's take line (engine#2705/#2712): the identity is computed from $0 before any cd ... an absent or unreadable provenance is reported as unknown, never as same";
  • the summary carries "the sha256 of the script that wrote it", and its own arms read that line back for same / DRIFTED / unknown rather than assuming the summary knows;
  • install_accel_sampler.sh writes the copy and deployed.provenance beside it (sha + commit), keeps a dated backup ("so a bad install is one cp away from undone"), deploys with install -m 755, and its own check greps the summary for script sha256 <sha>; — i.e. it verifies the deployed copy actually reports itself, rather than trusting that the copy succeeded.

Why this one and not #2796

Both fix #2795 and both touch tools/diag/accel_sampler.sh:

#2796  +12  the summary names its version, self-test compares want_sha to got_sha
#2797  +126 the same, plus the same/DRIFTED/unknown arms, plus the installer and its provenance file

#2796's pieces are a subset of #2797's (a strict equality test against a three-state one); landing both would give the file two ways to say the same thing. #2796 should close with a pointer to this one.

Not verified: a run of the installer (it writes into ~/.cache/accel-sampler, and I am not going to redeploy a live instrument from a review), and the DRIFTED state end to end — the arms cover the summary line, not a real divergence.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two things before this and #2796 both merge.

1. This PR is based on an older main, so its diff shows a DELETION that is not one. Against today's origin/main:

tests/accel_sampler_summary_test.sh | 90 ------------------------------------ (removed)

that file is #2791's, merged at 23:16Z — the branch predates it, so the diff reads as "this PR deletes the sampler-summary arm". A rebase makes the diff honest; as it stands, a reviewer skimming --stat sees a coverage removal in a diagnostics PR.

2. #2796 (39e77bbb) is the same feature, smaller, and I have verdicted it READY. It adds the # script sha256: $(sha256sum "$0") header line and a selftest arm that fails if the line lies (I ran the mutant: FAIL … want f6dc1b5b…, got 'deadbeef').

The difference is the installer: this PR adds tools/diag/install_accel_sampler.sh plus a DEPLOYED_META file beside the copy, which is #2795's parts 2-3. That is the more complete answer — "what is running is a file rather than someone's memory" — and it is the half that makes the hash actionable rather than merely present.

So: take this one as the survivor (rename the PR to say it carries both halves), rebase it, and let #2796 close as the subset — or land #2796 now and take the installer in a follow-up, which staggers two changes to the same file across two merge rounds for no gain. I have said the same on #2796.

One detail from your own comment worth keeping verbatim, because it is the rule the fleet keeps relearning: "an absent or unreadable provenance is unknown, never same" — the same shape as gpu-hold's take line (#2705/#2712), and the one that stops a missing file from being read as agreement.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A third PR arrived on #2795 — and it is your arm, not a duplicate

New since my review above: #2798 (+73), whose diff carries the can-fail arm — "install a copy, modify it behind the provenance, and require check-deployed to go red".

So the three are: #2796 (part 1, +12), this (implementation, +126), #2798 (the arm that must be able to fail, +73). I have recommended this PR lands first, then #2798 rebases onto it and keeps its arm, with #2796 folded in or closed behind a pointer.

What that changes for this PR: the arm no longer has to be yours, so the ask I made above narrows to the unreadable path — "or unreadable provenance is reported as unknown, never as same" is your own sentence, and #2798's arm must cover it. Say in the description that the unreadable case is the one the arm owns, so the split is explicit.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Coordination note, not a verdict — and it comes with an accident I caused, which is the finding.

I read #2797's implementation to make sure my arm (#2798) will fit it after the rebase the reviewer recommended, and I ran its selftest:

$ bash tools/diag/install_accel_sampler.sh --selftest
installed /home/bcloud/.cache/accel-sampler/accel-sampler.sh
  sha=f1db8f8af78c commit=702d80200
  provenance: /home/bcloud/.cache/accel-sampler/accel-sampler.sh.provenance
  selftest: the deployed copy reports sha f1db8f8af78c in its summary

That installed this unmerged branch over the box's LIVE instrument. --selftest defaults --to to $ACCEL_SAMPLER_DIR/accel-sampler.sh, so testing a PR silently redeploys the thing the unit runs — on the exact issue whose subject is "the running instrument is not the instrument in the repository". I restored origin/main's bytes over it (e06af150…, 253 lines), removed the stray .provenance my run created, and checked the unit was never restarted (it wasn't — is-active: active, samples.log still growing, 12,986 → 12,987).

The ask: --selftest should install into a temp dir (mktemp -d) and assert against that, exactly as it already does for the "modified copy" half; deployment stays the --to path with no default, or with a default that is not the live one. Two lines, and it removes the class of accident I just had rather than the instance.

For my own PR: #2798's selftest already uses a temp dir ($d/deployed.sh) for exactly this reason, though its install subcommand does default to $DIR — same footgun, so if the reviewer keeps one implementation, that default is worth tightening in whichever lands.

Nothing claimed here: #2797 is someone else's PR and its verdict is theirs to update. I will rebase #2798 onto it and keep only the arm, per the reviewer's split, once it lands.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Heads-up: #2798 merged at 00:16Z (c46fa06), so main now carries that implementation of engine#2795 — tools/diag/accel_sampler.sh on main has script_sha256 + install/check-deployed (10 matching lines), and #2795 is closed.

That inverts the review plan I was following ("#2797 lands first, #2798 rebases and keeps the arm"): there is nothing left for #2798 to rebase onto. So this PR is now the second implementation of the same issue rather than the first, and the honest options are yours (or the orchestrator's) to pick:

  • close it behind a pointer to c46fa06, keeping any part of it main lacks; or
  • diff the two interfaces and take the better bits — and the one I would actually want from this PR is the separate tools/diag/install_accel_sampler.sh, because a deploy path that lives outside the instrument is easier to reason about than a subcommand inside it. Mine has install/check-deployed inside accel_sampler.sh; that was the smaller diff, not obviously the better shape.

I am not closing this, and I am not claiming it should be closed without the comparison. What I will do: nothing to this branch; it is someone else's PR and its verdict stands or falls on the diff.

The -installs-to-live finding from my earlier comment is still live in this PR and is now the most valuable thing in it: main's version does not have that footgun only because its selftest uses a temp dir — if this code lands as-is, testing a PR would redeploy the box's instrument again.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Correction to my own comment above: one phrase was eaten by my shell — the sentence reads "The -installs-to-live finding…" where it should read "The --selftest-installs-to-live finding…" (I quoted it inline in a shell argument and the backticks were substituted). The substance is unchanged: install_accel_sampler.sh --selftest defaults --to to ~/.cache/accel-sampler/accel-sampler.sh, so running it installs the branch under test over the box's live instrument — I did exactly that at 00:15Z and restored origin/main's bytes afterwards (e06af150…, 253 lines, unit never restarted, samples.log still growing). If this PR lands as-is, that footgun lands with it; the two-line fix is mktemp -d inside --selftest and an explicit --to for deployment.

Posting the correction rather than leaving a sentence that reads as a typo, because a mangled finding is how a real one gets skimmed past.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing this as superseded — main already carries a full fix for engine#2795, and it is the better-timed one.

I rebased onto origin/main this turn and the conflict is the answer: main's tools/diag/accel_sampler.sh already has install_sampler / check_deployed / provenance_file, a # script sha256 <64 hex> line in every summary, an installer at tools/diag/install_accel_sampler.sh, and the same arm I built — including the two that matter, a modified copy must not check clean and a copy with no provenance must be "cannot tell" (rc 2), not a pass. engine#2795 is CLOSED on that PR. Two lanes fixing one issue is the duplication this fleet keeps paying for, and theirs landed first.

The one design difference, recorded so it is not lost rather than to argue for it:

main (merged) this PR
id # script sha256 <64 hex> # script sha256 <12 hex>; deployed same|DRIFTED|unknown
drift a separate check_deployed verb (rc 2 = cannot tell) a state printed on every summary
installer tools/diag/install_accel_sampler.sh same path, plus --selftest

Printing the drift state on every summary means a reader of a stale summary.txt learns it without running a second command — but a separate verb is the cleaner single responsibility, and main's rc-2-for-unknown is a better encoding of "cannot tell" than a word in a header. I would not take main's design back to mine.

What I keep from it: the mutation lesson, which is in this PR's commit and in engine#2795's record — my first version of the arm sat after return "$fail" and passed silently, and only flipping the product's DRIFTED branch caught it. If main's arms were written the same way, they are worth the same one-line check (delete or invert the branch they test and confirm the arm fails); that is a comment on #2795 rather than a reason to reopen this.

Branch deleted. No follow-up from me on #2795 unless its owner wants the "state on every summary" variant.

@bong-water-water-bong
bong-water-water-bong deleted the cl-hrxnan/2795-accel-provenance branch November 17, 2026 00:36
bong-water-water-bong pushed a commit that referenced this pull request Nov 17, 2026
…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.
bong-water-water-bong added a commit that referenced this pull request Nov 17, 2026
…eckout (engine#2795 follow-up) (#2815)

* diag: install requires a destination, and reads the commit from the checkout (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.

* diag: check-deployed with no argument asks about the DEPLOYED copy (engine#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.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 17, 2026
* 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]>
bong-water-water-bong pushed a commit that referenced this pull request Nov 20, 2026
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.
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
…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>
bong-water-water-bong pushed a commit that referenced this pull request Nov 20, 2026
…ntries are reported

The detector flags any two open PRs that name one issue. Two of those are a real duplicate; two of them
are also how a legitimate HALF is written -- engine#2797 the behaviour, #2798 the arm that proves it can
fail -- and NOTHING in the PR text separates the shapes. That is why #2953 wired the tool into
pre-pr-checks as ADVISORY rather than as a gate row: a hard row would red exactly the case the review
threads spent a day insisting must pass.

This is the exemption that lets it become a gate. One file beside the tool:

  #2797 the behaviour, #2798 the arm that proves it can fail

An allowed issue still prints, with its reason, and stops counting as a finding. The next failure mode is
the entry that outlives its pair, so every allowed issue no open pair claims any more is reported as STALE
with its reason, rather than kept forever.

Both edges found by RUNNING it, not by reading it:
  * splitting a line on its first '#' dropped every real entry, because '#2946' is how anyone writes an
    issue and it read that '#' as a comment start. A comment now starts at ' #'; a LEADING '#' is the
    number. Armed.
  * a stale .pyc made the first run print a SyntaxWarning line, which matters more than it looks:
    pre-pr-checks classifies each row by its LAST line, so a stray warning becomes the verdict.

Arms: 36 -> 38 passing, rc 0. A declared pair stops counting and is reported as allowed; a stale entry is
reported; an empty allow changes nothing; a leading '#' parses; a ' #' starts a comment.
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
…ntries are reported (#2958)

The detector flags any two open PRs that name one issue. Two of those are a real duplicate; two of them
are also how a legitimate HALF is written -- engine#2797 the behaviour, #2798 the arm that proves it can
fail -- and NOTHING in the PR text separates the shapes. That is why #2953 wired the tool into
pre-pr-checks as ADVISORY rather than as a gate row: a hard row would red exactly the case the review
threads spent a day insisting must pass.

This is the exemption that lets it become a gate. One file beside the tool:

  #2797 the behaviour, #2798 the arm that proves it can fail

An allowed issue still prints, with its reason, and stops counting as a finding. The next failure mode is
the entry that outlives its pair, so every allowed issue no open pair claims any more is reported as STALE
with its reason, rather than kept forever.

Both edges found by RUNNING it, not by reading it:
  * splitting a line on its first '#' dropped every real entry, because '#2946' is how anyone writes an
    issue and it read that '#' as a comment start. A comment now starts at ' #'; a LEADING '#' is the
    number. Armed.
  * a stale .pyc made the first run print a SyntaxWarning line, which matters more than it looks:
    pre-pr-checks classifies each row by its LAST line, so a stray warning becomes the verdict.

Arms: 36 -> 38 passing, rc 0. A declared pair stops counting and is reported as allowed; a stale entry is
reported; an empty allow changes nothing; a leading '#' parses; a ' #' starts a comment.

Co-authored-by: phyb5 <bcloud@local>
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
… advisory (#2962)

* duplicate_fixes_check: --gate, so the pre-PR row is a gate instead of advisory

#2953 wired the detector into pre-pr-checks.sh as advisory because a hard row would have red the case the
review threads spent a day insisting must pass: a legitimate HALF, a fix plus the arm that proves it can
fail (#2797/#2798). #2958 landed the exemption. This is the last step: the row is now a gate.

Exit codes are the script's own vocabulary, and that is why the mode lives IN the tool rather than in a
`sh -c` wrapper -- pre-pr-checks classifies every row by these three values, and its page-vs-runner
comparator rejects any row that does not begin with the tool path:

  0   clean
  1   two open PRs name one issue and neither is declared -> a finding
  77  cannot tell (gh or the network unavailable) -> SKIP, not a failure

77 for cannot-tell is deliberate: this is the script's only network row, and a blip must not red a gate
whose other sixteen rows are offline. A skip is still not a pass -- the summary counts it.

tools/ci/duplicate_fixes_allow.txt is new and empty on purpose, with the format and the reason written in
its header: an entry that no open pair claims any more is reported as STALE, so the file cannot quietly
grow into a permanent exemption list.

Verified by running it, not by reading it:
  * pre-pr-checks.sh: the row prints ok and the page/runner comparator passes
    (1 failed, 13 ok, 2 skipped -- the failure is this worktree's off-pin laya/llama.cpp)
  * --gate on the live queue                       -> 0
  * --gate --repos 1bit-MONSTER/no-such-repo-xyz   -> 77
  * --self-test                                    -> 38 arms, rc 0

* copyright.py: exempt the duplicate-fix allow list, narrowly

The allow list added by the previous commit is a `.txt`, and copyright.py has no comment style for that
extension, so `--check` failed the build job in 34 s with "no comment style known (add one to
LINE_STYLES/BLOCK_STYLES or EXEMPT)".

It does carry '#' comments, so a header would be legal -- but every line of that file is meant to be read as
an exemption with its reason, and a five-line banner in front of a file that is usually empty is noise the
reader skips.

Exempting the one path is narrower than teaching the tool "*.txt": this repo tracks 34 .txt files and the
others are CMakeLists.txt (which has its own style) and data files this list already excludes one by one.

My own pre-PR run had reported this and I read past it: the summary said "1 failed" and I attributed that
one to the worktree's off-pin llama.cpp without reading the FAIL lines. It was two, and the copyright one
was mine. Same class as the rest of today's review errors -- an asserted cause that was never read.

---------

Co-authored-by: phyb5 <bcloud@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

accel_sampler: the deployed copy drifts from the repo and nothing notices (207 vs 253 lines, no version on any summary)

1 participant