Skip to content

Add bounded MRT2 render worker protocol - #133

Closed
brxs wants to merge 3 commits into
codex/107-managed-runtime-finalfrom
codex/107-mrt2-render-protocol
Closed

Add bounded MRT2 render worker protocol#133
brxs wants to merge 3 commits into
codex/107-managed-runtime-finalfrom
codex/107-mrt2-render-protocol

Conversation

@brxs

@brxs brxs commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • add a dedicated authenticated --render-worker mode for PyTorch/CUDA MRT2 clip rendering
  • make integer frames authoritative on requests; the native gateway owns the documented half-up seconds-to-frames conversion
  • bind every job to a strictly increasing u64 sequence and exact {jobId, sequence, frames, pcmBytes} response oracle
  • define strict request, cancel, begin, chunk, end, and sanitized error frames with exact scalar types
  • cap all JSON, control, metadata, PCM, and chunk sizes and reject malformed, duplicate, out-of-order, truncated, or oversized input
  • keep one warmed MRT2 engine alive for serial jobs while terminating the disposable process on cancellation, EOF, write deadline, or overlapping/out-of-sequence requests
  • poll control before accepting a completed render, before BEGIN, between chunks, during bounded writes, and before/during END so cancellation and EOF cannot produce late output
  • consume the launch capability before its exact first-frame write, preventing reconnect or retry with the same child token
  • add a native-facing response parser that validates exact audio identity, aligned bounded chunks, exact PCM byte total, and SHA-256
  • add focused protocol tests for framing, limits, warm reuse, half-frame rounding, huge/deep JSON, exact scalar types, sequence ordering, one-shot authentication, cancellation/EOF at generation and chunk boundaries, and sanitized failures

Why

The portable managed-runtime work needs a bounded contract between the native host and an out-of-process MRT2 clip renderer. Keeping render traffic separate from real-time deck control prevents unbounded PCM or malformed control sequences from entering the deck-worker protocol, while process termination gives cancellation deterministic CUDA cleanup even though upstream inference is not cooperatively cancellable.

This is a stacked Wave A change based on codex/107-managed-runtime-final and contributes to #107.

User impact

There is no standalone UI change in this PR. It provides the reusable, warm PyTorch MRT2 render worker that the native Windows/Linux integration can supervise and consume without regressing the existing deck-worker behavior.

Validation

  • ruff format --check backend — 43 files already formatted
  • ruff check backend — passed
  • pytest backend/tests/test_render_sidecar.py backend/tests/test_sidecar.py -q — 48 passed
  • pytest backend/tests -q — 358 passed

@brxs

brxs commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by and fully consolidated into #131. The combined branch includes this lane's substantive changes, subsequent integration fixes, and exact-head cross-platform validation. Please continue review in #131.

@brxs brxs closed this Aug 10, 2026
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