Skip to content

Serialize the quality global in route decision tests to fix a flaky preview assertion - #240

Merged
GLinnik21 merged 1 commit into
mainfrom
worktree-agent-a0830799045232e64
Sep 25, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
worktree-agent-a0830799045232e64

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Summary

  • route::decision::resolve_route_tests::on_deck_hevc_p5_preview_uses_the_selected_episodes_codec flaked in CI and under local load, sometimes asserting Some(Converts) where Some(DirectPlay) was expected.
  • Root cause: playback_preview_with_capability_for_test reads the process-global playback quality ceiling (QUALITY: AtomicU8 in rust-modules/src/route/decision.rs, exposed via quality()) and the process-global server registry (crate::plex::client_for). This test ran unguarded, so a concurrently-running test on another thread could mutate the quality ceiling between this test's two assertions and flip the observed codec/decision outcome. Its sibling test right above it, the_preview_tells_a_container_remux_apart_from_a_re_encode, already avoided the bug by taking fresh_registry's lock and calling restore_quality.
  • Fix: give on_deck_hevc_p5_preview_uses_the_selected_episodes_codec the same fresh_registry + restore_quality(Quality::Original) guard, and add #[cfg(test)] crate::testlock::assert_held(...) to restore_quality and persist_quality_choice so any future test that mutates the quality global without holding testlock::serial() fails deterministically instead of racing silently.

Relative to #238

This PR does not contain the loopback-accept()/WouldBlock fixture fix. That class of flake (macOS accept() inheriting the listener's O_NONBLOCK) is already fixed on main by #238's shared crate::testnet::accept() helper (merged at 6d0b8e5b), which this branch is rebased on top of. This PR is scoped to only the independent quality-global race.

Evidence

  • Reproduced pre-fix: 1 failure in 10 runs of the target test at high thread count under CPU load; 0 failures in 30 runs post-fix.
  • make check on the committed tree — full host suite green (test result: ok).
  • CARGO_INCREMENTAL=0 cargo +nightly check --manifest-path rust-modules/Cargo.toml --lib --no-default-features — clean.
  • Codex adversarial review (codex-companion.mjs --wait --base main --scope branch -m gpt-6-astra) flagged one additional finding: back_dismisses_more_including_the_quality_recovery_variant in screens/player/overlay_tests.rs also constructs a More menu via MoreMenuState::new_quality, which reads quality() unguarded. Verified this is not a realistic flake: initial_selection and row_for only use the value to pick an initial focus row and a "checked" label, both bounded/unwrap_or(0)-safe for any Quality value, and the test's only assertions (handled, reqs.is_empty(), dismissed) are about BACK-key dismissal, which does not depend on which row started focused. No code change made for this finding per "fix only realistic findings."

Test plan

  • make check on the committed tree (full test result: ok)
  • cargo +nightly check --lib --no-default-features
  • Stress reproduction before/after the fix
  • Codex adversarial review, findings triaged

🤖 Generated with Claude Code

on_deck_hevc_p5_preview_uses_the_selected_episodes_codec called
playback_preview_with_capability_for_test without holding
crate::testlock::serial(), unlike its sibling test right above it
(the_preview_tells_a_container_remux_apart_from_a_re_encode). That
function reads the process-global quality ceiling (quality()) and the
plex server registry (client_for), both of which other tests in the
suite write while correctly holding the test lock. Without the lock on
this test's side, a concurrent test's restore_quality()/set_quality()
call could land between (or during) this test's two assertions and
flip the computed Preview from DirectPlay to Converts, which is
exactly the CI failure signature.

Fix the test itself by wrapping it in fresh_registry() + a baseline
restore_quality(Original), matching the established convention. Also
close the systemic gap: restore_quality and persist_quality_choice
were the only crate-global mutators route::decision reaches that did
not call testlock::assert_held, so a future test writing this global
without the lock would race silently instead of panicking at the
offending call site the way every other global mutator already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T03:39:13.209709Z 9360e1e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@GLinnik21
GLinnik21 merged commit 8fddd1d into main Sep 25, 2026
5 checks passed
@GLinnik21
GLinnik21 deleted the worktree-agent-a0830799045232e64 branch September 25, 2026 03:51
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
The note gains the image-subtitle fix, the trailer stop/reporting/redirect
behaviour, the art-crop, library-seat and profiles read-out fixes, and a
line for nightly users about BACK from the player. The audit records the
seven changes as host-verified and pending the device pass, the bundled
FFmpeg's new libz.so.1 dependency with its firmware evidence, and the
https HLS cross-origin redirect gap as a known follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
…brary firmware gate (#241)

* docs: correct two claims #235 and #239 left stale

ci/build-ffmpeg.sh: the firmware database fwsym holds spans platform
releases 1.2.0 to 11.2.0, not webOS 3 to 10; libz.so.1 is in every image.
docs/trailer-ux-plan.md: the deferred just_finished proposal names the
preview machine's current transitions, Machine::eos and Machine::stopped,
as docs/TODOS.md already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 release note and audit: cover #234-#240

The note gains the image-subtitle fix, the trailer stop/reporting/redirect
behaviour, the art-crop, library-seat and profiles read-out fixes, and a
line for nightly users about BACK from the player. The audit records the
seven changes as host-verified and pending the device pass, the bundled
FFmpeg's new libz.so.1 dependency with its firmware evidence, and the
https HLS cross-origin redirect gap as a known follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: the audit lint refuses an unfilled placeholder in the authored half

Nothing substitutes into a release audit's authored half; gen-release-audit
only replaces the generated block, so a __PLACEHOLDER__ left there
publishes literally. Watched red on the v0.7.0 audit's __GATES__ row before
it was filled; every existing audit and the template pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: record the gates run on the release-prep tree

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: fold in the second device pass over #234-#240

#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 release note and audit: #242 fixes the device pass's Sign-out focus finding

The audit lists #242 among the changes landed after the device pass,
host-verified and pending the device, and marks #237's focus-on-Sign-out
finding fixed by it. The note's smaller fixes gain the menu-focus line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: the gate row names the tree rebased onto #242

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 note and audit: scope the trailer and library promises, record the pass's account writes

Review findings on #241:
- A trailer started with Play Trailer is an ordinary playback
  (request_play, preview: false) and reports a timeline; only the
  background preview, full-screen mode included, never reports.
- The library DOWN fix holds only when the reader has not moved before
  the shelves load.
- The device-pass summary counts #236 as passed only for shelves-first.
- The pass wrote to the Guest profile: the explicit PGS pick's
  PUT /library/parts selection, and the harness's unscrobble, progress
  seeds and playback timelines.
- The gate row states that every commit after b99e79f is note/audit
  only and which checks were re-run on the head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fwcompat: grade the bundled FFmpeg libraries, and put their DT_NEEDED in the audit

#235 gave libavformat-plx a DT_NEEDED on libz.so.1, and nothing graded it:
the libraries are dlopen'd, webosbrew-ipk-verify grades only the app and
service executables, and fwcompat on a bundled library reported every
firmware FAIL for the sibling libav*-plx names no firmware carries.

tools/fwcompat.py --shipped DIR takes DT_NEEDED names that are files in DIR
off the firmware's list and counts what they export as resolved. Watched:
bare, libavformat-plx FAILs everywhere on its siblings; with --shipped pkg
all three pass from 4.4.2 to 11.2.0; against a copy of the 4.4.2 database
with libz removed it FAILs on libz.so.1 (4 symbols) and exits 1.

CI's firmware load matrix and the build's fwcompat gate now run it over
each bundled library; the build appends the matrix to pkg/ipk-verify.md,
which gen-release-audit.py embeds, and gen-release-audit.py lists each
bundled library's DT_NEEDED. Review finding on #241: the zlib verdict is
now read from the published package instead of typed into the audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: the zlib entry defers to the generated half; the gate row names the tooling commits

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fwcompat review: row() takes its cells, and --shipped says what it trusts

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build-package: the bundled-library matrix goes into ipk-verify.md unfenced

gen-release-audit.py already wraps that whole file in one code fence; a nested
fence closed it. Only the step summary fences the aligned columns now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[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.

1 participant