Repository navigation
ViewState writes emit store jobs keyed by ClientKey; a write whose profile or client moved is dropped, never sent as another profile - #1026
Merged
Conversation
A recording or a replay of a Home boot reaches the detail hero's ViewState store command and the item menu's committed row only through effects::store and effects::app, and neither has an arm for them. The new test sends each effect, for all three writes and for record and replay, to a fresh controlled Bridge and asserts the refusal, that nothing is delivered, that the loop's item-menu queue stays empty, that no outbox holds a job and that no write is queued. A pin: it is green on the tree that adds it, and fails the day someone gives either effect a recording arm. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…worker A step decides from a ClientKeys snapshot, and the worker it hands the work to runs later, after a profile switch may have re-tokened the registry's Client objects in place. KeyedClients holds the snapshot and a lookup fn pointer (a Send + Copy value a worker can build from its job's own keys), and client(sid) answers only while the registry's client still carries the snapshot's key. A slot the snapshot never held, a re-pointed slot and a moved credential all answer None. Pure addition: no caller yet. Four unit tests, one per refusal and one for the match; swapping the filter for an instance-only comparison fails the credential test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s's profile A scrobble, unscrobble, Remove from Continue Watching and the cross-server origin-watched fan-out are statements about one household member's viewing record. The step now captures what it needs to keep them that way at the press and decides at the kick from the snapshot the Bridge hands it: - `Req` records the server's `ClientKey` and the profile identity (`session::current_gen`, passed in by the Bridge as `Bridge::profile_scope()`, the way Search takes the household). The identity moves on seat, detach and sign-out, and not on a same-profile token refresh. - `request` and `fan_out_origin_watched` read `keys.key(sid)` instead of the registry (-2 globals). - `kick` drops and retires a write whose profile moved (logged); a write whose server is gone from the snapshot is dropped as before; the same profile with a re-tokened client is re-keyed and proceeds. - `viewstate_run`, `viewstate_pump` and `reconcile_pump` take the profile as a trailing argument. Tests are loopback only: a fake PMS on 127.0.0.1:0 counts the scrobbles. With the profile comparison scratch-removed, the cross-profile test fails with "nothing was sent under the new profile's token". Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…the app's runner
A scrobble, an unscrobble, a Continue Watching removal and the cross-server
origin-watched fan-out no longer start their own worker. The step decides from
the borrowed ClientKeys and the press's profile, and sends the runner one
typed job per write; the job's Port takes exactly one answer.
- StoreJob::ViewWrite (Direct admission, no tape record) carries the origin
server and the key the step decided on, the write, and the whole ClientKeys
snapshot it decided under. The runner starts it only through the client that
key names, and refuses it (nothing left the device) when the registry has
moved on, at the launch and again when a parked job runs.
- The worker reaches the title's OTHER copies only through KeyedClients built
from that snapshot, so a profile switch that re-tokens a server between the
press and the worker cannot send the lookup or the scrobble to it under the
next profile's credential. The registry read is passed in by the runner, so
no data-layer line names client_for.
- A refusal is NotStarted, not a failed write: no ledger change, no read-back,
no hub refresh. The write goes back to the head of the queue after the same
judgment any queued write gets (a moved profile drops and retires it, a
re-tokened client re-keys it); only an unmoved client waits out the retry
ladder. A panicking worker answers a failed write, never NotStarted, because
a second scrobble would add a second viewCount.
- Stores::VIEWSTATE_FILLS gains ViewState in StoreId order, and
RECONCILE_FILLS names the two outboxes Bridge::reconcile_pump now drains
(an end-of-stream fan-out it queues starts the next write).
- Ledger: ci/allow/{workers,globals}/data-viewstate.txt are deleted (workers
14 to 13, globals 73 to 70).
Tests: the job lane is graded port-driven (emission, the retry ladder, a
moved profile, a re-tokened client, a reset's outbox, a panicking worker); a
fan-out target whose key moved after the step receives no request (fails with
the raw registry read in fan_out/ask_sources: the server saw 3 requests); the
runner refuses a write whose origin key moved, live or parked (fails without
the key comparison in resolve).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
docs/sans-io.md gains the view-state write lane (the tenth store on the job lane): the profile as a second step input, the fan-out through KeyedClients, NotStarted as a non-failure, and the two fill lists; it no longer says viewstate_run emits nothing. The module docs of viewstate.rs, the runner, the reconcile rig and client_keys.rs, and the worker-inventory row in docs/poster-scheduler-design.md, now say the runner starts the write. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tever the profile reads (B1) A profile switch swaps the registry's tokens in the frame the session adopts them, but the new profile's identity (Bridge::profile_scope) is published by a later commit, so for at least one frame a real switch looked to the step like a same-profile refresh and a queued write was re-keyed and sent under the next profile's token. The step cannot tell the two apart, so admit now drops and retires a write whose key moved (the design default, lead decision 4's fallback), and restart_refused reduces to the admit judgment plus the ladder. The profile compare stays. Fails first: the former re-key test, flipped to expect no scrobble and a retired ledger entry, sent one scrobble on the previous tree (left: 1, right: 0). The two re-key unit tests and the two runner tests flip to a drop; the profile test now keeps the keys unmoved so the profile compare is pinned on its own. The module doc and docs/sans-io.md say the fallback and its cost. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Five sentences the lane left false: reconcile_pump drains RECONCILE_FILLS with start_store_jobs_in (not start_store_jobs_of) and joins the fan-out list; the deleted globals file held five client_for reads, not three; StoreJob::admission() names the view-state writes under Direct; a refused write is judged again (a moved profile, a vanished server or a re-tokened client drops it) before it waits out the ladder; the step reads no client_for but fan_out_origin_watched still reads server_ids(). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Conflicts, all of the "keep every arm of both sides" kind: - data/src/stores/mod.rs: StoreJob gains ViewWrite beside MetaSeason and MetaEpisodes, and all three are Direct in admission(). - app/adapters/stores.rs: start, admit_home, retire_parked_details and run_held_where take the ViewWrite arm and the two Metadata arms; the module doc names both lanes. - docs/sans-io.md: Metadata M2 is the tenth store on the job lane and the view-state writes the eleventh; the fan-out drain list and the admission list name both. - tests/test_harness.py: PINNED_LEDGER_TOTALS recomputed from the # count: headers at the merged tree: workers 11, globals 68, forks 58, fxlanes 11 (the comment lines of both sides kept). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The profile, vanished-server and moved-key branches each logged a DROPPED line and retired the ledger entry; drop_queued does both once. The log strings are unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
Metadata M2 (#1023) and ViewState (#1026) landed after the base. Both lanes and this one added their own test-only LiveKind, took PINNED_LEDGER_TOTALS down from the same base, and extended the same exhaustive StoreJob matches. - LiveKind = {Hubs, MetaSeason, BrowsePage}. held() runs all three live, so the season switch stays live for menu_play_season_tests and the page read for the library route rigs and session_dispatch_tests. park_page_reads() sets {Hubs, MetaSeason}: it parks only the page read. held_all() stays []. - Every StoreJob match in adapters/stores.rs (start, admit_home, retire_parked_details, run_held_where) lists both lanes' kinds. - PINNED_LEDGER_TOTALS = workers 9, globals 66, forks 58, fxlanes 11, recomputed from the `# count:` headers of the merged tree (main is 11/68; this lane takes 2 and 2), with every lane's comment kept. - docs/sans-io.md and the stores.rs //! paragraph carry every lane's prose. - Review notes N2 (the /// docs that named only the section-hubs read now also name the directory or page read) and N3 (one sentence: an Addr is not an identity across kinds). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1024
A household's watched-state writes (mark watched, mark unwatched, remove from Continue Watching, and the fan-out to the same item on the other servers) no longer start the ViewState store's own worker, and they no longer read the server registry from the step or the worker.
ClientKeysand the press's profile.StoreJob::ViewWrite, naming theClientKeyit decided.StoreRunnerstarts the write only if that key still holds.KeyedClients).This closes a cross-profile write on
main. A profile switch re-tokens the registry'sClientobjects in place, so a press queued behind another write, or a fan-out still running, could be sent with the next profile's token. It is wave 5, lane B of the Sans-IO series (docs/sans-io.md, "The store job lane").What changed
The step (
data/src/viewstate.rs):Reqcarrieskey: ClientKeyandprofile: u32, captured at the press.requestandfan_out_origin_watchedcheckkeys.key(sid)instead ofclient_for(sid).Bridge::profile_scope()=session::current_gen(), the way Search takes its household. The step reads no session.One judgment,
admit, runs when a queued write starts and when a refused write is tried again:viewstate: rk=.. DROPPED — server N was re-tokened while it was queued).The third rule is stricter than first planned, and the review proved why. A profile switch re-tokens the registry in the commit that adopts the swap, but
current_gen()moves on a later commit (publish_profile, fromtake_ready). For a frame or more, a real switch therefore looks to the step like a same-profile token refresh. Re-keying in that window would send the first profile's press under the second profile's token. A fails-first test reproduces it.The cost: a same-profile token refresh also drops a press that was queued or refused across it. The read-back then shows the server's values, so nothing is written wrongly; the press is lost. #1025 tracks an identity that moves at the switch commit itself, which would let a same-profile refresh proceed again.
The job (
data/src/viewstate.rs,data/src/stores/{viewstate,mod}.rs):StoreJob::ViewWrite(Job<ViewWriteReq>, ViewWritePort),Direct, belongs toStoreId::ViewState.ClientKeyssnapshot the fan-out may use.finish_view_write_job. It runsperformon the origin, thenfan_outthroughKeyedClients, all insidecatch_unwind. The answer is posted outside the guard, so a panic answers a failed write and never a refusal.kickemits the job and starts nothing.KeyedClients(plex/src/plex/client_keys.rs) resolves a server's client only while its key equals the snapshot's. So a fan-out target re-tokened after the step gets no request.The runner (
app/adapters/stores.rs):start_view_write/launch_view_writeresolve the origin's key once at launch. A moved key refuses the job.start,admit_home,retire_parked_detailsandrun_held_where.ViewWrite.Drains (S3):
VIEWSTATE_FILLSis now[Browse, Hubs, ViewState].RECONCILE_FILLSis[ViewState, ViewReconcile].Bridge::reconcile_pumpdrains it withstart_store_jobs_in, because an end-of-stream fan-out it queues starts ViewState's next write.Ledgers
ci/allow/workers/data-viewstate.txtkick::spawn_small)ci/allow/globals/data-viewstate.txtrequest,fan_out_origin_watched,kick,fan_out,ask_sourcesclient_for)PINNED_LEDGER_TOTALS(workers/globals/forks/fxlanes)No ledger line was added or edited.
Tests
All tests run on loopback: a fake PMS or a counting listener on
127.0.0.1. No real server or account is involved.Fails-first:
a_write_whose_client_was_re_tokened_while_the_profile_still_reads_the_old_one_is_dropped_and_retired: the profile stays, and the token is swapped in place. On the tree before the fix it sent one scrobble (left: 1 right: 0); now it sends none.Mutation checks, each restored:
if req.profile != profile→if false && ..failsa_write_whose_profile_moved_is_dropped_and_retired_wherever_it_is_judged, which keeps the keys unmoved so that it pins the profile rule alone.fan_out/ask_sourcesgoing back to the rawclient_forfailsa_fanout_target_whose_key_moved_after_the_step_gets_no_request: the other server heard 3 requests instead of 0.New and replaced tests:
viewstate.rs: emit, refused-then-ladder, the drop rules, a reset's retired adapter, and a panicking worker.viewreconcile_tests.rs;retire_parked_details; a held run; a parked write whose key moved is refused;viewstate_controlled_tests.rs.Targeted suites at 86baeeb, which merges
mainat 84a780d:plx_data: 1238 passed, 0 failed.plx_screens: 1706 passed, 0 failed.plx_plex: 732 passed, 0 failed.ci/check-deps.share green.Gates
This PR's CI is the gate for
make check,check-nodef, the replay fixtures and the ARM build. They were not run locally.Review. One review, verdict FIX FIRST, with one blocker, two should-fix findings and two notes:
# count:headers.client_keys.rs. It predates this PR.Doc-claim audit. It found five sentences made false, and all five are fixed:
reconcile_pump's drain andRECONCILE_FILLS;client_forreads";Directadmission list;server_ids()).Live path
Checked in the macOS simulator against
tests/mock_pms.py, with a placeholder token and plex.tv and Discover pointed at the mock. It was a mock-only run with no real account.Before any key, the log showed:
plex: server slot 0 registered at 127.0.0.1:32611;pms: server 0 version=1.41.0.0000-synthetic;notify: roster servers=1 described=1 owned=1.The run:
down,downto Mark as Watched, thenok.GET /:/scrobble key=200622, with no unscrobble, followed by the read-back. Nothing more arrived 8 seconds later.viewstate: rk=200622 watched → server 0 (sent to the runner), thenwatched ok=1 others=0. There was noDROPPED, nostores: WARNand no panic.This is host-simulator evidence only, with no TV claim. A profile switch, a token refresh and a refused launch were not driven in the simulator; the host tests above cover them.
Not in this PR
🤖 Generated with Claude Code