Repository navigation
route: honour the per-part stream selection the server already holds - #3
Merged
Merged
Conversation
We have always PUT the user's audio/subtitle pick to `/library/parts/{id}`
(`select_streams`) and never once read the selection already sitting there, so a
track chosen on a phone, in Plex Web, or on this TV in an earlier session was
silently overwritten by our own default-picking ladder on the next play.
`Stream.selected` was parsed in `plex/models.rs` and had zero readers.
It now reaches the ladder: `metadata::Stream` carries `selected`, and
`pick_dp_audio` gains a top rung preferring the server's pick, falling through to
the shipped policy (English over the file's default, then the flagged default,
then any direct-playable sibling) when there is nothing to honour.
The two gates on that rung are the design, and they come off the wire rather than
out of taste. PMS reports a selected AUDIO stream on essentially every part —
one this client has never PUT anything for still answers with the container's
default flagged `selected` — so:
* the selection must DIFFER from the file's own `default` flag. A selection
that merely echoes the default is not evidence that anyone chose anything,
and honouring it verbatim would delete the English rung, whose entire reason
to exist is that a foreign dub is often the file default. The Morning Show
reports exactly that shape (Russian default, `selected`), so obeying it
literally would have reinstated the foreign-dub-on-open bug — and turned the
harness's own audio-switch case into a no-op, since it picks that same row.
The cost is that a pick which LANDS on the default cannot round-trip; the
part carries nothing that distinguishes it, and the two things that would
(the account's defaultAudioLanguage, a remembered per-item choice) are their
own gaps. Documented at the rung.
* it must be direct-playable, or we fall through instead of forcing a transcode
to obey it. Toy Story 2/3/4 all report their TrueHD default as `selected`;
obeying that would drop the whole smart-direct-play class onto the server's
video-downscaling encoder to satisfy one audio track.
Subtitles need no such disambiguation and get the read-back too, on the
direct-play path: PMS does have a "nothing selected" state for them and uses it
(parts with a `default`-flagged subtitle come back with no selection), so a
selected subtitle is a choice. `build_stream` resolves it to the embedded-stream
ordinal the client renderer and the track menu already share
(`metadata::sub_render_ordinal`) — never a list position, and a sidecar pick is
skipped since nothing in the container would render — and `apply_plan` installs
it on the main thread after `request_play`'s reset, so the picture, the menu
checkmark and the timeline report agree. Id and ordinal travel together or not at
all: rendering a stream we cannot name would show subtitles while the menu said
Off.
The transcode path is deliberately untouched and still PUTs
`subtitleStreamID=0`. Honouring a selection there means a server-side burn — a
re-encode carrying a picture-quality cost — which is a trade to put behind a
settings surface, not to make silently at every play. A direct-played item that
later escalates to the transcoder (a DTS/TrueHD audio pick) does carry the seeded
id along, so the subtitle already on screen keeps burning.
Tests: +8 host (66). The new ones pin both gates, the fall-through order rung by
rung, and the ordinal maths against a list whose document order is not container
order with a sidecar in the middle. Every fixture is a shape the live server
actually serves — probed per identity while this landed, which is how the
`default`-echo gate was found before it broke anything.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
…n dub) Content is often authored with a foreign default-flagged audio track — The Office ships a Russian "kubik" AC3 track flagged default, so we opened on Russian even though an English EAC3 track exists. Now the decision prefers a direct-playable English track over the file's default flag, and sets the Load payload to THAT track's codec (so there's no payload/feed codec mismatch — the wedge class). route::pick_dp_audio precedence: (1) a direct-playable track in PREF_AUDIO_LANG (eng); (2) the file's default track if direct-playable; (3) any direct-playable track (smart-DP over a TrueHD/DTS default); else transcode. metadata::audio_codecs -> audio_tracks now returns (codec, languageCode) pairs. Hardcoded to English for now; trivially a per-user preference later. Verified: The Office (rk 766) opens on a=#3 (English EAC3), not the Russian default. No regression: home_alone (English is DTS/non-DP -> keeps its ac3 direct-play default, no wedge), morning_show, toy_story3 all still PASS. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
… View Finish home's retained View tree. Card gains an inherent update() that owns and steps its own focus-scale spring (moved out of Shelf::update — motion byte- identical: same 1.055/K_SCALE the ring scalar (s-1)/0.055 is tied to). Grid now formally impl View (update/layout(frame,env)/draw), keeping the two-pass focused-last z-order and its inherent nav/vert/hit_test/wheel input methods. Home impl View composes bg + hero(alpha) + grid; home_draw/home_update stay thin guarded wrappers holding frame_clear and the snap-step-before-env ordering that the trait can't sequence. Card/Shelf stay inherent hot-cells — the documented focused-last z-order carve-out (invariant #3) keeps them out of the View trait rather than adding a dead Card::draw. Verified on-device: home grid (focus ring + scale-pop + resume bars + hub titles) and hero view (backdrop + hero group + grid peek) both render pixel-identical, no perf change (40fps grid / 27fps hero). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kcauj6zm932EtcdTTtW998
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
…nent Extract the home shelf's animation state (per-cell scale springs + scroll spring) and tile rendering (poster + big glow ring + resume bar + centered title) into a new shared `ui::card_row` widget — `RowStyle::HOME` is the single source of the shelf's motion + geometry, and `CardRow`/`draw_tile`/`draw_focused` are used by BOTH the home Grid and the detail Related row. So Related is now a real instance of the same component, not a look-alike. Detail Related was the odd one out: it used the simple widgets::draw_card strip — a FIXED 1.05 focus scale (jumped) + FIXED snap scroll + radius 10 + tight ring. It now pops via an animated scale spring to 1.055, glides via an animated scroll spring, gets radius 14, the big glow ring, and a centered title — indistinguishable from a home shelf row, with an in-row focused-last pass (a lone row, no cross-row neighbour). Home stays byte-identical: the Grid keeps its two-pass CROSS-ROW focused-last orchestration and all x/base_y/env.sp math inline (invariant #3 preserved by construction); only the leaf spring state and the two cell draws route through the shared code, which reproduces every constant verbatim (CARD_RING_RAD=14.0, (s-1)/0.055, K_SCALE/K_SCROLL, resume offsets). widgets::draw_poster deleted (its sole caller, home, now uses card_row). Designed by a map->judge-panel->plan workflow; the applied diff was adversarially reviewed for home byte-identical parity (clean, no pixel drift). Build green. On-device verification (home before/after pixel-diff + Related animation) is PENDING — TV was in use; to check when free. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kcauj6zm932EtcdTTtW998
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
A decoded PGS/VobSub rect's x/y/w/h are in the SUBTITLE stream's own authoring canvas, not in screen pixels. We composited them 1:1 into our 1920x1080 UI and said so in a comment — which is right for Blu-ray PGS and wrong for everything else: a DVD VobSub rip is authored on 720x480, so it landed as a postage stamp in the upper-left quadrant, and a 4K-authored PGS track drew at double size with half of it off the panel. The track menu offers those tracks and badges them, so the failure was reachable from the UI with no warning. The canvas now comes off the decoder and travels with the cue to the renderer, which stretches the display set into the video rect — the same stretch the TV applies to the picture itself, since a subtitle canvas is the video's own storage grid. A 1920x1080 canvas is exactly identity, so every PGS track in the library renders as it did before; an undeclared canvas (0) falls back to 1:1, which is what the whole path did unconditionally. Reading it is FFI into the TV's own libavcodec, so it is done WITHOUT a new struct offset: `avcodec_parameters_from_context` copies the decoder's dimensions into the AVCodecParameters this crate already models, so the read runs inside the library's own code. That it does so for subtitles at all is not a header claim — the device's `libavcodec.so.57.89.100` is stripped, so the subtitle case (`cmp r3,#3`) and the exact loads (`ldr r2,[r5,#124] / ldr r3,[r5,#128]` into par+48/+52) were read out of its disassembly, which incidentally corroborates `OFF_CTX_WIDTH`/`OFF_CTX_HEIGHT` and the modeled sizeof=136. A canvas outside 160..8192 is reported as unknown rather than used, because scaling by a garbage ratio is worse than not scaling at all. Two smaller fidelity losses on the same path, both from the same audit entry: * EVERY rect of a display set is decoded and drawn, not just rect 0. Two-line dialogue and sign-plus-dialogue are authored as separate rects of one set, so the old code silently dropped half the line and logged that it had. The store now holds a set of rects per cue, which also makes the supersede rule correct by construction — pushing rects individually would have had the second one close the first at its own start. The 24 MB ceiling counts a set's rects together, and a pathological set is capped at 8 rects. * image cues lift clear of the transport like text cues do. They lift by their overhang rather than by a fixed offset, so a full-height set is clamped instead of pushed off screen. The shift is measured over — and applied to — only the rects that actually overhang: measuring the whole set lets a sign at y=100 clamp the lift to 100, sliding the sign for no reason and leaving the dialogue behind the scrim anyway. It is not per-rect either, because two-line dialogue is two rects with different overhangs and lifting each by its own collapses them onto each other. Both paths now take the same `subs_lift` expression from app.rs (an open track menu counts — that is exactly when the bottom of the screen is being read) and share the baseline/ceiling constants. The store's byte ceiling had to change ends. `v[0]` is the cue AT the playhead once the time-retain has run, and the tail is the demuxer's 10-20s read-ahead, so evicting index 0 blanked the subtitle being read while keeping cues nobody had reached. A set costing up to 8 rects instead of 1 is what made that reachable. It now drops a cue the playhead has already passed, and only falls back to the far end of the read-ahead when there is none; the test fails against the old policy. Two guards on the decode side went in with it: `rect_to_rgba` null-checks the rect (the loop walks up to 8 now, not just [0]) and bounds w/h before multiplying, since `usize` is 32 bits here and a wrapped `w*h*4` would size the buffer below what the write loop and glTexImage2D then read. The renderer keeps one texture per rect and re-specs the ids it can reuse, so the steady one-rect case still never allocates twice; its cache key gains the selected track, because two image tracks of one file routinely start a display set on the same pts and the timestamp alone left the outgoing track on screen. Tests: +7 host (65) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc
GLinnik21
added a commit
that referenced
this pull request
Aug 23, 2026
`doc-claim-auditor` on the coldstart diff. Two were caused by it and four were
already false in prose the diff touches — all six are the same failure mode, a
sentence that was true when written and that nothing compiles.
CAUSED BY THIS CHANGE:
* The release-notes **"written outside its own directory"** row (TEMPLATE.md and
README.md) listed the three logs and the session file. `coldstart` is NOT
behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a
release build, so `arm()` always runs — and it writes a second file into
`/media/{developer,internal}`. That row's whole value is being exhaustive; it
is a gate item, and README's own standard is that "a property stated in a form
that fails the reader's own check reads as a lie". Now names the file and what
is in it: the page, the profile id, one server/item id, no token, no position.
* **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to
disk is the credentials session", and the same claim again 400 lines later.
There are two files now, and the new one is the precedent that gap's own
*Where:* asks for ("a new preferences file alongside plex/session.rs"), so the
sentence said the thing it wanted did not exist.
ALREADY FALSE, in the same prose:
* `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and
the release-notes template's disclosure row and its worked example. Identical
string to the three img.rs comments this branch already fixed, stale since
6d79230 (2026-08-22), and each one cites `distribution.md` §6.10 as its
source — the section that says the "~74 MB peak" was never a measurement and
that the number is 160 against a measured 152 MiB. The template would have had
the next release publicly disclose a defect that is fixed.
* **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so
link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (56147f1)
and `stub/` was deleted (72b7d71). Three lines below the line this branch
added, in the list a newcomer reads first.
* **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked
transfer" — the exact sentence the root CLAUDE.md holds up as this repo's
archetypal false claim, surviving in another file. `stream.rs` decodes chunked;
its only disqualifiers are DNS and TLS.
Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does
not list the new per-install file, and that section refuses to be trusted as a
list by construction ("re-derived against the tree, not inherited"); the dated
`*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and
`lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true.
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
… real socket
CI was red on Linux with `thread '<unknown>' has overflowed its stack`,
at a different point in the output each run, while `make check` passed on
the dev Mac. The mechanism is not serde_json and not the session file.
`moving_a_server_to_https_re_points_its_slot` called the public
`register_origin`, where every other test in this module deliberately
goes through `register_with_client_id`. The public path fires
`serverinfo::refresh`, which spawns a `task::spawn_small` worker that
really opens a socket — and in a DEBUG build `stream::http_stream_boxed`
materialises its 64 KiB `HttpStream` as a STACK temporary before it ever
reaches the heap, despite the comment above it promising the opposite
("box it off the caller's stack"). lldb caught it on the guard page:
frame #0 stream::http_stream_boxed
frame #1 stream::http_get(host="10.0.0.1", port=32400, …)
frame #2 Client::get_json
frame #3 Client::server_root
frame #4 serverinfo::fetch_once
frame #5 serverinfo::refresh::{closure#0} <- spawn_small, 256 KiB
Measured on this branch by varying `SMALL_STACK`: debug overflows at 48,
128 and 192 KiB on ARM64 and needs more than 256 KiB on x86-64, which is
exactly why one host passed and the other did not. **`--release` passes at
48 KiB**, so the optimizer elides the temporary and the television — which
ships `cargo build --release` (Makefile:438) — is not affected. It is a
latent debug-only hazard in `stream.rs`, pre-existing and not this
branch's to fix; the base simply had no host test that reached
`http_get` from a `spawn_small` worker. Reported on the PR.
The fix is the test, which was wrong on its own terms: `register` also
mints and PERSISTS a client-id uuid, and that seam's doc has said since it
was written that a host test must not write one. It gains an origin-taking
sibling (the pair-shaped one cannot express a scheme, which is what this
test is about) and a second documented reason nobody had paid for yet.
Verified with the same differential that found it: at `SMALL_STACK = 48 *
1024` the branch was 3/3 aborts and is now 3/3 clean, 997 tests, both
`--test-threads=1` and parallel. `task.rs` is untouched.
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 never rebuilt from one (#53) * transport: an Origin is what a server's address IS, and it is parsed from a URL Everything below the transport carried a server's address as a bare `(host, port)` pair. That pair cannot say `https`, and — the half that matters — it cannot be *made* to say it afterwards, because the host a `plex.direct` certificate is issued for is the HOSTNAME plex.tv puts in `Connection.uri`, while `Connection.address` stays the dotted quad behind it. `probe.rs` has said so in prose since it was written ("https to the bare IP fails validation by design"), and `auth::resolve_roster` then threw `Candidate::url` away and wrote `address` into the session file. A later lane adding a `scheme` field on top of that would have produced a control plane that looks like it speaks TLS and fails hostname validation on every real server. So: `plex::Origin` — scheme + host + port, parsed from a URL by `Origin::parse`, never assembled from an address. `Candidate::origin()` is the one derivation; `Candidate::address` is documented down to what it actually is, the diagnostic half. Threaded through every site that passed a bare pair: `Client` (with `host()`/`port()` kept as views, so the ~30 call sites below the layer are untouched), `StreamUrl` and its two construction sites, `register_origin`/`install`, `SourceRef`/`ServerRef`, `ReadyCreds`, `app.rs`'s boot gate and `install_pms`, and the engine's URL splitter. `dev::DevServer` gains an optional `scheme`, which is how an https origin can be exercised headlessly through the `plxnative-servers` trigger by anyone who has no such server to discover. Two invariants are pinned by tests rather than left to prose. `Origin::host()` is ALWAYS unbracketed — it is the `getaddrinfo` node — and `Origin::authority()` ALWAYS brackets a v6 literal, because it is URL serialization; `probe::host_of` returned the bracketed spelling and is gone, replaced by one shared reading of a URL. And a session file written by 0.4.1, carrying `address`/`port` and no origin, must still boot as `http://{address}:{port}`: `Session::server` is not a soft-parsed roster entry, so dropping it is a silent sign-out at every boot for every existing user. Both have a test with a literal 0.4.1-shaped JSON string. NO BEHAVIOUR CHANGE. Every origin is still `http://` and dials the same address: `dial_target` accepts only a plain-http IPv4 candidate, whose URL `probe::candidates` synthesized as `http://{address}:{port}`, so the parsed origin and the old pair are equal today — asserted, not assumed. The registry's two log lines now print `origin.authority()`, which is byte-identical for every http/IPv4 origin and correct for a v6 literal, which `{host}:{port}` could not spell at all. 996 host tests pass. A simulator boot against a real PMS produces an event log identical to the pre-change one on all 30 non-heartbeat lines; the three `loop=`/`fps=` lines vary run to run on an unchanged binary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: name what the origin model made stale, rather than leaving it to rot `plex/CLAUDE.md` and `servers.rs`/`client.rs`'s module docs described the registry in terms of `(host, port)`, which is the shape the change replaced. `docs/plex-api-design.md` is a design note whose sketches were the implementation of their day — it gets a banner naming the one thing in it that would now mislead (rule 9, "Numeric host, no DNS", and the two struct sketches), not a rewrite. `docs/shared-servers.md` §7 gains the `plxnative-servers` trigger's new `scheme` field, which is the only way to put a TLS origin through the registry without an account that has one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * session: the stored origin field is `origin_url`, so it cannot be mistaken for `origin()` `SourceRef`/`ServerRef` had a FIELD `origin` (the serialized string) beside a METHOD `origin()` (the parsed value). Rust puts those in different namespaces so it compiles either way, which is exactly the problem: two characters separate "the raw JSON string" from "the thing to dial", at every use, forever. The field takes the `_url` suffix; `#[serde(rename)]` keeps the FILE's key spelled `origin`, which is what a human editing a session file on the television reads, and the round-trip test proves the rename applies to both halves of serde. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * review: close the gap between the origin that was DIALLED and the one recorded Eight findings from `/code-review high`; six fixed, two answered in prose. **The one that mattered.** `resolve_roster` recorded `Candidate::origin()` while `probe_server` dialled `(&c.address, dial_port(c.port))`, and the comment justifying that divergence was wrong about its own gate: `dial_target` checks `is_ipv4_literal(&c.address)`, which admits a plex.tv-advertised `uri` candidate and not only the synthesized twin. A connection whose `uri` names a different port from `port` would be verified at one and written into the session file as the other, and every later request would go somewhere nothing ever answered from. So `dial_target` now returns the ORIGIN, `probe_server` dials that origin's host and port, and `Reach::At` carries it back beside the candidate — one value, so what answered and what is recorded cannot be two addresses. The candidate stays for the diagnostic fields. Its fixture had `url` and `port` disagreeing, which is what let the old shape look consistent; it builds both from one pair now, as `probe::candidates` does. **The silent-instrument trap, twice.** `dev::DevServer`'s `scheme` field exists so a lane with no TLS server of its own can put an https origin through the registry — and both registry log lines and `DevServer:: describe` printed `host:port`, so such a run was byte-identical to an http one. `Origin::log_form()` is the shared answer: the bare authority for a plaintext origin (an archived log stays comparable, and the byte-identical gate holds) and the whole URL as soon as the scheme is worth saying. **`player::engine` REFUSES a TLS stream target** instead of silently downgrading it, which is what the code did while its comment claimed the opposite. It is reachable today: a client registered at an https origin copies that origin into `direct_play_url`/`transcode_start_url`, so `route` would store an https URL and the engine would open a plaintext socket to it. Also: an EMPTY port (`http://h:`) is a port that was WRITTEN and cannot be dialled, so `Origin::parse` refuses it rather than defaulting to 32400 — a truncated write of the session file is exactly the "port nobody wrote down" case `dial_port` exists for. And `reconcile_primary` no longer logs "primary now answers at …" when the only thing that changed was the stored origin going from empty to populated, which is what the FIRST BOOT after this lands does on every existing install — a false DHCP-churn report in the file this project treats as its primary evidence surface. Answered rather than changed: `Origin::port`'s doc claimed a narrowing one constructor does not perform (`ServerRef::origin`'s legacy `port as i32`), so the doc now says where the narrowing really lives; and `Session::can_go_local` still asks "is there an address written down" rather than "can THIS build's transport open it" — gating it would send a user to a QR code for a transport gap that is not theirs, and the half-landed state it exposes is named in the doc and refused out loud one layer down, in the engine. 997 host tests pass. The simulator event log is still identical to the pre-change one on all 30 non-heartbeat lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * tests: a registry test must not call the PUBLIC register — it opens a real socket CI was red on Linux with `thread '<unknown>' has overflowed its stack`, at a different point in the output each run, while `make check` passed on the dev Mac. The mechanism is not serde_json and not the session file. `moving_a_server_to_https_re_points_its_slot` called the public `register_origin`, where every other test in this module deliberately goes through `register_with_client_id`. The public path fires `serverinfo::refresh`, which spawns a `task::spawn_small` worker that really opens a socket — and in a DEBUG build `stream::http_stream_boxed` materialises its 64 KiB `HttpStream` as a STACK temporary before it ever reaches the heap, despite the comment above it promising the opposite ("box it off the caller's stack"). lldb caught it on the guard page: frame #0 stream::http_stream_boxed frame #1 stream::http_get(host="10.0.0.1", port=32400, …) frame #2 Client::get_json frame #3 Client::server_root frame #4 serverinfo::fetch_once frame #5 serverinfo::refresh::{closure#0} <- spawn_small, 256 KiB Measured on this branch by varying `SMALL_STACK`: debug overflows at 48, 128 and 192 KiB on ARM64 and needs more than 256 KiB on x86-64, which is exactly why one host passed and the other did not. **`--release` passes at 48 KiB**, so the optimizer elides the temporary and the television — which ships `cargo build --release` (Makefile:438) — is not affected. It is a latent debug-only hazard in `stream.rs`, pre-existing and not this branch's to fix; the base simply had no host test that reached `http_get` from a `spawn_small` worker. Reported on the PR. The fix is the test, which was wrong on its own terms: `register` also mints and PERSISTS a client-id uuid, and that seam's doc has said since it was written that a host test must not write one. It gains an origin-taking sibling (the pair-shaped one cannot express a scheme, which is what this test is about) and a second documented reason nobody had paid for yet. Verified with the same differential that found it: at `SMALL_STACK = 48 * 1024` the branch was 3/3 aborts and is now 3/3 clean, 997 tests, both `--test-threads=1` and parallel. `task.rs` is untouched. 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 23, 2026
…k there (#56) * coldstart: the app writes down where it was, and a cold boot goes back there The app-switch lifecycle was already handled properly, and all of it lives in the PROCESS: background suspends the buffer-feed and drops to Home, foreground reloads and resumes at the saved position with one Load. A COLD start — the set powered off and on, the mains pulled, the app closed from the Recent List — begins with a process that has seen none of that, and the boot route came purely from credential state. Where you actually were was written down nowhere. That is the persistence half of LG App Self Checklist #3 (Reboot). `rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at boot. A playback session records the played leaf and is restored to that item's DETAIL page, never to the player: coming out of a power cycle into a decoding video is an ambush, and the resume point is the server's `viewOffset` anyway. Three decisions worth carrying: * **Not the runtime root**, though that is the obvious home for a file this small. `/tmp` on a television is cleared by a reboot — this repo already leans on that in the other direction, since `tools/tv-lock.sh` puts the device lease there BECAUSE a reboot should release it — so a cold-start restore living there would be erased by the cold start. It goes where the session file goes (`paths::last_place_candidates`). Two smaller wins fall out: the name is outside the `plxnative-*` trigger namespace, so it cannot suppress the who's-watching picker the way a state file in `/tmp` would have, and it is outside the glob `tests/run.py` sweeps. * **Not in `Session`.** That file fails as a unit and a parse failure there is a silent sign-out at every boot; every list in it is soft-parsed for exactly that reason. A convenience feature has no business in that blast radius, so this owns its own file, its own format, and fails soft to today's behaviour on every path — absent, empty, truncated, hand-edited, unknown version, foreign profile, a server no longer registered. * **Two rules that stop the feature erasing its own state.** Nothing is recorded until the boot SEQUENCE has ended, because the sign-in, the picker and the first-run question all hand over to Home when answered — a recorder open through that window writes `home` over the record before anyone can ask for it, permanently, for exactly the multi-profile household the profile key exists for. And Home is recorded as a RETURN, never as a landing, so a boot whose restore was declined (the item's server not re-registered yet) does not destroy the record on its way past. Nothing is recorded on an AUTOMATED boot, which is where the harness's determinism is bought: this file is outside the glob `tests/run.py` clears, so refusing to arm is the only place that can be done. `pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and `nativeLifeCycleInterfaceVersion` are documented in the module and left alone — neither is evidence about a native app's cold-boot behaviour on this firmware, and the verdict for #3 belongs to the device matrix in the PR body. Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160. Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real two-boot round trip in the simulator — navigate to a detail page, close, relaunch, and the app comes up on that page; BACK then records Home; an automated boot neither records nor restores; a truncated record boots to Home. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: the six claims this change made false, and four it only sat beside `doc-claim-auditor` on the coldstart diff. Two were caused by it and four were already false in prose the diff touches — all six are the same failure mode, a sentence that was true when written and that nothing compiles. CAUSED BY THIS CHANGE: * The release-notes **"written outside its own directory"** row (TEMPLATE.md and README.md) listed the three logs and the session file. `coldstart` is NOT behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a release build, so `arm()` always runs — and it writes a second file into `/media/{developer,internal}`. That row's whole value is being exhaustive; it is a gate item, and README's own standard is that "a property stated in a form that fails the reader's own check reads as a lie". Now names the file and what is in it: the page, the profile id, one server/item id, no token, no position. * **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to disk is the credentials session", and the same claim again 400 lines later. There are two files now, and the new one is the precedent that gap's own *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the sentence said the thing it wanted did not exist. ALREADY FALSE, in the same prose: * `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and the release-notes template's disclosure row and its worked example. Identical string to the three img.rs comments this branch already fixed, stale since 6d79230 (2026-08-22), and each one cites `distribution.md` §6.10 as its source — the section that says the "~74 MB peak" was never a measurement and that the number is 160 against a measured 152 MiB. The template would have had the next release publicly disclose a defect that is fixed. * **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (56147f1) and `stub/` was deleted (72b7d71). Three lines below the line this branch added, in the list a newcomer reads first. * **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked transfer" — the exact sentence the root CLAUDE.md holds up as this repo's archetypal false claim, surviving in another file. `stream.rs` decodes chunked; its only disqualifiers are DNS and TLS. Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does not list the new per-install file, and that section refuses to be trusted as a list by construction ("re-derived against the tree, not inherited"); the dated `*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and `lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true. 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
…n dub) Content is often authored with a foreign default-flagged audio track — The Office ships a Russian "kubik" AC3 track flagged default, so we opened on Russian even though an English EAC3 track exists. Now the decision prefers a direct-playable English track over the file's default flag, and sets the Load payload to THAT track's codec (so there's no payload/feed codec mismatch — the wedge class). route::pick_dp_audio precedence: (1) a direct-playable track in PREF_AUDIO_LANG (eng); (2) the file's default track if direct-playable; (3) any direct-playable track (smart-DP over a TrueHD/DTS default); else transcode. metadata::audio_codecs -> audio_tracks now returns (codec, languageCode) pairs. Hardcoded to English for now; trivially a per-user preference later. Verified: The Office (rk 766) opens on a=#3 (English EAC3), not the Russian default. No regression: home_alone (English is DTS/non-DP -> keeps its ac3 direct-play default, no wedge), morning_show, toy_story3 all still PASS. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018QbpQTKYjwp6fDNLdXzGzr
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
… View Finish home's retained View tree. Card gains an inherent update() that owns and steps its own focus-scale spring (moved out of Shelf::update — motion byte- identical: same 1.055/K_SCALE the ring scalar (s-1)/0.055 is tied to). Grid now formally impl View (update/layout(frame,env)/draw), keeping the two-pass focused-last z-order and its inherent nav/vert/hit_test/wheel input methods. Home impl View composes bg + hero(alpha) + grid; home_draw/home_update stay thin guarded wrappers holding frame_clear and the snap-step-before-env ordering that the trait can't sequence. Card/Shelf stay inherent hot-cells — the documented focused-last z-order carve-out (invariant #3) keeps them out of the View trait rather than adding a dead Card::draw. Verified on-device: home grid (focus ring + scale-pop + resume bars + hub titles) and hero view (backdrop + hero group + grid peek) both render pixel-identical, no perf change (40fps grid / 27fps hero). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kcauj6zm932EtcdTTtW998
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
…nent Extract the home shelf's animation state (per-cell scale springs + scroll spring) and tile rendering (poster + big glow ring + resume bar + centered title) into a new shared `ui::card_row` widget — `RowStyle::HOME` is the single source of the shelf's motion + geometry, and `CardRow`/`draw_tile`/`draw_focused` are used by BOTH the home Grid and the detail Related row. So Related is now a real instance of the same component, not a look-alike. Detail Related was the odd one out: it used the simple widgets::draw_card strip — a FIXED 1.05 focus scale (jumped) + FIXED snap scroll + radius 10 + tight ring. It now pops via an animated scale spring to 1.055, glides via an animated scroll spring, gets radius 14, the big glow ring, and a centered title — indistinguishable from a home shelf row, with an in-row focused-last pass (a lone row, no cross-row neighbour). Home stays byte-identical: the Grid keeps its two-pass CROSS-ROW focused-last orchestration and all x/base_y/env.sp math inline (invariant #3 preserved by construction); only the leaf spring state and the two cell draws route through the shared code, which reproduces every constant verbatim (CARD_RING_RAD=14.0, (s-1)/0.055, K_SCALE/K_SCROLL, resume offsets). widgets::draw_poster deleted (its sole caller, home, now uses card_row). Designed by a map->judge-panel->plan workflow; the applied diff was adversarially reviewed for home byte-identical parity (clean, no pixel drift). Build green. On-device verification (home before/after pixel-diff + Related animation) is PENDING — TV was in use; to check when free. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kcauj6zm932EtcdTTtW998
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
A decoded PGS/VobSub rect's x/y/w/h are in the SUBTITLE stream's own authoring canvas, not in screen pixels. We composited them 1:1 into our 1920x1080 UI and said so in a comment — which is right for Blu-ray PGS and wrong for everything else: a DVD VobSub rip is authored on 720x480, so it landed as a postage stamp in the upper-left quadrant, and a 4K-authored PGS track drew at double size with half of it off the panel. The track menu offers those tracks and badges them, so the failure was reachable from the UI with no warning. The canvas now comes off the decoder and travels with the cue to the renderer, which stretches the display set into the video rect — the same stretch the TV applies to the picture itself, since a subtitle canvas is the video's own storage grid. A 1920x1080 canvas is exactly identity, so every PGS track in the library renders as it did before; an undeclared canvas (0) falls back to 1:1, which is what the whole path did unconditionally. Reading it is FFI into the TV's own libavcodec, so it is done WITHOUT a new struct offset: `avcodec_parameters_from_context` copies the decoder's dimensions into the AVCodecParameters this crate already models, so the read runs inside the library's own code. That it does so for subtitles at all is not a header claim — the device's `libavcodec.so.57.89.100` is stripped, so the subtitle case (`cmp r3,#3`) and the exact loads (`ldr r2,[r5,#124] / ldr r3,[r5,#128]` into par+48/+52) were read out of its disassembly, which incidentally corroborates `OFF_CTX_WIDTH`/`OFF_CTX_HEIGHT` and the modeled sizeof=136. A canvas outside 160..8192 is reported as unknown rather than used, because scaling by a garbage ratio is worse than not scaling at all. Two smaller fidelity losses on the same path, both from the same audit entry: * EVERY rect of a display set is decoded and drawn, not just rect 0. Two-line dialogue and sign-plus-dialogue are authored as separate rects of one set, so the old code silently dropped half the line and logged that it had. The store now holds a set of rects per cue, which also makes the supersede rule correct by construction — pushing rects individually would have had the second one close the first at its own start. The 24 MB ceiling counts a set's rects together, and a pathological set is capped at 8 rects. * image cues lift clear of the transport like text cues do. They lift by their overhang rather than by a fixed offset, so a full-height set is clamped instead of pushed off screen. The shift is measured over — and applied to — only the rects that actually overhang: measuring the whole set lets a sign at y=100 clamp the lift to 100, sliding the sign for no reason and leaving the dialogue behind the scrim anyway. It is not per-rect either, because two-line dialogue is two rects with different overhangs and lifting each by its own collapses them onto each other. Both paths now take the same `subs_lift` expression from app.rs (an open track menu counts — that is exactly when the bottom of the screen is being read) and share the baseline/ceiling constants. The store's byte ceiling had to change ends. `v[0]` is the cue AT the playhead once the time-retain has run, and the tail is the demuxer's 10-20s read-ahead, so evicting index 0 blanked the subtitle being read while keeping cues nobody had reached. A set costing up to 8 rects instead of 1 is what made that reachable. It now drops a cue the playhead has already passed, and only falls back to the far end of the read-ahead when there is none; the test fails against the old policy. Two guards on the decode side went in with it: `rect_to_rgba` null-checks the rect (the loop walks up to 8 now, not just [0]) and bounds w/h before multiplying, since `usize` is 32 bits here and a wrapped `w*h*4` would size the buffer below what the write loop and glTexImage2D then read. The renderer keeps one texture per rect and re-specs the ids it can reuse, so the steady one-rect case still never allocates twice; its cache key gains the selected track, because two image tracks of one file routinely start a display set on the same pts and the timestamp alone left the outgoing track on screen. Tests: +7 host (65) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc
GLinnik21
added a commit
that referenced
this pull request
Aug 26, 2026
… and never rebuilt from one (#53) * transport: an Origin is what a server's address IS, and it is parsed from a URL Everything below the transport carried a server's address as a bare `(host, port)` pair. That pair cannot say `https`, and — the half that matters — it cannot be *made* to say it afterwards, because the host a `plex.direct` certificate is issued for is the HOSTNAME plex.tv puts in `Connection.uri`, while `Connection.address` stays the dotted quad behind it. `probe.rs` has said so in prose since it was written ("https to the bare IP fails validation by design"), and `auth::resolve_roster` then threw `Candidate::url` away and wrote `address` into the session file. A later lane adding a `scheme` field on top of that would have produced a control plane that looks like it speaks TLS and fails hostname validation on every real server. So: `plex::Origin` — scheme + host + port, parsed from a URL by `Origin::parse`, never assembled from an address. `Candidate::origin()` is the one derivation; `Candidate::address` is documented down to what it actually is, the diagnostic half. Threaded through every site that passed a bare pair: `Client` (with `host()`/`port()` kept as views, so the ~30 call sites below the layer are untouched), `StreamUrl` and its two construction sites, `register_origin`/`install`, `SourceRef`/`ServerRef`, `ReadyCreds`, `app.rs`'s boot gate and `install_pms`, and the engine's URL splitter. `dev::DevServer` gains an optional `scheme`, which is how an https origin can be exercised headlessly through the `plxnative-servers` trigger by anyone who has no such server to discover. Two invariants are pinned by tests rather than left to prose. `Origin::host()` is ALWAYS unbracketed — it is the `getaddrinfo` node — and `Origin::authority()` ALWAYS brackets a v6 literal, because it is URL serialization; `probe::host_of` returned the bracketed spelling and is gone, replaced by one shared reading of a URL. And a session file written by 0.4.1, carrying `address`/`port` and no origin, must still boot as `http://{address}:{port}`: `Session::server` is not a soft-parsed roster entry, so dropping it is a silent sign-out at every boot for every existing user. Both have a test with a literal 0.4.1-shaped JSON string. NO BEHAVIOUR CHANGE. Every origin is still `http://` and dials the same address: `dial_target` accepts only a plain-http IPv4 candidate, whose URL `probe::candidates` synthesized as `http://{address}:{port}`, so the parsed origin and the old pair are equal today — asserted, not assumed. The registry's two log lines now print `origin.authority()`, which is byte-identical for every http/IPv4 origin and correct for a v6 literal, which `{host}:{port}` could not spell at all. 996 host tests pass. A simulator boot against a real PMS produces an event log identical to the pre-change one on all 30 non-heartbeat lines; the three `loop=`/`fps=` lines vary run to run on an unchanged binary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: name what the origin model made stale, rather than leaving it to rot `plex/CLAUDE.md` and `servers.rs`/`client.rs`'s module docs described the registry in terms of `(host, port)`, which is the shape the change replaced. `docs/plex-api-design.md` is a design note whose sketches were the implementation of their day — it gets a banner naming the one thing in it that would now mislead (rule 9, "Numeric host, no DNS", and the two struct sketches), not a rewrite. `docs/shared-servers.md` §7 gains the `plxnative-servers` trigger's new `scheme` field, which is the only way to put a TLS origin through the registry without an account that has one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * session: the stored origin field is `origin_url`, so it cannot be mistaken for `origin()` `SourceRef`/`ServerRef` had a FIELD `origin` (the serialized string) beside a METHOD `origin()` (the parsed value). Rust puts those in different namespaces so it compiles either way, which is exactly the problem: two characters separate "the raw JSON string" from "the thing to dial", at every use, forever. The field takes the `_url` suffix; `#[serde(rename)]` keeps the FILE's key spelled `origin`, which is what a human editing a session file on the television reads, and the round-trip test proves the rename applies to both halves of serde. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * review: close the gap between the origin that was DIALLED and the one recorded Eight findings from `/code-review high`; six fixed, two answered in prose. **The one that mattered.** `resolve_roster` recorded `Candidate::origin()` while `probe_server` dialled `(&c.address, dial_port(c.port))`, and the comment justifying that divergence was wrong about its own gate: `dial_target` checks `is_ipv4_literal(&c.address)`, which admits a plex.tv-advertised `uri` candidate and not only the synthesized twin. A connection whose `uri` names a different port from `port` would be verified at one and written into the session file as the other, and every later request would go somewhere nothing ever answered from. So `dial_target` now returns the ORIGIN, `probe_server` dials that origin's host and port, and `Reach::At` carries it back beside the candidate — one value, so what answered and what is recorded cannot be two addresses. The candidate stays for the diagnostic fields. Its fixture had `url` and `port` disagreeing, which is what let the old shape look consistent; it builds both from one pair now, as `probe::candidates` does. **The silent-instrument trap, twice.** `dev::DevServer`'s `scheme` field exists so a lane with no TLS server of its own can put an https origin through the registry — and both registry log lines and `DevServer:: describe` printed `host:port`, so such a run was byte-identical to an http one. `Origin::log_form()` is the shared answer: the bare authority for a plaintext origin (an archived log stays comparable, and the byte-identical gate holds) and the whole URL as soon as the scheme is worth saying. **`player::engine` REFUSES a TLS stream target** instead of silently downgrading it, which is what the code did while its comment claimed the opposite. It is reachable today: a client registered at an https origin copies that origin into `direct_play_url`/`transcode_start_url`, so `route` would store an https URL and the engine would open a plaintext socket to it. Also: an EMPTY port (`http://h:`) is a port that was WRITTEN and cannot be dialled, so `Origin::parse` refuses it rather than defaulting to 32400 — a truncated write of the session file is exactly the "port nobody wrote down" case `dial_port` exists for. And `reconcile_primary` no longer logs "primary now answers at …" when the only thing that changed was the stored origin going from empty to populated, which is what the FIRST BOOT after this lands does on every existing install — a false DHCP-churn report in the file this project treats as its primary evidence surface. Answered rather than changed: `Origin::port`'s doc claimed a narrowing one constructor does not perform (`ServerRef::origin`'s legacy `port as i32`), so the doc now says where the narrowing really lives; and `Session::can_go_local` still asks "is there an address written down" rather than "can THIS build's transport open it" — gating it would send a user to a QR code for a transport gap that is not theirs, and the half-landed state it exposes is named in the doc and refused out loud one layer down, in the engine. 997 host tests pass. The simulator event log is still identical to the pre-change one on all 30 non-heartbeat lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * tests: a registry test must not call the PUBLIC register — it opens a real socket CI was red on Linux with `thread '<unknown>' has overflowed its stack`, at a different point in the output each run, while `make check` passed on the dev Mac. The mechanism is not serde_json and not the session file. `moving_a_server_to_https_re_points_its_slot` called the public `register_origin`, where every other test in this module deliberately goes through `register_with_client_id`. The public path fires `serverinfo::refresh`, which spawns a `task::spawn_small` worker that really opens a socket — and in a DEBUG build `stream::http_stream_boxed` materialises its 64 KiB `HttpStream` as a STACK temporary before it ever reaches the heap, despite the comment above it promising the opposite ("box it off the caller's stack"). lldb caught it on the guard page: frame #0 stream::http_stream_boxed frame #1 stream::http_get(host="10.0.0.1", port=32400, …) frame #2 Client::get_json frame #3 Client::server_root frame #4 serverinfo::fetch_once frame #5 serverinfo::refresh::{closure#0} <- spawn_small, 256 KiB Measured on this branch by varying `SMALL_STACK`: debug overflows at 48, 128 and 192 KiB on ARM64 and needs more than 256 KiB on x86-64, which is exactly why one host passed and the other did not. **`--release` passes at 48 KiB**, so the optimizer elides the temporary and the television — which ships `cargo build --release` (Makefile:438) — is not affected. It is a latent debug-only hazard in `stream.rs`, pre-existing and not this branch's to fix; the base simply had no host test that reached `http_get` from a `spawn_small` worker. Reported on the PR. The fix is the test, which was wrong on its own terms: `register` also mints and PERSISTS a client-id uuid, and that seam's doc has said since it was written that a host test must not write one. It gains an origin-taking sibling (the pair-shaped one cannot express a scheme, which is what this test is about) and a second documented reason nobody had paid for yet. Verified with the same differential that found it: at `SMALL_STACK = 48 * 1024` the branch was 3/3 aborts and is now 3/3 clean, 997 tests, both `--test-threads=1` and parallel. `task.rs` is untouched. 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
…k there (#56) * coldstart: the app writes down where it was, and a cold boot goes back there The app-switch lifecycle was already handled properly, and all of it lives in the PROCESS: background suspends the buffer-feed and drops to Home, foreground reloads and resumes at the saved position with one Load. A COLD start — the set powered off and on, the mains pulled, the app closed from the Recent List — begins with a process that has seen none of that, and the boot route came purely from credential state. Where you actually were was written down nowhere. That is the persistence half of LG App Self Checklist #3 (Reboot). `rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at boot. A playback session records the played leaf and is restored to that item's DETAIL page, never to the player: coming out of a power cycle into a decoding video is an ambush, and the resume point is the server's `viewOffset` anyway. Three decisions worth carrying: * **Not the runtime root**, though that is the obvious home for a file this small. `/tmp` on a television is cleared by a reboot — this repo already leans on that in the other direction, since `tools/tv-lock.sh` puts the device lease there BECAUSE a reboot should release it — so a cold-start restore living there would be erased by the cold start. It goes where the session file goes (`paths::last_place_candidates`). Two smaller wins fall out: the name is outside the `plxnative-*` trigger namespace, so it cannot suppress the who's-watching picker the way a state file in `/tmp` would have, and it is outside the glob `tests/run.py` sweeps. * **Not in `Session`.** That file fails as a unit and a parse failure there is a silent sign-out at every boot; every list in it is soft-parsed for exactly that reason. A convenience feature has no business in that blast radius, so this owns its own file, its own format, and fails soft to today's behaviour on every path — absent, empty, truncated, hand-edited, unknown version, foreign profile, a server no longer registered. * **Two rules that stop the feature erasing its own state.** Nothing is recorded until the boot SEQUENCE has ended, because the sign-in, the picker and the first-run question all hand over to Home when answered — a recorder open through that window writes `home` over the record before anyone can ask for it, permanently, for exactly the multi-profile household the profile key exists for. And Home is recorded as a RETURN, never as a landing, so a boot whose restore was declined (the item's server not re-registered yet) does not destroy the record on its way past. Nothing is recorded on an AUTOMATED boot, which is where the harness's determinism is bought: this file is outside the glob `tests/run.py` clears, so refusing to arm is the only place that can be done. `pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and `nativeLifeCycleInterfaceVersion` are documented in the module and left alone — neither is evidence about a native app's cold-boot behaviour on this firmware, and the verdict for #3 belongs to the device matrix in the PR body. Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160. Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real two-boot round trip in the simulator — navigate to a detail page, close, relaunch, and the app comes up on that page; BACK then records Home; an automated boot neither records nor restores; a truncated record boots to Home. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: the six claims this change made false, and four it only sat beside `doc-claim-auditor` on the coldstart diff. Two were caused by it and four were already false in prose the diff touches — all six are the same failure mode, a sentence that was true when written and that nothing compiles. CAUSED BY THIS CHANGE: * The release-notes **"written outside its own directory"** row (TEMPLATE.md and README.md) listed the three logs and the session file. `coldstart` is NOT behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a release build, so `arm()` always runs — and it writes a second file into `/media/{developer,internal}`. That row's whole value is being exhaustive; it is a gate item, and README's own standard is that "a property stated in a form that fails the reader's own check reads as a lie". Now names the file and what is in it: the page, the profile id, one server/item id, no token, no position. * **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to disk is the credentials session", and the same claim again 400 lines later. There are two files now, and the new one is the precedent that gap's own *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the sentence said the thing it wanted did not exist. ALREADY FALSE, in the same prose: * `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and the release-notes template's disclosure row and its worked example. Identical string to the three img.rs comments this branch already fixed, stale since 66688ed (2026-08-22), and each one cites `distribution.md` §6.10 as its source — the section that says the "~74 MB peak" was never a measurement and that the number is 160 against a measured 152 MiB. The template would have had the next release publicly disclose a defect that is fixed. * **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (41720ab) and `stub/` was deleted (7e296ec). Three lines below the line this branch added, in the list a newcomer reads first. * **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked transfer" — the exact sentence the root CLAUDE.md holds up as this repo's archetypal false claim, surviving in another file. `stream.rs` decodes chunked; its only disqualifiers are DNS and TLS. Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does not list the new per-install file, and that section refuses to be trusted as a list by construction ("re-derived against the tree, not inherited"); the dated `*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and `lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true. 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 never rebuilt from one (#53) * transport: an Origin is what a server's address IS, and it is parsed from a URL Everything below the transport carried a server's address as a bare `(host, port)` pair. That pair cannot say `https`, and — the half that matters — it cannot be *made* to say it afterwards, because the host a `plex.direct` certificate is issued for is the HOSTNAME plex.tv puts in `Connection.uri`, while `Connection.address` stays the dotted quad behind it. `probe.rs` has said so in prose since it was written ("https to the bare IP fails validation by design"), and `auth::resolve_roster` then threw `Candidate::url` away and wrote `address` into the session file. A later lane adding a `scheme` field on top of that would have produced a control plane that looks like it speaks TLS and fails hostname validation on every real server. So: `plex::Origin` — scheme + host + port, parsed from a URL by `Origin::parse`, never assembled from an address. `Candidate::origin()` is the one derivation; `Candidate::address` is documented down to what it actually is, the diagnostic half. Threaded through every site that passed a bare pair: `Client` (with `host()`/`port()` kept as views, so the ~30 call sites below the layer are untouched), `StreamUrl` and its two construction sites, `register_origin`/`install`, `SourceRef`/`ServerRef`, `ReadyCreds`, `app.rs`'s boot gate and `install_pms`, and the engine's URL splitter. `dev::DevServer` gains an optional `scheme`, which is how an https origin can be exercised headlessly through the `plxnative-servers` trigger by anyone who has no such server to discover. Two invariants are pinned by tests rather than left to prose. `Origin::host()` is ALWAYS unbracketed — it is the `getaddrinfo` node — and `Origin::authority()` ALWAYS brackets a v6 literal, because it is URL serialization; `probe::host_of` returned the bracketed spelling and is gone, replaced by one shared reading of a URL. And a session file written by 0.4.1, carrying `address`/`port` and no origin, must still boot as `http://{address}:{port}`: `Session::server` is not a soft-parsed roster entry, so dropping it is a silent sign-out at every boot for every existing user. Both have a test with a literal 0.4.1-shaped JSON string. NO BEHAVIOUR CHANGE. Every origin is still `http://` and dials the same address: `dial_target` accepts only a plain-http IPv4 candidate, whose URL `probe::candidates` synthesized as `http://{address}:{port}`, so the parsed origin and the old pair are equal today — asserted, not assumed. The registry's two log lines now print `origin.authority()`, which is byte-identical for every http/IPv4 origin and correct for a v6 literal, which `{host}:{port}` could not spell at all. 996 host tests pass. A simulator boot against a real PMS produces an event log identical to the pre-change one on all 30 non-heartbeat lines; the three `loop=`/`fps=` lines vary run to run on an unchanged binary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: name what the origin model made stale, rather than leaving it to rot `plex/CLAUDE.md` and `servers.rs`/`client.rs`'s module docs described the registry in terms of `(host, port)`, which is the shape the change replaced. `docs/plex-api-design.md` is a design note whose sketches were the implementation of their day — it gets a banner naming the one thing in it that would now mislead (rule 9, "Numeric host, no DNS", and the two struct sketches), not a rewrite. `docs/shared-servers.md` §7 gains the `plxnative-servers` trigger's new `scheme` field, which is the only way to put a TLS origin through the registry without an account that has one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * session: the stored origin field is `origin_url`, so it cannot be mistaken for `origin()` `SourceRef`/`ServerRef` had a FIELD `origin` (the serialized string) beside a METHOD `origin()` (the parsed value). Rust puts those in different namespaces so it compiles either way, which is exactly the problem: two characters separate "the raw JSON string" from "the thing to dial", at every use, forever. The field takes the `_url` suffix; `#[serde(rename)]` keeps the FILE's key spelled `origin`, which is what a human editing a session file on the television reads, and the round-trip test proves the rename applies to both halves of serde. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * review: close the gap between the origin that was DIALLED and the one recorded Eight findings from `/code-review high`; six fixed, two answered in prose. **The one that mattered.** `resolve_roster` recorded `Candidate::origin()` while `probe_server` dialled `(&c.address, dial_port(c.port))`, and the comment justifying that divergence was wrong about its own gate: `dial_target` checks `is_ipv4_literal(&c.address)`, which admits a plex.tv-advertised `uri` candidate and not only the synthesized twin. A connection whose `uri` names a different port from `port` would be verified at one and written into the session file as the other, and every later request would go somewhere nothing ever answered from. So `dial_target` now returns the ORIGIN, `probe_server` dials that origin's host and port, and `Reach::At` carries it back beside the candidate — one value, so what answered and what is recorded cannot be two addresses. The candidate stays for the diagnostic fields. Its fixture had `url` and `port` disagreeing, which is what let the old shape look consistent; it builds both from one pair now, as `probe::candidates` does. **The silent-instrument trap, twice.** `dev::DevServer`'s `scheme` field exists so a lane with no TLS server of its own can put an https origin through the registry — and both registry log lines and `DevServer:: describe` printed `host:port`, so such a run was byte-identical to an http one. `Origin::log_form()` is the shared answer: the bare authority for a plaintext origin (an archived log stays comparable, and the byte-identical gate holds) and the whole URL as soon as the scheme is worth saying. **`player::engine` REFUSES a TLS stream target** instead of silently downgrading it, which is what the code did while its comment claimed the opposite. It is reachable today: a client registered at an https origin copies that origin into `direct_play_url`/`transcode_start_url`, so `route` would store an https URL and the engine would open a plaintext socket to it. Also: an EMPTY port (`http://h:`) is a port that was WRITTEN and cannot be dialled, so `Origin::parse` refuses it rather than defaulting to 32400 — a truncated write of the session file is exactly the "port nobody wrote down" case `dial_port` exists for. And `reconcile_primary` no longer logs "primary now answers at …" when the only thing that changed was the stored origin going from empty to populated, which is what the FIRST BOOT after this lands does on every existing install — a false DHCP-churn report in the file this project treats as its primary evidence surface. Answered rather than changed: `Origin::port`'s doc claimed a narrowing one constructor does not perform (`ServerRef::origin`'s legacy `port as i32`), so the doc now says where the narrowing really lives; and `Session::can_go_local` still asks "is there an address written down" rather than "can THIS build's transport open it" — gating it would send a user to a QR code for a transport gap that is not theirs, and the half-landed state it exposes is named in the doc and refused out loud one layer down, in the engine. 997 host tests pass. The simulator event log is still identical to the pre-change one on all 30 non-heartbeat lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * tests: a registry test must not call the PUBLIC register — it opens a real socket CI was red on Linux with `thread '<unknown>' has overflowed its stack`, at a different point in the output each run, while `make check` passed on the dev Mac. The mechanism is not serde_json and not the session file. `moving_a_server_to_https_re_points_its_slot` called the public `register_origin`, where every other test in this module deliberately goes through `register_with_client_id`. The public path fires `serverinfo::refresh`, which spawns a `task::spawn_small` worker that really opens a socket — and in a DEBUG build `stream::http_stream_boxed` materialises its 64 KiB `HttpStream` as a STACK temporary before it ever reaches the heap, despite the comment above it promising the opposite ("box it off the caller's stack"). lldb caught it on the guard page: frame #0 stream::http_stream_boxed frame #1 stream::http_get(host="10.0.0.1", port=32400, …) frame #2 Client::get_json frame #3 Client::server_root frame #4 serverinfo::fetch_once frame #5 serverinfo::refresh::{closure#0} <- spawn_small, 256 KiB Measured on this branch by varying `SMALL_STACK`: debug overflows at 48, 128 and 192 KiB on ARM64 and needs more than 256 KiB on x86-64, which is exactly why one host passed and the other did not. **`--release` passes at 48 KiB**, so the optimizer elides the temporary and the television — which ships `cargo build --release` (Makefile:438) — is not affected. It is a latent debug-only hazard in `stream.rs`, pre-existing and not this branch's to fix; the base simply had no host test that reached `http_get` from a `spawn_small` worker. Reported on the PR. The fix is the test, which was wrong on its own terms: `register` also mints and PERSISTS a client-id uuid, and that seam's doc has said since it was written that a host test must not write one. It gains an origin-taking sibling (the pair-shaped one cannot express a scheme, which is what this test is about) and a second documented reason nobody had paid for yet. Verified with the same differential that found it: at `SMALL_STACK = 48 * 1024` the branch was 3/3 aborts and is now 3/3 clean, 997 tests, both `--test-threads=1` and parallel. `task.rs` is untouched. 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
…k there (#56) * coldstart: the app writes down where it was, and a cold boot goes back there The app-switch lifecycle was already handled properly, and all of it lives in the PROCESS: background suspends the buffer-feed and drops to Home, foreground reloads and resumes at the saved position with one Load. A COLD start — the set powered off and on, the mains pulled, the app closed from the Recent List — begins with a process that has seen none of that, and the boot route came purely from credential state. Where you actually were was written down nowhere. That is the persistence half of LG App Self Checklist #3 (Reboot). `rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at boot. A playback session records the played leaf and is restored to that item's DETAIL page, never to the player: coming out of a power cycle into a decoding video is an ambush, and the resume point is the server's `viewOffset` anyway. Three decisions worth carrying: * **Not the runtime root**, though that is the obvious home for a file this small. `/tmp` on a television is cleared by a reboot — this repo already leans on that in the other direction, since `tools/tv-lock.sh` puts the device lease there BECAUSE a reboot should release it — so a cold-start restore living there would be erased by the cold start. It goes where the session file goes (`paths::last_place_candidates`). Two smaller wins fall out: the name is outside the `plxnative-*` trigger namespace, so it cannot suppress the who's-watching picker the way a state file in `/tmp` would have, and it is outside the glob `tests/run.py` sweeps. * **Not in `Session`.** That file fails as a unit and a parse failure there is a silent sign-out at every boot; every list in it is soft-parsed for exactly that reason. A convenience feature has no business in that blast radius, so this owns its own file, its own format, and fails soft to today's behaviour on every path — absent, empty, truncated, hand-edited, unknown version, foreign profile, a server no longer registered. * **Two rules that stop the feature erasing its own state.** Nothing is recorded until the boot SEQUENCE has ended, because the sign-in, the picker and the first-run question all hand over to Home when answered — a recorder open through that window writes `home` over the record before anyone can ask for it, permanently, for exactly the multi-profile household the profile key exists for. And Home is recorded as a RETURN, never as a landing, so a boot whose restore was declined (the item's server not re-registered yet) does not destroy the record on its way past. Nothing is recorded on an AUTOMATED boot, which is where the harness's determinism is bought: this file is outside the glob `tests/run.py` clears, so refusing to arm is the only place that can be done. `pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and `nativeLifeCycleInterfaceVersion` are documented in the module and left alone — neither is evidence about a native app's cold-boot behaviour on this firmware, and the verdict for #3 belongs to the device matrix in the PR body. Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160. Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real two-boot round trip in the simulator — navigate to a detail page, close, relaunch, and the app comes up on that page; BACK then records Home; an automated boot neither records nor restores; a truncated record boots to Home. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: the six claims this change made false, and four it only sat beside `doc-claim-auditor` on the coldstart diff. Two were caused by it and four were already false in prose the diff touches — all six are the same failure mode, a sentence that was true when written and that nothing compiles. CAUSED BY THIS CHANGE: * The release-notes **"written outside its own directory"** row (TEMPLATE.md and README.md) listed the three logs and the session file. `coldstart` is NOT behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a release build, so `arm()` always runs — and it writes a second file into `/media/{developer,internal}`. That row's whole value is being exhaustive; it is a gate item, and README's own standard is that "a property stated in a form that fails the reader's own check reads as a lie". Now names the file and what is in it: the page, the profile id, one server/item id, no token, no position. * **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to disk is the credentials session", and the same claim again 400 lines later. There are two files now, and the new one is the precedent that gap's own *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the sentence said the thing it wanted did not exist. ALREADY FALSE, in the same prose: * `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and the release-notes template's disclosure row and its worked example. Identical string to the three img.rs comments this branch already fixed, stale since 68536a1 (2026-08-22), and each one cites `distribution.md` §6.10 as its source — the section that says the "~74 MB peak" was never a measurement and that the number is 160 against a measured 152 MiB. The template would have had the next release publicly disclose a defect that is fixed. * **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (41720ab) and `stub/` was deleted (7e296ec). Three lines below the line this branch added, in the list a newcomer reads first. * **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked transfer" — the exact sentence the root CLAUDE.md holds up as this repo's archetypal false claim, surviving in another file. `stream.rs` decodes chunked; its only disqualifiers are DNS and TLS. Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does not list the new per-install file, and that section refuses to be trusted as a list by construction ("re-derived against the tree, not inherited"); the dated `*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and `lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true. 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 never rebuilt from one (#53) * transport: an Origin is what a server's address IS, and it is parsed from a URL Everything below the transport carried a server's address as a bare `(host, port)` pair. That pair cannot say `https`, and — the half that matters — it cannot be *made* to say it afterwards, because the host a `plex.direct` certificate is issued for is the HOSTNAME plex.tv puts in `Connection.uri`, while `Connection.address` stays the dotted quad behind it. `probe.rs` has said so in prose since it was written ("https to the bare IP fails validation by design"), and `auth::resolve_roster` then threw `Candidate::url` away and wrote `address` into the session file. A later lane adding a `scheme` field on top of that would have produced a control plane that looks like it speaks TLS and fails hostname validation on every real server. So: `plex::Origin` — scheme + host + port, parsed from a URL by `Origin::parse`, never assembled from an address. `Candidate::origin()` is the one derivation; `Candidate::address` is documented down to what it actually is, the diagnostic half. Threaded through every site that passed a bare pair: `Client` (with `host()`/`port()` kept as views, so the ~30 call sites below the layer are untouched), `StreamUrl` and its two construction sites, `register_origin`/`install`, `SourceRef`/`ServerRef`, `ReadyCreds`, `app.rs`'s boot gate and `install_pms`, and the engine's URL splitter. `dev::DevServer` gains an optional `scheme`, which is how an https origin can be exercised headlessly through the `plxnative-servers` trigger by anyone who has no such server to discover. Two invariants are pinned by tests rather than left to prose. `Origin::host()` is ALWAYS unbracketed — it is the `getaddrinfo` node — and `Origin::authority()` ALWAYS brackets a v6 literal, because it is URL serialization; `probe::host_of` returned the bracketed spelling and is gone, replaced by one shared reading of a URL. And a session file written by 0.4.1, carrying `address`/`port` and no origin, must still boot as `http://{address}:{port}`: `Session::server` is not a soft-parsed roster entry, so dropping it is a silent sign-out at every boot for every existing user. Both have a test with a literal 0.4.1-shaped JSON string. NO BEHAVIOUR CHANGE. Every origin is still `http://` and dials the same address: `dial_target` accepts only a plain-http IPv4 candidate, whose URL `probe::candidates` synthesized as `http://{address}:{port}`, so the parsed origin and the old pair are equal today — asserted, not assumed. The registry's two log lines now print `origin.authority()`, which is byte-identical for every http/IPv4 origin and correct for a v6 literal, which `{host}:{port}` could not spell at all. 996 host tests pass. A simulator boot against a real PMS produces an event log identical to the pre-change one on all 30 non-heartbeat lines; the three `loop=`/`fps=` lines vary run to run on an unchanged binary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: name what the origin model made stale, rather than leaving it to rot `plex/CLAUDE.md` and `servers.rs`/`client.rs`'s module docs described the registry in terms of `(host, port)`, which is the shape the change replaced. `docs/plex-api-design.md` is a design note whose sketches were the implementation of their day — it gets a banner naming the one thing in it that would now mislead (rule 9, "Numeric host, no DNS", and the two struct sketches), not a rewrite. `docs/shared-servers.md` §7 gains the `plxnative-servers` trigger's new `scheme` field, which is the only way to put a TLS origin through the registry without an account that has one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * session: the stored origin field is `origin_url`, so it cannot be mistaken for `origin()` `SourceRef`/`ServerRef` had a FIELD `origin` (the serialized string) beside a METHOD `origin()` (the parsed value). Rust puts those in different namespaces so it compiles either way, which is exactly the problem: two characters separate "the raw JSON string" from "the thing to dial", at every use, forever. The field takes the `_url` suffix; `#[serde(rename)]` keeps the FILE's key spelled `origin`, which is what a human editing a session file on the television reads, and the round-trip test proves the rename applies to both halves of serde. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * review: close the gap between the origin that was DIALLED and the one recorded Eight findings from `/code-review high`; six fixed, two answered in prose. **The one that mattered.** `resolve_roster` recorded `Candidate::origin()` while `probe_server` dialled `(&c.address, dial_port(c.port))`, and the comment justifying that divergence was wrong about its own gate: `dial_target` checks `is_ipv4_literal(&c.address)`, which admits a plex.tv-advertised `uri` candidate and not only the synthesized twin. A connection whose `uri` names a different port from `port` would be verified at one and written into the session file as the other, and every later request would go somewhere nothing ever answered from. So `dial_target` now returns the ORIGIN, `probe_server` dials that origin's host and port, and `Reach::At` carries it back beside the candidate — one value, so what answered and what is recorded cannot be two addresses. The candidate stays for the diagnostic fields. Its fixture had `url` and `port` disagreeing, which is what let the old shape look consistent; it builds both from one pair now, as `probe::candidates` does. **The silent-instrument trap, twice.** `dev::DevServer`'s `scheme` field exists so a lane with no TLS server of its own can put an https origin through the registry — and both registry log lines and `DevServer:: describe` printed `host:port`, so such a run was byte-identical to an http one. `Origin::log_form()` is the shared answer: the bare authority for a plaintext origin (an archived log stays comparable, and the byte-identical gate holds) and the whole URL as soon as the scheme is worth saying. **`player::engine` REFUSES a TLS stream target** instead of silently downgrading it, which is what the code did while its comment claimed the opposite. It is reachable today: a client registered at an https origin copies that origin into `direct_play_url`/`transcode_start_url`, so `route` would store an https URL and the engine would open a plaintext socket to it. Also: an EMPTY port (`http://h:`) is a port that was WRITTEN and cannot be dialled, so `Origin::parse` refuses it rather than defaulting to 32400 — a truncated write of the session file is exactly the "port nobody wrote down" case `dial_port` exists for. And `reconcile_primary` no longer logs "primary now answers at …" when the only thing that changed was the stored origin going from empty to populated, which is what the FIRST BOOT after this lands does on every existing install — a false DHCP-churn report in the file this project treats as its primary evidence surface. Answered rather than changed: `Origin::port`'s doc claimed a narrowing one constructor does not perform (`ServerRef::origin`'s legacy `port as i32`), so the doc now says where the narrowing really lives; and `Session::can_go_local` still asks "is there an address written down" rather than "can THIS build's transport open it" — gating it would send a user to a QR code for a transport gap that is not theirs, and the half-landed state it exposes is named in the doc and refused out loud one layer down, in the engine. 997 host tests pass. The simulator event log is still identical to the pre-change one on all 30 non-heartbeat lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * tests: a registry test must not call the PUBLIC register — it opens a real socket CI was red on Linux with `thread '<unknown>' has overflowed its stack`, at a different point in the output each run, while `make check` passed on the dev Mac. The mechanism is not serde_json and not the session file. `moving_a_server_to_https_re_points_its_slot` called the public `register_origin`, where every other test in this module deliberately goes through `register_with_client_id`. The public path fires `serverinfo::refresh`, which spawns a `task::spawn_small` worker that really opens a socket — and in a DEBUG build `stream::http_stream_boxed` materialises its 64 KiB `HttpStream` as a STACK temporary before it ever reaches the heap, despite the comment above it promising the opposite ("box it off the caller's stack"). lldb caught it on the guard page: frame #0 stream::http_stream_boxed frame #1 stream::http_get(host="10.0.0.1", port=32400, …) frame #2 Client::get_json frame #3 Client::server_root frame #4 serverinfo::fetch_once frame #5 serverinfo::refresh::{closure#0} <- spawn_small, 256 KiB Measured on this branch by varying `SMALL_STACK`: debug overflows at 48, 128 and 192 KiB on ARM64 and needs more than 256 KiB on x86-64, which is exactly why one host passed and the other did not. **`--release` passes at 48 KiB**, so the optimizer elides the temporary and the television — which ships `cargo build --release` (Makefile:438) — is not affected. It is a latent debug-only hazard in `stream.rs`, pre-existing and not this branch's to fix; the base simply had no host test that reached `http_get` from a `spawn_small` worker. Reported on the PR. The fix is the test, which was wrong on its own terms: `register` also mints and PERSISTS a client-id uuid, and that seam's doc has said since it was written that a host test must not write one. It gains an origin-taking sibling (the pair-shaped one cannot express a scheme, which is what this test is about) and a second documented reason nobody had paid for yet. Verified with the same differential that found it: at `SMALL_STACK = 48 * 1024` the branch was 3/3 aborts and is now 3/3 clean, 997 tests, both `--test-threads=1` and parallel. `task.rs` is untouched. 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
…k there (#56) * coldstart: the app writes down where it was, and a cold boot goes back there The app-switch lifecycle was already handled properly, and all of it lives in the PROCESS: background suspends the buffer-feed and drops to Home, foreground reloads and resumes at the saved position with one Load. A COLD start — the set powered off and on, the mains pulled, the app closed from the Recent List — begins with a process that has seen none of that, and the boot route came purely from credential state. Where you actually were was written down nowhere. That is the persistence half of LG App Self Checklist #3 (Reboot). `rust-modules/src/coldstart.rs` records a Place — Home, a library TAB PILL, or an item addressed as (machineIdentifier, ratingKey) — and app.rs reads it back at boot. A playback session records the played leaf and is restored to that item's DETAIL page, never to the player: coming out of a power cycle into a decoding video is an ambush, and the resume point is the server's `viewOffset` anyway. Three decisions worth carrying: * **Not the runtime root**, though that is the obvious home for a file this small. `/tmp` on a television is cleared by a reboot — this repo already leans on that in the other direction, since `tools/tv-lock.sh` puts the device lease there BECAUSE a reboot should release it — so a cold-start restore living there would be erased by the cold start. It goes where the session file goes (`paths::last_place_candidates`). Two smaller wins fall out: the name is outside the `plxnative-*` trigger namespace, so it cannot suppress the who's-watching picker the way a state file in `/tmp` would have, and it is outside the glob `tests/run.py` sweeps. * **Not in `Session`.** That file fails as a unit and a parse failure there is a silent sign-out at every boot; every list in it is soft-parsed for exactly that reason. A convenience feature has no business in that blast radius, so this owns its own file, its own format, and fails soft to today's behaviour on every path — absent, empty, truncated, hand-edited, unknown version, foreign profile, a server no longer registered. * **Two rules that stop the feature erasing its own state.** Nothing is recorded until the boot SEQUENCE has ended, because the sign-in, the picker and the first-run question all hand over to Home when answered — a recorder open through that window writes `home` over the record before anyone can ask for it, permanently, for exactly the multi-profile household the profile key exists for. And Home is recorded as a RETURN, never as a landing, so a boot whose restore was declined (the item's server not re-registered yet) does not destroy the record on its way past. Nothing is recorded on an AUTOMATED boot, which is where the harness's determinism is bought: this file is outside the glob `tests/run.py` clears, so refusing to arm is the only place that can be done. `pkg/appinfo.json` is UNCHANGED. `handlesRelaunch` and `nativeLifeCycleInterfaceVersion` are documented in the module and left alone — neither is evidence about a native app's cold-boot behaviour on this firmware, and the verdict for #3 belongs to the device matrix in the PR body. Also fixes three `requiredMemory: 60` comments in img.rs; the manifest says 160. Verified: 986/986 host tests (10 new), `--no-default-features` clean, and a real two-boot round trip in the simulator — navigate to a detail page, close, relaunch, and the app comes up on that page; BACK then records Home; an automated boot neither records nor restores; a truncated record boots to Home. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G * docs: the six claims this change made false, and four it only sat beside `doc-claim-auditor` on the coldstart diff. Two were caused by it and four were already false in prose the diff touches — all six are the same failure mode, a sentence that was true when written and that nothing compiles. CAUSED BY THIS CHANGE: * The release-notes **"written outside its own directory"** row (TEMPLATE.md and README.md) listed the three logs and the session file. `coldstart` is NOT behind `devtriggers` — `any_trigger_present()` is a compile-time `false` in a release build, so `arm()` always runs — and it writes a second file into `/media/{developer,internal}`. That row's whole value is being exhaustive; it is a gate item, and README's own standard is that "a property stated in a form that fails the reader's own check reads as a lie". Now names the file and what is in it: the page, the profile id, one server/item id, no token, no position. * **`docs/parity-gaps.md`'s on-disk inventory** — "the only thing ever written to disk is the credentials session", and the same claim again 400 lines later. There are two files now, and the new one is the precedent that gap's own *Where:* asks for ("a new preferences file alongside plex/session.rs"), so the sentence said the thing it wanted did not exist. ALREADY FALSE, in the same prose: * `requiredMemory: 60` in **three more places** — `docs/two-installs.md` §3.1 and the release-notes template's disclosure row and its worked example. Identical string to the three img.rs comments this branch already fixed, stale since fa257bd (2026-08-22), and each one cites `distribution.md` §6.10 as its source — the section that says the "~74 MB peak" was never a measurement and that the number is 160 against a measured 152 MiB. The template would have had the next release publicly disclose a defect that is fixed. * **`lib.rs:22`** described `ff` as "the TV's own FFmpeg 3.3 via the stub-.so link". Both halves inverted: the app bundles and pins FFmpeg 9.0 (56147f1) and `stub/` was deleted (72b7d71). Three lines below the line this branch added, in the list a newcomer reads first. * **`parity-gaps.md:1567`** carried "the raw-socket client cannot do chunked transfer" — the exact sentence the root CLAUDE.md holds up as this repo's archetypal false claim, surviving in another file. `stream.rs` decodes chunked; its only disqualifiers are DNS and TLS. Left alone deliberately: `two-installs.md` §3.1's shared-resource inventory does not list the new per-install file, and that section refuses to be trusted as a list by construction ("re-derived against the tree, not inherited"); the dated `*Verified:*` blocks in parity-gaps.md keep their 2026-07-29 line numbers; and `lg-self-checklist.md`'s #3 row still says the matrix is unrun, which is true. 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parity unit 7 — the "read back the server's per-part stream selection" gap
(
docs/parity-gaps.md, cheap-win #8 and the tracks appendix).We PUT the user's audio/subtitle pick to
/library/parts/{id}and never read theselection already there, so a track chosen on a phone, in Plex Web, or on this TV in
an earlier session was overwritten by our own default-picking ladder on the next play.
plex::Stream.selectedwas parsed and had zero readers.What changed
metadata::Streamcarriesselected(one field, one mapping line inconvert_streams).route::pick_dp_audiogains a top rung: prefer the stream the server has selected —when it differs from the file's own
defaultflag and is direct-playable — else theshipped ladder (English > flagged default > any DP sibling) runs exactly as before.
route::pick_dp_subtitle(new, pure) turns on a server-selected embedded subtitle at thestart of a direct play, resolved to
metadata::sub_render_ordinal— the same identifierspace the track menu commits and the demuxer enumerates.
apply_planinstalls it on the mainthread (
CUR_SUB_SID+player::request_subtitle) afterrequest_play's reset.Why the two gates on the audio rung (this is the whole design)
Probed against the live server, per identity, before writing the rung:
never PUT anything for still answers with the container default flagged
selected(ToyStory 2/3/4 all report their TrueHD default that way). So "selected wins" without a gate
would (a) delete the English rung — The Morning Show reports its Russian default as
selected, which is the exact foreign-dub-on-open bug that rung exists to prevent — and
(b) drop the whole smart-direct-play class onto the server's downscaling encoder.
on-the-wire evidence that something actually chose it. Cost, documented at the rung: a pick
that lands on the default cannot round-trip. The two things that would fix that (the
account's
defaultAudioLanguage, a remembered per-item choice) are separate gaps.(parts with a
default-flagged subtitle come back with no selection), so a selectedsubtitle is a choice. A sidecar selection is skipped — nothing in the container renders it.
Deliberately out of scope
The transcode path is untouched and still PUTs
subtitleStreamID=0. Honouring a selectionthere means a server-side burn — a re-encode with a picture-quality cost — which belongs behind
a settings surface, not behind a silent default. (A direct play that later escalates to the
transcoder does carry the seeded id along, so the subtitle on screen keeps burning.) The
consequence, which predates this change: a transcoded item still clears the server's subtitle
selection, so the read-back is one-way on that path.
Verification
make check— 66 host tests, 0 failures (58 baseline, +8 here). New tests pin both gates,the fall-through order rung by rung (table-driven), the sidecar exclusion, and the ordinal
maths on a list whose document order is not container order. Every fixture is a shape the live
server actually serves.
make— ARM cross-build green.ff.rs'ssub_pos, thereset_subtitle→resolve→apply_plan→start_bufferfeedordering, workerpurity, all seven
cur_sub_sid()readers) found no bug in the shipped logic; its two nits(an id-less selection applying half a pair; doc drift after the gate landed) are fixed here.
Device verification: DONE (no coordinator follow-up needed)
Deployed (md5-matched) and run under the shared TV lock, which was released cleanly after.
Scope was the selection cases only — this unit changes policy, not drawing, so no FPS tier.
Every case ended EARLY (17-24 s against 60-90 s caps), i.e. every assertion satisfied,
including
audio_native— the one that would have broken had thedefault-echo gate beenmissing, since it picks the same Russian row the server reports as selected on rk=1804.
Positive evidence that the new path actually fired, from the on-device event log (rk=1919,
before any menu interaction — the case's own pick comes later):
sid=13160is exactly the PGS English track the server holds selected for the test identity,render_idx=0is its embedded-stream ordinal, and the image cues follow — so the subtitle cameup from the server's own state at playback start rather than from a user action.
The harness is also stable under repetition, which matters because a case's stream selection —
unlike its resume point — is server state the harness does NOT reset: each case's own
put_selectionwrites back a value the two gates then classify the same way on the next run(rk=1804 writes the Russian default → still gated; rk=3 writes English DTS → still not
direct-playable; the subtitle cases write the track the ladder picks anyway).
🤖 Generated with Claude Code
https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc