Skip to content

fix(tests): pin non-failing hosts to checksum state; correct mic-check doc drift - #37

Merged
twistedmelonman merged 1 commit into
mainfrom
claude/fix-test-pinning-and-doc-drift-0a206b4b
Aug 25, 2026
Merged

fix(tests): pin non-failing hosts to checksum state; correct mic-check doc drift#37
twistedmelonman merged 1 commit into
mainfrom
claude/fix-test-pinning-and-doc-drift-0a206b4b

Conversation

@twistedmelonman

Copy link
Copy Markdown
Member

Closes #35, closes #36.

#35 — mechanism confirmed, and falsified both ways

The issue's stated mechanism is exactly right. provision_host
(bin/lock-fanout:117) compares remote_sha to local_sha; with no checksum
env var set, the stub returns empty stdout, which never matches, so it falls
through to the push.

Proved empirically before fixing, by dumping SSH_LOG: asiago received a
full cat >~/.local/bin/.lock-guard.tmp push on every run of that test.

Fix at tests/lock-fanout.bats:154-156 pins both non-failing hosts with
STUB_SSH_CHECKSUM_ALL_MATCH — the pattern already used by the sibling test at
line 131 — plus a no-push assertion at line 180.

Falsification: perturbing the digest to deadbeef... makes the new
assertion fail at line 182. Before this change, that same perturbation was
completely undetectable. Ordering was checked too: STUB_SSH_FAIL_HOST is
evaluated before the checksum stubs, so tilsit still fails as the test intends.

#36 — the code is correct; the doc was wrong

check_mic_active (bin/lock-guard:49-52) uses
pmset -g assertions | grep -qi 'coreaudiod.*preventuseridlesleep'.

The doc's planned ioreg/IOAudioEngine approach would have been worse than
merely different: IOAudioEngine is Intel/kext-era and publishes no live
instances on Apple Silicon, so that check would have silently failed open
on every current machine.

Since the doc is a dated plan record, rewriting its code blocks would
falsify what was actually planned at the time. Instead it gets an
"Implementation note" addendum below the header, an updated Status line, and
the two prose references marked superseded.

Verification

  • Full CI-equivalent suite: bats tests/ + shellcheck -S info bin/* +
    npx markdownlint-cli '**/*.md' — 66 pass / 0 fail, shellcheck clean,
    markdownlint exit 0. Identical before and after.
  • Both reviewers PASS on commit.
  • Pre-push whole-codebase review run as a dry-run first: PASS. Two
    non-blocking findings raised (a shasum availability guard on a test stub,
    and a doc/PR cross-reference); both are cosmetic and deliberately deferred
    rather than expanding this diff.

https://claude.ai/code/session_014iwogYZxFU6NqXmiobcMMv

Fixes #35, fixes #36.

#35: the "one of three ssh failures" test set no checksum env var, so the
ssh stub answered asiago's and mimolette's shasum call with empty stdout.
An empty remote_sha never equals local_sha, so provision_host fell through
to the push path and re-pushed lock-guard to both hosts on every run. The
test still passed because its assertions only checked log-line content, and
both push and steady-state end in ssh_exit=0 -- so it silently exercised the
push path while reading as a steady-state fan-out test.

Pin both non-failing hosts with STUB_SSH_CHECKSUM_ALL_MATCH, matching the
sibling "three clients all succeed" test, and assert no push (CMD=cat >) was
attempted for any host. STUB_SSH_FAIL_HOST is evaluated before the checksum
stubs in the ssh stub, so tilsit still fails as intended.

Falsified: perturbing STUB_SSH_CHECKSUM_ALL_MATCH to a non-matching digest
makes the new assertion fail. Before this change the same perturbation was
undetectable.

#36: the design doc described the mic-active signal as
`ioreg -c IOAudioEngine -r -l` stubbed via LOCK_SYNC_IOREG, but the shipped
check_mic_active uses `pmset -g assertions` matching
coreaudiod.*preventuseridlesleep, stubbed via LOCK_SYNC_PMSET. The code is
correct -- IOAudioEngine is Intel/kext-era and publishes no live instances on
Apple Silicon, so the planned check would have failed open everywhere.

The doc is a dated plan record, so rewriting its code blocks would falsify
what was actually planned. Instead: add an "Implementation note" addendum
below the header documenting the deviation and rationale, update the Status
line, and mark the two prose references (the signal list and the Testability
section) as superseded.
@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown

Doc-only update + test hardening. No production code changed.

The test fix correctly pins the two non-failing clients to steady-state checksum match so the test isolates the one variable it's about (single-host SSH failure) and adds an assertion that no provisioning push occurred. The new assertion (grep -q 'CMD=.*cat >' returning non-zero) is the right way to assert absence of a push in this stub framework.

No BLOCK criteria found.

VERDICT: PASS

@twistedmelonman
twistedmelonman merged commit 833fef6 into main Aug 25, 2026
4 checks passed
@twistedmelonman
twistedmelonman deleted the claude/fix-test-pinning-and-doc-drift-0a206b4b branch August 25, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant