A deep dive into the 16-byte cell architecture, Bayesian rendering strategies, and the zero-unsafe kernel that powers FrankenTUI.
Every frame follows a deterministic, 5-stage pipeline. Pure state transitions, no hidden I/O.
Input capture
01State transition
02Virtual buffer
03Bayesian selection
04ANSI emission
05The atom of FrankenTUI. Cache-aligned, SIMD-ready, and designed for extreme performance.
Cache Optimal
4 cells fit perfectly in a 64-byte L1 cache line.
SIMD Ready
Single 128-bit instruction for full cell equality.
Zero Leak
RAII-backed grapheme cleanup prevents memory growth.
Algorithms borrowed from statistical machine learning, not hand-tuned heuristics.
Bayesian Diff Strategy
Beta posterior over change rates adaptively selects between full diff, dirty-row, and full redraw strategies.
BOCPD Resize Coalescing
Bayesian Online Change-Point Detection detects regime transitions between steady typing and burst resizing.
E-Process Monitoring
Wealth-based sequential tests for anytime-valid statistical decisions. No peeking penalty.
Conformal Prediction
Distribution-free risk bounds that learn 'normal' from recent residuals.
Fenwick Tree
Binary Indexed Tree for O(log n) prefix sums in virtualized lists.
CUSUM Hover Stabilizer
Cumulative sum change-point detector suppresses mouse jitter at hover boundaries.
Damped Spring Physics
Critically-damped harmonic oscillator for natural motion without overshoot.
Jain's Fairness Index
Scale-independent fairness metric prevents rendering from starving input processing.
Porter-Duff Compositing
Full alpha-blending pipeline with opacity stacks for translucent overlays and layered widgets.
VOI Telemetry
Value-of-Information analysis that tracks which diagnostic measurements actually improve decisions.
Exponential Moving Average
Smoothed frame-time estimation for adaptive budget allocation across render cycles.
Gray-Scott Reaction-Diffusion
PDE-based pattern generator for organic visual effects rendered entirely in terminal cells.
Bayesian Fuzzy Scoring
Posterior odds via Bayes factors for match scoring. Each clue (word boundary, position, tags) is a multiplier on confidence.
Bayesian Hint Ranking
Keybinding hints ranked by expected utility minus display cost, with VOI exploration bonus and hysteresis for stability.
Bayesian Capability Detection
Log Bayes factors as evidence weights to combine noisy signals from env vars, DA1/DA2, and DECRPM probes.
Summed-Area Table
2D prefix sum enables O(1) tile density checks for skipping empty tiles on large screens.
Dirty-Span Interval Union
Each row tracks dirty spans; diff scans only the union of changed intervals instead of full row width.
Bayesian Height Prediction
Normal-Normal conjugate update predicts unseen row heights to avoid scroll jumps, with conformal bounds.
Bayes-Factor Evidence Ledger
Every probabilistic decision records its reasoning as a log10 Bayes factor ledger. Auditable, not black-box.
GRAPA Adaptive Betting
General Random Adaptive Proportion Algorithm auto-tunes the e-process betting fraction for optimal sensitivity.
Mondrian Conformal
Bucketed conformal prediction keyed by screen mode, diff strategy, and size for frame-time risk gating.
Count-Min Sketch
Probabilistic sketch for approximate frequency counts of hot items with PAC-Bayes error tightening.
W-TinyLFU Admission
Width cache admission policy using Doorkeeper + Count-Min Sketch to maximize hit-rate.
PAC-Bayes Calibration
Tightens sketch error bounds using PAC-Bayes theory. Bound shrinks as more data is observed.
Smith's Rule + Aging
Background work ordered by importance per remaining time, with aging to prevent starvation of long-waiting jobs.
CUSUM Budget Detection
Cumulative sum accumulates small deviations to catch sustained drift in allocation budgets quickly.
PID Frame Pacing
Classic feedback control for frame-time regulation. PI is the default; MPC tested but PI proven sufficient.
Conformal Rank Confidence
Gap-based p-values for deterministic tie-breaks and stable top-k ordering in search results.
Easing + Stagger Cascades
Analytic easing curves distribute start offsets across list items. Optional xorshift jitter for organic feel.
Sine Pulse Attention
Half-cycle sine for smooth attention cues. 0→1→0 emphasis without sharp edges or flicker.
Perceived Luminance
RGB to perceived luminance for dark/light theme detection from terminal background probe.
Core principles enforced at the type and crate level.
One-Writer Rule
All stdout goes through TerminalWriter. Single serialization point eliminates race conditions.
RAII Cleanup
State restored on drop—even on panic. Your terminal never stays broken.
Deterministic
Identical Model state + terminal size = bit-identical ANSI output. Always.
Zero Unsafe
#![forbid(unsafe_code)] across all core rendering and layout crates.
Key architectural decisions that ensure FrankenTUI runs at 60 FPS even on legacy hardware.
The diff algorithm compares buffers without allocating new vectors, reusing `ChangeRun` structs.
Cells are exactly 16 bytes, allowing single 128-bit SIMD comparison for equality checks.
WidthCache memoizes text measurements, skipping expensive grapheme segmentation on repeated frames.
Widgets mark specific rows as dirty, allowing the renderer to skip diffing static regions.
Hard performance targets enforced in CI. Violations are test failures, not warnings.
| Metric | Target | Hard Cap | Notes |
|---|---|---|---|
| Resize → first stable present | ≤ 120ms (p95) | ≤ 250ms (p99) | Drop intermediate sizes if over budget |
| Action resolution latency | < 16ms | < 16ms | All keybinding actions complete within one frame |
| Conformal prediction alpha | 0.05 | — | Coverage: P(y_t ≤ U_t) ≥ 95% within each bucket |
| Dirty-span overhead (dense) | < 2% | < 5% | Overhead of dirty-span tracking vs full scan |
| Dirty-span improvement (sparse) | > 50% | — | Scan cost reduction for ≤ 5% edit density |
Ready to build?
Add FrankenTUI to your project and start building interfaces with correctness guarantees from day one.