journeys tui-kit: tk-gradient, the 120 fps gradient in compiled Rust (byte-identical, rate verdict)

LA
5d ago
+1240-10

Summary

This is item 1 of the compiled-load plan (STATUS 4801; cmux-ad 03:40Z: "every load generator that must keep a rate moves to compiled code"). The 120 fps gradient is now tk-gradient, written in Rust.

  • The crate: scripts/journeys/tui-kit/rust/ is its own Cargo workspace, std only, with no dependencies. It is not part of cmux-tui, and CI does not build it. It builds from a copy of the kit with tuikit.py build-bins (cargo --release --offline).
  • The frames: tk-gradient draws tuikit.py's gradient frames byte for byte. tuikit.py passes gradient_style(seed) on the command line, so the seed semantics stay Python's.
  • Pacing: --pace spin is the default, as in #31671. hybrid and sleep are also there.
  • The log: it writes the same JSON-line events as the Python engine (mono is the same clock as time.monotonic()). The end event has achieved_fps, target_fps and verdict: NOT RUN below 95 % of the target.
  • Engine choice: tuikit.py gradient --engine auto (the default) execs tk-gradient when it is built, and runs the Python engine when it is not. The Python engine's end event now gets the same verdict fields, so a slow Python run shows NOT RUN, not ok.
  • heavy_profile: it records gradient_engine, and a new --build-bins flag builds the programs first.
  • pace_probe: it adds rust-spin, rust-hybrid and rust-sleep variants.
  • tui-kit-selftest.sh: it builds the programs, then runs cargo test -- --ignored (the crate's own tests are ignored in a plain cargo test). Then it runs test_tuikit.py with CMUX_TUIKIT_REQUIRE_RUST=1, so the parity and rate tests fail and never skip. Its TUI-KIT-PACE line is rust-spin.

Testing

Observed / Not run

Observed (cmux-orchestrator-1):

  • test_tuikit.py: 36 tests OK. The 2 Rust tests skip here, because I build no Rust on this VM. The new tests are:
    • the bytes match Python's for 5 seeds, sizes and cell widths;
    • the Rust engine holds 120 fps (achieved at least 95 %, p95 interval under 12.5 ms);
    • a Python run below the floor is NOT RUN.
  • test_load_profiles.py: 13 tests OK.
  • rustfmt --edition 2021 --check: clean.
  • scripts/cmux-next/prepush-gate.py: no new violations.

Not run:

  • The crate is not compiled yet. I do not compile Rust on this VM, and the fleet runs tui-kit-selftest.sh only at a feat-cmux-next commit. The first compile and the first parity and rate results come from the self-test after this lands.
  • If the build fails, tuikit.py gradient keeps the Python engine (auto). Its runs then show NOT RUN in their logs, and nothing else depends on the binary. A failure is fixed forward.

Changelog

none


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Adds tk-gradient, a compiled Rust implementation of the 120 fps gradient load, so rate-holding load no longer runs in Python. Its frames are byte-identical to the Python engine's, and both engines now log the same end event verdict.

New binary

  • scripts/journeys/tui-kit/rust/ is its own std-only Cargo workspace with no dependencies; CI does not build it.
  • tuikit.py build-bins compiles it via cargo --release --offline; the seed style still comes from the Python kit's gradient_style(seed).
  • The Rust binary supports the same pacing modes (spin default, hybrid, sleep) and JSON-line log format as the Python engine.

Integration

  • tuikit.py gradient --engine auto (default) execs tk-gradient when built and falls back to the Python engine otherwise.
  • Both engines' end events now include achieved_fps, target_fps, and verdict; runs below 95% of the target fps log NOT RUN instead of ok.
  • pace_probe.py adds rust-spin, rust-hybrid, and rust-sleep variants; heavy_profile.py records gradient_engine and gains --build-bins.
  • tui-kit-selftest.sh builds the crate, runs its ignored tests, then runs test_tuikit.py with CMUX_TUIKIT_REQUIRE_RUST=1 so parity and rate tests fail rather than skip.