Repository navigation
ui: the account menu answers from the session, not from an empty UserRef - #4
Merged
Merged
Conversation
The profile popover decided everything it said from session::current().is_some(). That is a sentinel, not a fact: auth's single-user path enters Home without ever writing a profile, so an account WITHOUT Plex Home is Some(UserRef::default()) -- empty title, empty thumb. Reading that emptiness as "signed out" is how a signed-in owner got headed "Account" by this popover and offered "Sign in" by the chip that opens it; and when current() really is None while a session sits on disk (the /tmp/plxnative-token boot never calls set_current), the popover offered "Sign in" to someone signed in and streaming. Session::account() is now the one definition of what these surfaces may say, taken from the persisted session -- the file of record -- plus the in-memory profile: signed_in (an account token, or a server we are already streaming on), can_switch (profiles need the plex.tv token specifically; start_switch refuses a server-only session), and a name that falls back from the active profile to the persisted one to the roster's admin entry. That last hop is what names an owner with no Plex Home, and it works for sessions ALREADY on disk, which seeding session.user at sign-in would not. The rows follow from that state, and the ordered row list is itself the index -> action map, so on_ok cannot drift from what was drawn. can_switch is deliberately not gated on roster length. An empty home_users means UNKNOWN, not none: it is only filled by a sign-in or a "Change profile", and a failed fetch persists an empty vec, so hiding that row on an empty roster would be a one-way door out of a Plex Home created later -- that row is the only thing that re-fetches it. The popover reads that file with a new session::peek(), not load(): load() mints and SAVES a client_id whenever the read or the parse fails, and save() truncates in place, so a file that momentarily failed to parse would come back as a bare client_id -- a silent sign-out. That is a fair trade on the boot path, which must end up with an id; it is not one on a path a keypress can reach. The Home profile chip is the other half of this bug and still reads the sentinel. It lives in another change's file, so it is left alone here and both doc comments say so. Tests: +8 host (66) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Aug 3, 2026
The ACB/Starfish seam and the ENGINE slot were main-thread-confined by comment only — documented in three CLAUDE.md files and enforced by nothing. Step 4 of docs/async-model-decision.md: a !Send ZST token, minted once at the top of plex_run and threaded down. Moving any of it onto a thread now fails to compile. Scoped wider than the seam on purpose. ENGINE is a `static mut` handed out as `&'static mut`, with workers holding raw pointers into the boxes it owns, so two live &mut is instant UB — and `static mut` carries no Sync bound to stop it (finding #4 of the decision doc proved that by compiling the counterexample, which is also why this is a token-as-argument and not a marker field). Privacy is what makes it a guarantee rather than a naming convention: ffi.rs's extern "C" block moved into a private `mod sys`, so the token-taking wrappers are the only way in, and ENGINE's four raw addr_of touches became four token-taking accessors. start_bufferfeed is the proof that mattered — it was the one function whose `mt` the compiler flagged unused, precisely because it reached the static directly instead of through engine(). Two deliberate holes, documented where someone would hit them. sf_load takes NO token because load_thread runs it off-main by design (the missing parameter is the documentation). And MainThread::assume() is callable, so `unsafe` inside a worker still defeats this — the ceiling of the pattern, not an oversight. What it buys is that the mistake has to be written, in an unsafe block, instead of made by forgetting a convention. The rule for new code, recorded in engine.rs and player/CLAUDE.md: take the token iff you reach the seam or the Engine. arm_seek/resume_at are main-thread too and deliberately don't take one — spread to everything that merely runs on main, it stops carrying information. Verified with teeth both ways: a temporary `spawn("evil", move || pause(mt))` fails to compile, and the new host test asserts the !Send-ness it all rests on (an absent impl is invisible to ordinary code, so it detects it via inherent-vs-trait const resolution, with a Send control case). 39 host tests, ARM release clean, device 18/18 playback + 5/5 FPS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0156NyUDnpnrmvrcfrBvR6s6
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 26, 2026
The ACB/Starfish seam and the ENGINE slot were main-thread-confined by comment only — documented in three CLAUDE.md files and enforced by nothing. Step 4 of docs/async-model-decision.md: a !Send ZST token, minted once at the top of plex_run and threaded down. Moving any of it onto a thread now fails to compile. Scoped wider than the seam on purpose. ENGINE is a `static mut` handed out as `&'static mut`, with workers holding raw pointers into the boxes it owns, so two live &mut is instant UB — and `static mut` carries no Sync bound to stop it (finding #4 of the decision doc proved that by compiling the counterexample, which is also why this is a token-as-argument and not a marker field). Privacy is what makes it a guarantee rather than a naming convention: ffi.rs's extern "C" block moved into a private `mod sys`, so the token-taking wrappers are the only way in, and ENGINE's four raw addr_of touches became four token-taking accessors. start_bufferfeed is the proof that mattered — it was the one function whose `mt` the compiler flagged unused, precisely because it reached the static directly instead of through engine(). Two deliberate holes, documented where someone would hit them. sf_load takes NO token because load_thread runs it off-main by design (the missing parameter is the documentation). And MainThread::assume() is callable, so `unsafe` inside a worker still defeats this — the ceiling of the pattern, not an oversight. What it buys is that the mistake has to be written, in an unsafe block, instead of made by forgetting a convention. The rule for new code, recorded in engine.rs and player/CLAUDE.md: take the token iff you reach the seam or the Engine. arm_seek/resume_at are main-thread too and deliberately don't take one — spread to everything that merely runs on main, it stops carrying information. Verified with teeth both ways: a temporary `spawn("evil", move || pause(mt))` fails to compile, and the new host test asserts the !Send-ness it all rests on (an absent impl is invisible to ordinary code, so it detects it via inherent-vs-trait const resolution, with a Send control case). 39 host tests, ARM release clean, device 18/18 playback + 5/5 FPS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0156NyUDnpnrmvrcfrBvR6s6
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 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 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
Oct 8, 2026
…loor, no secret echo) (#557) CodeQL py/* alerts #4-8, #10, #11, #16-20. serve_fixtures resolves and checks containment before isfile; every dev SSLContext sets minimum_version TLS 1.2; gen-release-audit parses the DSN host instead of a substring test; the census arm regex no longer backtracks; plxnative-lab start stops echoing the session secret (pkg/lab.json, 0600, carries it); remote-dpad echoes only a password it generated. Co-Authored-By: Claude Sonnet 5.5 <[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-gap unit 15 — the
accountappendix entry "A signed-in account without Plex Home managedusers is labelled 'Sign in'" (
docs/parity-gaps.md:936).The bug
The top-left account popover decided everything it said from
plex::session::current().is_some().That is a sentinel, not a fact:
auth.rs's single-user path (theusers.len() > 1else-branch,auth.rs:341-348) enters Home without ever writing a profile, so an account without Plex Home is
Some(UserRef::default())— empty title, empty thumb. Every surface that reads that emptiness tells asigned-in user they are signed out: this popover heads itself "Account", and the chip that opens it
(
ui/widgets.rs:131) says "Sign in". And whencurrent()genuinely isNonewhile a session sits ondisk (the
/tmp/plxnative-tokenboot never callsset_current), the popover offered "Sign in" to auser who is signed in and streaming.
The fix
Session::account(active) -> Account { signed_in, can_switch, name }(plex/session.rs, appended) is nowthe single definition of what an account surface may say, derived from the persisted session — the
file of record — plus the in-memory profile:
signed_in— a plex.tv account token, or at least a server + PMS token it can stream on.can_switch— switching needs the plex.tv token specifically (the roster and the per-user tokensboth come from plex.tv); it mirrors
auth::start_switch's own guard, which refuses a server-onlysession outright.
name— active managed profile → persisted profile → the roster's namedadminentry. Thatlast hop is what names an owner with no Plex Home, and it works for sessions already on disk,
which seeding
session.userat sign-in (the audit's suggested cure) would not.The popover's rows follow from that state, and the ordered row list is itself the index→action map, so
on_okcannot drift from what was drawn (it used to be a fixed 0/1 match against a capturedSIGNED_INbool); adebug_assertpinsROWS.len() == table().n_rows().open()reads via a newsession::peek()rather thanload().load()mints and saves aclient_id whenever the read or the parse fails, and
save()truncates in place — so a file thatmomentarily failed to parse would come back as a bare client_id, i.e. a silent sign-out. Acceptable on
the boot path, which must end up with an id; not on a path a keypress can reach.
The ambiguity, called out rather than papered over
session.home_usersbeing empty means "unknown", not "none". It is only ever filled by a sign-in ora "Change profile", and a failed fetch persists an empty vec (auth.rs:327,
home_users().unwrap_or_default()), so "never fetched", "fetch failed" and "genuinely empty" are onevalue. So
can_switchis deliberately not gated on roster length: hiding "Change profile" for a1-entry roster would be a one-way door — that row is the only thing that re-fetches the roster, so a
Plex Home created later would be unreachable without signing out. Documented at the field.
Second honest limit, also documented at the field:
signed_indescribes the session on disk, notthe identity in use. An automated
/tmp/plxnative-tokenboot streams on an injected token yet stillreports the stored account — deliberate, since the stored account is exactly what "Sign out" clears —
but it does mean a dev boot now shows "Sign out" where it used to show a no-op "Sign in".
Still lying: the profile chip (deliberately not touched)
ui/widgets.rs:117-186(profile_chip) has the identical root cause and still labels itself fromtitle.is_empty(), so the chip and the popover it opens now disagree on one screen. I was asked to keepedits outside
ui/account_menu.rspurely additive because siblings are editing this crate, and thatfile is not mine. Both doc comments say so, and the patch is one block inside the existing
generation-keyed cache:
Verification
make check— 66 host tests pass (+8: the state→(header, rows) table, the roster fallback, theindex→action map, and one over the live
set_currentglobal undertestlock::serial()).make— ARM cross-build clean (the same 5 pre-existing warnings, none in these files).code instead.