Define Perfect Machine native reservoir contract

This commit is contained in:
Meta Vens 2026-05-19 07:32:38 +01:00
commit 727afb23c0
7 changed files with 320 additions and 26 deletions

View file

@ -1,6 +1,10 @@
# LocalCastBridge
LocalCastBridge turns a Windows gaming/desktop PC into LAN sources for another machine's OBS scene.
LocalCastBridge turns the local streaming rig into synchronized OBS-facing
program output. The old SRT bridge is compatibility scaffolding; the target
machine is Aquarium GPU fusion plus Faust DSP over one five-second reservoir.
Start with `docs/perfect-machine.md` for the live architecture.
V1 does not fork OBS. OBS already accepts SRT Media Sources, and FFmpeg can capture Windows desktop/audio while encoding video with `h264_nvenc`. The sane first machine is:

View file

@ -0,0 +1,81 @@
{
"schema": "gamecult.localcast.perfect_machine.v1",
"reservoir": {
"durationSeconds": 5.0,
"clockAuthority": "presentation",
"lateSamplePolicy": "accept-inside-window",
"expiredSamplePolicy": "offline-calibration-only",
"storageLayout": "struct-of-arrays-native-rings"
},
"authorities": {
"configurationCalibrationLaunchStatus": "LocalCastBridge",
"denseVisualFusion": "Aquarium",
"gpuMaterialAndBrushReconciliation": "Aquarium",
"spoutPublication": "Aquarium",
"hotAudioDsp": "Faust",
"obsBroadcastControls": "OBS"
},
"visualSensors": [
{ "id": "kiyo-primary", "role": "rgb-main", "required": true },
{ "id": "kiyo-secondary", "role": "rgb-stereo", "required": true },
{ "id": "ps3eye-left", "role": "high-rate-feature", "required": true },
{ "id": "ps3eye-right", "role": "high-rate-feature", "required": true },
{ "id": "leap-left-ir", "role": "near-field-timing-depth", "required": true },
{ "id": "leap-right-ir", "role": "near-field-timing-depth", "required": true }
],
"audioSensors": [
{ "id": "host-focusrite", "role": "host-dialogue-anchor", "required": true },
{ "id": "co-streamer-focusrite", "role": "co-streamer-dialogue-anchor", "required": true },
{ "id": "kiyo-0", "role": "camera-spatial-witness", "required": true },
{ "id": "kiyo-1", "role": "camera-spatial-witness", "required": true },
{ "id": "ps-eye-0", "role": "camera-spatial-witness", "required": true },
{ "id": "ps-eye-1", "role": "camera-spatial-witness", "required": true }
],
"reservoirRings": [
"camera_frame",
"camera_feature",
"scene_ray",
"surface_claim",
"material_claim",
"audio_block",
"phase_claim",
"event_claim",
"render_packet"
],
"outputs": {
"video": {
"target": "Spout2",
"senderName": "LocalCastBridge Point Cloud",
"owner": "Aquarium"
},
"audio": {
"owner": "Faust",
"stems": [
"host_voice",
"co_streamer_voice",
"ambient",
"transients",
"local_loopback",
"co_streamer_loopback",
"spatial_bed"
]
}
},
"bridgeDemotion": {
"python": [
"calibration",
"contract-tests",
"device-discovery",
"status",
"compatibility-spout-diagnostics",
"offline-analysis"
],
"notPython": [
"dense-feature-extraction",
"reservoir-reconciliation",
"hot-dsp",
"brush-splat-rendering",
"program-output"
]
}
}

View file

@ -2,6 +2,9 @@
## Implemented
- Perfect Machine contract:
- `docs/perfect-machine.md` defines the target native machine: one five-second spatiotemporal reservoir, Aquarium-owned dense visual fusion/material/brush rendering, Faust-owned hot audio DSP, OBS-owned broadcast controls, and LocalCastBridge-owned calibration/config/status.
- `config/perfect-machine.example.json` declares the contract shape for six cameras, six microphones, reservoir rings, native authorities, outputs, and the demotion of bridge scripts to tooling.
- Repo-local persistence machinery.
- First architecture map.
- Example config for one video source plus two audio sources.
@ -71,22 +74,12 @@
## Next
1. Open OBS and confirm the three `Neighbor PC` sources load.
2. Start the sender from Madman's interactive desktop, not SSH.
3. Smoke-test the video endpoint in OBS.
4. Smoke-test the Focusrite endpoint in OBS.
5. Smoke-test the system-loopback endpoint in OBS.
6. Tune SRT latency and FFmpeg buffering for the local network.
7. Decide whether a small OBS scene/source generator is worth adding.
8. Reconsider plugin/fork only if standard OBS Media Source cannot preserve the required behavior.
9. Create local `config/audio-field.json`, confirm local Kiyo/PS Eye/Focusrite device matches, and confirm the neighbor Focusrite shotgun capture/transport path.
10. Replace placeholder mic/speaker geometry with measured world coordinates, then build the delay/SRO alignment stage that feeds the bounded field cache and emits aligned six-channel blocks before FOA encoding.
11. Move the render-frame consumer into Aquarium Engine so dense brush/splat rendering replaces the deadline OpenGL point sink behind the same OBS Spout boundary.
12. Capture fixed-board ChArUco observations for every camera, solve `config/sensor-fusion.json`, and verify cross-view feature triangulation with `scripts/triangulate_surface_features.py`.
13. Replace synchronous OpenCV camera reads in the hot producer with nonblocking camera ingress that continuously fills the five-second reservoir, then promote real PS3 Eye/Kiyo/Leap samples over fallback-only mode.
14. Replace the example speaker/camera-mic geometry used by `chirp_pose` with measured local `config/audio-field.json` coordinates, then let the common-space optimizer consume range residuals instead of only visualizing them.
15. Calibrate Leap as a geometric camera in the shared rig so the timing authority can also contribute direct 3D rays instead of only visual timing peaks.
16. Fix the live Leap capture backend so actual Leap frames, not fallback frames, populate `leap-ground-truth` cells in the multi-LOD cache.
17. Keep the neighbor loopback leg running through the scheduled interactive WASAPI capture path and use it as the timing witness once actual neighbor app audio is present.
18. Let the co-streamer surface delay drive the shared presentation buffer horizon for audio stems, AmbiX, and remote video.
19. Promote `scripts/stream_live_audio_field.py` from local deadline owner to the distributed owner by feeding it the neighbor Focusrite shotgun and neighbor loopback surfaces as synchronized live inputs instead of placeholders.
1. Implement the native reservoir ABI declared by `config/perfect-machine.example.json`.
2. Move camera ingest into native capture workers that append `camera_frame` samples to the reservoir.
3. Move feature extraction, flow, cross-view matching, LOD reconciliation, and material fitting into Aquarium GPU compute.
4. Move mic alignment, voice separation, room suppression, Ambisonic/HOA spatialization, and stem generation into Faust/native DSP.
5. Replace the deadline Spout sink with Aquarium-owned Spout publication from the native render target.
6. Feed the neighbor Focusrite shotgun and neighbor loopback into the reservoir as live synchronized audio inputs.
7. Replace placeholder mic/speaker/camera geometry with measured `config/audio-field.json` and `config/sensor-fusion.json` coordinates.
8. Calibrate Leap as a geometric camera so Leap contributes direct 3D rays, not only timing evidence.
9. Keep the Python bridge only for calibration, contract tests, device discovery, status, and offline analysis.

149
docs/perfect-machine.md Normal file
View file

@ -0,0 +1,149 @@
# Perfect Machine
## Objective
Build one synchronized spatial stream machine from six cameras, six microphones,
two speakers, Leap timing, Aquarium GPU rendering, Faust DSP, and OBS output.
The bridge scripts are not the product. They are scaffolding, launch surfaces,
calibration tools, and compatibility probes. The live hot path belongs to native
runtime code, GPU compute, and Faust.
## Current Mechanism
The repo currently proves the contracts:
```mermaid
flowchart TD
A["sensor samples"] --> B["typed CultCache docs"]
B --> C["Python deadline producers"]
C --> D["deadline Spout texture"]
D --> E["OBS"]
```
That was useful. It is not the final machine.
## Invariants
- One five-second spatiotemporal reservoir is the live authority.
- The reservoir is keyed by one shared presentation clock.
- Every sample has sensor id, local hardware time if available, arrival time,
calibrated world transform, confidence, and provenance.
- Missing data is absence, not a stale substitute.
- Late data can refine the reservoir while it is inside the five-second window.
- Anything older than the live reservoir is offline calibration evidence, not
broadcast geometry.
- Audio clocks, camera clocks, Leap timing, remote video, and OBS presentation
are reconciled before rendering.
- Aquarium owns dense visual fusion, temporal accumulation, material fitting,
brush/splat generation, final render target, and Spout publication.
- Faust owns hot audio DSP: voice separation, room suppression, Ambisonic/HOA
spatialization, and loopback/source stem generation.
- LocalCastBridge owns configuration, calibration, typed contracts, launch,
status, persistence, and compatibility surfaces.
## Native Runtime Shape
```mermaid
flowchart TD
A["camera capture workers"] --> R["5s native reservoir"]
B["mic/loopback capture workers"] --> R
C["Leap worker"] --> R
D["remote video/audio ingest"] --> R
E["speaker probe scheduler"] --> R
R --> F["clock/pose optimizer"]
F --> R
R --> G["Aquarium GPU fusion"]
G --> H["multi-LOD surface/material field"]
H --> I["brush/splat/TAA renderer"]
R --> J["Faust DSP graph"]
J --> K["program stems + spatial bed"]
I --> L["Spout2 texture"]
K --> M["OBS audio controls"]
L --> N["OBS video source"]
```
## Reservoir Contract
The reservoir stores struct-of-arrays blocks, not one giant JSON-ish object.
Required rings:
- `camera_frame`: raw or GPU-importable image handles plus timestamps.
- `camera_feature`: keypoints, descriptors, optical flow, confidence, sensor id.
- `scene_ray`: calibrated rays from feature observations.
- `surface_claim`: triangulated or depth-estimated world samples.
- `material_claim`: albedo, roughness, metallic/specular hints, view direction.
- `audio_block`: aligned mic/loopback samples and per-source clock state.
- `phase_claim`: delay/SRO/phase/coherence estimates from chirplets and program
reference.
- `event_claim`: claps, transients, gestures, active illumination pulses.
- `render_packet`: selected brush/splat work for the current presentation frame.
The reservoir owns retention. Producers append. Optimizers refine. Renderers
sample. No stage owns a private history that can outlive the reservoir.
## Visual Fusion
Camera fusion is feature matching across the reservoir, not a latest-frame
operation.
The visual path should:
- ingest all cameras continuously into pinned/native rings;
- extract features and flow on GPU where possible;
- match every plausible cross-view feature within time and epipolar bounds;
- use Leap as the strongest near-field timing/spatial witness when live;
- estimate surface points, normals, confidence, and material observations;
- keep multi-LOD cells resident for Aquarium compute reconciliation;
- emit only the frame budget needed for OBS while TAA accumulates detail.
The live target is not "points per frame." The live target is evidence per
reservoir window and how much of it Aquarium can reconcile before presentation.
## Audio Fusion
The audio path should:
- align all six microphones into one clocked field;
- use Focusrite dialogue mics as voice anchors;
- use camera mics as spatial/context witnesses;
- use loopback/program audio as ground truth where available;
- emit active probes only for channels that can observe them;
- continuously update delay, SRO, phase, frequency response, and confidence;
- feed Faust with aligned mic channels and control telemetry;
- produce host voice, co-streamer voice, ambient, transients, local loopback,
co-streamer loopback, and spatial bed as synchronized outputs.
Raw phase is internal. Meaning crosses the boundary.
## Cut Line
Cut these from the hot path:
- Python dense rendering.
- Python camera feature extraction in the presentation loop.
- File polling as a native runtime API.
- OBS-side sync between independent raw sources.
- Stale geometry clamped into looking current.
- Probe scheduling against placeholder channels.
Keep these as tooling:
- Python calibration scripts.
- Python contract tests.
- Python device discovery.
- Compatibility Spout sender for diagnostics.
- Offline analysis and reproducible evidence ledgers.
## First Native Cut
1. Define the native reservoir ABI from `config/perfect-machine.example.json`.
2. Build a native reservoir process or Aquarium module that owns the five-second
rings.
3. Move camera ingest into native capture workers that write reservoir samples.
4. Move audio ingest/phase claims into the same presentation-clock reservoir.
5. Let Aquarium consume reservoir surfaces/material claims directly on GPU.
6. Let Faust consume reservoir audio blocks and source controls directly.
7. Keep the old bridge only as a comparison and fallback surface.

View file

@ -1,6 +1,34 @@
# Current System Map
LocalCastBridge is intentionally thin.
LocalCastBridge is intentionally thin. The target live machine is not the
deadline bridge; it is the native reservoir described in
`docs/perfect-machine.md` and `config/perfect-machine.example.json`.
## Perfect Machine Target
```mermaid
flowchart TD
A["6 cameras"] --> R["5s native reservoir"]
B["6 microphones"] --> R
C["Leap timing/IR"] --> R
D["loopback + remote video/audio"] --> R
R --> E["Aquarium GPU fusion + material field"]
R --> F["Faust DSP"]
E --> G["Spout2 texture"]
F --> H["program stems + spatial bed"]
G --> I["OBS"]
H --> I
```
Ownership:
- LocalCastBridge owns configuration, calibration, contract tests, launch, status, and persistence.
- Aquarium owns dense visual fusion, material/brush/splat reconciliation, final render target, and Spout publication.
- Faust owns hot audio DSP and program stem generation.
- OBS owns broadcast controls.
- Python remains tooling, not the stream hot path.
Invariant: the five-second spatiotemporal reservoir is the live authority. Producers append, optimizers refine, Aquarium/Faust sample. No private history outlives the reservoir.
```mermaid
flowchart TD

View file

@ -1,7 +1,7 @@
workspace:
name: LocalCastBridge
status: active
focus: local-obs-lan-source
focus: perfect-machine-native-reservoir
premise: >
A second Windows PC should appear inside OBS as video plus separately
mixable audio sources. Use ordinary media transport first; native OBS code
@ -9,11 +9,12 @@ workspace:
objective:
primary: >
Provide a repeatable local streaming environment where the sender captures
desktop/video and audio sources, encodes video with NVENC, and delivers
stable OBS Media Source URLs to the receiver over LAN.
Build one synchronized spatial stream machine from six cameras, six
microphones, two speakers, Leap timing, Aquarium GPU rendering, Faust DSP,
and OBS output.
current: >
Establish the script-and-doc spine for a two-PC smoke test.
Cut the deadline bridge down to tooling and define the native five-second
reservoir contract Aquarium/Faust must implement.
constraints:
- Sender is Windows.
@ -39,6 +40,9 @@ accepted_design:
- Persistence follows the active repo pattern: map, scratch, evidence, branches, handoff, system map, implementation plan, state helpers.
active_subgoals:
- Implement the Perfect Machine native reservoir contract described by `docs/perfect-machine.md` and `config/perfect-machine.example.json`.
- Move dense visual fusion/material fitting/brush generation into Aquarium GPU compute.
- Move hot audio DSP/voice separation/room suppression/spatialization into Faust/native runtime.
- Validate the actual sender FFmpeg build and capture device names.
- Smoke-test the video endpoint in OBS.
- Smoke-test each audio endpoint in OBS and tune latency.

View file

@ -0,0 +1,35 @@
import json
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[1]
class PerfectMachineContractTests(unittest.TestCase):
def test_contract_declares_native_reservoir_authorities(self):
data = json.loads((ROOT / "config" / "perfect-machine.example.json").read_text(encoding="utf-8"))
self.assertEqual("gamecult.localcast.perfect_machine.v1", data["schema"])
self.assertEqual(5.0, data["reservoir"]["durationSeconds"])
self.assertEqual("Aquarium", data["authorities"]["denseVisualFusion"])
self.assertEqual("Faust", data["authorities"]["hotAudioDsp"])
self.assertEqual("Aquarium", data["outputs"]["video"]["owner"])
def test_contract_covers_six_cameras_six_mics_and_required_rings(self):
data = json.loads((ROOT / "config" / "perfect-machine.example.json").read_text(encoding="utf-8"))
self.assertEqual(6, len(data["visualSensors"]))
self.assertEqual(6, len(data["audioSensors"]))
self.assertEqual({"camera_frame", "surface_claim", "material_claim", "audio_block", "phase_claim"}, set(data["reservoirRings"]) & {
"camera_frame",
"surface_claim",
"material_claim",
"audio_block",
"phase_claim",
})
self.assertIn("dense-feature-extraction", data["bridgeDemotion"]["notPython"])
if __name__ == "__main__":
unittest.main()