Skip to content

Protect carried client streams during idle admission - #69

Merged
pjeweb merged 4 commits into
osb/integrationfrom
osb/pr/carrying-liveness
Nov 14, 2026
Merged

pjeweb merged 4 commits into
osb/integrationfrom
osb/pr/carrying-liveness

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 13, 2026 •

Copy link
Copy Markdown

Why

A phone can stream through the box while the box's own encoder is idle. Before this PR, the box could treat that moment as idle and allow an update that is only meant to run when nothing is streaming, cutting off the phone's stream.

What it adds

  • The box counts a client stream it carries as live: a phone uploading above 1 Mbit/s for 20 seconds, or an SRT or RTMP sender connected to the box. Protection then holds for two minutes, and ongoing traffic keeps renewing it.
  • Updates, restart, power-off and link changes wait while the box carries a client stream, and a notice explains why. A refused manual action says it was not run and asks for a new attempt.
  • If the box cannot read this evidence, it does not claim to be idle. After every backend start, it waits 120 seconds before it can report idle.

Screenshots

Mock data; the same state at the PR base and head.

Before After
Before: Carried-client traffic warning (notification fixture) (390 px) After: Carried-client traffic warning (notification fixture) (390 px)
Before: Carried-client traffic warning (notification fixture) (1280 px) After: Carried-client traffic warning (notification fixture) (1280 px)

How

Carrying evidence (upload rate on the client-facing side, SRT connection events and RTMP publisher polling) now feeds the box's existing liveness answer and idle clock. It also shares ownership of the OTA marker, the flag file the image's update activator checks before it switches to a new system copy: the marker stays set while either the encoder or a carried stream is live. A shared idle-action policy is added for later automations (home AP pause, home cellular exclusion, heat idle rest); those are separate topics and are not enabled here.

Targets the fork integration branch. #70 builds on this PR.

Technical detail

A phone can stream through a box whose own encoder is idle. Previously that box could grant idle-only update admission. Client carrying now contributes to the existing liveness answer and the idle clock, with shared ownership of the OTA activation marker.

Client-facing upload above 1 Mbit/s for 20 seconds qualifies, followed by a two-minute hold. SRT connection events and RTMP publisher polling protect immediately; unreadable evidence withholds idle permission. Notices explain why updates and link changes wait. Large local uploads can conservatively hold idle actions too.

The shared idle-action policy covers home AP pause, home cellular exclusion and heat idle rest. Those automation implementations are separate topics and are not enabled by this change. Future independent sender/relay owners must report their session through the supplied evidence seam. Emergency thermal safety limits retain authority.

The own-stream idle explanation uses an additive key, preserving the immutable catalog oracle.

Review fixes
  • A brief sample at or below 250 kbit/s no longer opens an idle admission window during qualification: entry-level evidence withholds idle for 20 seconds. Repeated 0/200 kbit/s dips every 10–15 seconds remain protected; a lone burst still expires without claiming carrying.

  • Startup uses its own fixed 120-second checking deadline and reports unknown until real evidence exists. Ambient keep-level traffic cannot extend it. The idle clock still includes the startup boundary.

  • Manual refusals now say the action was not run and ask for a new attempt, in all ten locales. They neither queue the action nor assert that any stream ended. Power and SSH use the backend’s named refusal notification without an additional frontend toast; add-on/display refusals use the same corrected copy in their existing frontend feedback. Transport and execution failures retain their feedback.

  • A refused loopback connection or an absent legacy RTMP statistics resource reports no legacy RTMP session. Malformed replies, server errors and timeouts remain distinct: they withhold idle for up to 120 seconds of consecutive failures, then release this optional source. The full request/body budget is two seconds, with overlapping polls suppressed. Other carrying owners remain authoritative; this is not MediaMTX session discovery.

  • Upload entry still begins above 1 Mbit/s with a 20-second qualification. A 250 kbit/s keep threshold tolerates adaptive dips during qualification and refreshes an established hold. Only real session or qualified-upload protection can be extended by this traffic. Qualification activity contributes to the idle clock, which ages from the final hold boundary.

  • Every backend startup seeds a fresh 120-second protection window, covering a restart that loses the prior in-memory hold. A quiet box subsequently reaches idle; updates, reboot and power-off cannot use the first sample as an admission gap.

  • Client-aware refusal copy no longer directs a phone stream to the box's Stop button. Notices explicitly cover restart and power-off, with translations in all ten catalogs. Existing refusal tokens and admission checks are retained.

  • The OTA marker changes only when protection changes; failed writes remain retryable. Notices remain deduplicated by state.

  • The typed carrying status field, independent forwarding-sender reporter and HUD rendering belong to the sender/status follow-up. This PR deliberately leaves those fields and the primary HUD label to that owner; the HUD limitation remains until the follow-up lands.

New regressions cover a real refused loopback endpoint, genuine/malformed/absent HTTP responses, a stalled body, overlapping polls, threshold dips and sustained lower bitrate, cold startup/restart, marker write deduplication, and idle-clock aging after the hold. The initial regression run failed before implementation.

Second-review regressions were written and observed failing before implementation: deep/stalled qualification dips, startup/restart state and ambient upload expiry, truthful refusal copy, and duplicate frontend refusal feedback. Existing burst-boundary expectations now include the bounded checking window. Startup publication is checked for the unknown notice, with OTA protection retained.

Validation

Validation includes the engine-less boot regression, counter and hold boundaries, OTA-owner interleavings and a veth phone uploading through a shaped forwarding path. No hardware qualification is claimed. Initial validation receipts (superseded by the review-fix validation below):

  • Backend: 12,661 passed, 20 skipped, no failures under Bun 1.4.4; focused source-contract tests also pass.
  • Frontend: 7,642 passed and eight locale-parity failures in the full one-worker Node 24 run. After adding the missing keys, the complete affected file passes 10/10; all ten locales have matching keys. Four preflight tests pass.
  • The network namespace forwarding check passes. Lint, types and technical-debt checks pass.

After the copy correction, the complete i18n package passes 808/808; focused HUD and locale-parity tests pass 45/45. The full frontend suite was not repeated after these corrections. No browser E2E or hardware continuity test was run.

Review-fix validation: backend 12,672 passed / 20 skipped / 0 failed across 1,104 files; frontend 7,650/7,650 across 459 files plus four preflight tests; i18n 819/819; RPC 827/827; sender helpers 123/123. The final focused regression run passed 11/11. Lint, all type checks, technical-debt and workspace checks passed. Bun 1.4.4 used explicit --parallel=1 --max-concurrency=1; frontend tests used Node 24 with --maxWorkers=1. Gates ran sequentially in transient units with UMask 0022, Nice 10, CPUWeight 50, C locale and the PID namespace wrapper. No browser E2E, new forwarding-namespace run or hardware test was performed for this revision.

Second-review validation: backend 12677 passed / 20 skipped / 0 failed; frontend 7662/7662 across 459 files plus 4 preflight tests; i18n 820, RPC 827, sender helpers 123. Final focused backend regressions 24/24; final focused frontend 110/110. Lint, types, technical-debt and workspace checks passed. Bun 1.4.4 suites used --parallel=1 --max-concurrency=1; frontend used Node 24 and --maxWorkers=1. All authoritative gates ran in transient units with UMask 0022, Nice 10, CPUWeight 50, C locale and the PID namespace wrapper. No browser E2E, hardware test, deployment or upstream write was performed.

The explicit one-worker preflight clears Bun’s inherited JEST_WORKER_ID before spawning the separate Playwright inventory command; the unmodified package invocation also passes. No tests or production source were changed for this runner-environment adjustment.

@pjeweb
pjeweb added this pull request to stack #78 November 13, 2026 21:23
@pjeweb
pjeweb merged commit 7d26e12 into osb/integration Nov 14, 2026
3 checks passed
pjeweb added a commit that referenced this pull request Nov 16, 2026
@pjeweb pjeweb added the upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal. label Nov 16, 2026
pjeweb added a commit that referenced this pull request Nov 17, 2026
pjeweb added a commit that referenced this pull request Nov 17, 2026
pjeweb added a commit that referenced this pull request Nov 18, 2026
pjeweb added a commit that referenced this pull request Nov 18, 2026
pjeweb added a commit that referenced this pull request Nov 19, 2026
pjeweb added a commit that referenced this pull request Nov 21, 2026
pjeweb added a commit that referenced this pull request Nov 22, 2026
pjeweb added a commit that referenced this pull request Nov 23, 2026
pjeweb added a commit that referenced this pull request Nov 24, 2026
pjeweb added a commit that referenced this pull request Nov 24, 2026
@pjeweb

pjeweb commented Nov 25, 2026

Copy link
Copy Markdown
Author

Still carried in the integration train and not upstream, so it continues as #238.

pjeweb added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal.

Development

Successfully merging this pull request may close these issues.

1 participant