Chapter 8: Mathematical Intersections (AVSinkIntersection & Unified Capabilities)
Chapter 8: Mathematical Intersections (AVSinkIntersection & Unified Capabilities)
"When audio and video are configured independently, silence is an accident and leakage is the default."
1. Historical Contrast: Uncoupled Pipelines vs. Mathematical Intersections
In classic Unix pipelines (cmd1 | cmd2) and desktop media stacks (OBS Studio, PulseAudio/WASAPI + OpenGL/DXGI screen capture), subsystems are wired by ambient side effects rather than algebraic contracts. A screen recorder captures the host compositor while an audio daemon separately taps the host mixer. The result is split-brain I/O:
- Audio bleeds onto the host speakers (
> 0 dBbleed) while video writes silently to an.mp4or RTMP stream. - A dropped encoder frame desynchronizes PTS timestamps from PCM audio clocks.
- Diagnostics are bolted on as after-the-fact log scraping rather than structural invariants of the pipeline itself.
In the White Dragon Book, a Section (S) is a pure capability primitive (e.g., an RGBA framebuffer, a procedural audio synthesizer, an H.264 encoder, or a structured telemetry bus). An Intersection (A & B & C) is the mathematical product that binds those capabilities onto one shared lifecycle, one shared clock, and one shared sink. A consumer cannot invoke video without audio, nor emit frames without telemetry.
2. AVSinkIntersection & B8gDemoStudioIntersection
Awesome-OS proves this principle across two live production intersections: intersections/b8g-stream (AVSinkIntersection for 24/7 headless RTMP broadcasting with 0 dB host speaker bleed) and intersections/b8g-demo-studio (B8gDemoStudioIntersection for RAM-resident offscreen desktop composition).
// intersections/b8g-demo-studio & intersections/b8g-stream unified intersection contract
export interface TelemetryTraceEvent {
readonly seq: number;
readonly stage: "hydrate" | "compose" | "encode" | "rtmp-push";
readonly frameIndex: number;
readonly durationMs: number;
readonly heapBytes: number;
readonly status: "ok" | "fail-fast";
}
export interface AVSinkIntersection {
readonly videoPipe: { width: number; height: number; fps: number; rgbaBuffer: Uint8Array };
readonly audioBus: { sampleRateHz: 48000; hostSpeakerBleedDb: 0 };
readonly telemetry: { emit(ev: TelemetryTraceEvent): void; assertInvariants(): void };
pushFrame(frameIndex: number, ptsMs: number): void;
dispose(): Promise<void>;
}
Every intersection enforces fail-fast Telemetry + Trace diagnostics:
- Single Flat RAM Framebuffer:
B8gDemoStudioIntersectionallocates one reusableUint8Array(1280 × 720 × 4 = 3.68 MB) in RAM. Zero intermediate PNGs ever touch disk, and zero host display capture APIs are opened. - Locked Audio/Video Clock: Raw RGBA frames stream zero-copy via
pipe:0intolibx264alongside a deterministic48 kHzprocedural synth bed (aevalsrc) — making host speaker bleed and A/V drift mathematically impossible. - Fail-Fast Invariant Gates: If a live workspace command exits non-zero, if frame budget drifts, or if an unredacted secret (
live_...stream key) appears in telemetry,assertInvariants()aborts immediately with a full structured trace instead of silently producing a corrupted artifact.
3. Deterministic State-Delta Video: 154x Smaller Than H.264
Because B8gDemoStudioIntersection composes from a deterministic state-transition log (.hydrated.json of real command outputs, timestamps, and scene keyframes) rather than pixel-scraped screen grabs, the entire visual timeline can be serialized as a deterministic state-delta stream (b8g-holonomic-puff-vs-all.html) that replays pixel-identically at 60 FPS inside a standalone Canvas player:
- Deterministic State-Delta Stream:
2.2 KB(3.5 kbps) — lossless vector/glyph/state replay at any resolution. - Equivalent H.264
.mp4Video:339.8 KB(~540 kbps) —154xlarger and lossy. - Offscreen RAM Encode Speed:
194.2 render-fps(780frames / 26s 720p30 HD MP4 in4.01 s,0 bytestemp disk).
4. Comparison: Traditional Media Pipelines vs. White Dragon Intersections
| Dimension | OBS / Host Screen Capture | Classic Unix Pipes (ffmpeg) |
White Dragon AVSinkIntersection |
|---|---|---|---|
| Audio/Video Coupling | Ambient host mixer + monitor | Separate flags; easy drift | Algebraic intersection (1 clock, 1 sink) |
| Host Speaker Bleed | Common unless manually muted | Unenforced | 0 dB guaranteed by construction |
| Disk Temp Overhead | Gigabytes of capture/PNGs | Intermediate mux files | 0 bytes (3.68 MB flat RAM buffer) |
| Diagnostics Mode | Post-mortem log inspection | Stderr text scraping | Fail-fast structured Telemetry + Trace |
| Video Size (State-Delta vs H.264) | 339.8 KB (lossy H.264) |
339.8 KB (lossy H.264) |
2.2 KB (3.5 kbps) — 154x smaller |
| Reproducibility from Git | Impossible (manual takes) | Partial | 100% deterministic from commit + JSON |
5. Key Takeaway
Never wire critical I/O capabilities by convention. Collapse video, audio, secret redaction, and Telemetry+Trace diagnostics into a single mathematical intersection so split-brain failure states cannot even be expressed.