Skip to content

ui: season tabs carry their episode count, and a tick once you are through - #1

Merged
GLinnik21 merged 2 commits into
mainfrom
parity/season-tab-counts
Jul 30, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
parity/season-tab-counts

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Parity unit 3 (docs/parity-gaps.md §2 theme A / §5c): the season tabs now say how big a season is and whether you have finished it.

What changed

  • metadata::Season gains leaf_count / viewed_leaf_count — already parsed at plex/models.rs:150-153, previously never copied across — plus Season::watched(), the season-scope form of the container rule fetch_detail applies to a show (viewed >= leaf && leaf > 0). It lives on the data so the tab's tick and the coming Mark Season Watched row read one truth. The leaf_count > 0 half is load-bearing: a season with no counts is 0 >= 0, which would otherwise report as fully watched.
  • ui/widgets.rs: TabPill gains a trailing TabNote — a count, or a tick — one type rung down (size::CAPTION), never bold, the pill's own ink one alpha step down. It is an annotation, not a second label. TabPill::note_w is the single width source, so pill width, the strip's x-advance and the scroll-into-view geometry cannot disagree.
  • ui/detail.rs: tabs_layout returns a TabLay (was a 4-tuple) carrying the note; the label centres in the pill minus the note so a counted tab keeps label+note centred as one unit.

No new colour literal, no raw font size, no hand-placed text; the note is drawn through Label / icons::draw (which snaps its own origin).

Verification

  • make check — 59/59 (baseline 58, +1: the fully-watched rule, including the no-counts and over-count edges).
  • make — ARM cross-build green.
  • Device, under the TV lock: ./tests/run.py --fps 5/5 (no playback cases — this is UI-only), then a DISPLAY capture of The Morning Show (rk=437).

Server truth vs. what rendered, from /library/metadata/437/children:

season leaves viewed tab shows
Season 1 10 10 ✓ tick
Season 2 10 1 10

Captured in all four pill states (focused, selected-unfocused, plain, plain-watched): the count is clearly legible and clearly subordinate to the label, and the pill padding stays even on both sides.

🤖 Generated with Claude Code

https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc

…rough

`/library/metadata/{show}/children` returns leafCount/viewedLeafCount on every
season row and `metadata::Season` dropped both on the floor, so a season tab was
its name and nothing else — no size, and no way to tell a season you have
finished from one you have not started.

Both fields now ride `Season`, with the fully-watched rule as `Season::watched()`
rather than a comparison copied to each draw site: it is the season-scope form of
the container rule `fetch_detail` already applies to a show, and the coming "Mark
Season Watched" row will decide which way to scrobble off the same method. Its
`leaf_count > 0` half is the load-bearing part — a season the server sent no
counts for is 0 >= 0, which would otherwise report as fully watched.

On the strip that surfaces as a `TabPill` trailing note (`TabNote`), not as a
second label: one type rung down (CAPTION), never bold, the pill's own ink one
alpha step down, and either the count or the tick — never both competing for the
same slot. The pill sizes itself through `TabPill::note_w`, which `tabs_layout`
also uses, so the strip's x-advance, the scroll-into-view geometry and the pill
width cannot disagree about how wide a tab is. The label then centres in the pill
MINUS the note, so a counted tab keeps label+note centred as one unit instead of
shoving the label off-centre; the note hugs the label's own painted right edge,
which is why none of this needs to know the caller's pill padding.

Verified on the device against The Morning Show (rk=437), whose two seasons are
exactly the interesting pair: season 1 leaves=10 viewed=10 draws the tick,
season 2 leaves=10 viewed=1 draws "10", legible and subordinate in all four pill
states (focused, selected, plain, plain-watched). fps 5/5.

Tests: +1 host (59).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018GuSHrq9oydnX7nhKE1Hvc
Copilot AI review requested due to automatic review settings July 29, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Review follow-ups, none of which change a pixel — the device evidence for the
previous commit still stands.

`Season` loses the `Default` derive it briefly had: the two test fixtures now
spell every field again, so the next field added to a season is a compile error
at each construction site rather than a silent zero. Counts are exactly the kind
of field whose default reads as a legitimate value.

`TabPill::draw` records WHY the note anchors on the label's painted width rather
than the width the caller measured. A strip that sizes its tabs bold — the season
tabs and `draw_tab_row` both do, so an advance cannot move with focus — paints an
unbolded label a few px narrower. Pinning the note to the caller's number would
hold it still while the label's right edge slid under it: a constant label→note
gap traded for a variable one. The gap is the relationship the eye reads.

`TabPill::width` says out loud that it covers the label only; a pill that also
carries a note must add `note_w`, or the note lands outside the fill.

And `tabs_layout` records its per-frame cost honestly: uncached, one CString plus
one text measure per season per call, now two with the count. Cheap since
`text_width` became a `TTF_SizeUTF8` metrics walk, but a 30-season strip is the
shape that would want `ep_meta_h`'s fingerprinted cache — and no FPS scene covers
it, because `fps:detail-transition` is a movie and returns before `draw_tabs`.

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

Copy link
Copy Markdown
Collaborator Author

Review pass — what was found, and what I did with it

A fresh-eyes correctness sweep over the diff (geometry, lifetimes, Season construction sites, TabPill's other users) turned up no lifetime or layout defects: the pill rect, the on_axis cull and tab_focus_geom's scroll extent all agree with the note-inclusive content width, and every TabNote::Count pointer is used inside the scope of the TabLay that owns its CString. draw_tab_row and the player Info/Chapters tabs degenerate to the exact previous call. Three items were worth acting on, all in 85cc10c and none of them moves a pixel, so the captures above still stand as evidence:

  • Season no longer derives Default. It briefly did, purely so two test fixtures could say ..Default::default() — which silently absorbs every field added later. Counts are exactly the field whose zero reads as a real value, so the fixtures spell everything again.
  • Documented why the note anchors on the label's painted width. The strip sizes tabs with the bold label so an advance can't move with focus; an unbolded segment therefore paints a few px narrower. Anchoring the note on the caller's measured width would pin the note while the label's right edge slid under it — a constant label→note gap traded for a variable one. The gap is the relationship the eye reads, so the painted edge wins; the leftover slack sits inside the pill's own padding and is the same slack the label alone always had.
  • TabPill::width now says it covers the label only — a pill that also carries a note must add note_w.

Two things left open, deliberately

  1. A bare count next to a label that often ends in a number (Season 12 12), and a Plex user trained by the orange badge could read 10 as unwatched rather than total. The alternative that removes both readings is showing the count on every tab and letting the tick sit beside it (Season 1 10 ✓) — uniform presence makes "total" the only consistent reading. It is busier, and it needs its own device pass, so it is left for the owner to call rather than slipped in unverified.
  2. tabs_layout is uncached on the draw path — one CString + one text measure per season per call, now two with the count. Cheap since text_width became a TTF_SizeUTF8 walk, but a 30-season strip (Top Gear) is the shape that would want ep_meta_h's fingerprinted cache, and no FPS scene covers it: fps:detail-transition is a movie, which returns from draw_tabs before any of this runs. Recorded in the code where the cost lives; worth a follow-up unit (a cache plus a many-season FPS scene) rather than an unverified cache here.

@GLinnik21
GLinnik21 merged commit f4cb279 into main Jul 30, 2026
@GLinnik21
GLinnik21 deleted the parity/season-tab-counts branch August 2, 2026 18:37
GLinnik21 added a commit that referenced this pull request Aug 3, 2026
The demuxer chose the default audio with av_find_best_stream, which picks the
"highest quality" track — on Home Alone (8 audio tracks, no default disposition)
it picked the DTS track (a=#7). But the Load payload carries Media[0].audioCodec
(ac3), so the pipeline was told AC3 while fed DTS: the audio ES never configures
and, with audioSync, the video slaves to the dead audio clock and wedges (~32s of
buffered video, then Feed() BufferFull forever, no window+PLAYING).

Now the default audio feeds the first track whose codec MATCHES the payload
(audio_stream_matching via avcodec_get_name), falling back to av_find_best_stream
only if none matches. Verified on rk 3: feeds a=#1 (ac3), window+PLAYING, timeline
climbs 72→142s. Caught by the new regression harness (home_alone_manyaudio).

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 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 demuxer chose the default audio with av_find_best_stream, which picks the
"highest quality" track — on Home Alone (8 audio tracks, no default disposition)
it picked the DTS track (a=#7). But the Load payload carries Media[0].audioCodec
(ac3), so the pipeline was told AC3 while fed DTS: the audio ES never configures
and, with audioSync, the video slaves to the dead audio clock and wedges (~32s of
buffered video, then Feed() BufferFull forever, no window+PLAYING).

Now the default audio feeds the first track whose codec MATCHES the payload
(audio_stream_matching via avcodec_get_name), falling back to av_find_best_stream
only if none matches. Verified on rk 3: feeds a=#1 (ac3), window+PLAYING, timeline
climbs 72→142s. Caught by the new regression harness (home_alone_manyaudio).

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
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants