Skip to content

preflight: Add a headless verdict engine with OBS's own thresholds - #814

Merged
zackees merged 2 commits into
obs-rust:masterfrom
chriscoveries:preflight/engine
Oct 16, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
chriscoveries:preflight/engine

Conversation

@chriscoveries

@chriscoveries chriscoveries commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Refs #752. The Auto-Configuration Wizard’s counter checks and server selection are implemented in UI-specific code. This PR adds the headless decision engine needed to evaluate recorded OBS counters without a running OBS instance.

Root cause

The existing warning comparisons are spread across the Qt statistics widgets: render time, skipped frames, render lag, and output drops are checked in frontend/widgets/OBSBasicStats.cpp:364-367,393-398,419-423,579-584; congestion bands are in frontend/widgets/OBSBasicStatusBar.cpp:18-21,400-408. The wizard’s server choice is a separate calculation in frontend/wizards/AutoConfigTestPage.cpp:393-399,414-420. There is no reusable headless evaluator for applying those checks to a bounded counter trace.

Fix

This adds rust/obs-preflight, a safe engine that rolls cumulative frame, output, encoder, congestion, connection and CPU measurements into windows and returns a pass, marginal or fail verdict with a reason. Counter decreases start a new window. It uses OBS's current warning bands and maps the four congestion icon levels to three verdicts, with excellent and good treated as pass. A CLI replays JSON Lines traces for deterministic testing.

A separate obs-preflight-ffi crate exposes the engine through a new C header and static library. Its #[path] module shares the implementation so the safe engine and C ABI use the same code while keeping their crate types separate. The engine is not wired into OBS in this step; the sampler and UI remain follow-up work.

The ABI test's CMake uses the pinned toolchain's real Cargo and Rust compiler when available, falls back to soldr or Corrosion's Cargo, and skips with a status message if none is available. It orders the separate ABI build after Corrosion's cargo-build_libobs_rust target to avoid concurrent Rustup component installs.

Evidence

  • RED: commit 152332eb263de0c9a608de61041b21638c56e377 leaves roll_up_windows and judge_window as todo!() stubs. The fork Pull run 38894365237 reported test result: FAILED. 16 passed; 18 failed; 0 ignored; 0 measured; 0 filtered out in obs-preflight/tests/preflight.rs; the failure output shows the intentional todo!() panics.

    Exact RED failures
    cli_rejects_reset_only_and_repeated_reset_traces
    cli_replays_jsonl_and_emits_verdicts_as_json
    cli_returns_a_stdout_error_when_the_consumer_closes_early
    congestion_threshold_boundaries_are_exact
    encoder_skip_ui_warning_boundaries_are_exact
    encoder_status_bar_warning_requires_both_count_and_percent
    every_decreasing_cumulative_counter_starts_a_new_window
    golden_clean_run_passes_with_exact_rollup
    golden_congested_uplink_is_marginal_with_exact_reason
    golden_encoder_falling_behind_is_marginal_with_exact_reason
    golden_stale_device_with_no_frames_fails_closed
    high_cpu_is_informational_only
    output_drop_threshold_boundaries_are_exact
    render_lag_threshold_boundaries_are_exact
    render_time_threshold_boundaries_are_exact
    trace_is_split_into_non_overlapping_time_windows
    trace_validation_rejects_bad_time_and_counter_resets_start_new_windows
    verdict_pressure_pairs_match_reference_bands_and_are_monotone
    
  • GREEN: commit f6b90878266a90db8d9c07d1a0e727e81f0d6f5c passed two exact-head fork Pull CI runs (same workflows as upstream PR CI): run 38896783523 and run 38899213391. Each run finished with 27 jobs succeeded, 0 failed, and 3 skipped. In both macOS Rust test jobs, obs-preflight/tests/preflight.rs passed all 34 tests: test result: ok. 34 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s.

  • C ABI: test_preflight_abi passed 10/10 under CTest on macOS after a macos-ci CMake configure and RelWithDebInfo build. It calls the Rust engine through the public C header. CTest reported 100% tests passed, 0 tests failed out of 1.

  • Tier 3 differential tests: not applicable because there is no C original for this new engine behavior.

  • Mergeability: git merge-tree --write-tree upstream/master HEAD against current upstream 2dae7366609405b552965e428b926dfc61394591 exited successfully twice and returned 7f6a132e78a2d080acb4c251162701daad567d69 both times.

Compatibility & risk

This adds a crate, a public C header, and a separate static library. It does not change existing libobs symbols or runtime behavior; OBS does not call the engine yet. test_preflight_abi is excluded on Windows as a known gap because linking the Rust static library there needs additional system libraries. No OBS application run was made because the engine is not integrated.

Status

Prepared on preflight/engine-v2 at f6b90878266a90db8d9c07d1a0e727e81f0d6f5c, based on upstream ce0b976fd8ca15cbca2373f820d1071943fe5f02. Both independent review gates passed, and both exact-head fork Pull runs passed. The OBS-facing sampler and UI remain follow-up work.

How this was tested

  • RED → GREEN: the fork Pull workflow ran the Rust test lane on RED commit 152332eb263de0c9a608de61041b21638c56e377 and GREEN commit f6b90878266a90db8d9c07d1a0e727e81f0d6f5c. RED produced the named todo!() failures above; both exact-head GREEN runs passed (27 jobs succeeded, 0 failed, 3 skipped each).
  • C ABI: CMake macos-ci / RelWithDebInfo; test_preflight_abi passed 10/10 with CTest timeout 300. No Cargo test command was run locally on macOS.
  • Real run: not applicable because the engine is not connected to a live OBS output or video mix.
  • Review: independent code/history and body-accuracy reviews passed.

Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

CI triage: "Rust Tier 2 Linux" fails at CMake configure, not in a test. test/cmocka/tests.d/test_preflight_abi.cmake:4 does find_program(SOLDR_EXECUTABLE soldr) and the Tier 2 lane has no soldr on PATH ("Could not find SOLDR_EXECUTABLE"), so configure aborts (reached from test/cmocka/CMakeLists.txt:664). Fix: make that .cmake tolerate a missing soldr (find_program(... NAMES soldr) with a if(NOT SOLDR_EXECUTABLE) fallback to the repo path/env CI uses, or skip/add the test only when found), and mirror how other tests.d/*.cmake that invoke Rust tools locate them. Reproduce with ./unittest (Tier 2 Linux). Run ./lint first. Also rebase on origin/master.

@chriscoveries

Copy link
Copy Markdown
Contributor Author

Thanks for the triage, @zackees. Both done; the new head is 61cefb8dd.

  • Rebased onto master (dd80fdec9). The rebase was clean.
  • test_preflight_abi.cmake no longer needs soldr. It prefers soldr cargo, falls back to the Rust::Cargo that Corrosion found for libobs's Rust build, and otherwise skips the test with -- Skipping test_preflight_abi: soldr and Corrosion's Rust::Cargo executable were not found instead of failing configure. Windows stays excluded.

Re-tested at the rebased head on an Apple Silicon Mac:

  • soldr cargo test -p obs-preflight -p obs-preflight-ffi --locked: 38 pass.
  • export_list: passes.
  • fmt and clippy -D warnings: clean.
  • The workspace builds.
  • test_preflight_abi (macos-ci, via soldr): 10 of 10 under ctest.
  • Configure with soldr hidden from PATH: with ENABLE_RUST_LIBOBS=OFF it prints the skip message; with ON it picks up Corrosion's cargo.
  • gersemi 0.25: clean.

Not run here: ./unittest Tier 2 Linux, because Docker isn't available on this machine. The next CI run is the check for that.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

Progress: the soldr configure error is gone. The new Tier 2 Linux failure is in the ENABLE_RUST_LIBOBS=ON configure + build: the cargo step that builds obs-preflight-cargo/release/libobs_preflight_ffi.a exits with code 101 (job 116644214376). The CI log hides cargo's output, so reproduce locally with ./unittest (Tier 2 lane) or by building the obs-preflight-ffi crate the way the ON build does. Code 101 is usually a build-script panic or a test-harness/link failure in that crate.

zackees added a commit that referenced this pull request Oct 16, 2026
* test: Tier 2 shows cargo errors and build-script panics (RED, Refs #932)

Fails: rust/tools/linux-validate/build-errors.sh does not exist; the
inline filter in validate.sh drops rustc errors.

* ci: Tier 2 shows cargo errors and build-script panics (Fixes #932)

A failed Tier 2 build printed only lines matching ': error' and
'FAILED:', so a failed Rust build in the ON configuration showed just
'FAILED: [code=101] ...' (#814). build-errors.sh keeps those lines and
adds rustc diagnostics with their location and build-script panics.
@chriscoveries

Copy link
Copy Markdown
Contributor Author

Thanks for the pointer. The Rust-ON failure was a race: with ENABLE_RUST_LIBOBS on, the ABI test's Cargo build ran alongside Corrosion's libobs Cargo build, and both Rustup proxies tried to install the pinned toolchain's rust-src at the same time. That caused the .partial rename failure and Cargo's exit 101.

47d1d8dc1 fixes it in test_preflight_abi.cmake only:

  • It calls the pinned toolchain's cargo and rustc directly (rustup which), falling back to soldr or Corrosion's cargo.
  • With Rust libobs on, it orders the archive target after cargo-build_libobs_rust.

The same tree passed our fork's Pull workflow twice, with Rust Tier 2 Linux ON and OFF, including test_preflight_abi:

The branch also merges current master.

@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Review at head 47d1d8dc1. CI is green on this head: all Tier 2 Linux lanes (ON and OFF), Rust Tests on macOS and Windows, Tier 2 macOS and Windows, Format and CI Gate. I read the diff but did not build or run it myself, so the results below come from CI, not from me.

What is good

  • The thresholds are only OBS's existing warnings, each with a source citation. The exact-boundary tests (strict comparisons, 1% passes and 5% is marginal) are the right kind of test.
  • The C ABI is a new header plus a separate static library, so libobs exports and existing public headers are untouched. No existing C test is edited. test_preflight_abi.c drives the Rust engine through the header, and your mutation check shows it observes the Rust verdicts.
  • Crate names follow obs-<area>. The ci/test_naming.py change is small and keeps obs-studio-rust as the product binary name.
  • The test_preflight_abi.cmake race fix is clear, and the "Corrosion's cargo target runs first" ordering is well commented.

Required changes before this leaves draft

  1. RED then GREEN history (coordination.md section 4). The branch has one commit with all 2,956 lines (engine, ABI, tests together), then two fixups and a merge commit. There is no RED commit that fails against a stub. Please rebase to a linear history: a RED commit (tests plus todo!() stubs, failing) followed by GREEN, with the cmake fixes squashed into whichever commit they belong to. Drop the merge commit by rebasing on origin/master. Then name the RED commit and its failing tests in the PR description. If a squash-merge makes history moot, the description still has to name the RED state, so please show it by checking out the tests with the engine stubbed.
  2. Platform boundary (testing-policy.md, "Platform boundary"). rust/obs-preflight/src/platform/mod.rs:1-2 uses a bare #[cfg(unix)] mod unix;. The policy wants the crate's single host-selection site to be one cfg_select! that declares the per-OS children. Also, src/main.rs:12-13 declares #[cfg(test)] mod platform;, and platform/unix.rs holds only two tests for non-Unicode paths. Please either switch mod.rs to cfg_select! (with a Windows or fallback arm), or drop the platform module and test non-Unicode paths in a way that is not host-gated. ./lint passing in CI suggests the dylint doesn't catch this, so this is a policy item, not a failing check.
  3. Link the issue. The description mentions proposal: Preflight, a "try before you go live" test in the Auto-Configuration Wizard (early engine only, no UI yet) #752 but doesn't use Refs #752. Add it (not Fixes, since this is step one of that proposal).

Questions and notes (not blockers)

  • rust/obs-preflight-ffi/src/lib.rs pulls ../../obs-preflight/src/ffi/mod.rs in with #[path], so the same file compiles in two crates. That works, but a reviewer may ask why the ABI isn't just the ffi module of one crate with crate-type = ["rlib", "staticlib"]. A one-line reason in the crate docs would help.
  • Differential tests (Tier 3) don't apply, because there is no C original to compare against. The description should say that in one line, so a reviewer doesn't look for them.
  • Windows is excluded from test_preflight_abi and the reason is stated in the cmake file. Fine, but please note it in the description as a known gap.

What is needed outside this PR: #752 is a proposal, and I can't see a maintainer decision on it. A maintainer (zackees) has to agree to the direction before this merges. I'm flagging that so you aren't waiting on something I can't answer.

When items 1 to 3 are done and CI is still green, mark it ready for review and comment here. I can't promise a merge date. Nothing here merges until a maintainer reviews it and it passes the merge queue.

@chriscoveries
chriscoveries marked this pull request as ready for review October 16, 2026 12:49
@chriscoveries

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've reworked the branch as asked:

  • History: it's now linear on master. RED 152332e adds the tests with intentional todo!() stubs, and 18 preflight tests fail there. GREEN f6b9087 implements the engine.
  • Platform boundary: the test-only platform module is gone. Non-Unicode path handling no longer sits behind a bare #[cfg(unix)].
  • Docs: the crate docs explain why the FFI source is shared with #[path].
  • Description: it now says Refs #752, names the RED commit and its failing tests, notes that Tier 3 doesn't apply because there's no C original, and records the Windows ABI-test exclusion as a known gap.

Two fork Pull runs passed on this exact head, including the Rust test lanes (34/34 preflight tests), and the C ABI test passes locally. I've marked it ready for review. I understand #752 still needs your decision on direction before this can merge.

@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into obs-rust:master with commit 0ce7533 Oct 16, 2026
27 checks passed
zackees added a commit that referenced this pull request Oct 16, 2026
#814 merged a new crate, obs-preflight, with one integration-test binary.
That is a new crate's single binary, not a missed consolidation, so the
workspace cap goes from 21 to 22.
zackees added a commit that referenced this pull request Oct 16, 2026
#814 merged a new crate, obs-preflight, with one integration-test binary.
That is a new crate's single binary, not a missed consolidation, so the
workspace cap goes from 21 to 22.
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 16, 2026
…test targets (obs-rust#968) (obs-rust#978)

* ci: Cap integration-test binaries per crate (RED, Refs obs-rust#968)

* test: Group Rust integration tests into category binaries (GREEN, Fixes obs-rust#968)

157 test targets -> 21 (<= 8 per crate). Pure moves via git mv; test count
unchanged (1102 passed, 1 ignored). Move-only edits: include_str! paths,
mod common -> use super::common, the base_parity self-respawn filter, and
the proptest regression files. bmem gets its own binary: it counts
allocations process-wide.

* test: Group obs-gpu-status's newer tests into its category binary (obs-rust#968)

* test: Profiler test modules must share one lock (RED, obs-rust#968)

profiler.rs and profiler_parity.rs both reset the process-global profiler.
As separate binaries each ran alone; grouped into one binary libtest runs
them on parallel threads, each behind its own mutex, so each saw the
other's roots (Windows Rust Tests on obs-rust#978: 3 roots instead of 2, and an
extra empty root in the parity snapshot).

* test: Serialize the profiler tests on one shared lock (GREEN, obs-rust#968)

One PROFILER_LOCK in the category binary's main.rs; profiler.rs and
profiler_parity.rs re-export it as TEST_LOCK and PARITY_LOCK, so their
tests no longer reset the global profiler under each other.

* ci: Count obs-preflight's test binary in the workspace cap (obs-rust#968)

obs-rust#814 merged a new crate, obs-preflight, with one integration-test binary.
That is a new crate's single binary, not a missed consolidation, so the
workspace cap goes from 21 to 22.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants