Skip to content

Browse pins: the pin logic takes the session the app reads, not the registry (B-F) - #1106

Merged
GLinnik21 merged 5 commits into
mainfrom
sansio/store-jobs-browse-bf
Oct 28, 2026
Merged

GLinnik21 merged 5 commits into
mainfrom
sansio/store-jobs-browse-bf

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1104

The Library's pin logic no longer reads the session registry from inside the Browse store. resolve_pins (now resolve_pins_from), pin_record_for, record_pins (now record_pins_from) and onboard::asks_for_sources take the &Session the app read and passed in. This is the fourth Browse PR of the Sans-IO series (docs/sans-io.md, "The store job lane"), design row B-F. It adds no job kind and no runner arm, and every replay fixture is byte-identical.

What changed

The input is a borrowed &plx_plex::plex::session::Session, read by the Bridge. Search's household scope (Bridge::household_ids) and the controlled run's preferences value are the precedents.

  • append_sections_with(source, list, session, user), apply_discovery(.., session, user, adapter), record::apply_to(.., session, user), run_owned(.., session, jobs), land_discovery_owned_with_gate, discover_pump_owned_with_gate, pump_owned_with_gate, apply_pins_from(answers, session), record_pins_from(asked, touched, snapshot) and onboard::{asks, asks_for_sources}(.., session) take it.
  • BrowseStore::run_with_session(cmd, keys, session) is the old run body. run(cmd, keys) stays for the Stores fan-outs, which send only ApplyView, HubsInvalidate* and ListingsChanged. It refuses ApplyPins and Discovery (a debug_assert, and a dropped command with a log line in a release build), so a step handed no session can never read the registry. The Machine arms hand Session::default() next to ClientKeys::default().
  • The controlled path keeps "" and io.preferences.
  • current_profile_key, queue_update_ticket's merge under IO, peek_settled and B-E's two peeks (discovery_needs_pump, sync_roster_owned) are untouched.

Same-step freshness: observe, then read. The worker sends the receipt after it installs the written session, so a session read after seeing the receipt contains the write.

  • PinWrite::observe polls once and latches. PinWrite::saved only reads the latch and never polls.
  • Bridge::browse_session calls observe_pin_write() and then peek(). It is the only production poller. Its callers are browse_run, browse_discover_pump, the StoreWork::Browse arm and reconcile_pump's requery (the requery_owed() check is made first, so no immutable borrow overlaps the borrow_mut).
  • A write not yet observed answers with the local pending record, never an older snapshot. Each write has its own latch, because record_pins_from replaces pending_pins.

The first-run gate. boot.rs (inside the lazy ask_first_run) and follow_auth_landing each read peek() where they ask. At login it is a fresh read, not the earlier saved, because install_pms_owned, reset_for_profile and refresh_browse_directory run in between.

Guards. apply_pins_from and record_pins_from join MUTATORS and the browse row of MUT_FNS_TABLE in ci/check-deps.sh.

Ledgers

Before After
ci/allow/globals/data-browse.txt 14 10 (pin_record_for, record_pins, resolve_pins, asks_for_sources session::peek gone)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 7/64/58/11 7/60/58/11

No ledger line was added or edited. No fixture under tests/fixtures/replay/ was touched. The shims (resolve_pins, apply_pins, record_pins, append_sections_for_test) are under #[cfg(test)] or #[cfg(any(test, feature = "test-support"))], so the rule does not scan them.

Tests

Fails-first. 2876c27 was committed first and run red on the base, with the four fails-first tests failing and the F1 characterisation pin green:
test result: FAILED. 1 passed; 4 failed; 0 ignored; 0 measured; 1270 filtered out; finished in 0.11s

The naive variant of F1 (delete the re-peek in pin_record_for but keep the poll inside it) goes red, so F1 does pin the order. This run was not committed:
test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 1270 filtered out; finished in 0.10s

New tests (data/src/browse/browse_pins_input_tests.rs, every one seeds the registry to disagree with the handed session):

  • a saved pin write resolves from the handed session; a live discovery landing resolves from the handed session;
  • the first-run gate is judged on the handed session, and on the published profile (G1);
  • a commit handed a signed-out session writes nothing and the visible selection stands;
  • F1 a receipt landing after the snapshot is never paired with it; F2 a latch belongs to its own write; F3 a receipt is consumed only once observed;
  • a pin command sent through the sessionless run entry is refused.

Gates

Verified on the committed tree (13c4302), targeted only (the full gates are CI's):

  • make test-crate C=plx_data T=pins_input: test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 1270 filtered out; finished in 0.18s
  • make test-crate C=plx_data: test result: ok. 1279 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.93s (the C3 commit then changed only comments, docs and the names in them; T=browse re-run after it: test result: ok. 268 passed; 0 failed; 0 ignored; 0 measured; 1011 filtered out; finished in 1.85s)
  • make test-crate C=plx_screens: test result: ok. 1721 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 24.79s
  • make test-crate C=plxnative_modules: test result: ok. 1085 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 25.73s
  • make test-hostsim T=return_hold: test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1194 filtered out; finished in 0.14s
  • make test-hostsim T=lifecycle: test result: ok. 88 passed; 0 failed; 0 ignored; 0 measured; 1112 filtered out; finished in 4.14s
  • python3 tests/test_harness.py -v DepGates.test_ledger_totals_match_the_pinned_table DepGates.test_ledger_count_header_must_equal_its_entries_in_every_area_file: Ran 2 tests in 13.447s / OK
  • bash ci/check-deps.sh: check-deps: all gates green (globals (60 sites))

Not run here, by the lane's rules: make check, make check-nodef, make check-replay and the ARM make. They are CI's.

Live path

macOS simulator at 960x540, a fresh instance root, a fresh tests/mock_pms.py --port 32499 --authorize-after 2 with plex.tv and Discover pointed at it, no token. The identity lines first: pms: server 0 version=1.41.0.0000-synthetic, notify: roster servers=1 described=1 owned=1. No Plex account was touched.

  1. First run. The QR sign-in through the mock completed and logged login: server installed — asking which sources feed Home (the gate, judged on the handed session). I turned the shows row Off, committed with Start watching, and got exactly one onboard: Home selection recorded — 1 of 2 libraries on.
  2. Change one later. Relaunched on the same root with plxnative-settings=home and plxnative-login removed. Favorite libraries showed step 1's choice (films On, shows Off). I turned shows back On and pressed Done: one more onboard: Home selection recorded — 2 of 2 libraries on. (BACK cancels the Settings editor and records nothing, as designed.)
  3. Relaunch. Favorite libraries showed both On.
  4. Relaunch without the trigger. Home's pills were Home, Movies, TV Shows, and no onboard: line was logged.

The state file is sealed, so each step's evidence is the next shot of the screen, not the file's home_pins. The boot-time gate (boot.rs) cannot be exercised live without a real plex.tv base, because a triggered boot is automated. It is covered by the_first_run_gate_is_judged_on_the_handed_session, the_gate_judges_the_published_profile and the existing the_first_run_question_is_asked_once_per_profile / every_profile_is_asked_even_on_a_single_server, and is not verified live. Another lane's mock_pms was listening on 0.0.0.0:32499 throughout; it was left alone, and this run's own mock was the one answering (the default 48-film library, where the other was started with --movies 4). Every sim and mock process this run started was killed by pid.

Decisions and deviations

  • The base is main at a2aa85d (B-D merged), not B-D's head, so the decision file's line numbers were re-found by grep. Behaviour is as decided.
  • The pin tests' registry reads (TestBrowse::first_run_asks, the *_for_test entries) pass &peek() after observe_pin_write(), never Session::default().
  • mod.rs's //! "The pins capture it at their spawn site" is about another mechanism and is left alone.

Not in this PR

  • B-E: the roster and gate reads (discovery_needs_pump, sync_roster_owned) stay on the ledger.
  • The Stores fan-outs and the ViewState lane's files are untouched.
  • The boot-time gate is not verified on a live boot (above).

Review

Verdict: MERGE, with two MINOR findings. Both were cheap and certain, so both are fixed.

  1. TestBrowse::pump observed the write after its roster sync. Fixed: it now observes and reads the session before sync_roster_owned, as Bridge::browse_session does before pump_with_gate. Red first: the_harness_pump_observes_the_write_before_the_roster_sync failed before the fix (test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1279 filtered out; finished in 0.05s) and passes after (test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1279 filtered out; finished in 0.05s).
  2. A docs/sans-io.md sentence was false for the roster path. Fixed: the bullet now says the roster reconcile (sync_roster_owned -> reconcile_pins_from -> pin_record_for) gets sync_roster_owned's own in-machine peek(), which stays on the ledger until B-E.

Nothing was left open or judged wrong.

Main merge

origin/main had not moved (still a2aa85d), so there was nothing to merge. git diff origin/main...HEAD --stat shows only this lane's files (22 files).

Gates after the review fixes

On the committed tree, clean before and after:

  • make test-crate C=plx_data: test result: ok. 1280 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.84s
  • make test-crate C=plx_plex: test result: ok. 752 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.80s
  • make test-crate C=plx_screens: test result: ok. 1721 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 24.57s
  • make test-crate C=plxnative_modules: test result: ok. 1085 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 25.55s
  • make test-hostsim T=return_hold: test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1194 filtered out; finished in 0.14s
  • make test-hostsim T=lifecycle: test result: ok. 88 passed; 0 failed; 0 ignored; 0 measured; 1112 filtered out; finished in 4.12s
  • the two ledger harness tests: Ran 2 tests in 14.128s / OK
  • bash ci/check-deps.sh: check-deps: all gates green

🤖 Generated with OpenCode

GLinnik21 and others added 5 commits October 28, 2026 14:22
Four tests that hand the pin logic a session that disagrees with the registry
and fail on the base, which reads the registry; one characterisation pin (F1)
that is green on both sides. The helper bodies are the base's own calls.

Co-Authored-By: OpenCode <[email protected]>
resolve_pins, pin_record_for, record_pins and onboard::asks_for_sources no
longer read the session registry. The Bridge observes the store's pending pin
write, then reads the session, and hands it down (Bridge::browse_session);
PinWrite::saved never polls again. Deletes the four globals ledger lines
(globals 64 -> 60) and names the _from mutators in the guard.

Co-Authored-By: OpenCode <[email protected]>
F2 (a latch belongs to its own write), F3 (a receipt is consumed only once
observed), G1 (the gate judges the published profile) and the refusal of a pin
command sent through the sessionless run entry.

Co-Authored-By: OpenCode <[email protected]>
Doc-claim audit: sans-io.md gains "The pins' session input" and the browse
row's remaining-on-ledger sentence is corrected; stores-as-machines and
shared-servers name the _from functions; the touched files' docs name the
session the Bridge hands and the observe/saved split.

Co-Authored-By: OpenCode <[email protected]>
… name the roster path in sans-io.md

Co-Authored-By: OpenCode <[email protected]>
@GLinnik21
GLinnik21 merged commit eb60dc7 into main Oct 28, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-browse-bf branch October 28, 2026 11:57
Bardioc1977 added a commit to Bardioc1977/plx-native that referenced this pull request Oct 28, 2026
Conflicts:
- rust-modules/data/src/browse/mod.rs: main's plxnative#1106 split the section append
  into `append_sections_with(.., session, user)` plus a test-only
  `append_sections_for_test`; this branch had made the same function the
  rediscovery door that also applies server renames. Kept both: main's
  signature and `append_sections_for_test`, with the branch's rename loop
  and doc inside. The one test seeder that still passed `None` now calls
  `append_sections_for_test`.
- tests/mock_pms.py: /_mock/config allows main's `refuse_conversions` and
  this branch's `section_titles` rename patch.

Follow-up: Polish (plxnative#1039) entries for the six Other Videos strings this
branch added to every other locale (browse.kind.*, browse.library.videos,
browse.library.no_videos, settings.libraries.detail_opt_in,
widgets.source.opt_in_hint).

Signed-off-by: Heiko Kopp <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Bardioc1977 added a commit to Bardioc1977/plx-native that referenced this pull request Oct 28, 2026
Merge main (plxnative#1103, plxnative#1106, plxnative#1108, Polish locale and the playback work) into the owner-stamp branch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Heiko Kopp <[email protected]>
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.

Browse pins: take the session as an input instead of reading the registry

1 participant