Skip to content

quality: a ceiling is a ROUTING policy first, a transcoder parameter second (#43 CASE1, partial) - #57

Merged
GLinnik21 merged 6 commits into
mainfrom
b2-quality-ceiling
Aug 23, 2026
Merged

GLinnik21 merged 6 commits into
mainfrom
b2-quality-ceiling

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses the tractable half of LG App Self Checklist #43 CASE1 — "resolution should change depending on network speed" — by giving the player a quality ladder. #43 CASE1 is NOT closed by this PR; see What is out of scope at the bottom.

The trap this deliberately avoids

The obvious implementation is a bitrate field on TranscodeSpec. It does nothing for exactly the file it exists for, and the tree already argued this out before there was a picker:

  • route::build_stream picks direct play → remux → re-encode BEFORE a spec exists (the directplay ladder, then let remux = …).
  • Only the re-encode branch of transcoder::transcode_query has ever carried maxVideoBitrate. Direct play streams the file's own bytes with no encoder anywhere to read a cap; a remux copies the codecs and sends no cap by design, because a cap is what would force the re-encode it exists to avoid — transcoder's own test says "a remux carries no cap, by design".
  • plex/params.rs argued against the field on purpose: "a link with a ceiling … is answered by choosing the FLAVOR — deny direct play, deny the remux, let the server pick a rate on the branch that has one — never by asking for a number."

So a 30 Mbit/s source on a 4 Mbit/s link direct-plays straight past any number on the spec, and the user who picked "4 Mbps" sees no change on the one file where it matters.

What this does instead

A rung is spent the way link_policy spends the relay tier: deny the two flavours that ship the file at its own rate, leaving the one whose whole point is that the server picks the rate. Only then does the number reach the wire.

piece what it is
route::Quality Auto + 5 rungs, each pairing a rate with the frame that rate can carry
route::quality_policy returns the same plex::LinkPolicy two flags link_policy does
route::flavors_allowed composes link ∧ user, per flavour — the stricter always wins
plex::Ceiling the parameter half; None (Auto) resolves to the native-4K literals this query has always sent

params.rs's argument is answered in the module doc rather than ignored: it was right about a link ceiling and wrong as a general rule, because a link is not the only thing that can impose one. A user-chosen ceiling is a different input through the identical mechanism, and the rule that survives unchanged is the ORDER — a number not preceded by a flavour refusal does nothing at all.

Two decisions worth arguing with:

  • An unmeasured source fails CLOSED. 0 is "the server did not say", and it passes video_direct_plays's device-capability gate. The asymmetry is deliberate: a device bound is a capability (unknown degrades to yesterday's behaviour), a user ceiling is an instruction (the only way to honour it about a file you have not measured is to route it where the server applies the bound for you). Failing open here reproduces the do-nothing bug above for every play that never loaded a detail page.
  • The ceiling is captured per PLAYBACK (Session::cur_ceiling), like cur_remux beside it, so a seek or a track switch rebuilds the identical query instead of reshaping the encode mid-film. set_quality is the one writer that may move it, because an explicit pick is new information and a seek is not.

The six routing tests are the gate

A screenshot proves a picker exists; it does not prove routing changed. All six grade the expression build_stream evaluates — flavors_allowed(link_policy(link), quality_policy(q, kbps, w, h)) was factored into a named function precisely so the tests are not a re-derivation that would agree with itself forever while the shipped path drifted.

  1. auto_leaves_every_routing_decision_exactly_where_it_was — the regression gate. Auto restricts nothing, for every source shape (including unmeasured) on every link tier, and composed it equals the link's own answer.
  2. a_source_measured_under_the_ceiling_stays_direct_play_eligible — 3 Mbit/s 720p keeps both fast paths under an 8 Mbit/s rung. This is what stops the feature degenerating into "a rung means always transcode".
  3. a_source_over_the_ceiling_is_refused_direct_play — over on rate alone, over on frame alone, and unmeasured.
  4. a_source_over_the_ceiling_is_refused_the_remux_as_well — the half a "force a transcode" instinct leaves behind.
  5. the_re_encode_query_carries_the_selected_ceiling_and_auto_still_asks_for_native_4k (in plex/transcoder.rs) — both axes replace rather than join the defaults, exactly one of each param, everything else in the query byte-identical, the remux still capless, and Auto byte-identical to the pre-ceiling literals.
  6. a_relay_link_and_a_user_ceiling_compose_to_the_stricter_of_the_two — full product of all 6 rungs × 4 source shapes × 4 link tiers. A relay is never loosened by a high rung; a rung is never loosened by a fast link.

Plus two more from the review (below). make check: 984 pass, up from 976 on cf6cef7e.

The UI

A second section of the player's existing … popover — no full-screen sheet, per docs/parity-gaps.md's standing decision ("The reference clients put nearly every action behind a full-screen modal sheet. We are not copying that"), and the reference client's Quality modal is one of those. A drill-in inside a popover was rejected too: it would need a BACK meaning "up one page" where every other panel's BACK means "dismiss".

Two row idioms, one design-system rule — a mark says where you are and a word says what is set, and no row says both: the Options switch keeps its trailing On/Off, the ladder gets Row::checked's leading checkmark, and each rung's rate rides inside its own label rather than in a trailing value beside the mark.

Screenshots (macOS simulator, 1920×1080, real PMS, player HUD → …):

  • Before — the popover holds one section: OPTIONS / Stats for nerds Off. Panel ~215px tall, bottom-anchored above the disc row.
  • After — the same popover holds OPTIONS / Stats for nerds Off, a divider, then QUALITY / ✓ Auto · 1080p · 20 Mbps · 1080p · 8 Mbps · 720p · 4 Mbps · 720p · 2 Mbps · 480p · 720 kbps. All nine rows visible, no scroll.
  • After, committed — selecting 720p · 4 Mbps and reopening shows the checkmark moved to that row and Auto unmarked.

The simulator cannot play video (the Starfish/ACB seam is absent), so the HUD sits in its Connecting… read-out — which is a Working read-out, so the transport and its discs draw normally and the whole picker path is exercised. Nothing here is a claim about frame rate, text rasterization, or video.

What /code-review found, and what it cost

Eight findings, all real, all fixed in the second commit. The two that mattered:

  • A direct play forgot the rung. plan.ceiling was set only on the transcode branch, after the direct-play return — and retranscode reaches a direct-play session (an audio-track switch, a subtitle burn; player/pump.rs says so in as many words) and spends cur_ceiling on the encode it then starts. Pick "480p · 720 kbps", play a small file that direct-plays, switch audio → re-encode at 4K/60 Mbps. The rung discarded on the one path where an encoder was actually running.
  • Every TV episode measured as unmeasured. src_kbps matched the loaded Detail on ratingKey alone, but pressing Play on a show page resolves the EPISODE's rk against a Detail holding the SHOW's. The match never landed, admits failed closed, and with any rung selected every episode lost direct play — while playback_preview, reading that same Detail's numbers directly, still promised Direct Play for it. detail_describes now also accepts the on-deck episode's key, which is the leaf whose technicals fetch_item_streams backfilled into the show and the leaf the preview already answers for.

And one the review turned up that changed the design: the picker did nothing in the only place it can be reached. The ladder lives in the player's … menu, so a rung that bound only future plays meant pressing BACK and replaying to see any effect, with nothing on screen saying so. set_quality now re-asks the routing question for the item on screen against the numbers that resolve measured, and reloads only when the answer changed — a higher rung than the picture already satisfies does nothing. It goes through request_transcode_refresh, the identical path a subtitle-burn change already takes, gated in the pump on a session that is actually Playing. This is user-initiated, not adaptive — nothing measures a link. It is also the one behaviour here no host test can see and the simulator cannot reach: flagged for the device pass.

Five smaller ones: a ptr::write into the now-owned static mut ROWS: Vec<Action> leaked the previous row list on every … press; the new panel-height cap was 4px under the content (derived from 560 of content, forgetting 40 of padding) so the last rung clipped; every rung's comment claimed to sit "under" a checklist leg it is numerically above (a rung is a CONTENT rate, a leg is a LINK rate — there is a table now, and it says out loud that the 512 Kbit/s leg is below this ladder's floor); admits judged a whole-file bitrate against a cap that ships as maxVideoBitrate, so each rung bit one AC-3 track early; and link_policy's doc still asserted the rule this work repealed — the third copy of that claim.

Verified against the tree, not the brief

  • params.rs's anti-bitrate argument, transcoder.rs's relay-only maxVideoBitrate=60000, and its "a remux carries no cap, by design" test: all confirmed verbatim.
  • The brief located direct-play/remux/re-encode selection at route.rs:1142-1162. The directplay ladder starts there; the remux decision is ~90 lines further on. Same function, one branch point, not one block.
  • docs/parity-gaps.md had already scoped this work and its Where prescription matches what landed almost line for line (store beside the remux flag, feed through the single transcode_spec constructor so build_stream, retranscode and transcode_seek rebuild an identical query). Its third row — "The source bitrate … not in the data model … Detail / PlayingItem" — is now half true: Detail carries all three; PlayingItem still does not, which is exactly the residual below.

What doc-claim-auditor found

Run over the diff after the review. Eight contradictions, across 71 tracked markdown files and 110 Rust files. Two were my own prose being wrong about my own code:

  • plex/CLAUDE.md claimed a Ceiling reaches transcode_query only once both fast flavours are denied. It reaches it on every spec, remux included — what reaches the wire only after a refusal is a rate. params.rs says the opposite two files away, and transcoder's own test builds exactly the spec the sentence said cannot exist.
  • app.rs's new call-site comment still said a rung "lands on the next resolve", which the review fix inverted. The only line left saying so, and it sat at the call site.

Two more were prose this change falsified: route::Preview's doc enumerates the gates build_stream applies and said three — there are four, and the ceiling is the one a reader debugging "why does this ordinary h264/AC-3 MKV say Converts" would never think of. And metadata.rs's technical-record block said it was "read by nothing else" than ui::tracks_panel; route::source_kbps reads video.bitrate from it now, so dropping the backfill would move every rung's threshold with a green suite.

Two are status records that decide what someone does next. ui/CLAUDE.md's module table said "a menu with one row" and named Row::checked for the row that draws Row::toggle — already inverted before this change, and now actively misleading, since Row::checked is what the Quality rungs in that same menu use. docs/lg-self-checklist.md #43 CASE1 said "one direct-play-vs-transcode decision at start, held for the session"; a user can change it mid-film now, a measurement still cannot — so the FAIL verdict is unchanged and only the reason is narrower.

Plus, across docs/parity-gaps.md, docs/shared-servers.md and docs/pms-api.md, nine more copies of "there is no picker" / "TranscodeSpec has no bitrate field" — parity-gaps.md repeats this gap once per reference-client audit, and shared-servers.md carries the relay argument twice more. Each is struck to "the gap it WAS" with the half that is still open kept: no badge, no persisted preference store, no force-direct-play, no disable-remux, and the live one below.

Files outside this lane's ownership

  • rust-modules/src/app.rs, +5 lines: one match arm in apply_more_action (Action is an exhaustive match there, so a new variant cannot compile without it) plus its comment correction. No other app.rs behaviour is touched.
  • rust-modules/src/metadata.rs — a block comment, no code.
  • plex/CLAUDE.md, ui/CLAUDE.md, docs/parity-gaps.md, docs/shared-servers.md, docs/pms-api.md, docs/lg-self-checklist.md — prose this change makes false. Leaving any of it would instruct the next reader wrongly, which is the failure mode the root CLAUDE.md opens by warning about.

Known residual

PlayingItem carries no bitrate, so the source rate is read off the loaded Detail. That covers the two ordinary paths (a movie's detail page; a show page's on-deck episode). An episode reached another way — a season list, Up Next — still measures 0 and so fails closed, meaning a selected rung transcodes it even when it would have fitted. Closing it is four lines in metadata.rs (one field, one assignment in fetch_playing_item, one in cached_playing), which is another lane's file.

What is out of scope — and why #43 CASE1 stays open

Mid-session ADAPTIVE switching is not here. Nothing measures the link or moves a rung on its own; measurement plus an automatic flavour switch is a 1–2 week piece with no precedent in this codebase (the closest machinery is the seek path, and a direct-play→transcode downgrade driven by a bandwidth estimate has none at all).

Do not mark #43 CASE1 Pass on this unit alone. It gives the checklist's scenario a control and a routing policy that honours it; it does not demonstrate the picture following the link unattended. A sibling lane is adding a rate:<kbps> mode to tools/netcond.py so the checklist's own 512 Kbps → 1 Mbps → 7 Mbps → 17.5 Mbps legs become reproducible — that is what a Pass needs, on the television.

Verification run

make check (984 pass, cargo +nightly, plus make lint and the packaging selftests) and the macOS simulator. No television — this lane held no device lock and ran no device suite. The live re-transcode on a rung change is the one path neither tier can see.


🤖 Generated with Claude Code

https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G

GLinnik21 and others added 6 commits August 23, 2026 13:05
…second

LG App Self Checklist #43 CASE1 asks that the picture follow the link. The
obvious implementation — a bitrate field on `TranscodeSpec` — does nothing for
exactly the file it exists for, and this deliberately is not that.

`build_stream` picks direct play → remux → re-encode BEFORE a spec exists, and
only the re-encode branch's query has ever carried `maxVideoBitrate`. Direct
play streams the file's own bytes with no encoder anywhere to read a cap; a
remux copies the codecs and sends no cap by design, because a cap is what would
force the re-encode it exists to avoid. So a 30 Mbit/s source on a 4 Mbit/s
link direct-plays straight past any number on the spec.

So a rung is spent the way `link_policy` spends the relay tier: deny the two
flavors that ship the file at its own rate, leaving the one whose whole point is
that the server picks the rate. Only then does the number reach the wire.

  route::Quality        Auto + 5 rungs, each pairing a rate with the frame it
                        makes sense at; each sits under one of the checklist's
                        own legs (512 Kbps / 1 Mbps / 7 Mbps / 17.5 Mbps).
  route::quality_policy returns the same two flags `link_policy` does.
  route::flavors_allowed composes the two — the stricter always wins, per
                        flavor. A relay cannot be loosened by a high rung.
  plex::Ceiling         the parameter half; `None` (Auto) resolves to the
                        native-4K literals this query has always sent.

An unmeasured source fails CLOSED, which is the opposite of
`video_direct_plays`'s unknown-passes rule and deliberately so: a device bound
is a capability, a user ceiling is an instruction. The ceiling is captured per
PLAYBACK (`Session::cur_ceiling`), like `cur_remux` beside it, so a seek or a
track switch rebuilds the identical query rather than reshaping the encode
mid-film.

The picker is a second section of the player's existing `…` popover — leading
checkmarks for the ladder, the trailing On/Off word for the switch above it, no
full-screen sheet (docs/parity-gaps.md's standing decision). Its panel could
hold 320px while this menu had one row; the ladder needs the room that is
actually there.

Six host tests are the gate, and they grade the expression `build_stream`
evaluates rather than a re-derivation of it: Auto changes nothing on any source
or link; under-ceiling content stays direct-play eligible; over-ceiling loses
direct play; over-ceiling loses the remux too; the re-encode query carries the
cap (and Auto's stays byte-identical); relay and rung compose to the stricter.

`plex/CLAUDE.md` said `TranscodeSpec` "must not grow" a bitrate field, which
was right about a LINK ceiling and wrong as a general rule — corrected there,
with the ORDER (flavour first, number second) kept as the rule that survives.

Mid-session adaptive switching is NOT here and #43 CASE1 is NOT closed by this.

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

`/code-review` found eight, and the two that mattered were both about the
ceiling being remembered in the wrong places.

**A direct play forgot the rung.** `plan.ceiling` was set only on the transcode
branch, after the direct-play `return`, so `cur_ceiling` stayed `None` for every
direct play — and `retranscode` reaches a direct-play session (an audio-track
switch, a subtitle burn; `player/pump.rs` says so in as many words) and spends
`cur_ceiling` on the encode it then starts. Picking "480p · 720 kbps", playing a
small file that direct-plays, then switching audio re-encoded at 4K/60 Mbps: the
rung silently discarded on the one path where an encoder was actually running.
It is now set on every plan, inert where it means nothing.

**Every TV episode measured as unmeasured.** `src_kbps` matched
`metadata::current()` on ratingKey alone, but pressing Play on a show page
resolves the EPISODE's rk against a Detail holding the SHOW's — so the match
never landed, `Ceiling::admits` failed closed, and with any rung selected every
episode in the library lost direct play while `playback_preview`, reading that
same Detail's numbers directly, still promised Direct Play for it. Two answers
to one question, which is the mismatch that preview exists to prevent.
`detail_describes` now accepts the on-deck episode's key too — the leaf whose
technicals `fetch_item_streams` backfilled into the show, and the leaf
`playback_preview` already answers for.

**And the picker did nothing in the only place it can be reached.** The ladder
lives in the player's `…` menu; a rung that bound only future plays meant
pressing BACK and replaying to see any effect, with nothing on screen saying so.
`set_quality` now re-asks the routing question for the item on screen, against
the numbers that resolve measured (`Session::cur_src`), and reloads only when
the answer changed — a higher rung than the picture already satisfies does
nothing. It goes through `request_transcode_refresh`, the identical path a
subtitle-burn change takes, gated in the pump on a session that is actually
Playing. User-initiated, not adaptive: nothing measures a link.

Five smaller ones, all real:
  - `ptr::write` into the now-owned `static mut ROWS: Vec<Action>` leaked the
    previous row list on every `…` press. It is an assignment now.
  - the new panel-height cap was 4px UNDER the content — derived from 560 of
    content, forgetting 40 of padding — so the last rung was clipped until you
    scrolled. Same symptom as the 320 it replaced, one row deep instead of five.
  - every rung's comment claimed to sit "under" a checklist leg it is
    numerically ABOVE. A rung is a CONTENT rate and a leg is a LINK rate; there
    is a table now, and it says out loud that the 512 Kbit/s leg is below this
    ladder's floor.
  - `admits` judged a whole-file bitrate against a cap that ships as
    `maxVideoBitrate`, so each rung bit one AC-3 track early. It reads the video
    stream's own rate where PMS gave one, whole-file as the fallback.
  - `link_policy`'s doc still asserted the rule this work repealed — the third
    copy of that claim, and the one the first commit missed.

Two new host tests pin the two MEDIUM findings; the six routing gates are
unchanged. 984 pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
The review fix set it for every flavour at the decision site, which left the
transcode branch's original assignment as a duplicate of a value that could not
have changed between the two lines. The comment stays, pointed at where the
assignment actually is.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
`docs/parity-gaps.md` is a gap CATALOG, so a landed gap left standing reads as
work still to do — and two of these three rows describe exactly what PR #57
built, which is the sort of claim that stays false for months here (the `ar`
claim and the `stream.rs` chunked claim both did).

  - "There is no Quality picker anywhere in the app" — there is. Annotated with
    what landed DIFFERENTLY from the row's own prescription (a section of the
    existing `…` popover, not a new `ui/quality_menu.rs` + a fifth
    `Overlay::Quality`) and with the half it did not anticipate at all: a rung
    is a ROUTING policy before it is a parameter.
  - "TranscodeSpec cannot express any other [target]" — it carries `ceiling`,
    and Auto resolves to those two literals byte for byte. Its *Where* said the
    remux branch should be "only taken at Original", which got sharper rather
    than simpler: a remux is refused for a source the rung cannot carry, and a
    small file under a low rung still remuxes.
  - "The source bitrate, width/height and videoResolution are not in the data
    model" — HALF true now. `Detail` has all three; `PlayingItem` has none, and
    that is the live residual, not a cosmetic one: an episode reached from a
    season list or Up Next measures 0 and fails closed.

Each keeps its *Where* and *Device* notes intact — they are still the map for
the half that is open.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
The first commit corrected three (`plex/CLAUDE.md`, `link_policy`'s doc,
`TranscodeSpec`'s own). A grep for the claim found four more, in three files —
which is the shape this repo keeps losing to: one sentence, copied into every
place that had to reason about it, then falsified in one edit.

  - parity-gaps.md's TOP-LEVEL summary ("G. Quality is one hard-coded rung"),
    which is the copy most likely to be read. It now also says out loud that
    every duplicate of the row further down the file is historical, so the four
    per-client audit sections do not each need their own annotation.
  - shared-servers.md's step-9 row and its relay-policy bullet. Both are ABOUT
    the relay, where nothing changed — the relay still names no rate — so they
    are corrected in place rather than rewritten: the branch-not-a-parameter
    argument survives, minus the premise that has stopped being true.
  - pms-api.md's Dolby Vision measurement, which quotes the re-encode query
    verbatim. Those two values are still exactly what Auto sends, so the
    measurement stands; the clause now says which configuration produced it.

Prose only.

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

Ran `doc-claim-auditor` over the diff. Eight contradictions across 71 tracked
markdown files and 110 Rust files; three I had already fixed while it ran. The
five that were left, plus its one nit:

**Two were MY OWN prose, wrong about my own code.**
  - `plex/CLAUDE.md` said a `Ceiling` reaches `transcode_query` only once both
    fast flavours are denied. It reaches it on EVERY spec, remux included —
    what reaches the WIRE only after a refusal is a rate. `params.rs` says the
    opposite two files away, and `transcoder`'s test builds exactly the spec
    the sentence claimed cannot exist. Corrected, and the remux branch's
    silence is now named as an invariant a test pins rather than a `None`
    anyone may rely on.
  - `app.rs`'s new call-site comment still said a rung "lands on the next
    resolve", which the second commit inverted. It was the only line left
    saying so, and it sat at the call site.

**Two were prose the change falsified elsewhere.**
  - `route::Preview`'s doc enumerates the gates `build_stream` applies and said
    THREE. There are four; the ceiling is the one a reader debugging "why does
    this ordinary h264/AC-3 MKV say Converts" would never think of.
  - `metadata.rs`'s technical-record block said it was "read by nothing else"
    than `ui::tracks_panel`. `route::source_kbps` reads `video.bitrate` from it
    now, so dropping the backfill would move every rung's threshold with a
    green suite.

**And two status records that decide what someone does next.**
  - `ui/CLAUDE.md`'s module table: "a menu with one row", and it named
    `Row::checked` for the row that draws `Row::toggle` — already inverted
    before this change, and now actively misleading, because `Row::checked` is
    what the Quality rungs in that same menu use. The table now carries the
    rule instead of one side of it.
  - `docs/lg-self-checklist.md` #43 CASE1: "one direct-play-vs-transcode
    decision at start, held for the session". A user can change it mid-film
    now; a measurement still cannot, which is why the item still FAILS — the
    verdict is unchanged and the reason is narrower.

Plus the six remaining `parity-gaps.md` quality rows the earlier pass missed
(the file repeats this gap once per reference-client audit), each struck to
"the gap it WAS" with the half that is still open kept: no badge, no PERSISTED
preference store, no force-direct-play, no disable-remux.

`params.rs`'s "asserted in `transcoder`'s tests" was half right — that suite
pins the ceiling is inert on a remux; `route`'s gates 2 and 4 pin the other
half. Both are named now.

Prose only; 984 tests unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GovTtrsD9P7Ld7DnLCMK2G
@GLinnik21
GLinnik21 merged commit 9a57e26 into main Aug 23, 2026
2 checks passed
GLinnik21 added a commit that referenced this pull request Aug 26, 2026
…second (#43 CASE1, partial) (#57)

* quality: a ceiling is a ROUTING policy first, a transcoder parameter second

LG App Self Checklist #43 CASE1 asks that the picture follow the link. The
obvious implementation — a bitrate field on `TranscodeSpec` — does nothing for
exactly the file it exists for, and this deliberately is not that.

`build_stream` picks direct play → remux → re-encode BEFORE a spec exists, and
only the re-encode branch's query has ever carried `maxVideoBitrate`. Direct
play streams the file's own bytes with no encoder anywhere to read a cap; a
remux copies the codecs and sends no cap by design, because a cap is what would
force the re-encode it exists to avoid. So a 30 Mbit/s source on a 4 Mbit/s
link direct-plays straight past any number on the spec.

So a rung is spent the way `link_policy` spends the relay tier: deny the two
flavors that ship the file at its own rate, leaving the one whose whole point is
that the server picks the rate. Only then does the number reach the wire.

  route::Quality        Auto + 5 rungs, each pairing a rate with the frame it
                        makes sense at; each sits under one of the checklist's
                        own legs (512 Kbps / 1 Mbps / 7 Mbps / 17.5 Mbps).
  route::quality_policy returns the same two flags `link_policy` does.
  route::flavors_allowed composes the two — the stricter always wins, per
                        flavor. A relay cannot be loosened by a high rung.
  plex::Ceiling         the parameter half; `None` (Auto) resolves to the
                        native-4K literals this query has always sent.

An unmeasured source fails CLOSED, which is the opposite of
`video_direct_plays`'s unknown-passes rule and deliberately so: a device bound
is a capability, a user ceiling is an instruction. The ceiling is captured per
PLAYBACK (`Session::cur_ceiling`), like `cur_remux` beside it, so a seek or a
track switch rebuilds the identical query rather than reshaping the encode
mid-film.

The picker is a second section of the player's existing `…` popover — leading
checkmarks for the ladder, the trailing On/Off word for the switch above it, no
full-screen sheet (docs/parity-gaps.md's standing decision). Its panel could
hold 320px while this menu had one row; the ladder needs the room that is
actually there.

Six host tests are the gate, and they grade the expression `build_stream`
evaluates rather than a re-derivation of it: Auto changes nothing on any source
or link; under-ceiling content stays direct-play eligible; over-ceiling loses
direct play; over-ceiling loses the remux too; the re-encode query carries the
cap (and Auto's stays byte-identical); relay and rung compose to the stricter.

`plex/CLAUDE.md` said `TranscodeSpec` "must not grow" a bitrate field, which
was right about a LINK ceiling and wrong as a general rule — corrected there,
with the ORDER (flavour first, number second) kept as the rule that survives.

Mid-session adaptive switching is NOT here and #43 CASE1 is NOT closed by this.

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

* quality: the review's two routing holes, and a picker that did nothing where it lives

`/code-review` found eight, and the two that mattered were both about the
ceiling being remembered in the wrong places.

**A direct play forgot the rung.** `plan.ceiling` was set only on the transcode
branch, after the direct-play `return`, so `cur_ceiling` stayed `None` for every
direct play — and `retranscode` reaches a direct-play session (an audio-track
switch, a subtitle burn; `player/pump.rs` says so in as many words) and spends
`cur_ceiling` on the encode it then starts. Picking "480p · 720 kbps", playing a
small file that direct-plays, then switching audio re-encoded at 4K/60 Mbps: the
rung silently discarded on the one path where an encoder was actually running.
It is now set on every plan, inert where it means nothing.

**Every TV episode measured as unmeasured.** `src_kbps` matched
`metadata::current()` on ratingKey alone, but pressing Play on a show page
resolves the EPISODE's rk against a Detail holding the SHOW's — so the match
never landed, `Ceiling::admits` failed closed, and with any rung selected every
episode in the library lost direct play while `playback_preview`, reading that
same Detail's numbers directly, still promised Direct Play for it. Two answers
to one question, which is the mismatch that preview exists to prevent.
`detail_describes` now accepts the on-deck episode's key too — the leaf whose
technicals `fetch_item_streams` backfilled into the show, and the leaf
`playback_preview` already answers for.

**And the picker did nothing in the only place it can be reached.** The ladder
lives in the player's `…` menu; a rung that bound only future plays meant
pressing BACK and replaying to see any effect, with nothing on screen saying so.
`set_quality` now re-asks the routing question for the item on screen, against
the numbers that resolve measured (`Session::cur_src`), and reloads only when
the answer changed — a higher rung than the picture already satisfies does
nothing. It goes through `request_transcode_refresh`, the identical path a
subtitle-burn change takes, gated in the pump on a session that is actually
Playing. User-initiated, not adaptive: nothing measures a link.

Five smaller ones, all real:
  - `ptr::write` into the now-owned `static mut ROWS: Vec<Action>` leaked the
    previous row list on every `…` press. It is an assignment now.
  - the new panel-height cap was 4px UNDER the content — derived from 560 of
    content, forgetting 40 of padding — so the last rung was clipped until you
    scrolled. Same symptom as the 320 it replaced, one row deep instead of five.
  - every rung's comment claimed to sit "under" a checklist leg it is
    numerically ABOVE. A rung is a CONTENT rate and a leg is a LINK rate; there
    is a table now, and it says out loud that the 512 Kbit/s leg is below this
    ladder's floor.
  - `admits` judged a whole-file bitrate against a cap that ships as
    `maxVideoBitrate`, so each rung bit one AC-3 track early. It reads the video
    stream's own rate where PMS gave one, whole-file as the fallback.
  - `link_policy`'s doc still asserted the rule this work repealed — the third
    copy of that claim, and the one the first commit missed.

Two new host tests pin the two MEDIUM findings; the six routing gates are
unchanged. 984 pass.

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

* quality: one assignment of plan.ceiling, not two

The review fix set it for every flavour at the decision site, which left the
transcode branch's original assignment as a duplicate of a value that could not
have changed between the two lines. The comment stays, pointed at where the
assignment actually is.

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

* docs: the three parity-gaps rows this quality work made false

`docs/parity-gaps.md` is a gap CATALOG, so a landed gap left standing reads as
work still to do — and two of these three rows describe exactly what PR #57
built, which is the sort of claim that stays false for months here (the `ar`
claim and the `stream.rs` chunked claim both did).

  - "There is no Quality picker anywhere in the app" — there is. Annotated with
    what landed DIFFERENTLY from the row's own prescription (a section of the
    existing `…` popover, not a new `ui/quality_menu.rs` + a fifth
    `Overlay::Quality`) and with the half it did not anticipate at all: a rung
    is a ROUTING policy before it is a parameter.
  - "TranscodeSpec cannot express any other [target]" — it carries `ceiling`,
    and Auto resolves to those two literals byte for byte. Its *Where* said the
    remux branch should be "only taken at Original", which got sharper rather
    than simpler: a remux is refused for a source the rung cannot carry, and a
    small file under a low rung still remuxes.
  - "The source bitrate, width/height and videoResolution are not in the data
    model" — HALF true now. `Detail` has all three; `PlayingItem` has none, and
    that is the live residual, not a cosmetic one: an episode reached from a
    season list or Up Next measures 0 and fails closed.

Each keeps its *Where* and *Device* notes intact — they are still the map for
the half that is open.

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

* docs: the FOUR remaining copies of "TranscodeSpec has no bitrate field"

The first commit corrected three (`plex/CLAUDE.md`, `link_policy`'s doc,
`TranscodeSpec`'s own). A grep for the claim found four more, in three files —
which is the shape this repo keeps losing to: one sentence, copied into every
place that had to reason about it, then falsified in one edit.

  - parity-gaps.md's TOP-LEVEL summary ("G. Quality is one hard-coded rung"),
    which is the copy most likely to be read. It now also says out loud that
    every duplicate of the row further down the file is historical, so the four
    per-client audit sections do not each need their own annotation.
  - shared-servers.md's step-9 row and its relay-policy bullet. Both are ABOUT
    the relay, where nothing changed — the relay still names no rate — so they
    are corrected in place rather than rewritten: the branch-not-a-parameter
    argument survives, minus the premise that has stopped being true.
  - pms-api.md's Dolby Vision measurement, which quotes the re-encode query
    verbatim. Those two values are still exactly what Auto sends, so the
    measurement stands; the clause now says which configuration produced it.

Prose only.

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

* docs: the doc-claim-auditor's eight, including two the code itself contradicted

Ran `doc-claim-auditor` over the diff. Eight contradictions across 71 tracked
markdown files and 110 Rust files; three I had already fixed while it ran. The
five that were left, plus its one nit:

**Two were MY OWN prose, wrong about my own code.**
  - `plex/CLAUDE.md` said a `Ceiling` reaches `transcode_query` only once both
    fast flavours are denied. It reaches it on EVERY spec, remux included —
    what reaches the WIRE only after a refusal is a rate. `params.rs` says the
    opposite two files away, and `transcoder`'s test builds exactly the spec
    the sentence claimed cannot exist. Corrected, and the remux branch's
    silence is now named as an invariant a test pins rather than a `None`
    anyone may rely on.
  - `app.rs`'s new call-site comment still said a rung "lands on the next
    resolve", which the second commit inverted. It was the only line left
    saying so, and it sat at the call site.

**Two were prose the change falsified elsewhere.**
  - `route::Preview`'s doc enumerates the gates `build_stream` applies and said
    THREE. There are four; the ceiling is the one a reader debugging "why does
    this ordinary h264/AC-3 MKV say Converts" would never think of.
  - `metadata.rs`'s technical-record block said it was "read by nothing else"
    than `ui::tracks_panel`. `route::source_kbps` reads `video.bitrate` from it
    now, so dropping the backfill would move every rung's threshold with a
    green suite.

**And two status records that decide what someone does next.**
  - `ui/CLAUDE.md`'s module table: "a menu with one row", and it named
    `Row::checked` for the row that draws `Row::toggle` — already inverted
    before this change, and now actively misleading, because `Row::checked` is
    what the Quality rungs in that same menu use. The table now carries the
    rule instead of one side of it.
  - `docs/lg-self-checklist.md` #43 CASE1: "one direct-play-vs-transcode
    decision at start, held for the session". A user can change it mid-film
    now; a measurement still cannot, which is why the item still FAILS — the
    verdict is unchanged and the reason is narrower.

Plus the six remaining `parity-gaps.md` quality rows the earlier pass missed
(the file repeats this gap once per reference-client audit), each struck to
"the gap it WAS" with the half that is still open kept: no badge, no PERSISTED
preference store, no force-direct-play, no disable-remux.

`params.rs`'s "asserted in `transcoder`'s tests" was half right — that suite
pins the ceiling is inert on a remux; `route`'s gates 2 and 4 pin the other
half. Both are named now.

Prose only; 984 tests unchanged.

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
…second (#43 CASE1, partial) (#57)

* quality: a ceiling is a ROUTING policy first, a transcoder parameter second

LG App Self Checklist #43 CASE1 asks that the picture follow the link. The
obvious implementation — a bitrate field on `TranscodeSpec` — does nothing for
exactly the file it exists for, and this deliberately is not that.

`build_stream` picks direct play → remux → re-encode BEFORE a spec exists, and
only the re-encode branch's query has ever carried `maxVideoBitrate`. Direct
play streams the file's own bytes with no encoder anywhere to read a cap; a
remux copies the codecs and sends no cap by design, because a cap is what would
force the re-encode it exists to avoid. So a 30 Mbit/s source on a 4 Mbit/s
link direct-plays straight past any number on the spec.

So a rung is spent the way `link_policy` spends the relay tier: deny the two
flavors that ship the file at its own rate, leaving the one whose whole point is
that the server picks the rate. Only then does the number reach the wire.

  route::Quality        Auto + 5 rungs, each pairing a rate with the frame it
                        makes sense at; each sits under one of the checklist's
                        own legs (512 Kbps / 1 Mbps / 7 Mbps / 17.5 Mbps).
  route::quality_policy returns the same two flags `link_policy` does.
  route::flavors_allowed composes the two — the stricter always wins, per
                        flavor. A relay cannot be loosened by a high rung.
  plex::Ceiling         the parameter half; `None` (Auto) resolves to the
                        native-4K literals this query has always sent.

An unmeasured source fails CLOSED, which is the opposite of
`video_direct_plays`'s unknown-passes rule and deliberately so: a device bound
is a capability, a user ceiling is an instruction. The ceiling is captured per
PLAYBACK (`Session::cur_ceiling`), like `cur_remux` beside it, so a seek or a
track switch rebuilds the identical query rather than reshaping the encode
mid-film.

The picker is a second section of the player's existing `…` popover — leading
checkmarks for the ladder, the trailing On/Off word for the switch above it, no
full-screen sheet (docs/parity-gaps.md's standing decision). Its panel could
hold 320px while this menu had one row; the ladder needs the room that is
actually there.

Six host tests are the gate, and they grade the expression `build_stream`
evaluates rather than a re-derivation of it: Auto changes nothing on any source
or link; under-ceiling content stays direct-play eligible; over-ceiling loses
direct play; over-ceiling loses the remux too; the re-encode query carries the
cap (and Auto's stays byte-identical); relay and rung compose to the stricter.

`plex/CLAUDE.md` said `TranscodeSpec` "must not grow" a bitrate field, which
was right about a LINK ceiling and wrong as a general rule — corrected there,
with the ORDER (flavour first, number second) kept as the rule that survives.

Mid-session adaptive switching is NOT here and #43 CASE1 is NOT closed by this.

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

* quality: the review's two routing holes, and a picker that did nothing where it lives

`/code-review` found eight, and the two that mattered were both about the
ceiling being remembered in the wrong places.

**A direct play forgot the rung.** `plan.ceiling` was set only on the transcode
branch, after the direct-play `return`, so `cur_ceiling` stayed `None` for every
direct play — and `retranscode` reaches a direct-play session (an audio-track
switch, a subtitle burn; `player/pump.rs` says so in as many words) and spends
`cur_ceiling` on the encode it then starts. Picking "480p · 720 kbps", playing a
small file that direct-plays, then switching audio re-encoded at 4K/60 Mbps: the
rung silently discarded on the one path where an encoder was actually running.
It is now set on every plan, inert where it means nothing.

**Every TV episode measured as unmeasured.** `src_kbps` matched
`metadata::current()` on ratingKey alone, but pressing Play on a show page
resolves the EPISODE's rk against a Detail holding the SHOW's — so the match
never landed, `Ceiling::admits` failed closed, and with any rung selected every
episode in the library lost direct play while `playback_preview`, reading that
same Detail's numbers directly, still promised Direct Play for it. Two answers
to one question, which is the mismatch that preview exists to prevent.
`detail_describes` now accepts the on-deck episode's key too — the leaf whose
technicals `fetch_item_streams` backfilled into the show, and the leaf
`playback_preview` already answers for.

**And the picker did nothing in the only place it can be reached.** The ladder
lives in the player's `…` menu; a rung that bound only future plays meant
pressing BACK and replaying to see any effect, with nothing on screen saying so.
`set_quality` now re-asks the routing question for the item on screen, against
the numbers that resolve measured (`Session::cur_src`), and reloads only when
the answer changed — a higher rung than the picture already satisfies does
nothing. It goes through `request_transcode_refresh`, the identical path a
subtitle-burn change takes, gated in the pump on a session that is actually
Playing. User-initiated, not adaptive: nothing measures a link.

Five smaller ones, all real:
  - `ptr::write` into the now-owned `static mut ROWS: Vec<Action>` leaked the
    previous row list on every `…` press. It is an assignment now.
  - the new panel-height cap was 4px UNDER the content — derived from 560 of
    content, forgetting 40 of padding — so the last rung was clipped until you
    scrolled. Same symptom as the 320 it replaced, one row deep instead of five.
  - every rung's comment claimed to sit "under" a checklist leg it is
    numerically ABOVE. A rung is a CONTENT rate and a leg is a LINK rate; there
    is a table now, and it says out loud that the 512 Kbit/s leg is below this
    ladder's floor.
  - `admits` judged a whole-file bitrate against a cap that ships as
    `maxVideoBitrate`, so each rung bit one AC-3 track early. It reads the video
    stream's own rate where PMS gave one, whole-file as the fallback.
  - `link_policy`'s doc still asserted the rule this work repealed — the third
    copy of that claim, and the one the first commit missed.

Two new host tests pin the two MEDIUM findings; the six routing gates are
unchanged. 984 pass.

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

* quality: one assignment of plan.ceiling, not two

The review fix set it for every flavour at the decision site, which left the
transcode branch's original assignment as a duplicate of a value that could not
have changed between the two lines. The comment stays, pointed at where the
assignment actually is.

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

* docs: the three parity-gaps rows this quality work made false

`docs/parity-gaps.md` is a gap CATALOG, so a landed gap left standing reads as
work still to do — and two of these three rows describe exactly what PR #57
built, which is the sort of claim that stays false for months here (the `ar`
claim and the `stream.rs` chunked claim both did).

  - "There is no Quality picker anywhere in the app" — there is. Annotated with
    what landed DIFFERENTLY from the row's own prescription (a section of the
    existing `…` popover, not a new `ui/quality_menu.rs` + a fifth
    `Overlay::Quality`) and with the half it did not anticipate at all: a rung
    is a ROUTING policy before it is a parameter.
  - "TranscodeSpec cannot express any other [target]" — it carries `ceiling`,
    and Auto resolves to those two literals byte for byte. Its *Where* said the
    remux branch should be "only taken at Original", which got sharper rather
    than simpler: a remux is refused for a source the rung cannot carry, and a
    small file under a low rung still remuxes.
  - "The source bitrate, width/height and videoResolution are not in the data
    model" — HALF true now. `Detail` has all three; `PlayingItem` has none, and
    that is the live residual, not a cosmetic one: an episode reached from a
    season list or Up Next measures 0 and fails closed.

Each keeps its *Where* and *Device* notes intact — they are still the map for
the half that is open.

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

* docs: the FOUR remaining copies of "TranscodeSpec has no bitrate field"

The first commit corrected three (`plex/CLAUDE.md`, `link_policy`'s doc,
`TranscodeSpec`'s own). A grep for the claim found four more, in three files —
which is the shape this repo keeps losing to: one sentence, copied into every
place that had to reason about it, then falsified in one edit.

  - parity-gaps.md's TOP-LEVEL summary ("G. Quality is one hard-coded rung"),
    which is the copy most likely to be read. It now also says out loud that
    every duplicate of the row further down the file is historical, so the four
    per-client audit sections do not each need their own annotation.
  - shared-servers.md's step-9 row and its relay-policy bullet. Both are ABOUT
    the relay, where nothing changed — the relay still names no rate — so they
    are corrected in place rather than rewritten: the branch-not-a-parameter
    argument survives, minus the premise that has stopped being true.
  - pms-api.md's Dolby Vision measurement, which quotes the re-encode query
    verbatim. Those two values are still exactly what Auto sends, so the
    measurement stands; the clause now says which configuration produced it.

Prose only.

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

* docs: the doc-claim-auditor's eight, including two the code itself contradicted

Ran `doc-claim-auditor` over the diff. Eight contradictions across 71 tracked
markdown files and 110 Rust files; three I had already fixed while it ran. The
five that were left, plus its one nit:

**Two were MY OWN prose, wrong about my own code.**
  - `plex/CLAUDE.md` said a `Ceiling` reaches `transcode_query` only once both
    fast flavours are denied. It reaches it on EVERY spec, remux included —
    what reaches the WIRE only after a refusal is a rate. `params.rs` says the
    opposite two files away, and `transcoder`'s test builds exactly the spec
    the sentence claimed cannot exist. Corrected, and the remux branch's
    silence is now named as an invariant a test pins rather than a `None`
    anyone may rely on.
  - `app.rs`'s new call-site comment still said a rung "lands on the next
    resolve", which the second commit inverted. It was the only line left
    saying so, and it sat at the call site.

**Two were prose the change falsified elsewhere.**
  - `route::Preview`'s doc enumerates the gates `build_stream` applies and said
    THREE. There are four; the ceiling is the one a reader debugging "why does
    this ordinary h264/AC-3 MKV say Converts" would never think of.
  - `metadata.rs`'s technical-record block said it was "read by nothing else"
    than `ui::tracks_panel`. `route::source_kbps` reads `video.bitrate` from it
    now, so dropping the backfill would move every rung's threshold with a
    green suite.

**And two status records that decide what someone does next.**
  - `ui/CLAUDE.md`'s module table: "a menu with one row", and it named
    `Row::checked` for the row that draws `Row::toggle` — already inverted
    before this change, and now actively misleading, because `Row::checked` is
    what the Quality rungs in that same menu use. The table now carries the
    rule instead of one side of it.
  - `docs/lg-self-checklist.md` #43 CASE1: "one direct-play-vs-transcode
    decision at start, held for the session". A user can change it mid-film
    now; a measurement still cannot, which is why the item still FAILS — the
    verdict is unchanged and the reason is narrower.

Plus the six remaining `parity-gaps.md` quality rows the earlier pass missed
(the file repeats this gap once per reference-client audit), each struck to
"the gap it WAS" with the half that is still open kept: no badge, no PERSISTED
preference store, no force-direct-play, no disable-remux.

`params.rs`'s "asserted in `transcoder`'s tests" was half right — that suite
pins the ceiling is inert on a remux; `route`'s gates 2 and 4 pin the other
half. Both are named now.

Prose only; 984 tests unchanged.

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
…second (#43 CASE1, partial) (#57)

* quality: a ceiling is a ROUTING policy first, a transcoder parameter second

LG App Self Checklist #43 CASE1 asks that the picture follow the link. The
obvious implementation — a bitrate field on `TranscodeSpec` — does nothing for
exactly the file it exists for, and this deliberately is not that.

`build_stream` picks direct play → remux → re-encode BEFORE a spec exists, and
only the re-encode branch's query has ever carried `maxVideoBitrate`. Direct
play streams the file's own bytes with no encoder anywhere to read a cap; a
remux copies the codecs and sends no cap by design, because a cap is what would
force the re-encode it exists to avoid. So a 30 Mbit/s source on a 4 Mbit/s
link direct-plays straight past any number on the spec.

So a rung is spent the way `link_policy` spends the relay tier: deny the two
flavors that ship the file at its own rate, leaving the one whose whole point is
that the server picks the rate. Only then does the number reach the wire.

  route::Quality        Auto + 5 rungs, each pairing a rate with the frame it
                        makes sense at; each sits under one of the checklist's
                        own legs (512 Kbps / 1 Mbps / 7 Mbps / 17.5 Mbps).
  route::quality_policy returns the same two flags `link_policy` does.
  route::flavors_allowed composes the two — the stricter always wins, per
                        flavor. A relay cannot be loosened by a high rung.
  plex::Ceiling         the parameter half; `None` (Auto) resolves to the
                        native-4K literals this query has always sent.

An unmeasured source fails CLOSED, which is the opposite of
`video_direct_plays`'s unknown-passes rule and deliberately so: a device bound
is a capability, a user ceiling is an instruction. The ceiling is captured per
PLAYBACK (`Session::cur_ceiling`), like `cur_remux` beside it, so a seek or a
track switch rebuilds the identical query rather than reshaping the encode
mid-film.

The picker is a second section of the player's existing `…` popover — leading
checkmarks for the ladder, the trailing On/Off word for the switch above it, no
full-screen sheet (docs/parity-gaps.md's standing decision). Its panel could
hold 320px while this menu had one row; the ladder needs the room that is
actually there.

Six host tests are the gate, and they grade the expression `build_stream`
evaluates rather than a re-derivation of it: Auto changes nothing on any source
or link; under-ceiling content stays direct-play eligible; over-ceiling loses
direct play; over-ceiling loses the remux too; the re-encode query carries the
cap (and Auto's stays byte-identical); relay and rung compose to the stricter.

`plex/CLAUDE.md` said `TranscodeSpec` "must not grow" a bitrate field, which
was right about a LINK ceiling and wrong as a general rule — corrected there,
with the ORDER (flavour first, number second) kept as the rule that survives.

Mid-session adaptive switching is NOT here and #43 CASE1 is NOT closed by this.

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

* quality: the review's two routing holes, and a picker that did nothing where it lives

`/code-review` found eight, and the two that mattered were both about the
ceiling being remembered in the wrong places.

**A direct play forgot the rung.** `plan.ceiling` was set only on the transcode
branch, after the direct-play `return`, so `cur_ceiling` stayed `None` for every
direct play — and `retranscode` reaches a direct-play session (an audio-track
switch, a subtitle burn; `player/pump.rs` says so in as many words) and spends
`cur_ceiling` on the encode it then starts. Picking "480p · 720 kbps", playing a
small file that direct-plays, then switching audio re-encoded at 4K/60 Mbps: the
rung silently discarded on the one path where an encoder was actually running.
It is now set on every plan, inert where it means nothing.

**Every TV episode measured as unmeasured.** `src_kbps` matched
`metadata::current()` on ratingKey alone, but pressing Play on a show page
resolves the EPISODE's rk against a Detail holding the SHOW's — so the match
never landed, `Ceiling::admits` failed closed, and with any rung selected every
episode in the library lost direct play while `playback_preview`, reading that
same Detail's numbers directly, still promised Direct Play for it. Two answers
to one question, which is the mismatch that preview exists to prevent.
`detail_describes` now accepts the on-deck episode's key too — the leaf whose
technicals `fetch_item_streams` backfilled into the show, and the leaf
`playback_preview` already answers for.

**And the picker did nothing in the only place it can be reached.** The ladder
lives in the player's `…` menu; a rung that bound only future plays meant
pressing BACK and replaying to see any effect, with nothing on screen saying so.
`set_quality` now re-asks the routing question for the item on screen, against
the numbers that resolve measured (`Session::cur_src`), and reloads only when
the answer changed — a higher rung than the picture already satisfies does
nothing. It goes through `request_transcode_refresh`, the identical path a
subtitle-burn change takes, gated in the pump on a session that is actually
Playing. User-initiated, not adaptive: nothing measures a link.

Five smaller ones, all real:
  - `ptr::write` into the now-owned `static mut ROWS: Vec<Action>` leaked the
    previous row list on every `…` press. It is an assignment now.
  - the new panel-height cap was 4px UNDER the content — derived from 560 of
    content, forgetting 40 of padding — so the last rung was clipped until you
    scrolled. Same symptom as the 320 it replaced, one row deep instead of five.
  - every rung's comment claimed to sit "under" a checklist leg it is
    numerically ABOVE. A rung is a CONTENT rate and a leg is a LINK rate; there
    is a table now, and it says out loud that the 512 Kbit/s leg is below this
    ladder's floor.
  - `admits` judged a whole-file bitrate against a cap that ships as
    `maxVideoBitrate`, so each rung bit one AC-3 track early. It reads the video
    stream's own rate where PMS gave one, whole-file as the fallback.
  - `link_policy`'s doc still asserted the rule this work repealed — the third
    copy of that claim, and the one the first commit missed.

Two new host tests pin the two MEDIUM findings; the six routing gates are
unchanged. 984 pass.

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

* quality: one assignment of plan.ceiling, not two

The review fix set it for every flavour at the decision site, which left the
transcode branch's original assignment as a duplicate of a value that could not
have changed between the two lines. The comment stays, pointed at where the
assignment actually is.

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

* docs: the three parity-gaps rows this quality work made false

`docs/parity-gaps.md` is a gap CATALOG, so a landed gap left standing reads as
work still to do — and two of these three rows describe exactly what PR #57
built, which is the sort of claim that stays false for months here (the `ar`
claim and the `stream.rs` chunked claim both did).

  - "There is no Quality picker anywhere in the app" — there is. Annotated with
    what landed DIFFERENTLY from the row's own prescription (a section of the
    existing `…` popover, not a new `ui/quality_menu.rs` + a fifth
    `Overlay::Quality`) and with the half it did not anticipate at all: a rung
    is a ROUTING policy before it is a parameter.
  - "TranscodeSpec cannot express any other [target]" — it carries `ceiling`,
    and Auto resolves to those two literals byte for byte. Its *Where* said the
    remux branch should be "only taken at Original", which got sharper rather
    than simpler: a remux is refused for a source the rung cannot carry, and a
    small file under a low rung still remuxes.
  - "The source bitrate, width/height and videoResolution are not in the data
    model" — HALF true now. `Detail` has all three; `PlayingItem` has none, and
    that is the live residual, not a cosmetic one: an episode reached from a
    season list or Up Next measures 0 and fails closed.

Each keeps its *Where* and *Device* notes intact — they are still the map for
the half that is open.

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

* docs: the FOUR remaining copies of "TranscodeSpec has no bitrate field"

The first commit corrected three (`plex/CLAUDE.md`, `link_policy`'s doc,
`TranscodeSpec`'s own). A grep for the claim found four more, in three files —
which is the shape this repo keeps losing to: one sentence, copied into every
place that had to reason about it, then falsified in one edit.

  - parity-gaps.md's TOP-LEVEL summary ("G. Quality is one hard-coded rung"),
    which is the copy most likely to be read. It now also says out loud that
    every duplicate of the row further down the file is historical, so the four
    per-client audit sections do not each need their own annotation.
  - shared-servers.md's step-9 row and its relay-policy bullet. Both are ABOUT
    the relay, where nothing changed — the relay still names no rate — so they
    are corrected in place rather than rewritten: the branch-not-a-parameter
    argument survives, minus the premise that has stopped being true.
  - pms-api.md's Dolby Vision measurement, which quotes the re-encode query
    verbatim. Those two values are still exactly what Auto sends, so the
    measurement stands; the clause now says which configuration produced it.

Prose only.

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

* docs: the doc-claim-auditor's eight, including two the code itself contradicted

Ran `doc-claim-auditor` over the diff. Eight contradictions across 71 tracked
markdown files and 110 Rust files; three I had already fixed while it ran. The
five that were left, plus its one nit:

**Two were MY OWN prose, wrong about my own code.**
  - `plex/CLAUDE.md` said a `Ceiling` reaches `transcode_query` only once both
    fast flavours are denied. It reaches it on EVERY spec, remux included —
    what reaches the WIRE only after a refusal is a rate. `params.rs` says the
    opposite two files away, and `transcoder`'s test builds exactly the spec
    the sentence claimed cannot exist. Corrected, and the remux branch's
    silence is now named as an invariant a test pins rather than a `None`
    anyone may rely on.
  - `app.rs`'s new call-site comment still said a rung "lands on the next
    resolve", which the second commit inverted. It was the only line left
    saying so, and it sat at the call site.

**Two were prose the change falsified elsewhere.**
  - `route::Preview`'s doc enumerates the gates `build_stream` applies and said
    THREE. There are four; the ceiling is the one a reader debugging "why does
    this ordinary h264/AC-3 MKV say Converts" would never think of.
  - `metadata.rs`'s technical-record block said it was "read by nothing else"
    than `ui::tracks_panel`. `route::source_kbps` reads `video.bitrate` from it
    now, so dropping the backfill would move every rung's threshold with a
    green suite.

**And two status records that decide what someone does next.**
  - `ui/CLAUDE.md`'s module table: "a menu with one row", and it named
    `Row::checked` for the row that draws `Row::toggle` — already inverted
    before this change, and now actively misleading, because `Row::checked` is
    what the Quality rungs in that same menu use. The table now carries the
    rule instead of one side of it.
  - `docs/lg-self-checklist.md` #43 CASE1: "one direct-play-vs-transcode
    decision at start, held for the session". A user can change it mid-film
    now; a measurement still cannot, which is why the item still FAILS — the
    verdict is unchanged and the reason is narrower.

Plus the six remaining `parity-gaps.md` quality rows the earlier pass missed
(the file repeats this gap once per reference-client audit), each struck to
"the gap it WAS" with the half that is still open kept: no badge, no PERSISTED
preference store, no force-direct-play, no disable-remux.

`params.rs`'s "asserted in `transcoder`'s tests" was half right — that suite
pins the ceiling is inert on a remux; `route`'s gates 2 and 4 pin the other
half. Both are named now.

Prose only; 984 tests unchanged.

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
GLinnik21 deleted the b2-quality-ceiling branch September 3, 2026 18:09
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.

1 participant