Skip to content

search: the state machine — zones, the ▼ handoff, scroll and the keyboard - #46

Closed
GLinnik21 wants to merge 58 commits into
shared-servers-basefrom
worktree-agent-ab178357dcb59ce34
Closed

GLinnik21 wants to merge 58 commits into
shared-servers-basefrom
worktree-agent-ab178357dcb59ce34

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

The Search screen's state machine — the spine the four region files (field / recents /
results / empty) draw against. Everything here is behind the stubs 1dafd764 landed;
rust-modules/src/ui/search/mod.rs is the only file touched.

Base: targets shared-servers-base for the same reason #43 and #44 do — the wave's real base
shared-servers-integration (1dafd764) is a local branch that was never pushed. Everything
below 1dafd764 in this diff belongs to those already-open PRs; review the two search:
commits only
(e7c05ce1, e931a23d), which are one file between them.

The ▼ handoff, which is the point of the unit

▼ off the field leaves it only for something that is DRAWN:

query terms remembered shelves ▼ lands on
— — — nowhere — focus stays visibly put
— yes — Recents
yes — yes Results, shelf 0
yes — no nowhere — the "no results" statement holds no focus

One expression answers it (below_of) and draw's region dispatch reads the same call, so the
zone focus moves to and the region on screen can never be two different answers. Dropping focus
into an invisible list is a screen the remote has silently stopped addressing, which is the failure
nobody sees until a user presses DOWN twice on a blank page.

Scroll

One Spring, so ui::idle hears the motion for free and this screen owes the frame gate no clock
of its own. The focused shelf's block top comes to CONTENT_TOP, clamped to the content's own end,
and it is zero whenever the shelves do not hold focus — forced rather than chosen: nothing clips
the flow, so a non-zero shift with focus on the field would draw shelf 0 up through the field and
the tab strip. That is also why ▼ lands on shelf 0 and not on the shelf last left — the shift is
already back at 0 by then, so restoring a deep row would jump the page under the user's eyes at the
exact moment they asked for a small move. The COLUMN is remembered and clamped, which is the half of
"lands where you were" that costs nothing.

A poster shelf's block comes out at HEAD_TO_ROW + 375 + LABEL_BLOCK = 549, which is
consts::ROW_PITCH exactly — a search shelf and a home shelf stack at one rhythm, and a test
asserts it rather than leaving the number a coincidence.

What OK does on a COLLECTION — nothing, deliberately

Asked for explicitly, so stated plainly. A collection hit is a Directory row: no ratingKey,
so it is not a detail page, and what it does carry (key = /library/sections/1/all?collection=…)
is a filtered listing that browse.rs has no query for. There is no Node this could build and no
screen to mount it on, so on_ok reports Action::None and the tile is inert — rather than routing
somewhere that would be a lie about what was pressed. The shelf still earns its place, because "this
collection exists" is the answer a lot of searches are actually after. The arm is named and carries
the reasoning, so when browse learns a collection listing the next person lands in the right place.

The two that DO open: a media item → Node::Detail { sid, rk, spot: default }; a person →
Node::Person { sid, key, guid, name, thumb }, where key follows metadata::Credit::person_key's
rule (the local numeric id, falling back to the tagKey guid) because the two ids address different
services and passing one for the other 404s. Nothing here calls detail::open_rk or touches the
route — the screen reports, app.rs performs.

Region signatures: UNCHANGED

Confirmed, since four workers are building against them right now: no region file was touched,
and every draw(p: Painter, v: &View) signature is byte-identical to 1dafd764. View gained no
fields and lost none — shift is now actually driven, and recent's doc gained a paragraph making
the Clear index precise (clear_index() = one past the last term SHOWN, which is MAX_RECENTS only
once the list is full; on a two-term list it is 2, or ▼ would walk onto rows that were never drawn).

Two additive seams the regions may adopt, both inert until they do:
note_recent_rect(i, rect) and note_tile_rect(row, col, rect). Pointer rects are recorded at
draw (library::TOOL_RECTS' idiom) and parked before each frame's regions run. They cannot be
derived from this side even in principle: a shelf's horizontal offset is the scroll spring inside
its own card_row::CardRow, which lives in results.rs. Until the regions record, the field and
the tab pills still hit-test exactly.

Typing

textinput::drain() is drained every frame and appended through search::set_query;
key(sym) -> bool is the seam for backspace, which app.rs's key arm has no route for yet (the
TV's keyboard delivers printable characters as SDL_TEXTINPUT but its delete as an ordinary key).
String::pop, not a byte, so a multi-byte term cannot be left invalid UTF-8. OK toggles the panel;
leaving the field for a zone below drops it and records the term; BACK drops it and records
nothing — BACK means "not that", and a list of the searches a user backed out of is a list of
their mistakes.

Three things are pure, so a host can grade them

library::readout_of's precedent. below_of — neither store behind it can be seeded on a host (the
recents list is the session file's, the shelves a live server answer), so a test of the live
function could only ever reach one of its four cases. seat/step_results — the ragged-grid
arithmetic that actually goes wrong, a column carried onto a shorter shelf. scroll_target_for.

The review pass (e931a23d)

/code-review found six real bugs in the first commit; all six are fixed there, and four tests
came with them. The two worth knowing about because they were user-visible:

  • A click on blank ground activated whatever held focus. click fell through to on_ok()
    unconditionally, so a stray click on the page background with the cursor resting on Clear wiped
    the user's recent searches
    . One hit() now serves hover and click, and a miss does nothing.
  • The pointer left the field without going through leave_field, so EDITING stayed true
    under another zone — and that freezes the shelf scroll unconditionally, so ▼ walked focus off the
    bottom of the panel with nothing moving. The same failure this screen exists to prevent, reached
    through the other input path.

Plus: focus_is_card now asks open_focused itself (a collection is an item and opens nothing, so
the old test armed a press that dipped and committed nothing); clamp_focus stopped throwing the
remembered column away on every keystroke; the results hit test gained the w > 0.5 guard its
recents branch already had; and note_recent_rect drops an out-of-range index instead of aliasing
it onto Clear's slot.

Verification

  • 553/553 host tests, 18 of them new in ui::search::tests — the ▼ handoff in all four cases,
    the shrinking-shelf re-seat, the scroll target rule (both clamps and both frozen cases), the strip
    cursor's ends, the click-miss, the zero-size rect, the sub-MIN_QUERY query, backspace, the
    OK/BACK edges and enter's mount. Every test touching a global holds both the module's own
    ZLOCK and testlock::serial(), and the animation carries the two-sided idle test
    ui/CLAUDE.md requires (reports while running, quiet at rest).
  • make lint clean; the ARM cross-build links (make → pkg/plxnative).
  • Simulator — the television is in use, so these are simulator results and nothing here has been
    seen on a television. Boots to route=search with the field seeded; keys move focus through every
    zone with no panic; the idle gate settles the screen (loop≈46 fps≈0) and wakes on each press
    (fps 15 → 50 → 61). A capture confirms the strip zone end to end: ▲ seats the cursor on the
    Search pill, ◀◀ walks the bright focus capsule to Movies while Search keeps its selected plate —
    i.e. focused_pill() is honest as the zone changes. Below the strip the screen is empty, because
    all four region files are still the stubs their own workers are filling; this is evidence the
    state machine runs, not evidence of how the screen looks.

Two things that need someone else's file

Neither is fixable from mod.rs and both are wiring another unit owns:

  1. app.rs has no arm for a strip pill press. ▲/◀/▶ walk the pills and the capsule travels, but
    OK does nothing: on_ok() reports Action::None there by design ("app.rs reads
    focused_pill() and performs the press") and the Route::Search OK arm only matches
    Action::Open. Compare Route::Library's Action::GoHome/GoSearch arms.
  2. key(), click() and wheel() are not called from app.rs yet — no Route::Search arm
    under the key fall-through, SDL_MOUSEBUTTONDOWN or SDL_MOUSEWHEEL. So backspace does not yet
    delete on the device. The functions are written and tested against; they need three call sites.

Unrelated, but it will bite this whole wave: the host suite has a pre-existing parallel race
— verified present at 1dafd764 with this file reverted to its stub, so it is not from this PR.
Roughly 1 run in 16 aborts with SIGABRT inside str::validations or fmt, i.e. a &str read
from a global while another thread writes it. cargo test --lib -- --test-threads=1 is 553/553
every time. Worth someone owning, because it reads exactly like a new test being flaky.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV

GLinnik21 and others added 30 commits August 14, 2026 00:05
…dy carries the facts

Deliverable E of the Shared Sources design. On a friend's item the detail
hero's date/runtime line reads "13 Jun 2024 · 1 hr 57 min · Shared by bamx23"
— one more run on a line that is already there, rather than a chip, a band or
a line of its own.

WHERE, AND WHY NOWHERE ELSE. An item's source is stated where the item is, and
the badges row above cannot be it: those chips say what the item IS — 4K, CC —
and where a copy came from is not a media property. Its own line would be a
fifth line in the one column already fighting for height, for a fact you read
once; a kicker above the title is where an episode's show name goes. So it
joins the FACTS line, last, after the facts about the item, because it is a
fact about where the item came from. It takes that line's own rung and ink
(CAPTION, tertiary, regular) after the same .45 middot every separator there
uses: it is dim because the line is dim, and the line is the lowest rung in
the ladder — under it is the couch legibility floor.

ON YOUR OWN SERVER THERE IS NO RUN AT ALL, not an empty one and not a
dangling dot. `Detail::source` is the owner's HANDLE and is empty for our own
machine, and empty means the flow emits nothing — no separator, no run, no
draw call — so the 90% of installs with one server pay nothing for the
feature. The host suite's first assertion is exactly that: the borrowed row's
event list is the own-server row's with the credit appended, prefix-identical.

The person, never the machine. "bamx23" is the same string the shelf headings
say; "bx23-ldn" stays in the Sources list and the failure read-out, because
"whose copy is this" is answered by a person and "what could not be reached"
by a machine.

THE ROW BECAME A FLOW, which is the part worth reading. It was a
`dotted_run` + `dotted_run_w` pair — a paint expression and a width expression
that had to be kept agreeing — plus a yield ladder written in terms of the
second. `home::heading_flow`'s doc names that exact pair as the pattern to
stop repeating, so this row now has ONE expression: `facts_flow` hands each
run to a closure that paints in the product and measures in the tests, and
`facts_fit` takes a measure rather than owning one, so the row that is graded
is the row that is drawn. `dotted_run_w` is gone; `dotted_run` stays, still
the identity line's join, which is a join and not a tail-with-a-fragment-in-
the-middle.

The ladder is unchanged for an item with no source, and the tests prove it
across every budget rather than at a corner: the extent goes entirely, then a
date that cannot fit alone is elided. The credit slots in AHEAD of both — the
trailing credit yields first, as the design calls it, because the item's own
facts outrank the attribution; and monotonically, so a row that had to drop
its extent can never win the credit back.

One behaviour changed for items with no source, and it is a fix: the
fragment's leading separator is now decided by whether anything was actually
emitted before it, not by whether the item HAD a date or an extent. An item
whose extent was dropped by the ladder while its date was empty used to open
its facts line with an orphan dot.

`Detail::source` is "" at its one construction site, so nothing new is
reachable in the product until the multi-server layer can say which server a
fetch was made against (docs/shared-servers.md step 2 threads `ServerId`
through this struct; the roster field behind it is `Resource::source_title`,
already parsed). It is captured at FETCH time rather than read at paint time
because the page outlives the fetch and the current server can move under it.

Host 418 -> 422 + lint, `make` (ARM) green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
A ratingKey names an item on ONE server. So does a Part.id, a Stream.id, a
playQueueID, and the resume point. Every PMS call on the playback path used to
find its server implicitly — `plex::client_opt()`, evaluated at the instant of
the call, which means "whichever server the user happens to be browsing right
now". With one server that is always the right answer. With a friend's share
merged into Home it is right only by luck, and the resolve worker alone asked
the question four independent times, so a switch landing mid-resolve could split
one playback across two servers.

The server is now captured ONCE, on the main thread, at `request_play` — the
same instant and under the same discipline as every other `ResolveEnv` field —
and carried by value from there: ResolveEnv → Plan → CUR_SID, installed beside
CUR_RK by `apply_plan`, which is the sole writer of the route statics. The
resolve's client bind, the PlayQueue, /decision, the stream-selection PUT, the
transcode seek, the retranscode and the final scrobble all take
`client_for(sid)`. None of them asks what is current any more.

`plex::client_opt()` deserves naming as the hazard it is. It is not a static a
worker could be caught reading — it is a function call, so `Send` cannot see it,
and a worker that resolves its own server compiles clean and passes every test
we have. That is why `build_stream`'s doc now says so in as many words.

The one that had to land in THIS commit rather than a follow-up is the
`/:/timeline` reporter. It runs on a worker every ten seconds for the whole of a
playback and had no capture at all — it re-read the current server on each tick.
Split from `CUR_SID`, the app would resolve correctly, play correctly, and
quietly write the resume point of a borrowed film onto your own server every ten
seconds for as long as it played. Nothing would show it: the POST is
fire-and-forget, the host suite has no runtime, and the device harness grades
progress from the app's own heartbeat rather than from the server the report
reached. So `report_timeline` takes the id as an argument and `engine.rs`
captures it at the spawn site, beside the `rk` it already captured.

Two smaller things fall out of the same rule.

The `/identity` machine id cache is now keyed to the server that taught it. It
feeds `uri=server://{machineIdentifier}/…` on the PlayQueue POST, so one cached
globally is server A's fingerprint sent to B, naming a machine B has never heard
of — on a POST that is best-effort and therefore fails silently. The registry's
own per-server id outranks the cache entirely, so a server registered with one
skips that round trip.

And the Up Next still-warm moves out of `apply_plan` into `pump_play`, its only
caller. That function's contract is to be the sole writer of the route statics;
a texture prefetch is not one of them. Keeping them apart is also what lets the
host suite reach the install at all — `warm_tex` drags in the poster cache and,
through it, a GL call the dev Mac cannot link.

`metadata::cached_playing` / `fetch_playing_item` take the id for the same
reason. The fetch uses it now; the cache HIT still tests the rk alone, because
`Detail` does not yet carry the server it was loaded from — that gap is written
up at the call site as the one hole left in the capture, with what it will cost
and the one-line shape of the fix.

Three host tests, plus one fixture repair. `Plan`/`ResolveEnv` round-tripping
the sid is graded on the resolve that FAILS, which is the exit `build_stream`
takes before any network. The machine-id cache is graded from both sides. And
the timeline routing is graded against two real loopback servers: the item plays
from B, the user switches to A, the POST must land on B — with a closing report
to A as the control, so "A heard nothing" is a fact about routing and not about
a listener that never worked. That test needed `plex`'s registry test seams
widened to `pub(crate)`: the public `register` resolves the device id through
`session::load`, which mints and PERSISTS a uuid, and a host test must not write
one; `reset_for_test` is what hands the table back empty afterwards.

The fixture repair is `ui::detail`'s test `mount`, which reset the filmstrip's
sub-row and the season capsules as retained state but not `saved_col`, the
per-section column memory `move_focus` seeds from when it enters a strip. So a
test that walked one strip decided where the next test's first DOWN landed.
Order-dependent and therefore invisible until the set of tests changes, which is
exactly what a route case holding `testlock` across real socket I/O did.

Device: ./tests/run.py 21/21. Host: make check green, 12 consecutive runs at
--test-threads=16.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Plex's relay is the last connection a server offers and the only one with a
ceiling: a tunnel to a Plex relay host, conventionally :8443, capped at 2 Mbps
with the server transcoding down to fit. probe.rs already ranks it last. What
was missing is what playback should DO when it wins, and the answer is a
branch rather than a parameter, because there is no parameter to reach for:
TranscodeSpec has no bitrate field, maxVideoBitrate is a literal on the
re-encode branch alone, and on direct play — this client's default and its
whole point — a cap means nothing, since no encoder is running to obey it.

So plex::link_policy denies TWO things over a relay, and the second is the one
a "force a transcode" instinct leaves behind. Direct play is obvious: the
share measured this week is 31 Mbit/s, and 31 down a 2 arrives as a stall two
minutes in with the AU queue draining and nothing on any surface saying why.
But a container REMUX is no better — it copies the codecs and deliberately
sends no cap, because a cap is exactly what would force the re-encode it is
avoiding. Same bytes, same rate, one layer down. Denying both leaves the
re-encode, which is the only flavor whose whole point is that the server picks
the rate; the server is on the other end of the tunnel and is the only party
that knows its real ceiling.

The tier itself is now a property of the SERVER, not of a request:
Client::set_link/link(), lock-free, LINK_UNKNOWN until something says
otherwise. route::build_stream reads it off the client it already holds — no
new global for the resolve worker to consult — and one derived `remux` local
keeps the payload guess, the stored flavor a seek rebuilds from, and the
/decision query from disagreeing. Nothing calls set_link yet, so link() is
None everywhere and UNRESTRICTED is what every play gets: byte-identical
behaviour, which is also why "unknown" is deliberately permissive rather than
defensive. Assuming relay would downgrade every direct play on earth to a
server-side encode to prevent a stall on a connection this codebase has never
made.

NO RELAY CONNECTION HAS EVER BEEN OBSERVED HERE. includeRelay=1 has been on
the query since the first login and every relay connection was then discarded
unconditionally. The 2 Mbps and the :8443 are Plex's documentation, not our
measurement, and this account's share advertises no relay at all — so it is
not merely untested, it is untestable from here. The policy doc says so, at
the policy.

A REGRESSION THIS WORK CAUSED, found by review. Adding includeIPv6=1 to the
roster query means plex.tv now offers v6 connections, and the live sign-in
chooser takes the FIRST `local` match and PERSISTS it. stream.rs parses a
dotted quad by hand (AF_INET, no DNS), so a v6 literal is not slower, it is
undialable: a server listing its LAN v6 first would have signed in
"successfully" to an empty Home and written that address to the session file,
so every later boot started there too. The chooser is extracted as
auth::choose_local_connection — the rule was not gradeable at all before —
guarded on both the flag and a colon in the address, since a null flag must
not be believed, and it has the two tests that would have caught it.

DOCS. plex/CLAUDE.md gains the registry section it never had: why the table is
atomic pointers (client() is called three times per key, per visible tile, per
frame), why each Client is leaked (a re-point costs a worker one request to
where that server used to be, never a dangling pointer), why token generations
are globally unique (the poster memo compares ONE number, so equal generations
would serve server B its cards from A's memoised token-bearing paths), and the
three states the whole feature rests on: granted, pinned, reachable.

The Makefile said FFmpeg is unlinked because "SONAMEs move between releases,
55->57->58->59->60" a hundred lines above the rules that build and stage a
bundled, PINNED copy. Both halves are in the same file and they contradict
each other. The real reason is different in kind: those .so files land beside
the binary, on no library search path and with no rpath, so a DT_NEEDED entry
would resolve at exec() against the system path and either find nothing (dead
before main) or find the TELEVISION's FFmpeg, which is the wrong one. Left
alone, the old wording is how "just use the TV's libavformat for https" keeps
coming back — when what we ship is --disable-network and cannot open a URL.

docs/shared-servers.md is brought level: §3 separates what was fixed from what
is still live (the 8-second trap is still exactly as live as it was), §5 marks
each step's status, §6 defers to the design canvas and names the two things
its own earlier draft got wrong, §7 retires the harness question and records
that relay is unverifiable from this account, §8 shows all four corrections
landed, and §9 covers all seven units.

Host 418 -> 424 + lint (x3), `make` (ARM) green. No device run: the docs half
cannot be observed on a television and the relay half cannot be reached.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…only observable on the TV

`/tmp/plxnative-shared=<handle>` stamps that handle onto every item the session
loads, which is what a fully-borrowed library looks like from the detail page.

It exists because there is no host runtime: nothing in the suite draws a pixel,
so the only place the hero's "Shared by bamx23" run can be JUDGED — its weight
against the runs either side of it, whether it reads as the same voice as the
date, what a long handle does to the line — is a real panel. And until the
multi-server layer lands, `Detail::source` is "" on every path, so there is no
item on this server that can put that run on screen at all. Without the trigger
the feature is unreviewable by anyone, including the owner.

It goes through `dev::read` like every other trigger, so `RELEASE=1` compiles it
out with the rest of the `/tmp` surface, and it is deliberately NOT in `DIAG`:
it changes what the app draws, so it should suppress the who's-watching picker
exactly as `plxnative-detail` does.

Host 422, `make` (ARM) green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Measured against the real share this evening, from the dev Mac:

  GET /photo/:/transcode?width=250&height=375&minSize=1&url=/library/metadata/1/thumb/1778526065
    -> our server:    Frozen's poster            25658 B  sha a211b9ac5a
    -> the shared one: Призраки в Венеции's      11707 B  sha 59928cd5b1

One request path, two different films. That is not a corner case: rating keys
are server-local integers from 1 on every Plex server, and the thumb path's
trailing timestamp is a cache-buster the other server ignores, so the paths
COLLIDE by construction rather than by coincidence.

THE POSTER STORE. The key was the request path and nothing else, so those two
posters were one slot: whichever landed first was drawn for both, and the tile
that missed showed a film from a library it had never asked about. The fetch
made it worse in the other direction — every worker read `plex::client()`, the
CURRENT server, whatever item the slot belonged to, so with a merged Home half
the requests went to the wrong host carrying the wrong grant.

So a ServerId rides every entry point, sits in the slot as the other half of
its identity, and is what the worker dials. It is a FIELD, not a key prefix:
keys already run ~135 bytes into a fixed 256-byte array, and `slot_matches`
compares the u16 first, which is the half that can reject without touching the
array — this runs for every slot of every probe of every visible tile.

Capture-at-the-spawn-site is honoured by the store itself: `lookup` writes the
slot's server on the main thread when it claims it, and the worker resolves
`client_for(that id)`. It never asks what the current server is, which is the
question that has no correct answer on a worker.

THE KEY MEMO had neither host nor token in its key and one token generation for
the whole map. Both halves are now per entry: the server is part of the key, so
server B's card can never be built from A's memoised token-bearing path (a
request to B carrying A's grant is a 401), and each entry remembers the
generation it was built at, because with a table of servers there is no single
"the token" to compare against any more.

LAYERING. The store fetched through `crate::stream` directly, behind the back of
the layer whose module doc says it is the only code that touches the socket. It
now goes through `Client::fetch_built` — deliberately NOT `get_bytes`, which
would append a second `X-Plex-Token`: the poster path IS the store key and
already ends in one.

SERVER FACTS. `serverinfo` kept one version, one subscription and one in-flight
latch for the whole app, justified in its own doc by "host/port fix at the first
install (a later install is only a token swap)". The registry retired that
premise. All three are now per server, indexed by the registry's own slot number
(and by its ceiling, so a second constant cannot drift out of agreement with it).
The LATCH mattered as much as the values: a global one silently skips the second
server's fetch while the first is in flight, and the answer it never fetched is
then read as fact. An id that names nothing reads Unknown — never a neighbouring
server's answer, and never a panic.

`register` now does the refresh, not `install`: install only ever reached the
current server, so a shared server registered beside it would have stayed
permanently Unknown — and `player::error_shape` blames a missing Plex Pass on a
known-free server, which is exactly the sentence you do not want aimed at the
wrong owner. The log line names the slot, because the machineIdentifier that
really identifies a server is a household fingerprint.

The three UI resolvers keep their signatures and gain `_on(ServerId, …)` twins;
the bare form is exactly `_on(current_server(), …)`, so a one-server install is
byte-identical and the item-server plumbing has a door to walk through. One
behaviour change falls out for free: a poster resolve before `plex::install`
used to panic through `client()` and now degrades to no artwork.

Host suite 421 (three new: the slot identity rule, the memo's two scopes, and
one server's Plex Pass never being read as another's), `make` ARM green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Deliverable E of the Shared Sources design. When a second pinned source also
holds the item on screen, the actions row grows an "Also available" pill with a
trailing chevron, and it opens the app's usual Popover + TableView listing the
copies: the library on each source, whose it is and how long it runs, and the
resolution class as a badge.

The reason it is a CONTROL and not a section of the page is that an item on
several servers is a rare fact — a permanent band would spend a whole row on
nothing on every other page in the library. So it is drawn only when a second
source actually holds the film, and `is_available` counts distinct SOURCES
rather than copies: two copies in two libraries of one server is not "also
available elsewhere", and the row naming the second one would lead back to the
machine you are already on.

OK NAVIGATES. It opens that server's own page for the film rather than swapping
the copy under you, which is also what settles the per-server progress problem:
watch state does not travel between servers, so a design that switched the copy
in place would have had to explain a resume position that jumped. Navigating
makes it self-evident — you are on a different page, and it says where you are
in that copy.

Ordering is the copy that PLAYS first, then what a viewer would prefer: higher
quality, and at equal quality yours before a friend's, because yours cannot go
offline mid-film. The design's own example is the case that separates the first
two clauses — a 1080p copy you are standing on outranks a friend's 4K one — and
it is what the host tests pin, along with the gate and the rule that exactly one
row is ever ticked (marked on the first copy matching the page's own (server,
ratingKey), so a duplicated input cannot say "you are here" twice).

Copies are keyed by the item's GUID and never by its ratingKey: every
item-shaped integer in Plex is server-local and starts at 1, so both servers in
this household have a ratingKey 4. `install()` is the seam the multi-server data
layer feeds; it is empty until that lands, which is what makes the whole feature
cost a one-server library nothing — no query, no control, no layout.

Three things this needed elsewhere, each smaller than it sounds:

`Button` gains a TRAILING accessory slot, because the leading `icon` is part of
the label's own statement (the Play triangle IS "play") while a chevron is a
disclosure mark about what the control does. `pill_w` grows a `pill_w_full`
twin rather than a second sizing path, since sizing the pill without the
chevron and then drawing one pushes the label off-centre.

The hero row's focus now follows its CONTROL through an index change by name
(`HeroCtl`/`hero_set`), not by a `+= 1` around one insertion point. That was
sound while the restart disc was the only conditional control; with a second
one, two controls can appear in the same frame and which of them moved the
focus depends on where it was sitting. The geometry walk is one accumulation
for the same reason — the alt pill is a variable-width control in the MIDDLE of
a row that was otherwise a pill followed by fixed-width discs.

And the source switch itself is performed by app.rs, not by the screen.
Re-pointing `plex::client()` invalidates every store keyed to the server that
was current when it was filled — the hub catalog, the browse grid, an open
person page — and none of them carries a server in its keys, so a screen doing
the switch itself would leave server A's ratingKeys being fetched from server B
with only the page in front of you correct. `install_pms`'s wipe is now
`activate_server`, shared by the profile switch and this one, and the BACK trail
is truncated to its root because `Node::Detail` carries a ratingKey and no
server (step 2 of docs/shared-servers.md).

Host 418 -> 430 + lint, `make` and `make RELEASE=1` both green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
`/tmp/plxnative-shared=<handle>` already means "pretend this item came from
<handle>" — it is how the hero's own "Shared by …" run is judged on a panel,
because with `Detail::source` empty at every construction site there is no item
in the product that can put a borrowed-item surface on screen. A second copy of
that film on <handle>'s source is the other half of the same pretence, so this
reuses that trigger rather than adding a second one for one deliverable.

What it stands in for, precisely, because a stand-in that lies is worse than
none. YOUR copy is real: the page's own ratingKey, on the current server, with
the loaded item's runtime and resolution class and the library the browse store
says you are in — which is what makes the tick meaningful. THEIR copy is that
same film on a second registry SLOT, and the slot is real: a genuinely different
server when one is registered, otherwise the current server registered again
under a synthetic machine id. From everything this feature does — counting
sources, resolving a client, switching, refetching — that is a second source,
and because it is the same machine the ratingKey it carries is honestly the same
film. So OK performs the real switch and opens a real page, which is the one
behaviour of this panel that cannot be judged from a still.

The single invention is that their copy is one resolution class better than
yours, and it earns its place: the ordering rule is otherwise unobservable. The
design's own example is a 1080p copy you are standing on sorting ABOVE a
friend's 4K one — the case that separates "the copy that plays" from "the best
copy" — and with two equal badges a capture cannot show the rule was applied at
all. `one_class_better` promotes nothing past the top of the ladder and leaves
an unrecognised class exactly as the server spelled it.

It is built by a `pump` on the detail page's frame, not by the store's `reset`,
because a mount deliberately clears `metadata::current()` for the whole 2-5
round-trip fetch: at reset time there is no runtime, no class and no title to
copy. Two string compares in the ordinary case, and `dev_stand_in` is `None` at
COMPILE time under `cfg(test)` so the host suite can never depend on what this
Mac happens to have under /tmp.

Host 430 + lint, `make` (ARM) green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
`pump` returned early only on SUCCESS, so the ordinary case — the trigger not
armed, which is every real boot — re-opened `/tmp/plxnative-shared` on every
frame of every detail page. It now marks the attempt whatever the outcome, and
takes the "has the item landed" gate BEFORE marking, so waiting out the mount's
2-5 round trips does not spend the one chance the page gets.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
The trigger swap replaced the parser but left its doc — a JSON schema for a
`/tmp/plxnative-altsources` file that no longer exists, which would have sent
the next reader to write one. What survives from it is the sentence that has to:
the trigger literal, spelled in a comment so the catalog grep in the root
CLAUDE.md still finds this surface.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Deliverable C of the Shared Sources design ruled the conditional in its own
list: "if the hero ever becomes independent of a shelf, it needs E's dim run
and the preference comes back." In this app the hero IS independent. It is a
rotating billboard built per fetch from Continue Watching plus every recent
hub, deduped and capped at 8, turning over on its own 8-second timer — so it
is nobody's focused tile, the shelf heading beneath it is attributing
something else entirely, and with a merged pool the front door could open on a
stranger's film with nothing on the screen saying so.

So the run comes back, on the hero's own meta line, as its last run:

    Movie · 2024 · 18 · Shared by bamx23
    S1 E4 · Episode title · Shared by bamx23

IT KEEPS THAT LINE'S RUNG AND TAKES ONE STEP OF INK. BODY, not the detail
page's CAPTION — a rung is a role, and the hero line is BODY because it is
read from across the room while E's is CAPTION because it sits under a page of
copy. What travels between the two screens is the ink step, secondary →
tertiary, after a middot at the separator token's own .45. The host tests
assert the rung explicitly, because "match E literally" is the plausible wrong
answer and it is invisible in a diff.

THE LINE NOW HAS A WIDTH BUDGET, WHICH IT NEVER HAD. This is copy over a
photograph, legible only inside the hero's corner wedge — which is gone by
four fifths of the frame and leaves the last fifth, the side the composition
is usually about, completely alone. HERO_META_R ends the line at three fifths,
a whole fifth of the panel short of that edge, and every run in the flow is
handed a budget running to it. So an over-long handle ELIDES where a wrapped
block would have spilled: there is no wrap in this flow to reach, only a bound
to truncate against, and the line can never become two. The facts ahead of the
run keep the hero column exactly as they always have — the handle is the last
thing on the line and a fact about where the item came from, so it is the
right thing to lose first.

OWN-ITEMS-FIRST IS AN ORDERING, NOT A FILTER. `own_items_first` promotes the
first owned page to the front and moves nothing else, so [B,B,O,O,B] becomes
[O,B,B,O,B]: the door opens on your own library and a friend's film arrives
one flip in, attributed. Filtering instead would leave a borrowed-only account
with no billboard at all and would overrule a pin the user made — which is why
a pool with nothing of ours in it is left exactly as it is. It needs no switch
of its own either: the pool is built from included sources only, so a borrowed
hero is always the consequence of a pin.

The pool's entries stop being bare catalog indices and become HeroSlot — index
plus the handle of the shelf's server. It is carried rather than looked up
because this is the one place in the app that lifts items OUT of their shelf
order, so an entry that knew only its index would have to scan its way back to
a hub to answer "whose is this", for a fact the build already had in hand.

With one source none of this exists: `HubRow::source` is "" everywhere, so the
flow returns before its first run — no pad, no dot, no draw call — and
own_items_first returns on its first line. Absence, not an empty annotation.

Two things the flow forced, both real:

  * hero_content's off-screen cull was measured on the text column, and the
    run is the one thing that draws outside it. Left alone, a flip would take
    the whole column away while ~400px of that line was still on the panel,
    and the tail of the meta line would blink out ahead of the item it
    belongs to.
  * meta_drawn_w clamps to the column. `TextView::truncates` answers "were
    WORDS left unplaced", and a single token too wide for the column leaves
    none — it is ellipsized by a separate safety pass — so the measured string
    can be wider than anything drawn. Unclamped the run would start in mid-air
    past the ellipsis, and an absurd one could hand the flow a negative
    budget, which text::elide reads as "no bound at all".

SOURCE_PAD is now one constant for both places this screen states a source.
The heading and the hero line are one annotation in two positions, not two
spacings.

/tmp/plxnative-shared — the detail page's own trigger, reused rather than
twinned — stands in for a source where the real answer is empty. The visible
half of this work is unreachable in the product until the multi-server layer
lands, and the two things the design states about this run (that it sits
inside the wedge, and that it ends well short of the last fifth) are things
only a panel can settle. One file arms both surfaces, which is the only way to
see the hero's run and the detail page's agree. Both hero accessors go through
it, or the run would pop into existence halfway through a flip.

Host 427 (+9: 4 for the ordering, 5 for the line) + lint, `make` (ARM) green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…' into shared-servers-integration

# Conflicts:
#	rust-modules/src/route.rs
…that looks local

Sign-in kept exactly one server and threw the rest of the account away. Both of
its passes filtered on `c.local && !c.relay`, and against a real share that is
worse than useless: `Connection.local` means "this address is RFC1918", not "you
are on that LAN", so for a friend's server it selected the OWNER's 172.20.x.x —
eight seconds of timeout from here, and the worse outcome is that it SUCCEEDS,
against whatever else happens to sit at that address on our own LAN.

So discovery now works the way every Plex client with a connection story works.
Each resource that provides a server — ours and every share alike — is turned
into ranked candidates by `plex::probe` (which is what drops that address), and
they are dialled in order until one answers. `/identity` is the probe, chosen
because it is unauthenticated: it answers 200 to anybody, which makes it useless
as a token test and perfect as a reachability one. The token is deliberately not
sent, because a probe can land on a machine that is not the one we asked for, and
that machine must never be handed a live credential.

Which is the same reason the answer is VERIFIED: a candidate that answered is not
yet a server, so its machineIdentifier must equal the resource's clientIdentifier
before the connection is accepted. Anything else is discarded and the next address
tried. A 401 is its own state and not "unreachable" — every other address of that
server answers a token problem identically, and reporting "can't reach bx23-ldn"
for one sends the user to look at their friend's router. Note what that does NOT
cover, spelled out where the probe path is defined: an accessToken revoked since
the resources fetch still probes as reachable, and surfaces on the first
authenticated request instead.

Everything that answers is registered with the server registry under its real
machine id and its OWN per-(user, server) token, and persisted as a roster in the
session beside the primary ServerRef, which is written exactly as before — a
single-server account produces the session file it always did, plus a one-entry
roster. Our own server stays current: a share is browsable, never the default.

Three things fall out of the rewrite that are worth naming.

The failure copy was one line, "No local Plex server found on this network.", for
every outcome. That sentence was the policy talking — a server reached over the
internet was a failure by construction, so the message named the LAN. It is now
three, and none of them sends the user to the wrong place.

A profile switch re-keys the WHOLE roster from the /resources response it already
fetches, because accessToken is per (user, server): a share left on the previous
profile's token answers 401 to everything. It is computed before the switch is
known to have worked and applied only on success — persisting a roster re-keyed
for a profile we did not switch to would delete the user's shares from disk.

And `choose_local_connection`'s IPv6 guard is now structural rather than a filter
that can be forgotten. Nothing but a dialable candidate — plain HTTP to four
decimal octets, which is all `stream.rs` can build a sockaddr from — is ever
dialled, and only a candidate that ANSWERED becomes a stored source. An address
can therefore only be persisted after it has been connected to, which is the
property the v6 fix was protecting: `includeIPv6=1` made plex.tv offer v6
connections, and writing one to disk broke every later boot, not just that one.

`probe.rs` gains the fourth ranking axis that makes the same point about names: a
numeric address outranks a HOSTNAME inside its tier. The transport has no resolver
at all, and this account's share lists an internal name that does not resolve
ahead of the public address that answers in 115 ms. Ranked, not dropped — a name
is the only thing TLS can ever validate.

The session file's structs are hardened while they are open: every one of them
takes `#[serde(default)]` on the container, and the three list fields decode
element by element. `#[serde(default)]` covers a field that is ABSENT, not one
that is present and the wrong shape, and for this file the cost of the difference
is not an empty roster — it is a Session that will not parse, which is a silent
sign-out and a QR code to scan on every boot.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…ing from 1 is the normal case

A Plex ratingKey — and a librarySectionID, a personId, a Part.key, a Stream.id — is a
server-local integer dense from 1. With one server that is a distinction without a
difference, and the app has always leaned on it: five places identify an item by a bare
rk. With a share registered it is not a distinction the app can skip, and it is not an
edge case either. It is the measured default: docs/shared-servers.md §2 records the
friend's server answering with section key 1, exactly like our own Movies, its
ratingKeys starting at 1 alongside ours.

So a key alone now names an item on neither machine, and each of the five sites turns
into a confident answer about the wrong one:

  * `pms::index_of_rk` scanned `m.rk == rk` over one flat catalog and returned whichever
    row came first. Its callers are the item menu's Play from Start — long-press a
    friend's episode on a merged Continue Watching shelf and OUR film with that number
    plays, with the friend's title still in the HUD — and `detail::mount_rk`, which
    mounts the wrong backdrop, blur envelope and selection.
  * `metadata::cached_playing` is the worst of them, because it is silent and it feeds
    playback. It is the fast path that SKIPS the PMS fetch, so a false hit substitutes
    the loaded page's whole `PlayingItem`: its audio and subtitle `Stream.id`s (which are
    then PUT to the other server), its frame size (so the direct-play gate reasons about
    the wrong resolution), its fps, its chapters, its markers.
  * `metadata::pump_season`'s `d.rk != r.rk` ownership test. Hop from A's show page to
    B's with the same rk while a `/children` is in flight and A's episodes install onto
    B's page. Nothing else can see it — the hop bumps no generation that separates them.
  * `plex::queue_index_of`'s rating-key FALLBACK. The primary key, `playQueueItemID`, is
    minted by the queue and needs no scoping; the fallback compares a key the caller
    supplied, which can come from anywhere.
  * `trail::Node::Detail{rk}` and `Node::Person{key}`. The trail stores identity
    precisely because indices go stale, and then stored an identity that had gone
    ambiguous: browse the share, open an item, go deeper, press BACK, land on a page the
    user has never seen.

The rule lives in one place, `plex::same_item((sid, key), (sid, key))`, so the five sites
cannot drift and one host test grades the rule itself. UNSET matches only UNSET — that is
the pre-registry state (and every row a host test builds by literal), not a wildcard, so
the single-server app is unchanged and a "server unknown" row never answers for a named
machine. Every miss degrades safely where it lands: a catalog miss opens the page
off-catalog, a playing-item miss costs one round trip, a season miss leaves the page it
found alone.

`PmsMovie`, `Detail`, `PlayingItem`, `QueueRow` and `person::Person` gain the server they
came from, stamped where they are parsed — and the server is PASSED IN, never looked up.
`parse_item` runs on the hub, page and person workers, `fetch_full` on the detail worker,
and the house rule (browse.rs's spawn site states it outright) is that a worker reads no
statics. It is also the only correct answer: the current server can move while a fetch is
in flight, and the rows in hand belong to the machine that was asked. So the fetches now
take a `ServerId` and dial `client_for(sid)` rather than `client()`, which is what makes a
row's stamp provable rather than incidental.

`Node::Person` prefers the plex.tv `tagKey` whenever both sides have one, because that id
is GLOBAL — one guid is one person however each machine numbers them — and falls back to
the server-scoped local pair only when a credit row carried none. Comparing a present guid
against a missing one would make every guid-less row the same person as every other.

`Trail::reset`'s doc calls a truncation the profile-switch guard, and a server switch has
the same shape. It does not get the same remedy: a source change does not revoke access to
what is behind you, and the trail's other rule is that a cycle is a HISTORY. A per-node
sid keeps that history walkable and still lands every pop on the page it names.

Two dropped-write paths in the item menu now say so. `client_for(sid)` can return None
where `client()` used to panic, and the repaint below ran either way — so a scrobble or a
deck removal that never reached a server is a log line rather than the one PMS write with
no trace at all.

Not in this change, deliberately: `route.rs` still resolves the STREAM against the current
server (`ResolveEnv::snapshot`). That is the sibling unit's seam, and its comment says so
rather than implying the play path is finished.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
… its Source chip

Deliverable A of the Shared Sources design. The Library's section table described
one server — a bare `key` with no server on it, a flat `SECTIONS`, and an
`ensure_sections` that fetched from whatever `client()` happened to be. Measured
against the real share on 2026-08-11, both servers have a section `1` and they are
different libraries, so a bare key names two things. The table is now addressed by
(SOURCE, section), and every fetch is issued through `client_for(sid)` CAPTURED AT
THE SPAWN SITE — the rule this file already stated for its page worker and did not
keep.

IT GROWS BY APPEND AND NEVER BY REBUILD, and that is the soundness argument, not a
detail. A page landing is blamed on a section INDEX, so a table that reshuffled
under an in-flight fetch would splice one library's items into another's store.
`ensure_sections`'s early-return was the only thing preventing that; appending
replaces it and holds for every source, not only for the second call. Two
generations now, each with one job: SECTIONS_GEN (shape — moves on an append, what
the label caches key on) and EPOCH (identity — moves on `reset` alone, what
index-blamed landings gate on), because one source's append must not discard
another source's answer.

ONLY THE CURRENT SERVER IS DISCOVERED ON THE MAIN THREAD. `ensure_sections` runs at
boot and on every Library entry, so fanning out there would park the SDL loop for
one connect(2) per unreachable share — seconds of frozen boot because a friend
switched their server off. Every other source is discovered by a worker off `pump`:
sections, then the server's own friendlyName (`GET /`, so a roster that never
reached plex.tv can still head its group with a machine name), then a size=0 count
probe per library. Ten-second per-source backoff. A dead share arrives as
`reachable: false` and costs the main thread nothing.

THE SOURCE CHIP, first in the toolbar: `Library · LDN Films  bamx23 ▾`, the handle a
MICRO run at 62% of the label's own ink and ABSENT ENTIRELY on your own libraries —
absence, not an empty run. With one source the chip is not drawn at all and the list
does not exist. Its panel is 640 wide because the rows are two-line, with two levels
swapped by pills at the panel top: Browse, a picker with one tick and no words, and
On Home, switches whose word is the only mark. The levels never mirror each other's
marks — a mark says where you are, a word says what is set. A server is a group whose
header is the MACHINE and whose accessory is the PERSON; the last pinned library dims
its VALUE and states the rule on its sub-line while its label keeps live ink; an
unreachable server's group dims whole at one alpha and still reads On, because
nothing was unpinned.

The toolbar is a TYPED chip list now, and that is a fix rather than a tidy-up: `on_ok`
matched on the chip's INDEX with a `_` catch-all, so inserting Source at 0 would have
made it open the Sort menu while Sort and Filter both opened Filter — silently, since
every index still resolved to something. `open_chip_menu` is the one chip → action
map, exhaustive so a new chip is a compile error, and the pointer path calls it
directly instead of deferring to `on_ok` (which reads the FOCUSED chip, so the two
agreed by side effect rather than by construction). The test asserts chip → menu by
IDENTITY and the row's contents by order, and pins position nowhere.

THE TAB STRIP DELIBERATELY DOES NOT CHANGE (deliverable B, "answered by subtraction").
`browse::tab_*` projects the table to one pill per TYPE — your own sections, plus any
type only a friend has — so the strip is the same width at one friend or at ten, and
a borrowed library's selection capsule rests on its type's pill. With one source it is
the identity map, so a single-server install draws exactly the strip it always did.
`/tmp/plxnative-library=N` therefore names a PILL now; the comment says so.

PICKING A LIBRARY ON ANOTHER SERVER MOVES THE APP'S CURRENT SERVER, which is
`docs/shared-servers.md` §5's named cheap variant and is here because without it this
panel is a trap. `PmsMovie` carries no ServerId, so a borrowed card's poster is
fetched from `client()` and its ratingKey resolved through `client()` — and ratingKeys
are server-local, so OK on a friend's card would quietly open, and play, a different
title of yours with the same number. Moving `current` makes them agree. The cost is
stated rather than hidden: Home's catalog belongs to the server it came from, so it is
dropped and re-armed asynchronously, and `route`'s cached machineIdentifier is
forgotten so the next PlayQueue names the right machine. Threading ServerId through
the stored structs retires the seam.

Two things `TableView` was missing for the panel, both now in the shared component
rather than drawn in the screen: `Section::accessory` was declared and NEVER PAINTED,
and `Section::dim` is one alpha over header, accessory, rows and the selection pill —
not `Row::dim` per row, because the state is a fact about the GROUP and a dimmed row's
own "On" must stay legible as itself.

Four latching bugs the review caught, all the same shape as the single-flight one this
module already had: an empty count landing no longer latches the probe off; `reachable`
is now written by every page fetch, in both directions, so a server that goes offline
after discovery can still dim; "Check for new shares" re-asks EVERY source rather than
only the ones already known to be down, and a library created since is appended; and
the Source chip reads the QUEUED section's owner, so the handle does not pop in 70 ms
after the name it belongs to.

Host 419 -> 431 (`make check` green three times), `make` and `make RELEASE=1` both
link. NOT VERIFIED ON DEVICE — the television was unavailable for the whole of this
work; the PR carries the recipe.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…it down

Home was one `?` chain over one server: `home_hubs()?` then `continue_watching()?`,
and a single failure anywhere in it committed nothing at all. That is defensible with
one server — there is nothing else to show — and it becomes a lie with two. Extended
naively over N sources, a friend's machine being asleep aborted the whole build, so on
a cold boot the user got the whole-screen "Can't reach your Plex server" read-out about
their own library, which was answering perfectly well the entire time.

So a verdict now belongs to a SOURCE, not to Home. Each one has its own single-flight
latch, its own place on the retry ladder, and its own last good projection; the merge
runs over whatever has answered so far. Every piece of that used to be process-global,
and each of the three was its own failure with a second server: one latch meant a share
that takes eight seconds to time out held the owned server's retry behind it; one
backoff meant the 30 s rung a dead share had climbed to was the rung everybody then
waited on; one `?` chain meant it blanked their shelves as well. `hub_state` folds the
per-source verdicts for the read-out, and the fold reserves the total-failure caption
for a total failure — any source answering makes Home answered.

What the merge draws, per the design canvas (deliverable C):

  * Continue Watching is ONE shelf across every source, ordered by `lastViewedAt`, so a
    borrowed item legitimately holds first position. It therefore carries no annotation
    at all — a shelf drawn from three servers cannot be named by one of them.
  * Every other shelf keeps its source: the owner's handle for a borrowed server, empty
    for our own. Ours come first, then each share whole, because adjacency is the
    grouping device and interleaving would destroy it.
  * A source that has never answered contributes NOTHING — no heading, no empty shelf,
    no spinner row. A spinner would also hold the panel presenting for something that
    is not coming, which is the 39.6% → 1.67% idle saving spent on an apology. One that
    HAS answered and has since failed keeps what it last had: a transient failure must
    not reflow the shelves under the focus ring, and what removes a source for good is
    it leaving the ROSTER, which is a fact about the grant rather than about one fetch.

Two caps had to move here from `ui::home`, because a cap the data layer has never heard
of is a cap that truncates a whole source away. Shelves and rows are now divided by
water-filling (`allot`): the smallest demand is served first and what it does not use
is re-divided, so a modest source costs nobody anything and two greedy ones split the
rest evenly. Handing the budget out first-come — which is what a single running total
does, and what this module did while there was only ever one server — means the first
source spends it: `/hubs` promotes several rows per library, so one four-library server
already overruns the sixteen shelves the grid can address. The per-shelf cap is the
other half: three sources' decks merge to 36 cards, and past 24 the focus ring and the
OK dispatch clamp differently, so the ring sits on one card while the press opens
another.

Boot stays synchronous for the owned server alone. A share that has gone away costs a
full connect timeout, and serialising those on the SDL thread would freeze the app for
as long as the friend's router stays quiet.

The open seam is named at the line that will close it: `PmsMovie` still carries no
`ServerId`, so a merged row's server is forgotten the moment it leaves `merge`, and
posters, the detail page and the scrobble paths all resolve a server-local ratingKey
against whichever server is current. That is steps 2 and 3 of `docs/shared-servers.md`,
and until they land a second source can only ever arrive through `/tmp/plxnative-servers`
— dev-only, and compiled out of a release build.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
`candidates()` sorted on (location, scheme, ipv6) and stopped. Two candidates
tying on those three fell through to plex.tv's listing order — so whether the
app reached a server depended on the order a remote service happened to return
its connections in, which is reproducible for one account and not another.

`stream.rs` takes a numeric address and speaks cleartext: it has no resolver at
all. A hostname is therefore not merely slower here, it is undialable, exactly
as an https origin is — and the existing `shared_server()` fixture already
carried the bug. Its custom hostname is listed BEFORE the public IPv4, so the
top-ranked candidate was an address the media transport cannot open, while the
one connection measured as reachable from the TV sat second. The old test
asserted that address was *present*, which it was.

Ranked, not filtered: the curl control plane does resolve names, so a
hostname-only server stays reachable once TLS lands — it just must never
outrank an address the byte path can open.

Found by unit 12's code review, in code from the shared-servers foundation.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…' into shared-servers-integration

# Conflicts:
#	rust-modules/src/auth.rs
#	rust-modules/src/plex/probe.rs
…' into shared-servers-integration

# Conflicts:
#	rust-modules/src/route.rs
Deliverable D of the Shared Sources design. The base branch stopped the grid
spinning on a failed page; what it left was the read-out itself, and the layer
above it.

THE COMPONENT. `StatusOverlay` grows a reason line and an action, so it can say
three things instead of one: the verdict (what happened), the reason (why, and
what is NOT broken), the action (the one thing to press). Its caption is a
borrowed `&CStr` rather than a `&'static` one, because a section read-out
interpolates a machine name and no `c"…"` literal can carry that; every existing
caller passes a `&'static` and is unchanged.

The action pill is the COMPONENT's now. Home hand-built its Retry — a
`Button::pill_w` and a y measured off the panel centre — under a caption that
came from the shared read-out, so one block was laid out by two pieces of code
and agreed only by inspection. The Library's read-out would have been a third
copy. `action_frame` is the one geometry the draw and the screen's hit test both
read, and Home's pill moves 7px up onto the shared `space::LG` rung as a result.
Everything hangs off ONE anchor — the caption band, exactly where it was — so a
read-out carrying neither optional block is laid out as before.

THE READ-OUT. The verdict names the MACHINE, the reason names the PERSON and
rules out the worry that everything is down, and there is one action. Focus
starts on it, because a server that did not answer often answers a second later.
It is anchored in the CONTENT REGION rather than at the read-out's canonical
full-screen position: the chrome above it is still live, and that is the whole
difference between a section failing and the app failing. Nothing else is drawn
beside it — no Sort, no Filter, no count, no A–Z rail (all four act on a grid
with no items), no alert glyph (that mark is the player's) and no BACK hint
(BACK is universal, and the chip and tabs above are the visible way out).
`toolbar_n` and `rail_drawn` are the ONE predicate each behind a control's draw,
its pointer hit test and the focus walk, so neither can be invisible-and-clickable
nor drawn-and-unreachable — and when the Source chip lands, UP from the read-out
reaches it with no change here.

Two identifying strings, and the list is CLOSED: the machine's own name and the
owner's handle. No address, no path, no URL, no machineIdentifier. That is
`ui::stats`' redaction rule and it applies for its reason — a read-out is what a
user PHOTOGRAPHS for a bug report, and on a borrowed source the machine is not
even theirs to publish. The session name is the only source for it; the address
that sits right there in the client is deliberately NOT a fallback, and "this
server" is the answer when there is no name.

The owner is `None` at its one seam today and the reason line is therefore
ABSENT, not empty — the same shape `HubRow::source` took for the shelf heading.
Nothing maps a section to the source it came from yet; when that lands, one line
of `dead_strs` learns about it.

AND THE LAYER ABOVE. `ensure_sections` swallowed every failure into
`unwrap_or_default`, so a server that could not be reached at all was
indistinguishable from a table nobody had asked for yet: no section, no state,
`fetch_state()` answering `Loading` out of its `unwrap_or`, and the grid spinning
for the rest of the session — the same bug the base branch fixed one layer down.
`SECTIONS_FETCH` is that state and `fetch_table` is the one place "the server
answered" and "the request failed" are told apart.

`readout_of` is where the whole decision lives now, as one pure function over
both fetch states and the store — four answers that were four `else if`s in the
middle of `draw`, none of which a host could reach. Catching only the FAILED
table was not enough: a server that answers with nothing we browse (a music-only
account) is Ready with no sections and falls into the same two `unwrap_or`
defaults, which is the eternal spinner one case over. That one is Empty, because
it answered. Its read-out was then drawn at alpha 0 — the grid's `Xfade` asks
"did a section answer" to decide it has content, and with no section that is
false forever — so `ready` now asks `readout()`, which is the question with the
right shape.

`browse::failed_initial` is gone: it was exactly one arm of `readout_of`, and one
rule in two places is what this file keeps being wrong about.

`/tmp/plxnative-libfail` forces one read-out state (`dead` / `own` / `table` /
`empty`). This screen's failure is the one state in the app that cannot be
reached on purpose — it needs a server that refuses — and the honest way there is
three moving parts, each of which fails looking exactly like "the app is fine".
It forces the PROJECTION only; `browse` keeps whatever state it really has, and
it is compiled out of a `RELEASE=1` build with every other trigger (verified: the
string is absent from the release binary). Deliberately not the player's
`failtest`, which already owns that name and a different vocabulary.

Host 418 -> 430, `make check` green three times; `make` and `make RELEASE=1` both
link. NOT VERIFIED ON DEVICE — the television was held for the whole of this work
and the coordinator has taken the fleet's device pass; the PR body carries the
recipe.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…' into shared-servers-integration

# Conflicts:
#	rust-modules/src/metadata.rs
#	rust-modules/src/plex/mod.rs
#	rust-modules/src/pms.rs
#	rust-modules/src/route.rs
…is public

139 sites across 12 files carried a real third party's plex.tv handle, machine
name, library name, port and LAN address: test fixtures, doc comments, the
shared-servers note, and the harness README. They came in through the
foundation commits and then spread, because each unit copied the shape of the
fixture next to it.

None of it is ours to publish. github.com/GLinnik21/plx-native is PUBLIC — a
fact this codebase had recorded as "private" for about a month — and the person
who shared their server is not a party to this project.

Replaced throughout with stand-ins, several chosen at the SAME character length
because ui/home.rs asserts text widths against them:

  handle       bamx23     -> friend
  machine      bx23-ldn   -> nas-home
  library      LDN Films  -> Film Club
  port         (real)     -> 31234
  LAN address  172.20.x   -> 10.9.9.x   (still RFC1918, as the real one is)
  machine id   (real 40h) -> aaaabbbb... run

docs/shared-servers.md already carried a paragraph promising exactly this
redaction while violating it, so that paragraph now states the convention as a
table, and says plainly that it was not followed. Stating a rule is not
applying it.

479 tests green; the length-matched stand-ins keep every width assertion.

Not fixed here, and both need a decision rather than an edit: the same values
are in the history of origin/shared-servers-base (commits 4b8a103, 9c7d676),
and one orphaned pre-force-push commit remains reachable by SHA on GitHub.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…no pill

Builds on #31's projection rather than replacing it: the strip stays "your own
libraries, plus a type only a friend has", and this makes that second half work.

`is_show: bool` has two values, so "does an owned library have this KIND" — the
test that decides whether a borrowed library gets its own pill — answers YES for
a friend's MUSIC library on the strength of your films. It would fold onto your
Movies pill, and everything in it would be unreachable from the strip. The other
half of the same gap was one layer up: `project_sections` dropped `artist` and
`photo` at discovery, so those types could never reach the projection to be
missing from it. A type dropped at the door cannot be the growth case.

So `SecKind` (Movie/Show/Music/Photo) replaces the boolean, discovery keeps every
type this product has a level for, and the projection compares by type. A music
library browses like any other section — the listing, its server-driven sorts and
the A-Z rail are all type-agnostic, and this account's own /hubs already put a
Recently Added Music shelf on Home, so the content was at the top level before it
had a tab. What is still missing is the level BELOW the grid: an artist opens the
movie detail page, which has nothing to play. That belongs to whoever builds the
music level; the strip's job is to say the type exists.

Two more things the multi-source table made true and one bug of my own:

- The label + width cache moves off the section table's generation onto the
  STRIP's (`browse::tabs_gen`), bumped only when the projected pill list actually
  changes. The table's generation now moves once per source as libraries land,
  and most of those fold onto pills already drawn — so the row was re-measuring
  every pill, several times a boot, on Home's hot path, for a strip that had not
  moved.
- `Nav::Library` carries a TAB and `pill = section + 1` is not true any more.
  Three comments still said "the first section" where they meant "the first tab"
  (the navosc scene, `select_pill`, the FPS manifest) and `nav.rs`'s TAB doc said
  the pill was a section index plus one. Wording only — #31 wired the arithmetic
  correctly; a doc that lies about an index space is how the next edit gets it
  wrong.
- `tabs()` compared the old and new projection with `addr_of!(TABS).read()`,
  which copies the Vec BITWISE and then drops the copy — freeing the buffer the
  static still points at. A double free that aborts the process, found by the new
  invariance test rather than by review. It borrows now.

The deliverable is host-provable, which matters because there is no host runtime:
`the_strip_is_the_same_row_at_one_friend_and_at_three` grows the roster to eleven
libraries across four sources and asserts the pill list never moves — the width
follows, since every pill's width is a pure function of its label.

Fixture names use the canonical stand-ins (`friend`, `nas-home`, `Film Club`),
which are also character-length-preserving for the width assertions in home.rs.
…sure

Two bugs of mine, both found by review with probe tests rather than by reading.

**A profile switch kept the previous account's pills.** Moving the label/width
cache onto the strip's own generation made `reset()` stop invalidating it:
`reset` CLEARED the projection's memo, so the next derivation compared `[]`
against `[]`, saw no change, and never bumped. `draw_tab_row` iterates the cache
rather than the live table, so after a re-login the strip went on drawing — and
hit-testing — libraries the new user cannot open, until some later landing
happened to change the row. The memo is now invalidated rather than emptied, so
the comparison that decides everything is made against what was actually on
screen. That is also the shape of the rule: a memo nobody clears early cannot
lie about what changed.

**The row grew by PEOPLE for an un-owned type.** `owned || !owned_kinds.contains`
admits one pill per borrowed LIBRARY of a missing type, so two friends who both
share Music are two identically-titled Music pills with nothing to tell them
apart — the exact property the projection exists to prevent, and the one the
invariance test claimed to hold, which it could not see because its fixtures were
all types we own. A missing type earns one pill now; the rest of that type are
reachable through the toolbar's Source chip, exactly as a borrowed library of a
type you DO own already is. Newly reachable because this branch admits
`artist`/`photo` at all.

Both are now regression tests, and the invariance test grew the half that would
have caught the second: three friends sharing music are one Music pill.

Also from the same review, smaller:

- The unwatched filter is a movie/show question and only those two types answer
  it, so the query no longer sends `unwatched=1` to a music or photo listing —
  and the Filter menu no longer offers the switch there, because a control that
  visibly changes nothing is a worse answer than one that is not offered. The
  menu's row indices go through `filter_rows` rather than literals, since the
  switch's absence shifts Genre up.
- `Nav::Library`'s own doc still said "section" where the arithmetic already
  meant "tab", and `docs/pms-api.md` still told the next reader to filter
  sections down to movie/show — the filter this branch removed on purpose.
…' into shared-servers-integration

# Conflicts:
#	docs/shared-servers.md
#	rust-modules/src/app.rs
#	rust-modules/src/browse.rs
#	rust-modules/src/plex/mod.rs
#	rust-modules/src/plex/servers.rs
Units 7 and 8 branched before the scrub landed, so merging them reintroduced
the handle, machine name and library name into dev.rs (the DevServer.handle
doc), plex/models.rs and ui/library.rs's Source-panel fixtures.

This is the shape to expect for every remaining merge: a scrub is a property of
a TREE, and any branch cut before it carries the old values forward. Re-scan
after each one — `grep -rlE` over rust-modules/src, docs and tests with the six
values, which is what caught these.

Stand-ins per the table at the top of docs/shared-servers.md. 497 tests green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
GLinnik21 and others added 12 commits August 14, 2026 11:00
Design-system change (owner: "I made section titles capitalized"),
components/panels/TableView.prompt.md: "Section headers are SET IN CAPS at
--size-caption, REGULAR weight in --text-tertiary, one size in both size classes
— the caps are what make it read as a label rather than a row, so it never ties
with the rows it heads."

Ours drew CAPTION when `compact` and HEADLINE otherwise, mixed case. The size
class was the bug the contract names: the Sources panel is a two-line picker, so
it is NOT compact, so its headers drew at HEADLINE — putting the machine names on
screen larger than the libraries they name, which is exactly a header tying with
its own rows.

`to_uppercase`, not `to_ascii_uppercase`: a header is a machine or library name
and can be any script — the share this was developed against is Cyrillic.

Uppercased at DRAW time, so the row model keeps the original string: the casing
is presentation, and `source_sections`' host tests still assert the real names.
`HDR_H` stays 58px in both classes, so no size change can reflow a panel.

NOT done, and it needs a text-renderer change rather than a token: the contract
also asks for `--track-caps` tracking, and `text::draw_text` has no letter-spacing
parameter at all. Caps at CAPTION without tracking still reads as a label; adding
tracking means a new advance path and a glyph-cache key that includes it.

526 tests green. Appearance is only observable on the television, which the owner
currently has — not visually verified.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…nt one

Found by a 13-agent comparison against the decompiled official webOS client.
This is a data-damage bug, not a cosmetic gap.

`ui/detail.rs` posted /:/scrobble and /:/unscrobble through `plex::client()` —
the CURRENT server — carrying the open item's ratingKey. It became live the
moment browsing a shared library stopped re-pointing `current` (the previous
commit, which was itself a fix): open a borrowed film from a merged Home shelf
and press Watched, and its ratingKey goes to OUR server. Both servers number
from 1, so that is not a harmless miss — the friend's film stays unwatched and
an unrelated film of ours is marked instead, and nothing surfaces it because
`refresh_view_state` then re-reads the page that did not change.

The official client resolves `findServer(item.metadataSourceUri)` and posts to
that server. `Detail` has carried its own `sid` since item identity became a
(server, key) pair; this now uses it. `client_for` also returns None where
`client()` panics, and a watch-state write is exactly the operation to skip and
log rather than send to the wrong machine.

Also: `excludeContinueWatching` is NOT a no-op. The call and its comment had
asserted that since they were written ("D-4: drop the no-op"). Measured against
this server, twice, independently of the agent that reported it:
/hubs?count=12 returns 10 hubs; &excludeContinueWatching=1 returns 8, dropping
home.continue and home.ondeck — precisely the two the dedicated
/hubs/continueWatching endpoint fetches properly. We were parsing and discarding
them once per source per fetch.

526 tests green x3; ARM links.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…lows its item

Five device-found defects from one session with the owner at the television.

1. A SHARE APPEARED ON HOME ONLY AFTER VISITING THE LIBRARY. `feeds_home` read
   "this server has no pinned library" as "the user turned it off". But section
   discovery for a source other than the current one runs on a worker off
   `browse::pump`, which only runs while the LIBRARY screen is up — so a booted
   app knows the roster and none of its shares' libraries. A server whose
   libraries have not been enumerated is UNDECIDED, not unpinned; you cannot have
   decided against a library nobody has discovered.

2. …and nothing re-merged when that changed. `pump` re-merged only on a build
   landing, so a late section discovery (or a pin toggled by hand, which bumped
   no generation at all) never reached Home. Both move `SECTIONS_GEN` now, and
   the merge re-runs on it — it is pure over builds each source already answered
   with.

3. ART RESOLVED AGAINST THE CURRENT SERVER, not the item's. A thumb path embeds a
   server-local ratingKey, so a friend's library drew grey skeletons for most
   tiles and OUR films for the keys that collide — both servers number from 1, so
   collisions are the normal case. Only invisible while browsing a share also
   re-pointed `current`; removing that (correctly) exposed it. Threaded through
   every art path: `Art::Poster` via the row's `sid`, `Art::Thumb`/`Art::Person`
   which carried no server at all, both heroes, the clearLogo (`HeroLogo` gained
   a `sid`; the logo API already took one and both call sites passed
   `current_server()`), Related, cast headshots, episode stills, chapters, Up
   Next and the info panel.

4. TWO THINGS WORE FOCUS AT ONCE in the Sources panel: the level pills took the
   accent capsule while the table went on painting its selected row, which a
   table always did. `TableView::list_focused` is the "nothing selected" mode it
   lacked — the row is remembered, simply not drawn as focused while the pills
   have it. (First attempt made the pills unfocusable instead, which the owner
   corrected: they want the rows deselected, not the tabs unreachable.)

5. Per-source landing now logs on SUCCESS, not only on failure. "hubs: source 1
   fetching" with nothing after it said only that a worker had started, which is
   what made 1 and 2 hard to see.

Device-verified: source 0 → 4 shelves, source 1 → 1 shelf and 2 in CW, commit
goes 40 items/5 shelves → 54/6. Home's Continue Watching interleaves both
servers exactly as the official client's does, borrowed artwork included.

526 tests green. NB one SIGABRT at process exit on a single `make check` run,
not reproduced in four since — flagged, not fixed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
All owner-found at the television, in one sitting.

**Unpinning a library did nothing.** `/hubs` is a whole-SERVER request that
answers with rows from every library on it, so the finest gate we had was "does
this server feed Home at all" — turning off one library of a two-library server
changed nothing on screen. Every row carries `librarySectionID`; that is the
join. `item_pinned` gates the merged deck AND every other shelf, before the row
budget is spent, so an emptied shelf contributes no heading rather than an empty
one. Unknown passes both ways (no id sent; library not yet enumerated), because
hiding what cannot be classified empties Home on the frame it boots.

Measured while sizing it: `/hubs?contentDirectoryID=N` does NOT scope (still
returns every library's hubs) — `/hubs/promoted?contentDirectoryID=…&
pinnedContentDirectoryID=…` is the endpoint that does, returning per-library
`movie.recentlyadded.<id>`. Switching to it is the better fix and is now a
sized, evidenced follow-up rather than a guess.

**"Also available" replaced the whole tab strip.** It still did the
`set_current` + `activate_server` re-point I had removed from browsing, so one
press wiped the section table and re-discovered only the newly-current server:
`altsources: source switched to slot 1` then `nsections=1`, and the top row
became Home | <the friend's one library>. Opening the other copy is a
NAVIGATION — `to_detail` carries the pair and every surface resolves its own
server from the item. The trail survives too, since its nodes carry a ServerId.

**Black row text.** Suppressing the selection pill when focus moves to the level
tabs left the row's ink flipped to near-black, which is only legible ON that
pill. Ink and pill now read from one flag.

**No tick in "Also available".** The tick was matched against
`plex::current_server()`, which stopped being the page's server the moment
browsing stopped re-pointing. It asks the page.

**No quality badge.** The badge was computed but always None: `/library/all?guid=`
returns no `Media[]` at all. Measured — `&type=1` is what makes it return
`4k 3840x2160`. The type comes off the guid (`plex://movie/…`); an unrecognised
kind sends none rather than guessing, since a wrong type answers size 0 and
would read as "that server does not have it".

**The level tabs did not animate** — the one tab row in the app that didn't.
They were standalone `segment` pills painting their own fills; they use the
shared `TabStrip` now, stepped in the update pass, so both capsules travel.

**Tab-to-list seam.** 16 + the list's own 20 = 36px, which is not a rung. The
band subtracts `TableView::TOP_PAD` so the seam is exactly `space::MD`, and
stays right if either constant moves.

528 tests green; ARM links.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Reuse / simplification / efficiency / altitude, run over the whole 50-commit
range. Applied the findings the four agents converged on; the deeper structural
ones are listed at the end, not done.

**Hot path — the poster key memo allocated on every HIT.** `HashMap::entry`
takes its key by value, so a flat `(u16, String, w, h, png)` key ran
`path.to_owned()` whether or not the entry existed, on top of the `cstr` that
had already built that string. `poster_key` runs once per visible tile per frame
plus the hero art and logo, so at ~25-40 tiles x 60fps that was ~1,500-2,400
needless heap allocations a second on the A53 — putting back a sixth of the
waste the memo was written to remove. Nesting the map (dims -> path -> entry)
keeps the hit path allocation-free and pays for the owned key only on a miss.

**`roster_key` allocated two Vecs per frame** to detect a change a u32 compare
five lines away already saw: the pinned set is a projection of the section
table, and `toggle_pin`/`append_sections`/`reset` all bump `SECTIONS_GEN`. Now
two atomic loads, no allocation, on a path `pump` runs every loop iteration —
including on a settled Home, which is the screen `ui::idle` was tuned down to
~1% of a core on.

**The hero's source measure ran with no source to draw.** Rust evaluates the
argument before the call can decide there is nothing to show, so a
single-server install — documented as paying nothing for this feature — paid a
`CString` + an uncached `TTF_SizeUTF8` over the whole meta line per hero frame,
twice per frame through a slide.

**Three roster projections became one.** `servers_with_known_sections` and
`pinned_servers` were the same index->slot fold as `library_pins_by_server` with
a different `browse` call feeding each, and each pulled its own `pub(crate)` out
of `browse` — so a change to how a source index maps to a registry slot had to
land in three places. Both are columns of the one table; `browse`'s
`discovered_sources` and `pinned_libraries` went with them.

**`alt_sources` asked "which copy am I on" two ways, and they disagreed.**
`live_rows` read the loaded Detail; `on_ok` passed `plex::current_server()`. So
the row that wore the tick and the row a press treated as "already here" could
be different rows — and after browsing stopped re-pointing `current`, the second
was a different MACHINE, not a synonym. One `here_sid()` via
`detail::mounted_sid`, which is the app-wide answer. Both hand-rolled
`(sid, rk)` comparisons in that file now go through `plex::same_item`, whose own
doc claimed every stored-item lookup already did.

**`shared_by` was written twice with two different empty-handle behaviours** and
interpolated a third time inline. One guarded formatter in `ui::fmt`, returning
`Option` — absence is what the design specifies for an owned item, and both call
sites were hand-rolling that guard.

**Dead code the branch's reversals left behind:** `route::forget_server_identity`
(retired by scoping MACHINE_ID behind MACHINE_SID), `browse::section_src`,
`browse::retry`, `pms::request_retry_source`, the unused `_sid` parameter on
`request_alt_sources`, and the bare `resolve_tex_wh`/`warm_tex` — zero callers
each, and the last two were the shorter names autocomplete offers for the case
where getting it wrong is a blank billboard.

I deleted `browse::loading_initial` too and put it back: rustc's dead-code
warning does not count test callers, and three tests assert exactly the
state/`total < 0` distinction it exists to make. Marked, so the next reader does
not repeat that.

**Skipped, deliberately.** The altitude review's central finding is that
`(ServerId, key)` is a calling convention rather than a type — 35 signatures
take the two as adjacent positional params, so a transposition compiles and
returns a confidently wrong row. An `ItemRef` newtype is the fix and it is
mechanical, but it is a few hundred lines across a dozen files: a refactor, not
a cleanup. Same for making the ambient accessors demand `task::MainThread` (the
`!Send` token this repo already ships) so a worker reading the current server is
a compile error rather than eight paragraphs of doc. Also skipped: fanning out
the serial guid resolve and roster probe (behaviour), wiring `Client::set_link`
(adds behaviour to a currently-dead path), and deleting `ServerFacts::owned` —
it has no readers, but the right move is to USE it, since two of its three
writers currently fabricate it from the empty-handle test its own doc forbids.

528 tests green x3; ARM links.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…vision

The television is a mutex. One set, one app instance, and two `tests/run.py`
jobs kill each other's app — so every UI change waits for every other one, and
an agent with no TV can verify nothing.

`make sim` builds the same app core with `--features hostsim`, linked against
desktop SDL2 and desktop GL 4.1 core. It draws the real interface against a
real PMS, boots to a screen with the same `plxnative-*` triggers, is driven by
the same remote-FIFO tokens, and screenshots itself. Several run side by side,
each pointed at its own instance root; unset `PLXNATIVE_RUNTIME_DIR` and
everything resolves to `/tmp` exactly as before. The `ui-sim` skill is the loop.

The whole TV seam is 29 symbols — 13 `sf_*`, 7 `acb_*`, 5 `vp_*`, wayland,
glib, the LG cursor call — and `player/ffi.rs` already had the right shape for
it, so the host arm is a `#[path]` swap of one private `sys` module. Nothing in
`engine`/`pump`/`threads` branches. The stand-in reports the seam's own
"no video path" failure rather than faking success, so Play lands on the app's
real failure read-out: a state a television can genuinely be in (issue #22).

Three bugs this found in code that ships to the device:

- `text.rs` uploaded glyph surfaces assuming `w * 4` stride while SDL is free
  to pad rows. `surface_ink_v` two lines above had always read `pitch`; only
  the upload assumed they were equal. Repack rather than `GL_UNPACK_ROW_LENGTH`,
  which does not exist in GLES2 and would have fixed the host while silently
  doing nothing on the TV.
- The runtime namespace was three `/tmp` literals (`dev`, `remote`, `log`), so
  N instances shared one trigger set, one FIFO and one log.
- `env` overrides were gated on `devtriggers`, on in every dev TV build. Since
  `src/main.c` opens the event and crash logs by absolute literal before any
  Rust runs, a TV launched with `PLXNATIVE_RUNTIME_DIR` set would have written
  the two halves of one log to two places. `ENV_STEERABLE` makes that
  impossible at compile time.

Guardrails, because the failure mode is an agent reporting a Mac number as a
device result: every simulator heartbeat carries `sim=1`, the event log's first
line says what wrote it, and `tests/run.py` now refuses to grade a log carrying
the tag. `--fps`, text rasterization, video and the video plane stay device-only.

Also fixed while here: `encode_key`/`decode_key` had no coupling and had already
shipped disagreeing (every FIFO token silently swallowed) — now one pure encoder
plus a round-trip test that passes in both layouts; each simulator gets its own
session file instead of sharing `pkg/auth.json`, which held live tokens in the
payload directory of a public repo; and `gl_is_es()` is one source of truth so
the shader preamble and the core-profile VAO cannot disagree.

Verified: `make check` 390 green, TV cross-build unchanged, sim rendered and
driven end to end (boot -> keys -> detail page -> screenshot).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
The pitch was `min(34, band / n)`, so how far apart the letters sat was a
function of how many a section happens to have. Nine Latin letters drew at 34px;
a mixed Cyrillic+Latin library's thirty collapsed to 27.5 against a CAPTION cap
height of ~17 — under half a letter of air, which reads as a column of type
rather than an index you can aim at.

The pitch is a constant 34 now and the rail scrolls past what fits (24 slots),
driven by rail focus while the rail has it and by the grid's current letter
otherwise, so scrolling the grid carries the rail with it. One letter of
clearance is kept at each end and the ends with more beyond them fade over one
letter, so it reads as scrollable rather than cut. A section that fits is
byte-identical to before: no scroll, same origin, same spacing.

Two latent bugs fell out of the same read:

- MAX_LETTERS was 34. `#` + Latin is 27 and Cyrillic adds 32 more, so a mixed
  library can want 59. At 35 the rail would have stopped mid-alphabet with every
  title past it unreachable by jump, and nothing on screen saying so. Now 64.
- The hit rects were a fixed 38px against a 27.5px pitch, so they overlapped and
  `rail_at`'s first match won — the top of every letter clicked the one above it.
  The target is the slot now, and a scrolled-away letter keeps an empty rect so a
  click can only land on a letter you can actually see.

`rail_geom` and `rail_scroll_target` are pure, so the window invariant is host-
tested at every letter from three starting scrolls.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
The design system's TableView cell is four places in screen-x order — leading
mark, label over its sub-line, trailing read-out, right-aligned badge. Ours drew
the badge inline from the label's DRAWN right edge, so the chip landed at a
different x on every row: a column of 1080p/4K, or the subtitle picker's
FORCED/SDH, read as ragged text instead of a column you compare down. On a
two-line row it was also centred on the title's cap band rather than the row box.

Right-aligned and row-centred now, which forces a second fix that was harmless
only while the chips sat on the title's line: the sub-line has to elide to the
same right edge as the label, not to the bare row width.

Two more places where the row diverged from the contract:

- The badge ring is `theme::OVERLAY_BORDER`. That token's own doc has said
  "outlined-badge / meta-badge border" for as long as it has had zero consumers,
  while every chip off a focus pill outlined at full TEXT_PRIMARY.
- The header accessory drops to MICRO; at CAPTION it tied with the header it
  qualifies.

"Also available" then fills all four places — ✓ | Movies / This account |
1 hr 57 min | 1080p. The runtime was a dotted second half of the sub-line, which
left the read-out empty and buried the one fact that lines up down the panel.

Also removes a stray `mut` on a test closure left behind by the last simplify
pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
… in parallel

Everything a Search unit needs to exist against, and nothing a unit should own.
The screen is reachable, wears the shared strip, and draws nothing yet.

The route. `Route::Search` is a PEER of Home and the Library, not a stacking
page: it is reached from the strip and BACK from it returns to Home, so it needs
no trail node — what it opens stacks, it does not. Two of its match sites are
exhaustive and would have failed the build; thirteen are `_` catch-alls that
would not, and three of those are why this landed as one commit rather than
per-unit: the draw dispatch ends `} else { home_draw() }`, so a missing arm
silently draws Home; the BACK arm ends `running = false`, so a missing arm quits
the app; and the heartbeat's route name ends `_ => "home"`, so every harness
scene grading `route=search` would have read Home and passed.

The pill goes LAST, and that is the whole reason it cost nothing. Prepending it
would have shifted every `pill - 1 -> section` conversion to `+2` at eight
sites; appending leaves `Home = 0, sections = 1..=n` exactly as written, and the
only new rule is `is_search_pill` — one test, in one place. It is the one pill
that is a mark instead of a word, inked through the same `TabPill::mixed_ink`
the labels use so it travels under the focus capsule with them instead of being
a separate colour story. Two host tests that encoded the pill count moved with
it; they were right, the row is genuinely one longer.

`Hub.directory`, because the DTO would have silently rendered three of the five
shelves as nothing. `/hubs/search` was probed live over six queries rather than
modelled from `plex-openapi.json`, whose own worked example disagrees with this
server: movies, shows and episodes arrive as `Metadata[]`, but **actors,
directors and collections arrive as `Directory[]`** — so Cast & Crew and
Collections both need it. Those entries are the SAME record the detail page's
cast row already parses, so `plex::Tag` grew the three fields only search sets
rather than gaining a near-identical twin; a search hit can now be handed
straight to the person page, and `Tag::is_person` matches one against a credit.

Two more measured facts are written down where they decide something: a
one-character query returns every hub empty (so `MIN_QUERY` is 2, and the first
keystroke of a search costs no round trip), and hub ORDER moves per query (so
the shelf order is fixed and ranking is honoured only inside a shelf —
reordering rows per keystroke would move the row under the user's focus while
they are still typing).

`/tmp/plxnative-search[=<query>]` seeds the field at boot. It is not a
convenience: `sim-shot` and the TV harness both run with no keyboard, so without
it every headless look at this screen is the empty state.

Verified: `make check` 535 green, sim boots and the pill draws (screenshot).
FFmpeg/ARM build unaffected — nothing here touches the seam.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
…oard

The Search screen's spine, behind the stubs `1dafd764` landed. Four zones, each
with its own cursor, so leaving the shelves for the field and coming back lands
where you were.

**The ▼ handoff is the point of the unit, and it is one expression.** ▼ off the
field lands only on something that is DRAWN: with no query and no remembered
terms there is nothing below it and focus stays visibly put, where dropping it
into an invisible list is a screen the remote has silently stopped addressing.
`below_of` answers it and `draw`'s region dispatch reads the SAME call, so the
zone focus moves to and the region on screen cannot become two different
answers — the failure that shape prevents is the one nobody sees until a user
presses DOWN twice on a blank page.

Scroll is one `Spring`, so `ui::idle` hears the motion for free and this screen
owes the frame gate no clock. The focused shelf's block top comes to
CONTENT_TOP, clamped to the content's own end, and it is zero whenever the
shelves do not hold focus — forced rather than chosen: nothing clips the flow,
so a non-zero shift with focus on the field would draw shelf 0 up through the
field and the tab strip. That is also why ▼ lands on shelf 0 rather than the
shelf last left; the COLUMN is remembered, which is the half of "lands where
you were" that costs nothing. A poster shelf's block comes out at 549, which is
`consts::ROW_PITCH` exactly — a search shelf and a home shelf stack at one
rhythm, and a test says so rather than the number being a coincidence.

Three things are pure so the host can grade them, `library::readout_of`'s
precedent: `below_of` (neither store behind it can be seeded on a host — the
recents list is the session file's and the shelves are a live server answer, so
a test of the live function could only ever reach one of its four cases),
`step_results`/`seat` (the ragged-grid arithmetic that actually goes wrong — a
column carried onto a shorter shelf), and `scroll_target_for`.

OK on a focused COLLECTION does NOTHING, deliberately. Its `Directory` row
carries no ratingKey, so it is not a detail page, and what it does carry
(`key` = /library/sections/1/all?collection=…) is a filtered listing `browse.rs`
has no query for. There is no `Node` this could build and no screen to mount it
on, so the tile is inert rather than routed somewhere that would be a lie about
what was pressed; the shelf still earns its place, because "this collection
exists" is what a lot of searches are after. The arm is named and documented so
the next person lands in it.

Pointer rects are RECORDED AT DRAW (`library::TOOL_RECTS`' idiom) through
`note_recent_rect` / `note_tile_rect`, and parked before each frame's regions
draw. They cannot be derived from here even in principle: a shelf's horizontal
offset is the scroll spring inside its own `card_row::CardRow`, which lives in
`results.rs`. The regions do not call them yet — those four files are being
written in parallel — so the seam is in place and inert, and the field and the
tab pills hit-test exactly today.

`key()` is the typing seam app.rs's key arm has no route for yet: the TV's
keyboard delivers printable characters as SDL_TEXTINPUT (`textinput::drain`,
drained every frame here) but its delete as an ordinary key.

14 host tests. `make check` 549/549 green, `make lint` clean, and the ARM
cross-build links.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
… four clamps

Findings from `/code-review` on the state machine, fixed.

**A click on blank ground activated whatever held focus.** `click` ran the hit
test for its side effect and then fell through to `on_ok()` unconditionally, so
a stray click on the page background with the cursor resting on the Clear
control wiped the user's recent searches — and with it on a result tile, opened
that page. `library::click`, whose shape this claimed to copy, answers
`Action::None` on a miss. There is now one `hit()` shared by hover and click,
returning `Option<Hit>`, and a miss moves nothing and activates nothing.

**The pointer left the field without going through `leave_field`.** Hovering a
tile assigned `ZONE` directly, so `EDITING` stayed true underneath another zone
— and a true `EDITING` freezes the shelf scroll unconditionally, so ▼ walked
focus off the bottom of the panel with nothing moving. That is precisely the
"screen the remote has silently stopped addressing" this state machine exists
to prevent, reached through the other input path. It also skipped the term's
only commit point.

**One typed character is not a search.** `below()` tested "the query is
non-empty" while the store's own threshold is `MIN_QUERY` (2), below which it
stays Idle and sends nothing. So the first keystroke of every search dropped
the recents list and put a never-searched statement in its place, and a
backspace brought it back — a flicker at the start of every search, for a
request that was never made. `has_query()` is now the store's own test, and the
`results::draw` gate reads the same call.

**`focus_is_card` is asked of `open_focused` itself** rather than of "is there
an item here". A COLLECTION is an item and opens nothing, so the cheaper test
armed a tvOS press that dipped the card, bounced it and committed nothing —
the affordance `library::focus_is_card` exists to refuse.

Three more clamps. `clamp_focus`'s fall-back zeroed ROW/COL while `move_focus`'s
identical fall-back preserves them; since `set_query` wipes the store
synchronously, that threw the remembered column away on every keystroke — the
common case, not the rare one. The results hit test now applies the `w > 0.5`
guard its own recents branch already had (a culled tile records a zero-size
rect, and `Rect::contains` is inclusive). And `note_recent_rect` DROPS an
out-of-range index instead of clamping it onto the Clear control's slot — the
store may hold more terms than the screen draws, and aliasing one onto Clear
would make hovering a term park the cursor on the control that wipes the list.

The module doc's layout arithmetic said 699 for a sum that is 683. A stated
equality nobody can reproduce is worse than the slack, because the next person
tuning `CONTENT_TOP` balances against a figure that was never true; the test
asserts the real numbers now, and `block_h` records what `LABEL_BLOCK` owes
`TileLabel::height` (fine at one title line, 8px short at two — a cross-file
decision for whoever raises `title_lines`).

Four new tests, 18 in the module. The scroll spring now owes `ui::idle` BOTH
halves, as `ui/CLAUDE.md` requires — it reports while running and goes quiet at
rest. That test RESTORES the gate's clock before returning, which is not
politeness: `LAST_PRESENT` is a process-global that `testlock::serial()` orders
but does not clean, and `pms.rs` asserts `should_present(0)` at an absolute now
of 0, so a timeline parked in the ten-thousands trips the 2 s keepalive and
fails an assertion in a module this one never touches.

553/553 on `--test-threads=1`, `make lint` clean, ARM cross-build links.

NB the suite has a PRE-EXISTING parallel race, present at 1dafd76 with this
file reverted to its stub: ~1 run in 16 aborts with SIGABRT inside
`str::validations` or `fmt`, i.e. a `&str` read from a global while another
thread writes it. Not introduced here and not this module's to fix.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01TxZ585ehWMnuScciTQ9WgV
Copilot AI lite review requested due to automatic review settings August 14, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR significantly expands the UI/search and multi-server infrastructure, and introduces a desktop “hostsim” simulator path (runtime-dir isolation, screenshot capture, and build/link plumbing) to enable parallel UI iteration off-device. It also continues the shared-servers work by scoping identities (ServerId) through UI navigation/history, poster/logo fetches, and timeline/playqueue behavior.

Changes:

  • Adds a desktop simulator build/configuration (Makefile targets, Cargo/bin/build.rs, runtime-dir isolation, screenshots, GL shader/core-profile compatibility).
  • Extends shared-server scoping across UI navigation/history and playback reporting (ServerId propagation, item-menu/action scoping, playqueue/timeline fallbacks).
  • Lays down Search screen/store scaffolding (new search store + UI region stubs) and improves test harness behavior (reject sim perf logs, shared-server “handle” plumbed).

Reviewed changes

Copilot reviewed 72 out of 76 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/run.py Adds handle to shared-server injection payload; rejects simulator logs for FPS gating.
tests/README.md Updates shared-server examples (but currently has payload/log snippet drift—see comments).
tests/manifest.json Clarifies navosc scene comment for tab-vs-section semantics.
rust-modules/src/ui/up_next.rs Routes card art resolution through server-scoped draw_card API.
rust-modules/src/ui/trail.rs Makes navigation trail nodes server-scoped and adds same_page identity logic.
rust-modules/src/ui/search/results.rs Introduces stub module for typed result shelves + tile sizing.
rust-modules/src/ui/search/recents.rs Introduces stub module for recent searches store/draw surface.
rust-modules/src/ui/search/field.rs Introduces stub module for query capsule/caret/scope line.
rust-modules/src/ui/search/empty.rs Introduces stub module for empty/no-results screen states.
rust-modules/src/ui/profiles.rs Scopes profile avatar art fetches by current server id.
rust-modules/src/ui/person.rs Threads ServerId through person open/reopen and art fetch.
rust-modules/src/ui/nav.rs Documents pill/tab indexing semantics after tab projection change.
rust-modules/src/ui/mod.rs Exposes new UI modules (alt_sources, search) (also highlights PR scope mismatch vs description).
rust-modules/src/ui/item_menu.rs Captures item ServerId at menu open time to scope actions correctly.
rust-modules/src/ui/info_panel.rs Resolves info-panel artwork on the playing item’s server.
rust-modules/src/ui/icons.rs Adds Icon::Search and wires in assets/icons/search.svg.
rust-modules/src/ui/hero_logo.rs Makes hero logo resolution server-scoped.
rust-modules/src/ui/fmt.rs Adds shared_by(handle) formatter for consistent attribution text.
rust-modules/src/ui/consts.rs Adds named webOS BACK wcode constant and uses it in is_back.
rust-modules/src/ui/chapters_panel.rs Scopes chapter thumbnail resolution by server id.
rust-modules/src/ui/anim.rs Moves anim log path into runtime dir (supports simulator isolation).
rust-modules/src/textinput.rs Adds stub module for VKB/textinput seam.
rust-modules/src/text.rs Fixes SDL surface upload to honor pitch (repack when padded).
rust-modules/src/system.rs Gates TV-only wayland/glib symbols and behavior away from hostsim.
rust-modules/src/shot.rs Adds hostsim screenshot capture (glReadPixels → PNG), with on-demand token support.
rust-modules/src/search.rs Adds stub search data layer types/state machine (query/shelves/state).
rust-modules/src/remote.rs Moves remote FIFO path under runtime-dir to support multiple simulators.
rust-modules/src/plex/transcoder.rs Adds relay-aware link_policy to restrict direct-play/remux on relays.
rust-modules/src/plex/timeline.rs Scopes playqueue rows/fallback matching by server id.
rust-modules/src/plex/probe.rs Improves candidate ranking with “dialable numeric host” tie-break.
rust-modules/src/plex/params.rs Documents why bitrate caps are not a TranscodeSpec parameter in this design.
rust-modules/src/plex/models.rs Adds friendlyName, hub Directory[] support, and portable guid documentation/fields.
rust-modules/src/plex/mod.rs Expands re-exports for multi-server registry + link policy helpers.
rust-modules/src/plex/library.rs Adds friendly_name() and find_by_guid() helpers and guid→type mapping.
rust-modules/src/plex/hubs.rs Adds excludeContinueWatching=1 and documents measured behavior.
rust-modules/src/plex/client.rs Adds per-client link tier storage and fetch_built() for token-bearing paths.
rust-modules/src/plex/CLAUDE.md Updates data-layer docs for server registry and new policies.
rust-modules/src/plex/account.rs Updates shared-server examples/fixtures to new naming.
rust-modules/src/player/threads.rs Captures ServerId for timeline reporter to avoid cross-server scrobble writes.
rust-modules/src/player/ffi.rs Adds hostsim FFI switch to a host stub implementation.
rust-modules/src/player/ffi_host.rs Implements hostsim Starfish/ACB seam as “fail honestly” stubs.
rust-modules/src/player/engine.rs Passes sid into timeline reporter spawn.
rust-modules/src/person.rs Stores ServerId in Person and scopes worker fetches via client_for(sid).
rust-modules/src/paths.rs Introduces runtime-dir abstraction and hostsim env overrides (with safety constraints).
rust-modules/src/lib.rs Routes event logging through runtime-dir; exports sim helpers and plex_run for hostsim bin.
rust-modules/src/gfx.rs Adds GLSL preamble + VAO binding for desktop core-profile compatibility.
rust-modules/src/dev.rs Moves trigger paths under runtime-dir; adds handle to DevServer and logs.
rust-modules/src/bin/sim.rs Adds plxnative-sim desktop simulator binary entry point.
rust-modules/Cargo.toml Adds rlib crate type and hostsim binary + feature.
rust-modules/build.rs Adds hostsim-only link configuration (SDL2/GL + compiling svg.c).
Makefile Adds simulator targets and updates linkage commentary for bundled FFmpeg vs dlopen libs.
docs/pms-api.md Updates section-key guidance reflecting multi-kind tabs/strip projection.
CLAUDE.md Updates repo-level docs to include plex/CLAUDE + simulator tier.
assets/icons/search.svg Adds search icon asset.
.gitignore Ignores simulator target dir and pkg/auth.json to avoid credential leaks.
.claude/skills/ui-sim/SKILL.md Adds a skill doc describing simulator workflow and limitations.
.claude/skills/tv-session/SKILL.md Cross-references simulator skill as a first choice when TV isn’t required.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/README.md
Comment on lines 94 to +97
- With `shared_server` configured, the runner resolves it **before touching the TV** and writes
`/tmp/plxnative-servers` for those cases only — a JSON array of
`{name, machine_id, host, port, token}` — beside `plxnative-token`. Value never on stdout; the
printed line is `plxnative-servers: <bx23-ldn @ 10.0.0.9:32400, token redacted>`.
printed line is `plxnative-servers: <nas-home @ 10.0.0.9:32400, token redacted>`.
Comment thread tests/README.md
Comment on lines 108 to 111
```
servers: #0 name="bx23-ldn" 10.0.0.9:32400 mid=a348a464.. creds=ok
servers: #0 name="nas-home" 10.0.0.9:32400 mid=a348a464.. creds=ok
servers: 1 extra server(s) injected, 1 usable
```
Comment on lines 12 to 33
@@ -28,6 +29,7 @@ pub mod more_menu; // the player's `…` overflow popover (holds the Stats for n
pub mod login; // sign-in screen (QR / short code) for the plex.tv account flow
pub mod nav; // ROUTE-level page cross-fade + the continuous-chrome rule (the tab bar rides across)
pub mod person; // the person / actor page (Apple-TV shape) — opened from a detail page's cast row
pub mod search; // the Search screen: field + recents + typed result shelves (the last pill in the top strip)
pub mod profiles; // "who's watching" Plex Home picker + PIN keypad
@GLinnik21

Copy link
Copy Markdown
Collaborator Author

Superseded by #47, which is the integration branch this unit was built for and which now carries the whole feature.

Closed rather than merged because #47 already contains this work — verified before closing, not assumed: every commit on this branch is either an ancestor of #47 or reached it through the shared servers, squashed commit, and the one genuine follow-up that was NOT in it (the OK NAVIGATES test on #27) has been cherry-picked across.

The review record lives here; the code ships there.

@GLinnik21 GLinnik21 closed this Aug 15, 2026
@GLinnik21
GLinnik21 deleted the worktree-agent-ab178357dcb59ce34 branch August 22, 2026 23:25
GLinnik21 added a commit that referenced this pull request Aug 23, 2026
…, and a proxy that can be slow

Three checklist items were unanswerable for three different reasons, and none of
them was a defect in the app.

**#50/#51 — resolution x codec.** The item is graded as a MATRIX and this repo
could only answer it as "pieces are covered": every pipeline fixture was 1080p
except one 4K HEVC, so SD and HD had never been played AT ALL, and 4K H.264
existed in neither pack — which is a fact about the maintainer's library (every
4K item there is HEVC or AV1) rather than about the player. Six new generated
clips complete the grid: SD 720x480 / HD 1280x720 / FHD 1920x1080 / UHD 3840x2160
x {h264, hevc}, with ONE audio codec per column so a row-to-row difference is the
raster and nothing else. Each of the eight cells now grades `expect.video_size`,
an EXACT WxH out of the `ff:` line, because `min_video_width` cannot tell 720x480
from 720x576 and a matrix answered with "at least 1900 wide" is the answer the
item is asking us to stop giving.

Four decisions in the matrix look arbitrary and are argued where they live
(`PIPE_SHAPES`' block comment): square pixels at 720x480 (an anamorphic fixture
would grade PAR handling, an axis with no assertion behind it anywhere here);
CRF held constant is constant QUALITY, not bitrate, so 4K H.264 is crf 26 and not
its 1080p sibling's 20 — the same CRF measures ~30 Mbit/s up there, a
quarter-gigabyte clip in service of no assertion; SDR 8-bit throughout, which
makes the UHD/HEVC cell the odd one out because it is the existing HDR10 fixture,
already device-verified; and E-AC-3 down the HEVC column, which is also the
better false-PASS defence, since `engine`'s `_ =>` arm can only ever produce
"AC3".

**#46 — replay after completion.** Its FIRST half now runs: `pipe_finish_eos`
plays a deliberately short 20 s clip to its end and asserts `EOS reached ...
-> ended` followed by `stop_bufferfeed: torn down`, in that order. Ordered
because every stop tears the engine down — the harness's own close included — and
searched forward from the EOS rather than compared against the first teardown in
the log, because `teardown` writes the same line for a `for_reload` stop, which
would fail the case for its whole cap with the evidence reading "the player froze
on the last frame". This is the only case in either tier that is SUPPOSED to run
out, so it gets its own fixture that nothing else may name (everything else is
sized so it cannot hit EOF mid-window, trap 9's second half), and
`_resolve_fixtures` grew the opposite duration bound: it SKIPS when the clip is
longer than 0.6x the cap, so a `--secs`-regenerated pack skips rather than failing
as a frozen player.

The SECOND half — starting the same content again — is NOT closed, and it is an
app gap rather than a test gap. `plxnative-playurl` is read behind `app.rs`'s
one-shot `auto_tried` latch, so a boot gets exactly one playback; on EOS
`finish_playback` -> `exit_player` leaves the player, and with no Plex session
there is no detail page, no Play control and no key path back in. The manifest
case carries a `_replay_note` naming the small app-side change that would close
it (`engine::start_bufferfeed` already re-reads `dev::playurl()` whenever
`route::url()` is empty), and `docs/lg-self-checklist.md` still marks the replay
half untested.

**#43 CASE1 and #14 — `tools/netcond.py` gains `rate:<kbps>`.** The proxy could
make the server dead in four ways and slow in none, so CASE1's own legs (512 Kbps
-> 1 Mbps -> 7 Mbps -> 17.5 Mbps) could not be PRODUCED and #14's degrading link
was anecdote. One token bucket for the whole proxy, because `rate:` names a link
and a link is shared; decimal kilobits, because that is the unit the item states
its legs in; empty at the start, because a full bucket hands the first
quarter-second a free burst and that is most of a short transfer; live under an
open connection, so one scripted run covers all four legs instead of four
launches. Measured through the real proxy: 512 -> 496 kbps, 2000 -> 2000,
17500 -> 17518.

Two pre-existing bugs surfaced in the code it touches, both fixed:

* **The mode SCOPE was honoured only at accept.** `serve_conn` consulted the
  scope-aware `applies()` and then handed `relay` a bare `Mode.split`, which
  discards it — so `stall@/:/timeline` really froze every open connection
  including the media stream, i.e. the exact opposite of what the scope exists
  for. Both docs claimed the working behaviour. `relay` now takes the
  connection's own first bytes.
* **The read poll's socket timeout was also the other direction's WRITE
  timeout.** Both relay threads share one pair of sockets, so `src.settimeout(0.5)`
  set the timeout on the other thread's `dst`; `sendall` on a timed-out socket
  raises having written an unspecified number of bytes, the `except OSError`
  swallowed it, and the stream truncated silently — reachable in exactly the
  situation the proxy exists to measure. The poll moved to `select` and both
  sockets are put back to blocking before relaying.

`--selftest` proves the shaper against a loopback transfer with no television in
the room, in its own temp control file so it cannot release the mode under a live
experiment.

**What this costs and what it does not prove.** The pipeline pack goes from ~0.4
to ~0.7 GB (the 4K H.264 clip is 93 MB of that) and from 8 clips to 15; resolution
is a property of the media, so a matrix cell cannot be a second case on an
existing file. Everything here is generated, so what none of it reaches is a PMS
DECISION on any of these shapes — `library_gaps` says so per entry. While
correcting those entries: `8-bit-hevc` was ALREADY covered by
`pipe_hevc_aac_mp4` (no `hdr` key, so Main / yuv420p) and the gap list had not
caught up; only `4k-h264` is newly closed.

Host-verified only — this lane has no television. `make check` is green (976 Rust
+ 47 harness tests, the harness suite now including the netcond shaper against
real loopback sockets), every fixture verifies under `make_fixtures.py`'s own
ffprobe checks, and `serve_fixtures.py` answers 206/416 with a byte-exact tail
for each new clip. The device run is the integrator's; the recipe is in the PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
GLinnik21 added a commit that referenced this pull request Aug 23, 2026
The replay half of LG App Self Checklist #46 was the one thing my last PR could
not reach from `tests/`, and the reason was six lines in `app.rs`: the synthetic
tier's only entry into the player is `plxnative-playurl`, read behind a one-shot
`auto_tried` latch, so a boot got exactly one playback. On EOS `finish_playback`
→ `exit_player` leaves the player, and with no Plex session there is no detail
page, no Play control and no key path back in.

Everything else was already in place, which is why the change is small:
`teardown` clears the URL and the `ended` flag on a real stop, and
`engine::start_bufferfeed` re-reads `dev::playurl()` whenever `route::url()` is
empty. So a replay is a second trip through the entry the boot already used.

**A COUNTER re-arming the latch, not a lifted latch.** `auto_tried` also guards
the `autoplay`+`playidx` arm, which does a `request_play_movie` +
`load_detail_now` — an unconditionally re-armable latch would re-fetch a catalog
item on every player exit and loop a REAL playback forever.
`/tmp/plxnative-replay[=N]` is bounded, opt-in, read once at boot (so no file
appearing mid-run can turn it into a loop), gated on `playurl` being armed, and
declines when `finish_playback` handed off to Up Next instead — an auto-advance
chain returns to the player, and that is exactly what the route check tells
apart. An absent file is 0, so every existing boot is byte-identical.
`dev::flag`/`dev::read` are `false`/`None` at COMPILE time without `devtriggers`,
so a release build has no replay arm at all; both feature sets type-check.

`replay_budget` is split out and host-tested for `note_global_press`'s reason one
step removed: the call site is inside the SDL event loop where no host test can
reach, and this half touches no SDL. It matters more than it looks, because every
value it can return is plausible and a misparse is invisible on the panel — 0
reads as "the replay arm is missing from this binary" and 2 reads as a loop.

**The two hazards in the lanes that landed in this file since I last read it are
both safe by construction, and I checked rather than assumed.** b6's
unconsumed-press invariant lives in `note_global_press`, and this change is
nowhere near key dispatch — it adds no press path and no global side effect. b7's
recorder cannot write a bogus record for a synthetic playback either:
`coldstart_place` answers `Route::Player` from `metadata::playing()`, which is
installed ONLY by `route::apply_plan` (the PMS decision path), so a URL-fed
session has no playing item and records nothing — before this change or after it.
A replay also re-enters on the next frame, so the 800 ms post-exit hub refresh
never fires between the two viewings.

**The case.** `pipe_replay_after_eos` plays the same 20 s clip, lets it end, and
starts it again. `expect.replays` is one statement, not two: the harness writes it
into the trigger AND `a_replayed` counts it, so the number the app is told cannot
drift from the number that is graded. Three signals, each worthless alone — the
`replay:` line exactly N times (counted, because more often than asked is a loop
and a loop satisfies everything else); at least N+1 `load:` lines, since
`start_bufferfeed` writes one per SESSION and `teardown` cleared the URL, so a
second line is what says the declaration was really re-read; and a media position
that FALLS and then climbs, which is the only thing separating a restart from a
session that carried on. `server_opens_min: 2` is the wire-side half no log line
can give: the second viewing has to fetch the clip again.

`_resolve_fixtures`' EOS bound becomes per VIEWING (`dur * (1 + replays)`), so a
`--secs`-regenerated pack skips this case instead of failing it as a missing
feature. `pipe_finish_eos` stays separate and grades the finish alone: "never
ends" and "ends and cannot be restarted" are different failures, and one case
would report either as the other.

**Two prose corrections this branch's netcond findings force, both about the same
sentence.** The root `CLAUDE.md` describes scoping — "`stall@/:/timeline` freezes
the progress reporter while video keeps streaming, which is what makes a clean
experiment possible" — as a working feature. It was FALSE for as long as it
existed, because `relay` took a scope-less `Mode.split`; it became true on
2026-08-23. Said so at the sentence rather than three sentences later.

And the **6974 ms** measurement cited beside it was taken under that broken
instrument, so the proxy was stalling every connection and not only the
reporter's. **The number and the conclusion both survive, and the mechanism is
worth recording rather than re-deriving:** it was logged as `THREADJOIN timeline
6974ms` — `task::join` emits one NAMED line per join, so the attribution came
from the instrument and not from inferring a total — and `timeline` is the only
join that COULD have parked whatever else was stalled, because `engine::teardown`
step 1 deliberately wakes the other two before joining them (`http_shutdown` on
the demux socket, `aq_abort` on both AU lanes) while the reporter's POST had no
such wake. Before and after were taken the same way, so the 14x is
apples-to-apples. What CANNOT be claimed from that session is that video kept
streaming while the reporter was frozen — a property of the tool today, not of
that run. Recorded in `CLAUDE.md`, `threads.rs` and `engine.rs`, all three of
which carried the number.

Host-verified: `make check` green — 1069 Rust tests (1066 on main + 3 new) and 51
harness tests — and `--no-default-features` type-checks. No television: the device
run is the integrator's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
GLinnik21 added a commit that referenced this pull request Aug 23, 2026
…and says so

`stream_case`'s soundness note names exactly two ABSENCE checks that early exit
cannot see, and asks that a third be REASONED ABOUT rather than added. `a_replayed`
is a third of the same shape: it grades an EQUALITY (exactly N `replay:` lines,
because more than N is a loop), and an equality can pass at N and fail at N+1.

What it cannot see, stated rather than left to be discovered: an app replaying
forever fires its next `replay:` line only after another full viewing — ~20 s on
the short clip — while the case satisfies everything else at ~28 s, so an early
exit two seconds later stops before the evidence arrives.

Not closed by making this one case burn its whole 100 s cap. That is ~1.5 min on
every suite run to guard three lines whose bound is ALREADY gradeable by `make
check`: `replay_left` is decremented before each re-arm, and `replay_budget`'s
parsing has host tests. `--no-early` is how to go looking for a loop deliberately,
and the trade is worth re-taking only if that app-side bound moves.

Also: `docs/ux-scenario.md`'s #46 row pointed at the checklist "where it is listed
as untested", which stopped being true one commit ago. It now points at the case.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
GLinnik21 added a commit that referenced this pull request Aug 23, 2026
…, and a proxy that can be slow (#59)

* tests: the resolution matrix LG asks for, a clip that is meant to end, and a proxy that can be slow

Three checklist items were unanswerable for three different reasons, and none of
them was a defect in the app.

**#50/#51 — resolution x codec.** The item is graded as a MATRIX and this repo
could only answer it as "pieces are covered": every pipeline fixture was 1080p
except one 4K HEVC, so SD and HD had never been played AT ALL, and 4K H.264
existed in neither pack — which is a fact about the maintainer's library (every
4K item there is HEVC or AV1) rather than about the player. Six new generated
clips complete the grid: SD 720x480 / HD 1280x720 / FHD 1920x1080 / UHD 3840x2160
x {h264, hevc}, with ONE audio codec per column so a row-to-row difference is the
raster and nothing else. Each of the eight cells now grades `expect.video_size`,
an EXACT WxH out of the `ff:` line, because `min_video_width` cannot tell 720x480
from 720x576 and a matrix answered with "at least 1900 wide" is the answer the
item is asking us to stop giving.

Four decisions in the matrix look arbitrary and are argued where they live
(`PIPE_SHAPES`' block comment): square pixels at 720x480 (an anamorphic fixture
would grade PAR handling, an axis with no assertion behind it anywhere here);
CRF held constant is constant QUALITY, not bitrate, so 4K H.264 is crf 26 and not
its 1080p sibling's 20 — the same CRF measures ~30 Mbit/s up there, a
quarter-gigabyte clip in service of no assertion; SDR 8-bit throughout, which
makes the UHD/HEVC cell the odd one out because it is the existing HDR10 fixture,
already device-verified; and E-AC-3 down the HEVC column, which is also the
better false-PASS defence, since `engine`'s `_ =>` arm can only ever produce
"AC3".

**#46 — replay after completion.** Its FIRST half now runs: `pipe_finish_eos`
plays a deliberately short 20 s clip to its end and asserts `EOS reached ...
-> ended` followed by `stop_bufferfeed: torn down`, in that order. Ordered
because every stop tears the engine down — the harness's own close included — and
searched forward from the EOS rather than compared against the first teardown in
the log, because `teardown` writes the same line for a `for_reload` stop, which
would fail the case for its whole cap with the evidence reading "the player froze
on the last frame". This is the only case in either tier that is SUPPOSED to run
out, so it gets its own fixture that nothing else may name (everything else is
sized so it cannot hit EOF mid-window, trap 9's second half), and
`_resolve_fixtures` grew the opposite duration bound: it SKIPS when the clip is
longer than 0.6x the cap, so a `--secs`-regenerated pack skips rather than failing
as a frozen player.

The SECOND half — starting the same content again — is NOT closed, and it is an
app gap rather than a test gap. `plxnative-playurl` is read behind `app.rs`'s
one-shot `auto_tried` latch, so a boot gets exactly one playback; on EOS
`finish_playback` -> `exit_player` leaves the player, and with no Plex session
there is no detail page, no Play control and no key path back in. The manifest
case carries a `_replay_note` naming the small app-side change that would close
it (`engine::start_bufferfeed` already re-reads `dev::playurl()` whenever
`route::url()` is empty), and `docs/lg-self-checklist.md` still marks the replay
half untested.

**#43 CASE1 and #14 — `tools/netcond.py` gains `rate:<kbps>`.** The proxy could
make the server dead in four ways and slow in none, so CASE1's own legs (512 Kbps
-> 1 Mbps -> 7 Mbps -> 17.5 Mbps) could not be PRODUCED and #14's degrading link
was anecdote. One token bucket for the whole proxy, because `rate:` names a link
and a link is shared; decimal kilobits, because that is the unit the item states
its legs in; empty at the start, because a full bucket hands the first
quarter-second a free burst and that is most of a short transfer; live under an
open connection, so one scripted run covers all four legs instead of four
launches. Measured through the real proxy: 512 -> 496 kbps, 2000 -> 2000,
17500 -> 17518.

Two pre-existing bugs surfaced in the code it touches, both fixed:

* **The mode SCOPE was honoured only at accept.** `serve_conn` consulted the
  scope-aware `applies()` and then handed `relay` a bare `Mode.split`, which
  discards it — so `stall@/:/timeline` really froze every open connection
  including the media stream, i.e. the exact opposite of what the scope exists
  for. Both docs claimed the working behaviour. `relay` now takes the
  connection's own first bytes.
* **The read poll's socket timeout was also the other direction's WRITE
  timeout.** Both relay threads share one pair of sockets, so `src.settimeout(0.5)`
  set the timeout on the other thread's `dst`; `sendall` on a timed-out socket
  raises having written an unspecified number of bytes, the `except OSError`
  swallowed it, and the stream truncated silently — reachable in exactly the
  situation the proxy exists to measure. The poll moved to `select` and both
  sockets are put back to blocking before relaying.

`--selftest` proves the shaper against a loopback transfer with no television in
the room, in its own temp control file so it cannot release the mode under a live
experiment.

**What this costs and what it does not prove.** The pipeline pack goes from ~0.4
to ~0.7 GB (the 4K H.264 clip is 93 MB of that) and from 8 clips to 15; resolution
is a property of the media, so a matrix cell cannot be a second case on an
existing file. Everything here is generated, so what none of it reaches is a PMS
DECISION on any of these shapes — `library_gaps` says so per entry. While
correcting those entries: `8-bit-hevc` was ALREADY covered by
`pipe_hevc_aac_mp4` (no `hdr` key, so Main / yuv420p) and the gap list had not
caught up; only `4k-h264` is newly closed.

Host-verified only — this lane has no television. `make check` is green (976 Rust
+ 47 harness tests, the harness suite now including the netcond shaper against
real loopback sockets), every fixture verifies under `make_fixtures.py`'s own
ffprobe checks, and `serve_fixtures.py` answers 206/416 with a byte-exact tail
for each new clip. The device run is the integrator's; the recipe is in the PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the which-tier skill still said the synthetic tier was twelve cases

It is 19 as of this branch, and the number in that sentence was going to rot
again — the same way the host test count in CLAUDE.md rotted three times — so it
now points at `./tests/run.py --list` instead of restating a census.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: five sentences this branch made false, one of them mine twice over

`doc-claim-auditor` over the branch. All five are contradictions, not omissions.

**The one that matters, because it is the skill whose whole subject is this
error.** `which-tier` opens by warning against "reading a bare `./tests/run.py`
as the suite it used to be" — and its pasteable `sh` block still said **12
synthetic cases**. Worse, 8ede10e fixed the identical number in that file's
PROSE two paragraphs above and left the two copies in the code block, i.e. the
half a reader copies. The file contradicted itself inside one commit. Both counts
are gone; the block now points at `--list`, which it already named two lines down,
and says why a second copy of the number does not survive here.

**`tests/fixtures/README.md` listed two gaps as unbuilt that this script builds.**
Its `library_gaps` summary still named `8-bit HEVC` and `4K H.264` — while
`manifest.json`, rewritten in the same commit, says 4K H.264 is closed by
`pipe_res_h264_uhd` and 8-bit HEVC has been covered since `pipe_hevc_aac_mp4`
landed (no `hdr` key, so `-profile:v main` / yuv420p). A reader of that page goes
off to author media that already exists. Both cut, with what a generated clip
still cannot close said plainly: a PMS DECISION on such an item.

Same sentence, pre-existing and one word: it named **`plxnative-url`** as the
trigger these are fed through. `tests/README.md` says the opposite and is right —
`plxnative-playurl` is the one carrying the DECLARATION, and several remaining
gaps (HLG, HDR10+) are *about* what the payload declares.

**Trap 9 was falsified by this branch's own fixture, 260 lines below it.** "Nothing
is ever shorter than 60 s" is now false: `pipe_h264_ac3_short` is 20 s because
ENDING is what it grades, and `_resolve_fixtures` enforces the opposite bound for
it. The new shape's comment cited "trap 9's second half" as the rule it breaks;
trap 9 itself was never told, and neither was `PIPE_SHAPES`' header, which still
said the only length constraint left was "do not hit EOF". Both now carry both
bounds, and say that adding a second short clip means picking a side.

**`_probe_fixture`'s "three of the twelve" was never right.** It is four fixtures
carrying two cases each, and it was four of twelve on `main` too — a count that
was wrong before the denominator moved. Replaced with the property (a seek case
beside its play case; an audio-lane pair), which is true at any number.

**`docs/lg-self-checklist.md` was dated the day before its own newest content** —
"Status taken 2026-08-22" above four entries that name 2026-08-23. Bumped, and the
line now says to bump it in the same edit as any row, since it is the only sentence
in that file nothing else restates.

Rejected and recorded so the next run does not re-derive them: the Makefile's
"~0.5s" harness-suite note (measured 1.22 s, hedged with a tilde AND an explicit
"measure before budgeting", subprocess count unchanged); `README.md:176`'s "two
gitignored files", false since 072a60e and not this branch's; and four notes
recording the 6974 ms reporter-join measurement taken while netcond's scope was
broken — they assert the park and the mechanism, not that the media stream kept
flowing, so none is contradicted. Two more (`async-model-decision.md:399`,
`ui/library.rs:171`) described scoping as working per-request and were FALSE until
this branch fixed `relay`; they are true again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* player: a finished stream can be started again, and #46 gets both halves

The replay half of LG App Self Checklist #46 was the one thing my last PR could
not reach from `tests/`, and the reason was six lines in `app.rs`: the synthetic
tier's only entry into the player is `plxnative-playurl`, read behind a one-shot
`auto_tried` latch, so a boot got exactly one playback. On EOS `finish_playback`
→ `exit_player` leaves the player, and with no Plex session there is no detail
page, no Play control and no key path back in.

Everything else was already in place, which is why the change is small:
`teardown` clears the URL and the `ended` flag on a real stop, and
`engine::start_bufferfeed` re-reads `dev::playurl()` whenever `route::url()` is
empty. So a replay is a second trip through the entry the boot already used.

**A COUNTER re-arming the latch, not a lifted latch.** `auto_tried` also guards
the `autoplay`+`playidx` arm, which does a `request_play_movie` +
`load_detail_now` — an unconditionally re-armable latch would re-fetch a catalog
item on every player exit and loop a REAL playback forever.
`/tmp/plxnative-replay[=N]` is bounded, opt-in, read once at boot (so no file
appearing mid-run can turn it into a loop), gated on `playurl` being armed, and
declines when `finish_playback` handed off to Up Next instead — an auto-advance
chain returns to the player, and that is exactly what the route check tells
apart. An absent file is 0, so every existing boot is byte-identical.
`dev::flag`/`dev::read` are `false`/`None` at COMPILE time without `devtriggers`,
so a release build has no replay arm at all; both feature sets type-check.

`replay_budget` is split out and host-tested for `note_global_press`'s reason one
step removed: the call site is inside the SDL event loop where no host test can
reach, and this half touches no SDL. It matters more than it looks, because every
value it can return is plausible and a misparse is invisible on the panel — 0
reads as "the replay arm is missing from this binary" and 2 reads as a loop.

**The two hazards in the lanes that landed in this file since I last read it are
both safe by construction, and I checked rather than assumed.** b6's
unconsumed-press invariant lives in `note_global_press`, and this change is
nowhere near key dispatch — it adds no press path and no global side effect. b7's
recorder cannot write a bogus record for a synthetic playback either:
`coldstart_place` answers `Route::Player` from `metadata::playing()`, which is
installed ONLY by `route::apply_plan` (the PMS decision path), so a URL-fed
session has no playing item and records nothing — before this change or after it.
A replay also re-enters on the next frame, so the 800 ms post-exit hub refresh
never fires between the two viewings.

**The case.** `pipe_replay_after_eos` plays the same 20 s clip, lets it end, and
starts it again. `expect.replays` is one statement, not two: the harness writes it
into the trigger AND `a_replayed` counts it, so the number the app is told cannot
drift from the number that is graded. Three signals, each worthless alone — the
`replay:` line exactly N times (counted, because more often than asked is a loop
and a loop satisfies everything else); at least N+1 `load:` lines, since
`start_bufferfeed` writes one per SESSION and `teardown` cleared the URL, so a
second line is what says the declaration was really re-read; and a media position
that FALLS and then climbs, which is the only thing separating a restart from a
session that carried on. `server_opens_min: 2` is the wire-side half no log line
can give: the second viewing has to fetch the clip again.

`_resolve_fixtures`' EOS bound becomes per VIEWING (`dur * (1 + replays)`), so a
`--secs`-regenerated pack skips this case instead of failing it as a missing
feature. `pipe_finish_eos` stays separate and grades the finish alone: "never
ends" and "ends and cannot be restarted" are different failures, and one case
would report either as the other.

**Two prose corrections this branch's netcond findings force, both about the same
sentence.** The root `CLAUDE.md` describes scoping — "`stall@/:/timeline` freezes
the progress reporter while video keeps streaming, which is what makes a clean
experiment possible" — as a working feature. It was FALSE for as long as it
existed, because `relay` took a scope-less `Mode.split`; it became true on
2026-08-23. Said so at the sentence rather than three sentences later.

And the **6974 ms** measurement cited beside it was taken under that broken
instrument, so the proxy was stalling every connection and not only the
reporter's. **The number and the conclusion both survive, and the mechanism is
worth recording rather than re-deriving:** it was logged as `THREADJOIN timeline
6974ms` — `task::join` emits one NAMED line per join, so the attribution came
from the instrument and not from inferring a total — and `timeline` is the only
join that COULD have parked whatever else was stalled, because `engine::teardown`
step 1 deliberately wakes the other two before joining them (`http_shutdown` on
the demux socket, `aq_abort` on both AU lanes) while the reporter's POST had no
such wake. Before and after were taken the same way, so the 14x is
apples-to-apples. What CANNOT be claimed from that session is that video kept
streaming while the reporter was frozen — a property of the tool today, not of
that run. Recorded in `CLAUDE.md`, `threads.rs` and `engine.rs`, all three of
which carried the number.

Host-verified: `make check` green — 1069 Rust tests (1066 on main + 3 new) and 51
harness tests — and `--no-default-features` type-checks. No television: the device
run is the integrator's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay count is a third exception to the early-exit rule, and says so

`stream_case`'s soundness note names exactly two ABSENCE checks that early exit
cannot see, and asks that a third be REASONED ABOUT rather than added. `a_replayed`
is a third of the same shape: it grades an EQUALITY (exactly N `replay:` lines,
because more than N is a loop), and an equality can pass at N and fail at N+1.

What it cannot see, stated rather than left to be discovered: an app replaying
forever fires its next `replay:` line only after another full viewing — ~20 s on
the short clip — while the case satisfies everything else at ~28 s, so an early
exit two seconds later stops before the evidence arrives.

Not closed by making this one case burn its whole 100 s cap. That is ~1.5 min on
every suite run to guard three lines whose bound is ALREADY gradeable by `make
check`: `replay_left` is decremented before each re-arm, and `replay_budget`'s
parsing has host tests. `--no-early` is how to go looking for a loop deliberately,
and the trade is worth re-taking only if that app-side bound moves.

Also: `docs/ux-scenario.md`'s #46 row pointed at the checklist "where it is listed
as untested", which stopped being true one commit ago. It now points at the case.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay assertion passed on a replay that never played, and three notes it made false

`/code-review` on the replay work, five findings, all mine, all fixed.

**The one that mattered: `a_replayed` was a false PASS in the ordering the field
will actually produce.** It measured the post-drop climb from the GLOBAL floor —
and a floor is a VALUE, so it only lands in viewing 2 when viewing 2 happens to
reach viewing 1's minimum. The `pos=` heartbeat is 1 Hz and free-running, so
viewing 1 logging `pos=0s` while viewing 2's first sample lands at `pos=1s` puts
the anchor back in viewing 1 and measures VIEWING 1'S OWN CLIMB. Reproduced
against the real function: `[0,5,10,19,1]` read as "fell 18s then climbed 19s" and
PASSED with the second viewing having produced one sample and zero seconds of
playback — defeating near-miss (e) in its own docstring, "restarted and then
stalled at the join".

Worse than a corner: the harness exits the moment every assertion passes, so that
is the state it would NORMALLY have graded. My own near-miss test passed only
because its series starts at 2 rather than 0 — exactly the accident a regression
test is for, and there is now one carrying the counterexample verbatim.

The climb is anchored at the index of the deepest DROP, which the loop computing
`drop` already had in hand.

Four more, each a sentence this branch itself made false:

* `a_finished`'s docstring still said the replay half "is unreachable from this
  tier today and it is an app gap, not a test gap … exactly one playback per boot
  and no key path back into the player" — contradicted by the `a_replayed` fifty
  lines below it, by `/tmp/plxnative-replay`, and by `pipe_replay_after_eos`, all
  added in the same change. It now points at them and says why the two cases stay
  apart.
* `_eof_note`, `make_fixtures.py` trap 9, the `pipe_h264_ac3_short` shape comment
  and `tests/README.md` all said `pipe_finish_eos` was the ONLY case allowed to
  reach EOF and the only one allowed to name that fixture. Two cases do both now.
  The rule was never "one case" anyway — it is "a case graded through a teardown
  has to have declared `reaches_eos`", which is what the unit test was deliberately
  loosened to, so the prose was the last thing still asserting the old form.
* `CLAUDE.md` and the `which-tier` skill both said "19 cases as of 2026-08-23".
  The manifest holds 20. **That count rotted inside the branch that wrote it, one
  commit after that same branch corrected the previous stale copy of it.** Both are
  now the pointer to `--list` rather than a fourth number waiting to go stale.
* `NetcondRate.setUp` leaked a `mkdtemp` per test — six `/tmp` directories per
  `make check`, on the command run most often. `addCleanup(shutil.rmtree)`, like
  every other temp use in that file. Verified: no new directories after a run.

`make check` green — 1069 Rust, 52 harness.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 26, 2026
…, and a proxy that can be slow (#59)

* tests: the resolution matrix LG asks for, a clip that is meant to end, and a proxy that can be slow

Three checklist items were unanswerable for three different reasons, and none of
them was a defect in the app.

**#50/#51 — resolution x codec.** The item is graded as a MATRIX and this repo
could only answer it as "pieces are covered": every pipeline fixture was 1080p
except one 4K HEVC, so SD and HD had never been played AT ALL, and 4K H.264
existed in neither pack — which is a fact about the maintainer's library (every
4K item there is HEVC or AV1) rather than about the player. Six new generated
clips complete the grid: SD 720x480 / HD 1280x720 / FHD 1920x1080 / UHD 3840x2160
x {h264, hevc}, with ONE audio codec per column so a row-to-row difference is the
raster and nothing else. Each of the eight cells now grades `expect.video_size`,
an EXACT WxH out of the `ff:` line, because `min_video_width` cannot tell 720x480
from 720x576 and a matrix answered with "at least 1900 wide" is the answer the
item is asking us to stop giving.

Four decisions in the matrix look arbitrary and are argued where they live
(`PIPE_SHAPES`' block comment): square pixels at 720x480 (an anamorphic fixture
would grade PAR handling, an axis with no assertion behind it anywhere here);
CRF held constant is constant QUALITY, not bitrate, so 4K H.264 is crf 26 and not
its 1080p sibling's 20 — the same CRF measures ~30 Mbit/s up there, a
quarter-gigabyte clip in service of no assertion; SDR 8-bit throughout, which
makes the UHD/HEVC cell the odd one out because it is the existing HDR10 fixture,
already device-verified; and E-AC-3 down the HEVC column, which is also the
better false-PASS defence, since `engine`'s `_ =>` arm can only ever produce
"AC3".

**#46 — replay after completion.** Its FIRST half now runs: `pipe_finish_eos`
plays a deliberately short 20 s clip to its end and asserts `EOS reached ...
-> ended` followed by `stop_bufferfeed: torn down`, in that order. Ordered
because every stop tears the engine down — the harness's own close included — and
searched forward from the EOS rather than compared against the first teardown in
the log, because `teardown` writes the same line for a `for_reload` stop, which
would fail the case for its whole cap with the evidence reading "the player froze
on the last frame". This is the only case in either tier that is SUPPOSED to run
out, so it gets its own fixture that nothing else may name (everything else is
sized so it cannot hit EOF mid-window, trap 9's second half), and
`_resolve_fixtures` grew the opposite duration bound: it SKIPS when the clip is
longer than 0.6x the cap, so a `--secs`-regenerated pack skips rather than failing
as a frozen player.

The SECOND half — starting the same content again — is NOT closed, and it is an
app gap rather than a test gap. `plxnative-playurl` is read behind `app.rs`'s
one-shot `auto_tried` latch, so a boot gets exactly one playback; on EOS
`finish_playback` -> `exit_player` leaves the player, and with no Plex session
there is no detail page, no Play control and no key path back in. The manifest
case carries a `_replay_note` naming the small app-side change that would close
it (`engine::start_bufferfeed` already re-reads `dev::playurl()` whenever
`route::url()` is empty), and `docs/lg-self-checklist.md` still marks the replay
half untested.

**#43 CASE1 and #14 — `tools/netcond.py` gains `rate:<kbps>`.** The proxy could
make the server dead in four ways and slow in none, so CASE1's own legs (512 Kbps
-> 1 Mbps -> 7 Mbps -> 17.5 Mbps) could not be PRODUCED and #14's degrading link
was anecdote. One token bucket for the whole proxy, because `rate:` names a link
and a link is shared; decimal kilobits, because that is the unit the item states
its legs in; empty at the start, because a full bucket hands the first
quarter-second a free burst and that is most of a short transfer; live under an
open connection, so one scripted run covers all four legs instead of four
launches. Measured through the real proxy: 512 -> 496 kbps, 2000 -> 2000,
17500 -> 17518.

Two pre-existing bugs surfaced in the code it touches, both fixed:

* **The mode SCOPE was honoured only at accept.** `serve_conn` consulted the
  scope-aware `applies()` and then handed `relay` a bare `Mode.split`, which
  discards it — so `stall@/:/timeline` really froze every open connection
  including the media stream, i.e. the exact opposite of what the scope exists
  for. Both docs claimed the working behaviour. `relay` now takes the
  connection's own first bytes.
* **The read poll's socket timeout was also the other direction's WRITE
  timeout.** Both relay threads share one pair of sockets, so `src.settimeout(0.5)`
  set the timeout on the other thread's `dst`; `sendall` on a timed-out socket
  raises having written an unspecified number of bytes, the `except OSError`
  swallowed it, and the stream truncated silently — reachable in exactly the
  situation the proxy exists to measure. The poll moved to `select` and both
  sockets are put back to blocking before relaying.

`--selftest` proves the shaper against a loopback transfer with no television in
the room, in its own temp control file so it cannot release the mode under a live
experiment.

**What this costs and what it does not prove.** The pipeline pack goes from ~0.4
to ~0.7 GB (the 4K H.264 clip is 93 MB of that) and from 8 clips to 15; resolution
is a property of the media, so a matrix cell cannot be a second case on an
existing file. Everything here is generated, so what none of it reaches is a PMS
DECISION on any of these shapes — `library_gaps` says so per entry. While
correcting those entries: `8-bit-hevc` was ALREADY covered by
`pipe_hevc_aac_mp4` (no `hdr` key, so Main / yuv420p) and the gap list had not
caught up; only `4k-h264` is newly closed.

Host-verified only — this lane has no television. `make check` is green (976 Rust
+ 47 harness tests, the harness suite now including the netcond shaper against
real loopback sockets), every fixture verifies under `make_fixtures.py`'s own
ffprobe checks, and `serve_fixtures.py` answers 206/416 with a byte-exact tail
for each new clip. The device run is the integrator's; the recipe is in the PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the which-tier skill still said the synthetic tier was twelve cases

It is 19 as of this branch, and the number in that sentence was going to rot
again — the same way the host test count in CLAUDE.md rotted three times — so it
now points at `./tests/run.py --list` instead of restating a census.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: five sentences this branch made false, one of them mine twice over

`doc-claim-auditor` over the branch. All five are contradictions, not omissions.

**The one that matters, because it is the skill whose whole subject is this
error.** `which-tier` opens by warning against "reading a bare `./tests/run.py`
as the suite it used to be" — and its pasteable `sh` block still said **12
synthetic cases**. Worse, 8ede10e fixed the identical number in that file's
PROSE two paragraphs above and left the two copies in the code block, i.e. the
half a reader copies. The file contradicted itself inside one commit. Both counts
are gone; the block now points at `--list`, which it already named two lines down,
and says why a second copy of the number does not survive here.

**`tests/fixtures/README.md` listed two gaps as unbuilt that this script builds.**
Its `library_gaps` summary still named `8-bit HEVC` and `4K H.264` — while
`manifest.json`, rewritten in the same commit, says 4K H.264 is closed by
`pipe_res_h264_uhd` and 8-bit HEVC has been covered since `pipe_hevc_aac_mp4`
landed (no `hdr` key, so `-profile:v main` / yuv420p). A reader of that page goes
off to author media that already exists. Both cut, with what a generated clip
still cannot close said plainly: a PMS DECISION on such an item.

Same sentence, pre-existing and one word: it named **`plxnative-url`** as the
trigger these are fed through. `tests/README.md` says the opposite and is right —
`plxnative-playurl` is the one carrying the DECLARATION, and several remaining
gaps (HLG, HDR10+) are *about* what the payload declares.

**Trap 9 was falsified by this branch's own fixture, 260 lines below it.** "Nothing
is ever shorter than 60 s" is now false: `pipe_h264_ac3_short` is 20 s because
ENDING is what it grades, and `_resolve_fixtures` enforces the opposite bound for
it. The new shape's comment cited "trap 9's second half" as the rule it breaks;
trap 9 itself was never told, and neither was `PIPE_SHAPES`' header, which still
said the only length constraint left was "do not hit EOF". Both now carry both
bounds, and say that adding a second short clip means picking a side.

**`_probe_fixture`'s "three of the twelve" was never right.** It is four fixtures
carrying two cases each, and it was four of twelve on `main` too — a count that
was wrong before the denominator moved. Replaced with the property (a seek case
beside its play case; an audio-lane pair), which is true at any number.

**`docs/lg-self-checklist.md` was dated the day before its own newest content** —
"Status taken 2026-08-22" above four entries that name 2026-08-23. Bumped, and the
line now says to bump it in the same edit as any row, since it is the only sentence
in that file nothing else restates.

Rejected and recorded so the next run does not re-derive them: the Makefile's
"~0.5s" harness-suite note (measured 1.22 s, hedged with a tilde AND an explicit
"measure before budgeting", subprocess count unchanged); `README.md:176`'s "two
gitignored files", false since b6b9bdb and not this branch's; and four notes
recording the 6974 ms reporter-join measurement taken while netcond's scope was
broken — they assert the park and the mechanism, not that the media stream kept
flowing, so none is contradicted. Two more (`async-model-decision.md:399`,
`ui/library.rs:171`) described scoping as working per-request and were FALSE until
this branch fixed `relay`; they are true again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* player: a finished stream can be started again, and #46 gets both halves

The replay half of LG App Self Checklist #46 was the one thing my last PR could
not reach from `tests/`, and the reason was six lines in `app.rs`: the synthetic
tier's only entry into the player is `plxnative-playurl`, read behind a one-shot
`auto_tried` latch, so a boot got exactly one playback. On EOS `finish_playback`
→ `exit_player` leaves the player, and with no Plex session there is no detail
page, no Play control and no key path back in.

Everything else was already in place, which is why the change is small:
`teardown` clears the URL and the `ended` flag on a real stop, and
`engine::start_bufferfeed` re-reads `dev::playurl()` whenever `route::url()` is
empty. So a replay is a second trip through the entry the boot already used.

**A COUNTER re-arming the latch, not a lifted latch.** `auto_tried` also guards
the `autoplay`+`playidx` arm, which does a `request_play_movie` +
`load_detail_now` — an unconditionally re-armable latch would re-fetch a catalog
item on every player exit and loop a REAL playback forever.
`/tmp/plxnative-replay[=N]` is bounded, opt-in, read once at boot (so no file
appearing mid-run can turn it into a loop), gated on `playurl` being armed, and
declines when `finish_playback` handed off to Up Next instead — an auto-advance
chain returns to the player, and that is exactly what the route check tells
apart. An absent file is 0, so every existing boot is byte-identical.
`dev::flag`/`dev::read` are `false`/`None` at COMPILE time without `devtriggers`,
so a release build has no replay arm at all; both feature sets type-check.

`replay_budget` is split out and host-tested for `note_global_press`'s reason one
step removed: the call site is inside the SDL event loop where no host test can
reach, and this half touches no SDL. It matters more than it looks, because every
value it can return is plausible and a misparse is invisible on the panel — 0
reads as "the replay arm is missing from this binary" and 2 reads as a loop.

**The two hazards in the lanes that landed in this file since I last read it are
both safe by construction, and I checked rather than assumed.** b6's
unconsumed-press invariant lives in `note_global_press`, and this change is
nowhere near key dispatch — it adds no press path and no global side effect. b7's
recorder cannot write a bogus record for a synthetic playback either:
`coldstart_place` answers `Route::Player` from `metadata::playing()`, which is
installed ONLY by `route::apply_plan` (the PMS decision path), so a URL-fed
session has no playing item and records nothing — before this change or after it.
A replay also re-enters on the next frame, so the 800 ms post-exit hub refresh
never fires between the two viewings.

**The case.** `pipe_replay_after_eos` plays the same 20 s clip, lets it end, and
starts it again. `expect.replays` is one statement, not two: the harness writes it
into the trigger AND `a_replayed` counts it, so the number the app is told cannot
drift from the number that is graded. Three signals, each worthless alone — the
`replay:` line exactly N times (counted, because more often than asked is a loop
and a loop satisfies everything else); at least N+1 `load:` lines, since
`start_bufferfeed` writes one per SESSION and `teardown` cleared the URL, so a
second line is what says the declaration was really re-read; and a media position
that FALLS and then climbs, which is the only thing separating a restart from a
session that carried on. `server_opens_min: 2` is the wire-side half no log line
can give: the second viewing has to fetch the clip again.

`_resolve_fixtures`' EOS bound becomes per VIEWING (`dur * (1 + replays)`), so a
`--secs`-regenerated pack skips this case instead of failing it as a missing
feature. `pipe_finish_eos` stays separate and grades the finish alone: "never
ends" and "ends and cannot be restarted" are different failures, and one case
would report either as the other.

**Two prose corrections this branch's netcond findings force, both about the same
sentence.** The root `CLAUDE.md` describes scoping — "`stall@/:/timeline` freezes
the progress reporter while video keeps streaming, which is what makes a clean
experiment possible" — as a working feature. It was FALSE for as long as it
existed, because `relay` took a scope-less `Mode.split`; it became true on
2026-08-23. Said so at the sentence rather than three sentences later.

And the **6974 ms** measurement cited beside it was taken under that broken
instrument, so the proxy was stalling every connection and not only the
reporter's. **The number and the conclusion both survive, and the mechanism is
worth recording rather than re-deriving:** it was logged as `THREADJOIN timeline
6974ms` — `task::join` emits one NAMED line per join, so the attribution came
from the instrument and not from inferring a total — and `timeline` is the only
join that COULD have parked whatever else was stalled, because `engine::teardown`
step 1 deliberately wakes the other two before joining them (`http_shutdown` on
the demux socket, `aq_abort` on both AU lanes) while the reporter's POST had no
such wake. Before and after were taken the same way, so the 14x is
apples-to-apples. What CANNOT be claimed from that session is that video kept
streaming while the reporter was frozen — a property of the tool today, not of
that run. Recorded in `CLAUDE.md`, `threads.rs` and `engine.rs`, all three of
which carried the number.

Host-verified: `make check` green — 1069 Rust tests (1066 on main + 3 new) and 51
harness tests — and `--no-default-features` type-checks. No television: the device
run is the integrator's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay count is a third exception to the early-exit rule, and says so

`stream_case`'s soundness note names exactly two ABSENCE checks that early exit
cannot see, and asks that a third be REASONED ABOUT rather than added. `a_replayed`
is a third of the same shape: it grades an EQUALITY (exactly N `replay:` lines,
because more than N is a loop), and an equality can pass at N and fail at N+1.

What it cannot see, stated rather than left to be discovered: an app replaying
forever fires its next `replay:` line only after another full viewing — ~20 s on
the short clip — while the case satisfies everything else at ~28 s, so an early
exit two seconds later stops before the evidence arrives.

Not closed by making this one case burn its whole 100 s cap. That is ~1.5 min on
every suite run to guard three lines whose bound is ALREADY gradeable by `make
check`: `replay_left` is decremented before each re-arm, and `replay_budget`'s
parsing has host tests. `--no-early` is how to go looking for a loop deliberately,
and the trade is worth re-taking only if that app-side bound moves.

Also: `docs/ux-scenario.md`'s #46 row pointed at the checklist "where it is listed
as untested", which stopped being true one commit ago. It now points at the case.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay assertion passed on a replay that never played, and three notes it made false

`/code-review` on the replay work, five findings, all mine, all fixed.

**The one that mattered: `a_replayed` was a false PASS in the ordering the field
will actually produce.** It measured the post-drop climb from the GLOBAL floor —
and a floor is a VALUE, so it only lands in viewing 2 when viewing 2 happens to
reach viewing 1's minimum. The `pos=` heartbeat is 1 Hz and free-running, so
viewing 1 logging `pos=0s` while viewing 2's first sample lands at `pos=1s` puts
the anchor back in viewing 1 and measures VIEWING 1'S OWN CLIMB. Reproduced
against the real function: `[0,5,10,19,1]` read as "fell 18s then climbed 19s" and
PASSED with the second viewing having produced one sample and zero seconds of
playback — defeating near-miss (e) in its own docstring, "restarted and then
stalled at the join".

Worse than a corner: the harness exits the moment every assertion passes, so that
is the state it would NORMALLY have graded. My own near-miss test passed only
because its series starts at 2 rather than 0 — exactly the accident a regression
test is for, and there is now one carrying the counterexample verbatim.

The climb is anchored at the index of the deepest DROP, which the loop computing
`drop` already had in hand.

Four more, each a sentence this branch itself made false:

* `a_finished`'s docstring still said the replay half "is unreachable from this
  tier today and it is an app gap, not a test gap … exactly one playback per boot
  and no key path back into the player" — contradicted by the `a_replayed` fifty
  lines below it, by `/tmp/plxnative-replay`, and by `pipe_replay_after_eos`, all
  added in the same change. It now points at them and says why the two cases stay
  apart.
* `_eof_note`, `make_fixtures.py` trap 9, the `pipe_h264_ac3_short` shape comment
  and `tests/README.md` all said `pipe_finish_eos` was the ONLY case allowed to
  reach EOF and the only one allowed to name that fixture. Two cases do both now.
  The rule was never "one case" anyway — it is "a case graded through a teardown
  has to have declared `reaches_eos`", which is what the unit test was deliberately
  loosened to, so the prose was the last thing still asserting the old form.
* `CLAUDE.md` and the `which-tier` skill both said "19 cases as of 2026-08-23".
  The manifest holds 20. **That count rotted inside the branch that wrote it, one
  commit after that same branch corrected the previous stale copy of it.** Both are
  now the pointer to `--list` rather than a fourth number waiting to go stale.
* `NetcondRate.setUp` leaked a `mkdtemp` per test — six `/tmp` directories per
  `make check`, on the command run most often. `addCleanup(shutil.rmtree)`, like
  every other temp use in that file. Verified: no new directories after a run.

`make check` green — 1069 Rust, 52 harness.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 27, 2026
…, and a proxy that can be slow (#59)

* tests: the resolution matrix LG asks for, a clip that is meant to end, and a proxy that can be slow

Three checklist items were unanswerable for three different reasons, and none of
them was a defect in the app.

**#50/#51 — resolution x codec.** The item is graded as a MATRIX and this repo
could only answer it as "pieces are covered": every pipeline fixture was 1080p
except one 4K HEVC, so SD and HD had never been played AT ALL, and 4K H.264
existed in neither pack — which is a fact about the maintainer's library (every
4K item there is HEVC or AV1) rather than about the player. Six new generated
clips complete the grid: SD 720x480 / HD 1280x720 / FHD 1920x1080 / UHD 3840x2160
x {h264, hevc}, with ONE audio codec per column so a row-to-row difference is the
raster and nothing else. Each of the eight cells now grades `expect.video_size`,
an EXACT WxH out of the `ff:` line, because `min_video_width` cannot tell 720x480
from 720x576 and a matrix answered with "at least 1900 wide" is the answer the
item is asking us to stop giving.

Four decisions in the matrix look arbitrary and are argued where they live
(`PIPE_SHAPES`' block comment): square pixels at 720x480 (an anamorphic fixture
would grade PAR handling, an axis with no assertion behind it anywhere here);
CRF held constant is constant QUALITY, not bitrate, so 4K H.264 is crf 26 and not
its 1080p sibling's 20 — the same CRF measures ~30 Mbit/s up there, a
quarter-gigabyte clip in service of no assertion; SDR 8-bit throughout, which
makes the UHD/HEVC cell the odd one out because it is the existing HDR10 fixture,
already device-verified; and E-AC-3 down the HEVC column, which is also the
better false-PASS defence, since `engine`'s `_ =>` arm can only ever produce
"AC3".

**#46 — replay after completion.** Its FIRST half now runs: `pipe_finish_eos`
plays a deliberately short 20 s clip to its end and asserts `EOS reached ...
-> ended` followed by `stop_bufferfeed: torn down`, in that order. Ordered
because every stop tears the engine down — the harness's own close included — and
searched forward from the EOS rather than compared against the first teardown in
the log, because `teardown` writes the same line for a `for_reload` stop, which
would fail the case for its whole cap with the evidence reading "the player froze
on the last frame". This is the only case in either tier that is SUPPOSED to run
out, so it gets its own fixture that nothing else may name (everything else is
sized so it cannot hit EOF mid-window, trap 9's second half), and
`_resolve_fixtures` grew the opposite duration bound: it SKIPS when the clip is
longer than 0.6x the cap, so a `--secs`-regenerated pack skips rather than failing
as a frozen player.

The SECOND half — starting the same content again — is NOT closed, and it is an
app gap rather than a test gap. `plxnative-playurl` is read behind `app.rs`'s
one-shot `auto_tried` latch, so a boot gets exactly one playback; on EOS
`finish_playback` -> `exit_player` leaves the player, and with no Plex session
there is no detail page, no Play control and no key path back in. The manifest
case carries a `_replay_note` naming the small app-side change that would close
it (`engine::start_bufferfeed` already re-reads `dev::playurl()` whenever
`route::url()` is empty), and `docs/lg-self-checklist.md` still marks the replay
half untested.

**#43 CASE1 and #14 — `tools/netcond.py` gains `rate:<kbps>`.** The proxy could
make the server dead in four ways and slow in none, so CASE1's own legs (512 Kbps
-> 1 Mbps -> 7 Mbps -> 17.5 Mbps) could not be PRODUCED and #14's degrading link
was anecdote. One token bucket for the whole proxy, because `rate:` names a link
and a link is shared; decimal kilobits, because that is the unit the item states
its legs in; empty at the start, because a full bucket hands the first
quarter-second a free burst and that is most of a short transfer; live under an
open connection, so one scripted run covers all four legs instead of four
launches. Measured through the real proxy: 512 -> 496 kbps, 2000 -> 2000,
17500 -> 17518.

Two pre-existing bugs surfaced in the code it touches, both fixed:

* **The mode SCOPE was honoured only at accept.** `serve_conn` consulted the
  scope-aware `applies()` and then handed `relay` a bare `Mode.split`, which
  discards it — so `stall@/:/timeline` really froze every open connection
  including the media stream, i.e. the exact opposite of what the scope exists
  for. Both docs claimed the working behaviour. `relay` now takes the
  connection's own first bytes.
* **The read poll's socket timeout was also the other direction's WRITE
  timeout.** Both relay threads share one pair of sockets, so `src.settimeout(0.5)`
  set the timeout on the other thread's `dst`; `sendall` on a timed-out socket
  raises having written an unspecified number of bytes, the `except OSError`
  swallowed it, and the stream truncated silently — reachable in exactly the
  situation the proxy exists to measure. The poll moved to `select` and both
  sockets are put back to blocking before relaying.

`--selftest` proves the shaper against a loopback transfer with no television in
the room, in its own temp control file so it cannot release the mode under a live
experiment.

**What this costs and what it does not prove.** The pipeline pack goes from ~0.4
to ~0.7 GB (the 4K H.264 clip is 93 MB of that) and from 8 clips to 15; resolution
is a property of the media, so a matrix cell cannot be a second case on an
existing file. Everything here is generated, so what none of it reaches is a PMS
DECISION on any of these shapes — `library_gaps` says so per entry. While
correcting those entries: `8-bit-hevc` was ALREADY covered by
`pipe_hevc_aac_mp4` (no `hdr` key, so Main / yuv420p) and the gap list had not
caught up; only `4k-h264` is newly closed.

Host-verified only — this lane has no television. `make check` is green (976 Rust
+ 47 harness tests, the harness suite now including the netcond shaper against
real loopback sockets), every fixture verifies under `make_fixtures.py`'s own
ffprobe checks, and `serve_fixtures.py` answers 206/416 with a byte-exact tail
for each new clip. The device run is the integrator's; the recipe is in the PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the which-tier skill still said the synthetic tier was twelve cases

It is 19 as of this branch, and the number in that sentence was going to rot
again — the same way the host test count in CLAUDE.md rotted three times — so it
now points at `./tests/run.py --list` instead of restating a census.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: five sentences this branch made false, one of them mine twice over

`doc-claim-auditor` over the branch. All five are contradictions, not omissions.

**The one that matters, because it is the skill whose whole subject is this
error.** `which-tier` opens by warning against "reading a bare `./tests/run.py`
as the suite it used to be" — and its pasteable `sh` block still said **12
synthetic cases**. Worse, 8ede10e fixed the identical number in that file's
PROSE two paragraphs above and left the two copies in the code block, i.e. the
half a reader copies. The file contradicted itself inside one commit. Both counts
are gone; the block now points at `--list`, which it already named two lines down,
and says why a second copy of the number does not survive here.

**`tests/fixtures/README.md` listed two gaps as unbuilt that this script builds.**
Its `library_gaps` summary still named `8-bit HEVC` and `4K H.264` — while
`manifest.json`, rewritten in the same commit, says 4K H.264 is closed by
`pipe_res_h264_uhd` and 8-bit HEVC has been covered since `pipe_hevc_aac_mp4`
landed (no `hdr` key, so `-profile:v main` / yuv420p). A reader of that page goes
off to author media that already exists. Both cut, with what a generated clip
still cannot close said plainly: a PMS DECISION on such an item.

Same sentence, pre-existing and one word: it named **`plxnative-url`** as the
trigger these are fed through. `tests/README.md` says the opposite and is right —
`plxnative-playurl` is the one carrying the DECLARATION, and several remaining
gaps (HLG, HDR10+) are *about* what the payload declares.

**Trap 9 was falsified by this branch's own fixture, 260 lines below it.** "Nothing
is ever shorter than 60 s" is now false: `pipe_h264_ac3_short` is 20 s because
ENDING is what it grades, and `_resolve_fixtures` enforces the opposite bound for
it. The new shape's comment cited "trap 9's second half" as the rule it breaks;
trap 9 itself was never told, and neither was `PIPE_SHAPES`' header, which still
said the only length constraint left was "do not hit EOF". Both now carry both
bounds, and say that adding a second short clip means picking a side.

**`_probe_fixture`'s "three of the twelve" was never right.** It is four fixtures
carrying two cases each, and it was four of twelve on `main` too — a count that
was wrong before the denominator moved. Replaced with the property (a seek case
beside its play case; an audio-lane pair), which is true at any number.

**`docs/lg-self-checklist.md` was dated the day before its own newest content** —
"Status taken 2026-08-22" above four entries that name 2026-08-23. Bumped, and the
line now says to bump it in the same edit as any row, since it is the only sentence
in that file nothing else restates.

Rejected and recorded so the next run does not re-derive them: the Makefile's
"~0.5s" harness-suite note (measured 1.22 s, hedged with a tilde AND an explicit
"measure before budgeting", subprocess count unchanged); `README.md:176`'s "two
gitignored files", false since 4f69d32 and not this branch's; and four notes
recording the 6974 ms reporter-join measurement taken while netcond's scope was
broken — they assert the park and the mechanism, not that the media stream kept
flowing, so none is contradicted. Two more (`async-model-decision.md:399`,
`ui/library.rs:171`) described scoping as working per-request and were FALSE until
this branch fixed `relay`; they are true again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* player: a finished stream can be started again, and #46 gets both halves

The replay half of LG App Self Checklist #46 was the one thing my last PR could
not reach from `tests/`, and the reason was six lines in `app.rs`: the synthetic
tier's only entry into the player is `plxnative-playurl`, read behind a one-shot
`auto_tried` latch, so a boot got exactly one playback. On EOS `finish_playback`
→ `exit_player` leaves the player, and with no Plex session there is no detail
page, no Play control and no key path back in.

Everything else was already in place, which is why the change is small:
`teardown` clears the URL and the `ended` flag on a real stop, and
`engine::start_bufferfeed` re-reads `dev::playurl()` whenever `route::url()` is
empty. So a replay is a second trip through the entry the boot already used.

**A COUNTER re-arming the latch, not a lifted latch.** `auto_tried` also guards
the `autoplay`+`playidx` arm, which does a `request_play_movie` +
`load_detail_now` — an unconditionally re-armable latch would re-fetch a catalog
item on every player exit and loop a REAL playback forever.
`/tmp/plxnative-replay[=N]` is bounded, opt-in, read once at boot (so no file
appearing mid-run can turn it into a loop), gated on `playurl` being armed, and
declines when `finish_playback` handed off to Up Next instead — an auto-advance
chain returns to the player, and that is exactly what the route check tells
apart. An absent file is 0, so every existing boot is byte-identical.
`dev::flag`/`dev::read` are `false`/`None` at COMPILE time without `devtriggers`,
so a release build has no replay arm at all; both feature sets type-check.

`replay_budget` is split out and host-tested for `note_global_press`'s reason one
step removed: the call site is inside the SDL event loop where no host test can
reach, and this half touches no SDL. It matters more than it looks, because every
value it can return is plausible and a misparse is invisible on the panel — 0
reads as "the replay arm is missing from this binary" and 2 reads as a loop.

**The two hazards in the lanes that landed in this file since I last read it are
both safe by construction, and I checked rather than assumed.** b6's
unconsumed-press invariant lives in `note_global_press`, and this change is
nowhere near key dispatch — it adds no press path and no global side effect. b7's
recorder cannot write a bogus record for a synthetic playback either:
`coldstart_place` answers `Route::Player` from `metadata::playing()`, which is
installed ONLY by `route::apply_plan` (the PMS decision path), so a URL-fed
session has no playing item and records nothing — before this change or after it.
A replay also re-enters on the next frame, so the 800 ms post-exit hub refresh
never fires between the two viewings.

**The case.** `pipe_replay_after_eos` plays the same 20 s clip, lets it end, and
starts it again. `expect.replays` is one statement, not two: the harness writes it
into the trigger AND `a_replayed` counts it, so the number the app is told cannot
drift from the number that is graded. Three signals, each worthless alone — the
`replay:` line exactly N times (counted, because more often than asked is a loop
and a loop satisfies everything else); at least N+1 `load:` lines, since
`start_bufferfeed` writes one per SESSION and `teardown` cleared the URL, so a
second line is what says the declaration was really re-read; and a media position
that FALLS and then climbs, which is the only thing separating a restart from a
session that carried on. `server_opens_min: 2` is the wire-side half no log line
can give: the second viewing has to fetch the clip again.

`_resolve_fixtures`' EOS bound becomes per VIEWING (`dur * (1 + replays)`), so a
`--secs`-regenerated pack skips this case instead of failing it as a missing
feature. `pipe_finish_eos` stays separate and grades the finish alone: "never
ends" and "ends and cannot be restarted" are different failures, and one case
would report either as the other.

**Two prose corrections this branch's netcond findings force, both about the same
sentence.** The root `CLAUDE.md` describes scoping — "`stall@/:/timeline` freezes
the progress reporter while video keeps streaming, which is what makes a clean
experiment possible" — as a working feature. It was FALSE for as long as it
existed, because `relay` took a scope-less `Mode.split`; it became true on
2026-08-23. Said so at the sentence rather than three sentences later.

And the **6974 ms** measurement cited beside it was taken under that broken
instrument, so the proxy was stalling every connection and not only the
reporter's. **The number and the conclusion both survive, and the mechanism is
worth recording rather than re-deriving:** it was logged as `THREADJOIN timeline
6974ms` — `task::join` emits one NAMED line per join, so the attribution came
from the instrument and not from inferring a total — and `timeline` is the only
join that COULD have parked whatever else was stalled, because `engine::teardown`
step 1 deliberately wakes the other two before joining them (`http_shutdown` on
the demux socket, `aq_abort` on both AU lanes) while the reporter's POST had no
such wake. Before and after were taken the same way, so the 14x is
apples-to-apples. What CANNOT be claimed from that session is that video kept
streaming while the reporter was frozen — a property of the tool today, not of
that run. Recorded in `CLAUDE.md`, `threads.rs` and `engine.rs`, all three of
which carried the number.

Host-verified: `make check` green — 1069 Rust tests (1066 on main + 3 new) and 51
harness tests — and `--no-default-features` type-checks. No television: the device
run is the integrator's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay count is a third exception to the early-exit rule, and says so

`stream_case`'s soundness note names exactly two ABSENCE checks that early exit
cannot see, and asks that a third be REASONED ABOUT rather than added. `a_replayed`
is a third of the same shape: it grades an EQUALITY (exactly N `replay:` lines,
because more than N is a loop), and an equality can pass at N and fail at N+1.

What it cannot see, stated rather than left to be discovered: an app replaying
forever fires its next `replay:` line only after another full viewing — ~20 s on
the short clip — while the case satisfies everything else at ~28 s, so an early
exit two seconds later stops before the evidence arrives.

Not closed by making this one case burn its whole 100 s cap. That is ~1.5 min on
every suite run to guard three lines whose bound is ALREADY gradeable by `make
check`: `replay_left` is decremented before each re-arm, and `replay_budget`'s
parsing has host tests. `--no-early` is how to go looking for a loop deliberately,
and the trade is worth re-taking only if that app-side bound moves.

Also: `docs/ux-scenario.md`'s #46 row pointed at the checklist "where it is listed
as untested", which stopped being true one commit ago. It now points at the case.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay assertion passed on a replay that never played, and three notes it made false

`/code-review` on the replay work, five findings, all mine, all fixed.

**The one that mattered: `a_replayed` was a false PASS in the ordering the field
will actually produce.** It measured the post-drop climb from the GLOBAL floor —
and a floor is a VALUE, so it only lands in viewing 2 when viewing 2 happens to
reach viewing 1's minimum. The `pos=` heartbeat is 1 Hz and free-running, so
viewing 1 logging `pos=0s` while viewing 2's first sample lands at `pos=1s` puts
the anchor back in viewing 1 and measures VIEWING 1'S OWN CLIMB. Reproduced
against the real function: `[0,5,10,19,1]` read as "fell 18s then climbed 19s" and
PASSED with the second viewing having produced one sample and zero seconds of
playback — defeating near-miss (e) in its own docstring, "restarted and then
stalled at the join".

Worse than a corner: the harness exits the moment every assertion passes, so that
is the state it would NORMALLY have graded. My own near-miss test passed only
because its series starts at 2 rather than 0 — exactly the accident a regression
test is for, and there is now one carrying the counterexample verbatim.

The climb is anchored at the index of the deepest DROP, which the loop computing
`drop` already had in hand.

Four more, each a sentence this branch itself made false:

* `a_finished`'s docstring still said the replay half "is unreachable from this
  tier today and it is an app gap, not a test gap … exactly one playback per boot
  and no key path back into the player" — contradicted by the `a_replayed` fifty
  lines below it, by `/tmp/plxnative-replay`, and by `pipe_replay_after_eos`, all
  added in the same change. It now points at them and says why the two cases stay
  apart.
* `_eof_note`, `make_fixtures.py` trap 9, the `pipe_h264_ac3_short` shape comment
  and `tests/README.md` all said `pipe_finish_eos` was the ONLY case allowed to
  reach EOF and the only one allowed to name that fixture. Two cases do both now.
  The rule was never "one case" anyway — it is "a case graded through a teardown
  has to have declared `reaches_eos`", which is what the unit test was deliberately
  loosened to, so the prose was the last thing still asserting the old form.
* `CLAUDE.md` and the `which-tier` skill both said "19 cases as of 2026-08-23".
  The manifest holds 20. **That count rotted inside the branch that wrote it, one
  commit after that same branch corrected the previous stale copy of it.** Both are
  now the pointer to `--list` rather than a fourth number waiting to go stale.
* `NetcondRate.setUp` leaked a `mkdtemp` per test — six `/tmp` directories per
  `make check`, on the command run most often. `addCleanup(shutil.rmtree)`, like
  every other temp use in that file. Verified: no new directories after a run.

`make check` green — 1069 Rust, 52 harness.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Aug 28, 2026
…, and a proxy that can be slow (#59)

* tests: the resolution matrix LG asks for, a clip that is meant to end, and a proxy that can be slow

Three checklist items were unanswerable for three different reasons, and none of
them was a defect in the app.

**#50/#51 — resolution x codec.** The item is graded as a MATRIX and this repo
could only answer it as "pieces are covered": every pipeline fixture was 1080p
except one 4K HEVC, so SD and HD had never been played AT ALL, and 4K H.264
existed in neither pack — which is a fact about the maintainer's library (every
4K item there is HEVC or AV1) rather than about the player. Six new generated
clips complete the grid: SD 720x480 / HD 1280x720 / FHD 1920x1080 / UHD 3840x2160
x {h264, hevc}, with ONE audio codec per column so a row-to-row difference is the
raster and nothing else. Each of the eight cells now grades `expect.video_size`,
an EXACT WxH out of the `ff:` line, because `min_video_width` cannot tell 720x480
from 720x576 and a matrix answered with "at least 1900 wide" is the answer the
item is asking us to stop giving.

Four decisions in the matrix look arbitrary and are argued where they live
(`PIPE_SHAPES`' block comment): square pixels at 720x480 (an anamorphic fixture
would grade PAR handling, an axis with no assertion behind it anywhere here);
CRF held constant is constant QUALITY, not bitrate, so 4K H.264 is crf 26 and not
its 1080p sibling's 20 — the same CRF measures ~30 Mbit/s up there, a
quarter-gigabyte clip in service of no assertion; SDR 8-bit throughout, which
makes the UHD/HEVC cell the odd one out because it is the existing HDR10 fixture,
already device-verified; and E-AC-3 down the HEVC column, which is also the
better false-PASS defence, since `engine`'s `_ =>` arm can only ever produce
"AC3".

**#46 — replay after completion.** Its FIRST half now runs: `pipe_finish_eos`
plays a deliberately short 20 s clip to its end and asserts `EOS reached ...
-> ended` followed by `stop_bufferfeed: torn down`, in that order. Ordered
because every stop tears the engine down — the harness's own close included — and
searched forward from the EOS rather than compared against the first teardown in
the log, because `teardown` writes the same line for a `for_reload` stop, which
would fail the case for its whole cap with the evidence reading "the player froze
on the last frame". This is the only case in either tier that is SUPPOSED to run
out, so it gets its own fixture that nothing else may name (everything else is
sized so it cannot hit EOF mid-window, trap 9's second half), and
`_resolve_fixtures` grew the opposite duration bound: it SKIPS when the clip is
longer than 0.6x the cap, so a `--secs`-regenerated pack skips rather than failing
as a frozen player.

The SECOND half — starting the same content again — is NOT closed, and it is an
app gap rather than a test gap. `plxnative-playurl` is read behind `app.rs`'s
one-shot `auto_tried` latch, so a boot gets exactly one playback; on EOS
`finish_playback` -> `exit_player` leaves the player, and with no Plex session
there is no detail page, no Play control and no key path back in. The manifest
case carries a `_replay_note` naming the small app-side change that would close
it (`engine::start_bufferfeed` already re-reads `dev::playurl()` whenever
`route::url()` is empty), and `docs/lg-self-checklist.md` still marks the replay
half untested.

**#43 CASE1 and #14 — `tools/netcond.py` gains `rate:<kbps>`.** The proxy could
make the server dead in four ways and slow in none, so CASE1's own legs (512 Kbps
-> 1 Mbps -> 7 Mbps -> 17.5 Mbps) could not be PRODUCED and #14's degrading link
was anecdote. One token bucket for the whole proxy, because `rate:` names a link
and a link is shared; decimal kilobits, because that is the unit the item states
its legs in; empty at the start, because a full bucket hands the first
quarter-second a free burst and that is most of a short transfer; live under an
open connection, so one scripted run covers all four legs instead of four
launches. Measured through the real proxy: 512 -> 496 kbps, 2000 -> 2000,
17500 -> 17518.

Two pre-existing bugs surfaced in the code it touches, both fixed:

* **The mode SCOPE was honoured only at accept.** `serve_conn` consulted the
  scope-aware `applies()` and then handed `relay` a bare `Mode.split`, which
  discards it — so `stall@/:/timeline` really froze every open connection
  including the media stream, i.e. the exact opposite of what the scope exists
  for. Both docs claimed the working behaviour. `relay` now takes the
  connection's own first bytes.
* **The read poll's socket timeout was also the other direction's WRITE
  timeout.** Both relay threads share one pair of sockets, so `src.settimeout(0.5)`
  set the timeout on the other thread's `dst`; `sendall` on a timed-out socket
  raises having written an unspecified number of bytes, the `except OSError`
  swallowed it, and the stream truncated silently — reachable in exactly the
  situation the proxy exists to measure. The poll moved to `select` and both
  sockets are put back to blocking before relaying.

`--selftest` proves the shaper against a loopback transfer with no television in
the room, in its own temp control file so it cannot release the mode under a live
experiment.

**What this costs and what it does not prove.** The pipeline pack goes from ~0.4
to ~0.7 GB (the 4K H.264 clip is 93 MB of that) and from 8 clips to 15; resolution
is a property of the media, so a matrix cell cannot be a second case on an
existing file. Everything here is generated, so what none of it reaches is a PMS
DECISION on any of these shapes — `library_gaps` says so per entry. While
correcting those entries: `8-bit-hevc` was ALREADY covered by
`pipe_hevc_aac_mp4` (no `hdr` key, so Main / yuv420p) and the gap list had not
caught up; only `4k-h264` is newly closed.

Host-verified only — this lane has no television. `make check` is green (976 Rust
+ 47 harness tests, the harness suite now including the netcond shaper against
real loopback sockets), every fixture verifies under `make_fixtures.py`'s own
ffprobe checks, and `serve_fixtures.py` answers 206/416 with a byte-exact tail
for each new clip. The device run is the integrator's; the recipe is in the PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: the which-tier skill still said the synthetic tier was twelve cases

It is 19 as of this branch, and the number in that sentence was going to rot
again — the same way the host test count in CLAUDE.md rotted three times — so it
now points at `./tests/run.py --list` instead of restating a census.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* docs: five sentences this branch made false, one of them mine twice over

`doc-claim-auditor` over the branch. All five are contradictions, not omissions.

**The one that matters, because it is the skill whose whole subject is this
error.** `which-tier` opens by warning against "reading a bare `./tests/run.py`
as the suite it used to be" — and its pasteable `sh` block still said **12
synthetic cases**. Worse, 8ede10e fixed the identical number in that file's
PROSE two paragraphs above and left the two copies in the code block, i.e. the
half a reader copies. The file contradicted itself inside one commit. Both counts
are gone; the block now points at `--list`, which it already named two lines down,
and says why a second copy of the number does not survive here.

**`tests/fixtures/README.md` listed two gaps as unbuilt that this script builds.**
Its `library_gaps` summary still named `8-bit HEVC` and `4K H.264` — while
`manifest.json`, rewritten in the same commit, says 4K H.264 is closed by
`pipe_res_h264_uhd` and 8-bit HEVC has been covered since `pipe_hevc_aac_mp4`
landed (no `hdr` key, so `-profile:v main` / yuv420p). A reader of that page goes
off to author media that already exists. Both cut, with what a generated clip
still cannot close said plainly: a PMS DECISION on such an item.

Same sentence, pre-existing and one word: it named **`plxnative-url`** as the
trigger these are fed through. `tests/README.md` says the opposite and is right —
`plxnative-playurl` is the one carrying the DECLARATION, and several remaining
gaps (HLG, HDR10+) are *about* what the payload declares.

**Trap 9 was falsified by this branch's own fixture, 260 lines below it.** "Nothing
is ever shorter than 60 s" is now false: `pipe_h264_ac3_short` is 20 s because
ENDING is what it grades, and `_resolve_fixtures` enforces the opposite bound for
it. The new shape's comment cited "trap 9's second half" as the rule it breaks;
trap 9 itself was never told, and neither was `PIPE_SHAPES`' header, which still
said the only length constraint left was "do not hit EOF". Both now carry both
bounds, and say that adding a second short clip means picking a side.

**`_probe_fixture`'s "three of the twelve" was never right.** It is four fixtures
carrying two cases each, and it was four of twelve on `main` too — a count that
was wrong before the denominator moved. Replaced with the property (a seek case
beside its play case; an audio-lane pair), which is true at any number.

**`docs/lg-self-checklist.md` was dated the day before its own newest content** —
"Status taken 2026-08-22" above four entries that name 2026-08-23. Bumped, and the
line now says to bump it in the same edit as any row, since it is the only sentence
in that file nothing else restates.

Rejected and recorded so the next run does not re-derive them: the Makefile's
"~0.5s" harness-suite note (measured 1.22 s, hedged with a tilde AND an explicit
"measure before budgeting", subprocess count unchanged); `README.md:176`'s "two
gitignored files", false since 8a5ac95 and not this branch's; and four notes
recording the 6974 ms reporter-join measurement taken while netcond's scope was
broken — they assert the park and the mechanism, not that the media stream kept
flowing, so none is contradicted. Two more (`async-model-decision.md:399`,
`ui/library.rs:171`) described scoping as working per-request and were FALSE until
this branch fixed `relay`; they are true again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* player: a finished stream can be started again, and #46 gets both halves

The replay half of LG App Self Checklist #46 was the one thing my last PR could
not reach from `tests/`, and the reason was six lines in `app.rs`: the synthetic
tier's only entry into the player is `plxnative-playurl`, read behind a one-shot
`auto_tried` latch, so a boot got exactly one playback. On EOS `finish_playback`
→ `exit_player` leaves the player, and with no Plex session there is no detail
page, no Play control and no key path back in.

Everything else was already in place, which is why the change is small:
`teardown` clears the URL and the `ended` flag on a real stop, and
`engine::start_bufferfeed` re-reads `dev::playurl()` whenever `route::url()` is
empty. So a replay is a second trip through the entry the boot already used.

**A COUNTER re-arming the latch, not a lifted latch.** `auto_tried` also guards
the `autoplay`+`playidx` arm, which does a `request_play_movie` +
`load_detail_now` — an unconditionally re-armable latch would re-fetch a catalog
item on every player exit and loop a REAL playback forever.
`/tmp/plxnative-replay[=N]` is bounded, opt-in, read once at boot (so no file
appearing mid-run can turn it into a loop), gated on `playurl` being armed, and
declines when `finish_playback` handed off to Up Next instead — an auto-advance
chain returns to the player, and that is exactly what the route check tells
apart. An absent file is 0, so every existing boot is byte-identical.
`dev::flag`/`dev::read` are `false`/`None` at COMPILE time without `devtriggers`,
so a release build has no replay arm at all; both feature sets type-check.

`replay_budget` is split out and host-tested for `note_global_press`'s reason one
step removed: the call site is inside the SDL event loop where no host test can
reach, and this half touches no SDL. It matters more than it looks, because every
value it can return is plausible and a misparse is invisible on the panel — 0
reads as "the replay arm is missing from this binary" and 2 reads as a loop.

**The two hazards in the lanes that landed in this file since I last read it are
both safe by construction, and I checked rather than assumed.** b6's
unconsumed-press invariant lives in `note_global_press`, and this change is
nowhere near key dispatch — it adds no press path and no global side effect. b7's
recorder cannot write a bogus record for a synthetic playback either:
`coldstart_place` answers `Route::Player` from `metadata::playing()`, which is
installed ONLY by `route::apply_plan` (the PMS decision path), so a URL-fed
session has no playing item and records nothing — before this change or after it.
A replay also re-enters on the next frame, so the 800 ms post-exit hub refresh
never fires between the two viewings.

**The case.** `pipe_replay_after_eos` plays the same 20 s clip, lets it end, and
starts it again. `expect.replays` is one statement, not two: the harness writes it
into the trigger AND `a_replayed` counts it, so the number the app is told cannot
drift from the number that is graded. Three signals, each worthless alone — the
`replay:` line exactly N times (counted, because more often than asked is a loop
and a loop satisfies everything else); at least N+1 `load:` lines, since
`start_bufferfeed` writes one per SESSION and `teardown` cleared the URL, so a
second line is what says the declaration was really re-read; and a media position
that FALLS and then climbs, which is the only thing separating a restart from a
session that carried on. `server_opens_min: 2` is the wire-side half no log line
can give: the second viewing has to fetch the clip again.

`_resolve_fixtures`' EOS bound becomes per VIEWING (`dur * (1 + replays)`), so a
`--secs`-regenerated pack skips this case instead of failing it as a missing
feature. `pipe_finish_eos` stays separate and grades the finish alone: "never
ends" and "ends and cannot be restarted" are different failures, and one case
would report either as the other.

**Two prose corrections this branch's netcond findings force, both about the same
sentence.** The root `CLAUDE.md` describes scoping — "`stall@/:/timeline` freezes
the progress reporter while video keeps streaming, which is what makes a clean
experiment possible" — as a working feature. It was FALSE for as long as it
existed, because `relay` took a scope-less `Mode.split`; it became true on
2026-08-23. Said so at the sentence rather than three sentences later.

And the **6974 ms** measurement cited beside it was taken under that broken
instrument, so the proxy was stalling every connection and not only the
reporter's. **The number and the conclusion both survive, and the mechanism is
worth recording rather than re-deriving:** it was logged as `THREADJOIN timeline
6974ms` — `task::join` emits one NAMED line per join, so the attribution came
from the instrument and not from inferring a total — and `timeline` is the only
join that COULD have parked whatever else was stalled, because `engine::teardown`
step 1 deliberately wakes the other two before joining them (`http_shutdown` on
the demux socket, `aq_abort` on both AU lanes) while the reporter's POST had no
such wake. Before and after were taken the same way, so the 14x is
apples-to-apples. What CANNOT be claimed from that session is that video kept
streaming while the reporter was frozen — a property of the tool today, not of
that run. Recorded in `CLAUDE.md`, `threads.rs` and `engine.rs`, all three of
which carried the number.

Host-verified: `make check` green — 1069 Rust tests (1066 on main + 3 new) and 51
harness tests — and `--no-default-features` type-checks. No television: the device
run is the integrator's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay count is a third exception to the early-exit rule, and says so

`stream_case`'s soundness note names exactly two ABSENCE checks that early exit
cannot see, and asks that a third be REASONED ABOUT rather than added. `a_replayed`
is a third of the same shape: it grades an EQUALITY (exactly N `replay:` lines,
because more than N is a loop), and an equality can pass at N and fail at N+1.

What it cannot see, stated rather than left to be discovered: an app replaying
forever fires its next `replay:` line only after another full viewing — ~20 s on
the short clip — while the case satisfies everything else at ~28 s, so an early
exit two seconds later stops before the evidence arrives.

Not closed by making this one case burn its whole 100 s cap. That is ~1.5 min on
every suite run to guard three lines whose bound is ALREADY gradeable by `make
check`: `replay_left` is decremented before each re-arm, and `replay_budget`'s
parsing has host tests. `--no-early` is how to go looking for a loop deliberately,
and the trade is worth re-taking only if that app-side bound moves.

Also: `docs/ux-scenario.md`'s #46 row pointed at the checklist "where it is listed
as untested", which stopped being true one commit ago. It now points at the case.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

* tests: the replay assertion passed on a replay that never played, and three notes it made false

`/code-review` on the replay work, five findings, all mine, all fixed.

**The one that mattered: `a_replayed` was a false PASS in the ordering the field
will actually produce.** It measured the post-drop climb from the GLOBAL floor —
and a floor is a VALUE, so it only lands in viewing 2 when viewing 2 happens to
reach viewing 1's minimum. The `pos=` heartbeat is 1 Hz and free-running, so
viewing 1 logging `pos=0s` while viewing 2's first sample lands at `pos=1s` puts
the anchor back in viewing 1 and measures VIEWING 1'S OWN CLIMB. Reproduced
against the real function: `[0,5,10,19,1]` read as "fell 18s then climbed 19s" and
PASSED with the second viewing having produced one sample and zero seconds of
playback — defeating near-miss (e) in its own docstring, "restarted and then
stalled at the join".

Worse than a corner: the harness exits the moment every assertion passes, so that
is the state it would NORMALLY have graded. My own near-miss test passed only
because its series starts at 2 rather than 0 — exactly the accident a regression
test is for, and there is now one carrying the counterexample verbatim.

The climb is anchored at the index of the deepest DROP, which the loop computing
`drop` already had in hand.

Four more, each a sentence this branch itself made false:

* `a_finished`'s docstring still said the replay half "is unreachable from this
  tier today and it is an app gap, not a test gap … exactly one playback per boot
  and no key path back into the player" — contradicted by the `a_replayed` fifty
  lines below it, by `/tmp/plxnative-replay`, and by `pipe_replay_after_eos`, all
  added in the same change. It now points at them and says why the two cases stay
  apart.
* `_eof_note`, `make_fixtures.py` trap 9, the `pipe_h264_ac3_short` shape comment
  and `tests/README.md` all said `pipe_finish_eos` was the ONLY case allowed to
  reach EOF and the only one allowed to name that fixture. Two cases do both now.
  The rule was never "one case" anyway — it is "a case graded through a teardown
  has to have declared `reaches_eos`", which is what the unit test was deliberately
  loosened to, so the prose was the last thing still asserting the old form.
* `CLAUDE.md` and the `which-tier` skill both said "19 cases as of 2026-08-23".
  The manifest holds 20. **That count rotted inside the branch that wrote it, one
  commit after that same branch corrected the previous stale copy of it.** Both are
  now the pointer to `--list` rather than a fourth number waiting to go stale.
* `NetcondRate.setUp` leaked a `mkdtemp` per test — six `/tmp` directories per
  `make check`, on the command run most often. `addCleanup(shutil.rmtree)`, like
  every other temp use in that file. Verified: no new directories after a run.

`make check` green — 1069 Rust, 52 harness.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 2, 2026
LG App Self Checklist #46 (`pipe_replay_after_eos`) fails on the device: the
stream reaches EOS, teardown logs `stop_bufferfeed: torn down`, `app.rs` logs
`replay: starting the finished stream again (0 left)`, and the second start is
refused with `start_bufferfeed: route reducer refused a start owner` — one
Starfish Load and one HTTP fetch where the case requires two.

The test drives the real `stop_bufferfeed` teardown and then asks the reducer
for a start owner exactly as `start_bufferfeed_tracked` does. Watched RED
against this commit's parent:

    running 1 test
    test player::engine::replay_after_stop_tests::a_completed_stop_grants_the_next_start_a_route_owner ... FAILED

    thread '...' panicked at src/player/engine.rs:3273:14:
    a completed stop must grant the replay a start owner

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1917 filtered out

Co-Authored-By: Claude Fable 5.1 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 2, 2026
`engine::teardown(mt, false)` announced the stop with
`route::begin_engine_teardown(false)`, which parks the reducer in
`ControlPhase::Stopping` so a worker that was still running cannot publish into
the route being destroyed. Nothing moved it out again once the synchronous
teardown returned, so `Stopping` described a teardown that never finishes.

The UI never noticed: `begin_playback_request` already treats `Idle` and
`Stopping` alike. The dev-fixture entry does not travel that path — `app.rs`
re-arms `auto_tried`, `start_playback` calls `start_bufferfeed_tracked`, and
`route::begin_route_start` minted a transaction only from `Stable` or `Failed`.
So LG App Self Checklist #46's replay was refused outright.

- `route::finish_engine_teardown()` moves `Stopping` -> `Idle` and nothing else,
  called at the end of both `!for_reload` exits of `engine::teardown`. A reload
  keeps its own phase, which is the transaction its caller is about to start.
- `begin_route_start` accepts `Idle` beside `Failed`, both going straight to
  `Prepared`: neither owns a live Engine, so `Preparing`'s "old route is still
  recoverable" window has nothing to protect and a `NoRoute` abort out of it
  would publish `Stable` around a decoder that no longer exists.
- `engine::settle_missing_route_start` now observes `pending_route_start`
  instead of reserving through `begin_route_start`. It still settles every phase
  that really owns a transaction; it no longer mints one from a stopped reducer
  only to abort it into `Failed`.

`Stopping` still fences for the duration of the teardown
(`teardown_invalidates_the_worker_before_it_can_publish` unchanged, and the new
reducer test asserts `begin_route_start` is refused before the finish edge).

    test result: ok. 1899 passed; 0 failed  (default features)
    test result: ok. 1919 passed; 0 failed  (hostsim)

Co-Authored-By: Claude Fable 5.1 <[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.

2 participants