Skip to content

Audit the implicit state machines; fix eleven traced defects - #1417

Merged
GLinnik21 merged 27 commits into
mainfrom
claude/zen-meitner-8nv0h3
Nov 16, 2026
Merged

GLinnik21 merged 27 commits into
mainfrom
claude/zen-meitner-8nv0h3

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

An audit of the app's implicit state machines, and fixes for the eleven defects it traced that a host test can prove.

The audit

docs/implicit-machines-audit-2026-11-16.md lists 164 lifecycles that are held in loose flags, scattered phase writes, statics or pending_* fields, by area, with the defects traced while reading them. Its recommendation is to convert a lifecycle only when it has a traced defect or is being changed anyway, never in bulk: every traced defect has one shape (a transition wrote one field and not its sibling, or a reader tested a stand-in for the state). docs/sans-io-guide.md gains checklist item 9, which sends a reader to the row of the type they are about to touch.

The fixes

Each has a regression test that failed first.

where what was wrong fix
screens/src/hud_settings.rs An offer that landed over an open drop-file question took the viewer's answer, and a drop row could ask while the store was busy (the store refuses that install silently) ask never replaces the viewer's own question; drop rows are inert while the store is busy
data/src/browse/mod.rs A failed first page with a change notice owed stayed Loading through every retry only a re-list that holds rows is exempt from Failed
data/src/stores/watchlist.rs "Never read" was spelled rows.is_empty(): an empty Watchlist reloaded at every mount and a failed reread replaced it with Failed WatchlistState::unread
data/src/pms.rs Src.deferred outlived the page or quiet read it stood for, so the next tick launched a prompted whole-source read begin_request clears it; cancel_page and pump_reloads keep it only for a quiet read the gate refused
media/src/route/decision.rs A panic in the encoder cleanup check left checking set for the process EncoderCleanupClaim drop guard
telemetry/src/telemetry/mod.rs A consent decision installed inside a three-instruction window lost its flush the worker's tail reruns when the installed decision is newer than the one it ran with
screens/src/profiles.rs BACK on a denied PIN pad published pad_open = false, pin_denied = true for one tick the verdict is cleared before the state is published
ui/src/dispatch/press.rs A key-up at tick.ms == 0 stored the "still held" sentinel now.max(1), as commit_at and HeldKey::release do
src/app/input.rs, playback.rs The PLAY key entered D-pad mode without resetting mot_accum, back_cursor or the edge glide one Pointer::enter_dpad() for both entries
platform/src/playback_trace.rs A failed Start returned its status without storing it, so Settings kept showing a saved trace for an empty file start_stored; availability and path are arguments of start
net/src/curlio.rs A successful reopen_until left the old body failure pinned on every later stop it clears failure and heal_pending after the request succeeds. No curl option or FFI declaration changed

Verified

  • Host gate, in a Linux container on 7f3640cb8 (every code change; what followed is a comment/doc commit and a clean merge of main's CI and docs files): make check-cargo-lint, the default unit suite (13576 passed, 14 failed), the hostsim suite (8653 passed, 13 failed), make check-python and make check-nodef. The failures are environmental and the same on untouched main: the container runs as root, so 13 "unwritable directory" tests cannot fail to write (re-run as an ordinary user: 26 passed; 0 failed), and one plx_net connect-abort test needs a route the sandbox refuses.
  • Red first: eight of the eleven tests were seen failing against the original code. Three (encoder cleanup, the telemetry tail, the trace Start) call a seam the fix introduced, so they were seen failing against that seam with the old logic in it.
  • Reviews: fw-compat-reviewer on the curl change (no findings; source only), doc-claim-auditor (five wording findings, corrected), pr-reviewer on the combined diff (no findings).
  • Not run: the ARM cross-build (no NDK in the container) and anything on the television. The pointer change's feel on the remote, the HLS segment reader end to end and the fan-out gate's timing with five or more servers are unverified. CI is the cross-build's first run.
  • No Makefile, Cargo.toml, Cargo.lock, workflow or module-layout change, so no build-bench table. No ledger under ci/allow/ changed.

Still open

Eight rows of the audit's defect table are left open on purpose: they need the device (two feed seek stalls, the ACB bind retry, the preview deferred start, the refused-foreground retry, the background pointer reset) or an owner's decision (the Browse retry backoff, HttpStream's end of stream at a chunk boundary).


Generated by Claude Code

docs/implicit-machines-audit-2026-11-16.md inventories the lifecycles the
code tracks without one enum and one transition function: 164 of them
outside the ten machines in ci/machines.ini, found by a mechanical pass
over flag-heavy structs and phase-like enums and then judged by reading.
It records 19 traced defects, the lifecycles written more than once, the
types that are already explicit but unregistered, and what was not read.

Its decision is not to convert in bulk. Every traced defect is one shape:
a transition wrote one field of a cluster and not its sibling, or a reader
tested a stand-in for the state. Three of them are provable on the host
and are fixed here, each by a test that failed first:

- Player HUD settings: an address-fetched offer landing on a later tick
  replaced an open drop-file install question under the same title, so
  the viewer's answer installed or declined a package they had not been
  asked about and the file they picked was never installed. Every
  question opens in HudPage::ask, which now refuses to replace the
  viewer's own; the offer is not latched as asked until its prompt has
  opened, so it is asked on the first tick after the answer.

- Library grid: a library-change notice during the first page read owes
  a re-list, and the failure arm skipped SecFetch::Failed for every
  section with a re-list owed. That exemption is for a grid holding
  rows. A first read holds none, so the grid spun through every failed
  retry instead of showing the failure.

- Watchlist: "no list has landed" was spelled rows.is_empty(), so an
  account whose Watchlist is empty went back to Loading at every mount
  and to Failed on a failed background reread, which drops the
  Watchlist row from item menus. WatchlistState::unread names the state.

docs/sans-io-guide.md's checklist gains the rule and points at the audit.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…view found

The doc-claim audit of the previous commit found its HUD fix was half a
fix. HudPage::ask no longer lets an offer take over the viewer's own
install question, but the answer it then sends is InstallDrop, and
HudStore takes that only when idle: with the offer held, the confirmed
install was still dropped as Handled::No, with no notice.

The way into that state was the row. A drop file's row opened its
question while a fetch was in flight, although the store would refuse
the install either way. It is now inert while the store is busy
(fetching or package_busy), as the removal rows and the address row
already are, so a question is not opened across a fetch. The guard in
ask stays for a listing that is a tick behind the store; the audit
records what is still open there (the store's refusal is silent).

Prose: the review found WatchlistState::unread's doc claimed more than
the code (a later-page failure of a reread of an empty list still
differs from a populated one), and docs/watchlist.md and three comments
still drew the line at "a populated list" where it is now "a list that
has landed".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
Src.deferred was not cleared with its siblings page/quiet. request_page kicks
ungated over a source holding a gate-deferred quiet read, taking quiet and
leaving deferred; the next tick's source_waiting then launched a prompted
whole-source read (HubState::Loading) after the page landed. cancel_page left
it on a source with no page for the same reason. begin_request and cancel_page
now clear it. Tests: a_page_ask_that_took_a_deferred_quiet_read_leaves_nothing_deferred_behind
and cancelling_a_page_clears_the_deferral_with_it, both red before.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
take_unchecked sets checking=true and only finish cleared it; run_encoder_cleanup_check had no
drop guard, so a panic in the observation left the record claimed for the process, is_clear(sid)
stayed false and encoder_cleanup_ready deferred every ABR trial on that server. An
EncoderCleanupClaim guard now releases the claim (finish with no verdict) on drop. The observation
is split out as an argument so the test can panic it.

Test a_panicking_encoder_cleanup_check_releases_its_claim: red before (retry.len() 0 != 1), green after.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…after its snapshot

flush_soon's loser (thread B) relies on AGAIN, but the winner (thread A) clears AGAIN after B
raised it and spawns with the stale revision; process_records then sends nothing and the tail saw
AGAIN false, so the new decision was never flushed. The tail now asks the pure
rerun_after_flush(again, ran_revision, installed_revision). The test drives that interleaving as
plain data (red before: rerun_after_flush(false, 1, 2) was false).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
retire_pad synced the published ProfilesState before clearing pin_denied, so after BACK on a
denied pad the state carried pad_open=false, pin_denied=true until the next Tick. Clear the
field first. The new test asserts the PUBLISHED s.state fields after BACK on a denied pad.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…rap tick

A key-up at tick 0 was dropped, so a card press latched long and delivered a hold
instead of the tap. Store now.max(1), as commit_at and HeldKey::release do. The test
presses at u32::MAX-15, releases at 0 and asserts the tap commits and is not long.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
key_play wrote dpad_mode/cur_hidden but not back_cursor, mot_accum or edge, so after PLAY
mot_accum held all earlier travel and the first small motion passed DPAD_MOTION_GATE. The arrow
entry and key_play now both call Pointer::enter_dpad, each keeping its own hide_cursor condition.
The hostsim test drives key_play with mot_accum=500 (red: left 500.0, right 0.0) and the arrow
path for parity.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
execute(Command::Start) returned Unavailable/Failed without storing it in STATE.status,
after stop() had moved Recording to Saved and set_len(0) had truncated the file, so
Settings re-read a stale Saved/Exported for an empty trace. Start's body is now start()
with the availability and trace path as arguments; start_stored stores every non-Recording
result. The test reaches both failing exits and asserts the stored status.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…eal_pending

reopen_until reset off/size/poisoned but not failure/heal_pending, so an HLS source reused across
segments kept naming the old mid-body cut from body_failure() after a later successful reopen.
The new test cuts mid-body, reopens via reopen_until and asserts body_failure() is None and no
heal is pending (red before: Some(BodyFailure{rc:18,..})). The seek-based retention tests are
unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…t the worker calls

The test pinned only the pure predicate; the tail could revert to AGAIN.load alone and stay green.
The worker now calls worker_tail_reruns(&AGAIN, ran, installed), and the test drives it with a real
AtomicBool and a revision closure (newer decision reruns, request reruns, nothing new stops).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…uiet read

cancel_page and pump_reloads cleared `deferred` unconditionally, losing a
gate-deferred quiet read that shared the flag and stranding quiet = true.
Both now set deferred = quiet. The new test (red before: 'the quiet read the
gate deferred is still owed') proves the quiet read is still launched.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
The guard only runs on a panic unwinding out of observe; the parenthetical about
worker teardown overclaimed. Doc-only change, no test applicable.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
…eight fixes

The swarm's review left one change without a test: pump_reloads drops a reload
page whose row left the ring and now keeps the deferral only for a quiet read
the gate refused (deferred = quiet). a_reload_page_dropped_off_the_ring_keeps_a_
deferred_quiet_read fills the fan-out gate (five sources, four out), and fails
with the old 'deferred = false' at 'the quiet read the gate deferred is still
owed'.

The audit's defect table records the eight fixes and what each test does not
show. The telemetry test moves below its module's use line.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
Comments and prose only. The audit's inventory rows for the fixed defects now
say so; the curl comment and the audit row no longer claim a successful seek
clears `failure` (it clears only `heal_pending`); the evidence note names all
three tests that were red against the fix's own seam; the trace row names the
two exits the test drives; `Src::deferred`'s doc lists who clears it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P6ZnFcrmAsJorfw1Hnt2DC
@GLinnik21
GLinnik21 merged commit 9ae9ac2 into main Nov 16, 2026
13 checks passed
@GLinnik21
GLinnik21 deleted the claude/zen-meitner-8nv0h3 branch November 16, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants