# Production readiness audit

Audit started 2026-12-01. Scope: the entire Rust workspace, native boundaries,
CLI/window lifecycle, tests, CI, packaging and benchmark tooling. Work began
locally; the user later authorized pushing the audit branch. No release is authorized. This report distinguishes executed checks,
source-review findings, and unverified release requirements.

## Baseline and scoring

Baseline revision: `5828b71`. About 3,730 implementation lines across eight crates.
Original tests are useful smoke/regression coverage, not a security certification. Final score: **54/100**, verdict **NO-GO**; see executed evidence and remaining gates below.
Each category is scored 0–10: 0 absent; 2 design only; 4 basic implementation and
smokes; 6 negative/regression automation; 8 sustained independent validation;
10 maintained release evidence across the supported platform matrix. Scores are
engineering judgments, not probabilities of correctness. A release requires no
critical/high unresolved security/reliability issue and actual platform evidence;
a total alone cannot override those gates.

| Category | Initial | Final |
| --- | ---: | ---: |
| Architecture/maintainability | 6 | 6 |
| Code quality/FFI | 4 | 7 |
| Tests/fuzz/stress | 4 | 6 |
| Security | 2 | 5 |
| Performance | 3 | 5 |
| Concurrency | 5 | 7 |
| Playback correctness | 5 | 6 |
| Reliability/soak | 3 | 5 |
| Compatibility | 2 | 2 |
| Release engineering | 3 | 5 |
| **Total /100** | **37** | **54** |

Initial verdict: **NO-GO**. The known CPU gap, Linux-only runtime evidence,
no fuzz/sanitizer campaign, unaudited dependency/license inventory, and native
parser exposure prevent a production claim.

## Reproducible validation

Run `python3 tools/validate.py --output target/validation/baseline` from the repo.
Add `--device --stress 20` for audio-device and repeated seek/queue checks.
Requires stable Rust with clippy/rustfmt, FFmpeg CLI and development libraries,
libass, ALSA development libraries (Linux), pkg-config and libclang. Lockfile is
mandatory. The harness records environment versions, revision, lockfile digest,
commands, exit status, bounded runtime and log digests. It fails on the first
failure. Logs are private ignored artifacts; commit summarized public evidence.
The existing local libclang extraction is auto-detected without system changes.

## Findings register

Severity: Critical = likely arbitrary execution/data loss; High = untrusted-input
access beyond scope or serious persistent availability failure; Medium = bounded
crash/incorrect behavior or major validation gap; Low = maintenance/diagnostics.
No speculative issue is labeled a demonstrated exploit.

| ID | Severity | Finding | Status/evidence |
| --- | --- | --- | --- |
| SEC-01 | High | Canonicalizing the top-level path does not restrict FFmpeg nested protocols/resources. Local media can reference other inputs. | Fixed; local file/manifest/cancellation regressions and workspace checks pass. |
| SEC-02 | High | Native FFmpeg/libass/font parsing occurs in-process without an OS sandbox or process memory/time isolation. Rust cannot contain a native vulnerability. | Open release blocker. |
| REL-01 | High | Native open/read/seek can hold the UI or prevent worker joins; no interrupt/deadline policy. Special files are accepted. | Partially mitigated; kernel reads/native CPU still not preemptible. |
| REL-02 | Medium | Unchecked PTS arithmetic and zero-rate resampler division can panic in debug or wrap in release. | Saturating PTS arithmetic and audio metadata limits added. |
| REL-03 | Medium | Worker panics are ignored at join and can silently leave remaining workers running. | Worker unwind supervision and persistent failure added. |
| MEM-01 | Medium | GPU upload allocates textures before validating public frame dimensions/strides; device limits not checked. | Public frame validation runs before texture allocation; device limits enforced. |
| REL-04 | Medium | An old callback could retire newly queued seek-generation audio. | Fixed; deterministic generation-preservation regression. |
| SEC-03 | High | Older libass runtimes can contain known ASS memory-safety defects; no minimum version was enforced. | Fixed runtime floor >= 0.17.5; local version is 0.17.5. |
| SEC-04 | High | Native plane slicing assumed allocated planes and positive bounded strides. | Fixed checks before ffmpeg-next::data; missing-plane regression reproduced a panic before the fix. No exploit demonstrated. |
| REL-05 | High | Repeated subtitle campaign exceeded its 1 GiB process RSS budget. Saved input does not reproduce alone or repeated 1000 times. | Open; cumulative resource behavior remains unresolved. |
| QA-01 | High | No Windows/macOS runtime validation, sanitizer campaign, measured A/V loopback or prolonged soak. | Open release blockers. |
| PERF-01 | Medium | Previous same-file measurements show substantially higher CPU than mpv/VLC. GPU adapter/backend not controlled. | Matched OpenGL comparison executed; final scalars below. Higher UI/render overhead still needs profiling. |
| RELEASE-01 | Medium | Floating CI image/toolchain/actions; no dependency vulnerability/license gate or reproducible package artifact. | Partially fixed: locked validation, pinned CI inputs, inventory and deterministic staging; release gates remain. |

## Architecture review

Core types do not expose FFmpeg; separate ownership of demux/audio/video contexts
and bounded media/control queues are good foundations. Player orchestration still
knows FFmpeg parameter types and reconstructs concrete decoders: traits exist but
backend swapping needs a factory/bootstrap abstraction. Do not add a speculative
plugin framework during security fixes. `Player` intentionally stays on one UI
thread through Cell/RefCell; native contexts live on their owning workers. The
callback uses atomics and a single-producer ring; its per-sample atomics/copies are
performance candidates, not yet proven bottlenecks. Packet limits allow roughly
1 GiB across the two 32-entry queues; native allocation occurs before Rust checks.
Frame/subtitle budgets similarly do not constitute a process memory bound.

## Progress

- Read all crate implementations, app lifecycle/control paths, existing tests,
  CI, packaging, benchmark methodology and architecture documentation.
- Added a fail-closed local validation harness. Baseline checks are next.

### Hardening evidence and scope

Baseline `target/validation/baseline/results.json`: all 11 commands passed,
including both feature variants. The new custom AVIO input owns a regular-file
handle, supplies no filename hint, restricts demuxers to self-contained formats,
and sets `protocol_whitelist=NONE`. Regression tests reject concat/HTTP manifests,
directories and /dev/zero and cancel during open. Native I/O polls a cancellation
closure and a ten-second per-operation deadline; player stop and subtitle loader
cancellation reach that closure. This is cooperative, not a hard CPU/kernel I/O
bound. FIFOs/devices are rejected before open, but concurrent hostile filesystem
replacement is not contained. Native parsing still needs an OS sandbox.

Decoded video is checked against device dimensions, finite aspect, checked stride
arithmetic and buffer length before GPU operations. Native decoder `max_pixels`
and `max_samples` options limit ordinary decoder allocations; audio conversion
also validates rates/channels/output capacity. Libass caches now have explicit
limits; raster clipping uses wide coordinate arithmetic. These do not bound all
native allocations or complex ASS rendering time.

Queue budgets were reduced to eight packets per stream, four MiB per packet and
three decoded frames (roughly 64 MiB queued packet payload plus at most about
77 MiB ordinary YUV420 frames). Codec internal buffers/side data are additional.
Rust worker panics trigger stop/error propagation; error state remains observable
on repeated checks. A failed audio stream reset is terminal rather than leaving
an uncommitted seek. Non-UTF8 CLI media paths no longer pass through env::args.

An attempted four-thread decoder configuration broke the existing corruption
regression because error delivery became asynchronous. Restored single-thread
native decoding; retained the strict test and resource-limit options. An early
locked validation also correctly rejected a changed workspace dependency edge
until Cargo.lock was regenerated offline. Neither failure was waived.

RustSec cargo-audit 0.23.0, database revision
`8cfccd2c20916f01964332b40623bc7cb8e1f211` (2026-11-30): zero known vulnerabilities
among 395 lockfile packages, two unmaintained warnings: paste 1.0.15
(RUSTSEC-2024-0436, target-specific graphics dependency) and ttf-parser 0.25.1
(RUSTSEC-2026-0192 via ab_glyph/egui and winit decorations). No advisory is ignored.
No fixed compatible version is indicated by these notices; upstream migration
needs tracking. This scan does not cover installed FFmpeg, libass or GPU drivers.

### Audio generation and native ABI follow-up

Source review found a concrete generation-ordering problem: the old callback
compared ring entries against a cached generation, so a sample published after a
seek could be discarded as obsolete. The callback now observes the head before
loading the active generation and preserves new-generation samples for the new
stream. A deterministic test covers an old callback, stale data, newly published
data, pause and exact queue accounting. PCM output clamps finite amplified values
and converts NaN/infinity to silence. No callback allocation/lock was introduced.

Upstream libass advisories [GHSA-5gf7-wjfm-vmvm](https://github.com/libass/libass/security/advisories/GHSA-5gf7-wjfm-vmvm)
and [GHSA-pjjp-65r7-ppgm](https://github.com/libass/libass/security/advisories/GHSA-pjjp-65r7-ppgm)
identify 0.17.5 as patched. RLC now rejects older runtime versions before parsing
subtitles and validates public SubtitleSource budgets/timestamp sums before FFI.
No exploit in the installed 0.17.5 library was demonstrated. A test compiles a C
layout probe against the actual ASS_Image header and compares size, alignment and
all used field offsets with Rust. This validates the local ABI, not Windows ABI.

Config and playlist readers also reject non-regular inputs before opening them.
Cooperative deadlines still cannot preempt kernel filesystem stalls, decoder CPU
loops or font-provider stalls; full process isolation remains necessary.

### Native plane boundary regression

A new missing-plane test failed on the pre-fix code inside ffmpeg-next::data
(`out of bounds`), then passed after the fix. The wrapper converts native signed
linesizes to usize and constructs slices from stride × height. RLC now rejects
missing planes, negative/oversized stride encodings and copy budgets before
calling data(), and checks scaler output too. A separate regression exercises
usize::MAX, short strides and over-budget planes. Negative-stride inputs are
rejected, not vertically normalized. This avoids adding new unsafe code.

### Subtitle campaign resource failure

The final ASS fuzz rerun **failed** with libFuzzer exit 71: observed RSS 1626 MiB
exceeded the unchanged 1024 MiB limit. Artifact:
`oom-2cea00927c92df5253edf6fed84fd6d0a1528b90` (ignored local fuzz/artifacts/ass).
This supersedes the earlier 3,000-case passing ASS smoke. The saved input passes both one execution (18 ms) and 1,000 repeated executions
(13.587 s) under the same unchanged 1024 MiB limit. The original failure reported
about 28 MiB live heap and 87 MiB quarantine, substantially below observed RSS.
This points toward cumulative process/instrumentation retention, but does not
establish its cause or exonerate the native lifecycle. Do not treat the original
campaign as passing or claim a proven native leak. A longer campaign and native
lifecycle memory investigation remain NO-GO work. The artifact is retained as an
explicit lifecycle regression fixture.

The user subsequently authorized pushing this audit branch. Local commits are
being published for review; this does not authorize merging or a release.

## Executed validation and reproducibility limits

The final implementation check (`target/validation/final/results.json`) passes
all 31 harness commands: format, locked all-target Clippy with warnings denied,
workspace tests in both feature variants, 19 additional seek/full-queue stress
runs, and real-device tests. Default workspace: 28 passed, zero failed, four
explicit opt-in tests ignored; VAAPI: 29 passed, zero failed, four ignored.
Both ignored audio-device tests were separately run and passed. The original-file
near-EOF pause/seek test on the 1552×840 lecture also passed separately. The optional subtitle lifecycle regression passed separately: 1,000 open/render/drop cycles, warm RSS 11,168 KiB, peak 11,216 KiB (48 KiB growth).

The text/timestamp libFuzzer target completed **2,000,000** executions in 137 s,
with address sanitizer enabled and no reported crash. Local runs used
RUSTC_BOOTSTRAP=1 on installed Rust 1.100 to access sanitizer instrumentation;
production builds use ordinary stable Rust. The native FFmpeg/libass/system font
libraries were **not** sanitizer-instrumented. This is a limited smoke campaign,
not a native memory-safety proof or substitute for long-running CI fuzzing.

A deterministic 400-case subprocess decode mutation run completed: **378 decoded,
22 returned ordinary errors, zero crashes/timeouts/abnormal exits**. The target
reads at most 512 packets and decodes bounded prefixes; it does not test every
byte of every file. Child CPU, address-space and wall-time limits were enforced.
Seeds are generated fixtures, not user-owned lecture files.

Commands (logs and generated assets remain under ignored target/):

```sh
python3 tools/validate.py --device --stress 20
cargo build --locked -p rlc-codec --example audit_decode
python3 tools/mutate_media.py --cases 400 \
  target/test-media/av-smoke.mkv target/test-media/demux.mkv target/test-media/audio-smoke.wav
cargo install cargo-fuzz --version 0.13.2 --locked --root target/audit-tools
# Use a nightly sanitizer toolchain in maintained fuzz CI; this host used the
# recorded stable compiler with RUSTC_BOOTSTRAP=1 for these diagnostic runs.
PATH="$PWD/target/audit-tools/bin:$PATH" RUSTC_BOOTSTRAP=1 \
  cargo fuzz run text -- -runs=2000000 -max_len=8192 -timeout=5 -rss_limit_mb=1024
PATH="$PWD/target/audit-tools/bin:$PATH" RUSTC_BOOTSTRAP=1 \
  cargo fuzz run ass -- -runs=3000 -max_len=4096 -timeout=5 -rss_limit_mb=1024
cargo test --locked -p rlc-subs --test lifecycle -- --ignored --nocapture
```

The ASS campaign command currently has a recorded resource-limit failure; it is
included for reproduction, not advertised as a passing gate. No RSS threshold,
warning or existing corruption assertion was relaxed to produce a green result.
The saved artifact passes single and 1,000-repeat replay under the same limit.

## Endurance, playback and resource observations

A complete **437.803-second** 1080p30 H.264/AAC introduction-video window run
finished in **438.18 s**, exit zero, with **13,132 frames submitted to the renderer**
and zero application-reported scheduled drops. Peak sampled RSS **184,052 KiB**;
median RSS during seconds 10–70 **183,536 KiB**, final 60 s **184,052 KiB**. Maximum
absolute once-per-second logged scheduling drift **9,970 µs**, final **3,500 µs**.
No build/test workload was prohibited during this endurance observation.

This whole-file run used the hardening build before the final audio-generation
and native-plane follow-up fixes; final-build coverage includes workspace/device
regressions and complete benchmark-clip runs. It is not a final-build 24-hour soak.
The application metric named "presented" counts uploaded due frames; it does not
prove that the monitor displayed every frame. Scheduling drift is not measured
acoustic/video loopback drift. No listening assessment or photodiode/loopback
measurement was performed. PTS-less video still uses a fixed 40 ms fallback and
nonzero-start, VFR, HDR, unusual channel maps and device hotplug need wider tests.

## Dependency, packaging and CI evidence

SPDX-expression/source checks pass with cargo-deny 0.22.2. Exact package-specific
exceptions document the FFmpeg binding grants and bundled OFL/Ubuntu fonts;
unknown sources/licenses still fail. The generated 395-package inventory and
available notices are staged with native build flags. **57 packages have no
matching standalone notice file under the scanner's naming rules**; this is a
manual notice-review queue, not a finding that all 57 lack a license. It includes
platform-specific crates. Complete distributor notices/source obligations are
still a release gate. The local native FFmpeg package declares GPL-3.0-only.

Strict dependency health intentionally remains **RED**: cargo-audit --deny warnings
and cargo-deny advisories reject the two unmaintained transitive dependencies.
Neither is listed as a known vulnerability in this database snapshot. There are
no ignored advisories. Upstream migrations for the graphics/font stacks are
needed rather than patching names or suppressing notices.

Pinned libass 0.17.5 source build completed under target. Repeated archive staging
produced identical SHA-256 with fixed tar order/mtime/ownership and gzip headers.
This demonstrates repeatable staging on this host, not cross-machine reproducible
native binaries. The workflow pins checkout/upload actions by commit, Rust
1.100.0 and ubuntu-24.04, builds the patched subtitle library under target, runs
locked checks and publishes validation logs. Native apt dependency versions are
not frozen. CI results after publication must be distinguished from local tests;
no Windows/macOS hosted or runtime success is claimed.

## Remaining production release gates

1. **High:** contain untrusted native parsing in a process/OS boundary with
   enforceable memory/CPU/I/O budgets; cooperative callbacks are insufficient.
2. **High:** investigate the aggregate subtitle campaign RSS failure with native
   libraries instrumented; run sustained lifecycle, sanitizer and malformed-media
   campaigns. Saved-input replay alone does not resolve the failed campaign.
3. **High:** build and exercise Windows/macOS playback, seeks, subtitle ABI,
   audio devices, packaging and clean shutdown on real target hosts.
4. **High:** establish measured A/V loopback accuracy and 24-hour/failure-injection
   soak evidence, including device removal, stalled filesystems and recovery.
5. **Medium:** resolve transitive maintenance warnings, complete notice/source
   handling, freeze release native dependencies, sign/attest artifacts and verify
   builds on a clean independent machine. The dependency health gate must pass.
6. **Medium:** profile CPU/GPU/allocations, improve idle/redraw cadence, handle
   missing/nonzero/VFR timestamps and additional sample/device formats, and extend
   recovery beyond visible terminal errors. No profiler was installed on this host.

**Final verdict: NO-GO for a production release.** This audit delivers verified
hardening, repeatable validation and a prioritized release backlog. It does not
claim parity with VLC/CPython's years of compatibility and reliability evidence.


Final machine-readable validation summaries and implementation fingerprints:
[linux-2026-12-01.json](audit/linux-2026-12-01.json). All four opt-in tests were
executed separately: both device tests, original-file seek/EOF and the new native
subtitle lifecycle regression. The original failed aggregate campaign remains
unresolved despite passing replay/lifecycle tests; no resource threshold changed.

Hosted run [46496811666](https://github.com/raman118/rlc/actions/runs/46496811666):
Linux **check passed**, including patched native build and strict workspace
checks. The **dependencies job failed** on the two unmaintained notices under the
unwaived health policy. This hosted evidence covers the published hardening
revision; the new lifecycle fixture and final documentation are verified locally.


## Final matched playback benchmark

Three **complete** passes per player: fixed order RLC → mpv → VLC; the same
15.087667 s, 1920×1080p30 H.264/AAC segment with 452 video frames; XWayland;
requested 960×540 windows; software decode; Intel Mesa OpenGL rendering.
RLC/mpv renderer logs and all processes' DRM PCI counters identify Intel
0000:00:02.0. VAAPI was disabled. XDG state/cache directories are isolated under
target; extracted VLC libraries apply only to VLC. No build, test, lifecycle,
fuzz or endurance process ran alongside these final benchmark passes.

An attempted third pass had **mpv paused near the start until the deadline**,
exiting 4. The harness failed closed. All three samples of that pass were
excluded together, retained in the raw artifact, and the complete pass repeated.
The repeat disabled mpv interactive keyboard bindings; decoding/rendering options
were unchanged. The pause's trigger was not established. An early progress update
claiming all nine attempts completed was incorrect; these are the corrected data.

| Player | Median CPU (100% = one core) | Median peak RSS | Median last-sampled DRM render time | Reported drops per complete run |
| --- | ---: | ---: | ---: | --- |
| rlc-software | 31.61% | 175.0 MiB | 2.621 s | 0 / 0 / 0 |
| mpv-software | 29.82% | 286.7 MiB | 1.959 s | 0 / 0 / 0 |
| vlc-software | 27.97% | 269.5 MiB | 2.759 s | 0 / 0 / 0 |

All nine **selected** runs exited zero and reached EOF. Raw selected and excluded
measurements: [readiness-linux-2026-12-01.json](benchmarks/readiness-linux-2026-12-01.json).
The matched configuration gives closer CPU results than the earlier automatic
adapter/Vulkan desktop baseline. It cannot establish a code-only improvement;
RLC still has a higher CPU median here. One short clip does not establish broad
performance parity.

Decoder/upload readiness markers were observed within 0.251–0.252 s. Sampling
is every 250 ms and stages differ (RLC first frame ready for upload/presentation,
mpv video-params, VLC first decoded picture); these are coarse upper bounds,
not a visible-startup ranking. RLC device timestamp latency observations were
all zero: **actual output latency remains unknown**, not measured zero. Sampled
scheduling drift is included in the raw data, not an external lip-sync result.

DRM counters are last-sampled cumulative render-engine nanoseconds, not GPU
utilization or energy; retired clients and final sampling tail can be missed.
Window sizes may be adjusted by the window manager. Nominal volume was about
20%, without acoustic calibration; cpal used ALSA while mpv/VLC used PulseAudio.
Renderer/UI/sync internals and drop-counter semantics differ. VLC uses its final
RC sample before EOF; RLC counts scheduled drops rather than physical display
scans. Cache warmth, normal desktop activity, fixed order and uncontrolled
power/thermal state limit statistical conclusions. No GPU-energy measurement or
hardware audio/video latency measurement is claimed.

Reproduce with the default-feature release binary and a local clip:

```sh
python3 tools/benchmark.py /path/to/clip.mp4 \
  --rlc target/release/rlc --vlc /path/to/vlc \
  --controlled-gl --runs 3 --output target/bench-release-audit
# Add --vlc-lib-dir /path/to/extracted/usr/lib only for an extracted VLC runtime.
```

## Distribution follow-up (2026-12-01)

[Distribution tooling and evidence](DISTRIBUTION.md) now cover Linux packages,
Windows installers and portable bundles, macOS app/DMG bundles and registry recipe
generation. Local Linux package payload playback passes. A pinned shared LGPL
FFmpeg build avoids redistributing the development host's GPL-enabled FFmpeg.
Cross-platform native execution, full distributor notices/corresponding sources,
signing and registry publishing remain open; this does not change the audit's
production-release verdict or establish verified Windows/macOS compatibility.
