| Map state | Imagination pass 1. No cut dispatched. Seven operator forks are open (end of file). |
| Cuts ready for Hands without a ruling | Cut 0 (doc corrections), Cut 1 (dead-code subtraction), Cut 2 (bounded sender + seam), minus the latency default, which waits on Q7 |
**End.** A Muninn stream that loses packets degrades by what each signal class
permits, and recovers inside one latency budget without a human. Loss is
repaired by parity first, then by selective retransmit, then by a keyframe. The
sender never holds more than it can send in time, and every figure it reports
comes from observation.
Invariants. Each one must be falsifiable by a test or a probe.
1.**One latency budget, owned by the request.**`latency_budget_ms` on
`gamecult.media_stream_request.v1` is the only deadline source. The sender's
queue age, repair eligibility and parity grouping, and the receiver's
assembly age, all derive from it. Nothing else mints a deadline. Two
constants disagree today (finding B6).
2.**No unbounded buffers on the media path.** Every queue between the encoder
and the socket has a count bound and a time bound. Crossing the bound drops
**whole frame groups** (chunks together with their parity), oldest first. It
never returns an error that restarts the stream, and it never sends a partial
frame whose parity is then useless.
3.**Deterministic parity.** Parity bytes are a pure function of the data
shards, `(k, m)` and the scheme id. They involve no clock, no randomness and
no per-process state. A known-answer vector pins the scheme, so a library
upgrade that changes its matrix fails a test.
4.**MDS recovery guarantee.** Any `≤ m` erasures in a `k+m` block recover the
data exactly. Any `> m` erasures report failure and never produce wrong
bytes. This is proved exhaustively for every shipped `(k, m)`.
5.**One codec, both ends.** The encoder and decoder of the erasure code live in
one place, CultLib, with the record that carries it. A producer and a
consumer that disagree on the math cannot both compile against the same pin.
This is the split that stranded audio recovery in Mimir's C++ (teardown-map
L241-247).
6.**Each media payload fits one datagram, parity included.** Encoded wire size
is `≤ MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES` (1431; `main.rs:82-86`) for
data and parity shards alike. The fragment amplification `1-(1-p)^n`
(teardown-map L417-419) must not return through parity.
7.**Health is observed, never configured** (teardown-map L210-211). Parity
recovered, parity failed, repairs sent, IDRs requested and bitrate changes
are counted where they happen, per leg.
8.**A keyframe request is an edge, not a level.** One decode-chain
invalidation produces at most one IDR per cooldown. A recoverable missing
chunk never forces an IDR. That is already true on the receiver side:
Ratatoskr `feedback.rs:92` and CultLib `4160ab5`.
9.**The transport stays semantics-free.** CultNet RUDP gains no media-, HID-
or producer-named channel behaviour beyond what it has. The donor's
`"hid.edge"` / `"hid.edge.assist"` arms in a vendored `rudp.rs` (`9af2edb`,
`80adfd3`) are the pattern this forbids.
Explicitly **not** in scope:
- Mimir's `Mimir.CultMeshMedia`: a separate MPEG-TS-over-documents relay,
`mimir.cultmesh_media_frame`, `Program.cs:11`. It is not a
`gamecult.media_*` consumer.
- The retired C++ OBS receiver. It is "deliberately no longer understood"
(teardown-map L672-674).
- Opus itself, which is Muninn's own named cut. It is sequenced here, not
mapped here.
---
## Probed mechanism claims
These were run, not inferred from names.
| Claim | How it was established | Result |
|---|---|---|
| What Muninn's sender emits | Read `media_packetizer.rs` @`cee7b9c`; Yggdrasil `cargo test -p muninn-daemon --bin muninn -- media parity repair rudp` | 78 pass. Video: data chunks plus XOR stripe parity (`gamecult.media_video_parity_shard.v2`) on `media`, unreliable. Audio: `pcm-f32le-interleaved`, 3,840-byte packets, on `audio`, **reliable**. **No audio parity.** |
| Receiver recovery present | Read Ratatoskr @`488b5b1` | Video: XOR stripe recovery, one chunk per stripe (`video.rs:224-269`). Audio: **none**; it passes straight through (`receiver.rs:320-323`). Keyframe request: yes, edge-triggered with a cooldown (`feedback.rs:92,130`). `cargo test -p ratatoskr-core` on Yggdrasil: 31 + 2 pass, including `parity_gives_back_one_lost_chunk_per_stripe` and `two_losses_in_one_stripe_are_beyond_repair`. |
| Donor GF(256) tested | Yggdrasil `cargo test -p muninn-daemon --bin muninn -- fec parity gf audio_fec video_wire` @`80adfd3` | 9 pass. Audio 4+2: exhaustive over every 1- and 2-erasure pattern (`donor media_packetizer.rs:4919`). **Video 8+4 Cauchy: only one single-erasure recovery, done by hand inside the test (`:2957`). There is no Rust multi-erasure video decoder** (it lived in Mimir's C++). **There is no known-answer vector for `gf256_mul`/0x11d**: a consistent wrong polynomial passes every round-trip. |
| An established codec fits | Scratch crate `rs-probe` on Yggdrasil, `--release` | `reed-solomon-erasure` 6 (GF(2^8)): any shard length (849 OK), exhaustive `≤m` recovery true for 4+2 and 8+4, `m+1` erasures fail cleanly. It costs 13.5 µs to encode and 11 µs to decode an 8+4 block of 850 bytes, and 2.6 µs / 3.4 µs for 4+2 at 864 bytes. `reed-solomon-simd` 3: **refuses odd shard sizes** (`InvalidShardSize{849}`), decode about 230 µs per block. |
| Current XOR vs RS at equal overhead | iid model, `python` (arithmetic, not a harness) | For a 200-chunk keyframe at 3% loss, XOR16 fails the frame **63%** of the time at 8% overhead, and RS 8+4 fails 4e-4 at 50%. For frames of `n ≤ 16` chunks, XOR16 is **duplication**: each stripe holds one chunk, so the overhead is 100%. |
- Today Muninn sends snapshots only (`M main.rs:6172-6200, 6758-6800`), so a tap
shorter than one sample, or lost with its packet, never happens.
---
## Donor ledger: port, rewrite, drop
| Donor piece | Verdict | Why |
|---|---|---|
| `gf256_mul`/`gf256_inv`, `recover_audio_fec_data`, `video_fec_coefficient` (`D media_packetizer.rs:1177-1180, 1525-1612`) | **Drop; replace with `reed-solomon-erasure`** (Q3) | No video decoder, no KAT, and it solves a matrix per byte for audio. The probed crate is MDS-exhaustive at the shipped sizes and fast enough by 3 orders of magnitude. Owned math is a liability we need not carry. |
| 4+2 audio block and 8+4 video block sizing | **Port as defaults**, parameterised as `(k, m)` in the record | Field-chosen numbers, but carried by the record so a decoder needs no config. |
| Within-frame round-robin send order over blocks (`D :1295-1360`) | **Port** (rewrite against CultLib types) | Turns a burst into one loss per block. It is policy, not math. |
| `pad_audio_codec_frame` 2-byte BE length prefix (`D media_packetizer.rs:674-686`) | **Port** into the Opus cut's framing (`opus-padded-v1`) | Constant shard size for variable codec frames. Matches the `aac-adts-padded-v1` precedent (teardown-map L477-479). |
| Datagram-fit tests (`D :3065`, `production_aac_audio_fec_shards_fit_one_rudp_datagram`) | **Port as behavioural tests** at the CultLib codec and in Muninn | They pin invariant 6. |
| Exhaustive erasure test (`D :4919`) | **Port**, generalised to every shipped `(k, m)` | Pins invariant 4. |
| `MuninnKeyframeRequestGate` (`D main.rs:2864-2884`, cooldown 500 ms at `:102`) | **Port** (Cut 6) | Small and correct: an edge with a cooldown. |
| `MuninnVideoBitrateController` (`D :2439-2512`) | **Rewrite** (Cut 6, only if Q6 = a) | Its ceiling halving assumes 50% FEC overhead, and its doc and code disagree. It must key on the chosen parity rate, and aggregate across hub receivers, which the donor predates. |
| `native/muninn-video-encoder` (C++, 265 lines) plus build script | **Held at the donor tag, pending Q6** | A new native target with FFmpeg dev libraries on Raven, built by an Idunn `rust-host` runner whose vocabulary is `cargo`. That is a large liability, bought only if IDR and bitrate adaptation earn it. |
| Bounded `sync_channel` plus per-frame groups, capacities 256/512 (`D main.rs:85-87, 2023-2028, 2356-2369`) | **Port the shape**, rewrite against the hub loop (Cut 2) | Exactly invariant 2. |
| `cultnet-impair` (696 lines, seeded loss/burst/jitter/reorder/dup/stall, CSV) | **Port to CultLib**`packages/cultnet-rs/examples/` (Cut 3b) | It is a CultNet transport tool. `media_delivery_probe.rs` already sits there and expects it (its header, `C examples/media_delivery_probe.rs:5`). |
| HID edges, epochs and acks in Muninn + Sleipnir + vendored `rudp.rs` | **Park** until Q1 | Purpose unknown, and it breaks invariant 9. |
| Vendored `rudp.rs` ACK changes (`9af2edb``direct_ack_state`, ACK reliable duplicates) | **Drop** | CultLib evolved separately (`75c1807` acknowledges retransmits across horizons; `47b9fc4` changes reader semantics). Anything still missing is a CultLib finding with its own proof, not a port. |
| `muninn.*` v4/v1 parity schemas | **Drop** | Superseded by `gamecult.*` in CultLib. No live reader. |
Recommend Self tags the donor `parked/muninn-bounded-realtime-send` at `80adfd3`
before anything cites it again. This is the parked-not-dead pattern: the branch
is untracked per the morning file item 11.
---
## Where FEC lives: owner decision
**Owner: CultLib `cultnet-rs`, a new `media_fec.rs` module beside
`media_stream_wire.rs`.** It holds pure functions and no I/O.
- **Not Muninn.** The receiver needs the decoder, so a codec in Muninn is either
duplicated in Ratatoskr or missing there. The first reproduces the Mimir split
(invariant 5). The second reproduces today's audio situation.
- **Not CultNet RUDP (transport FEC).**
- Transport FEC would group datagrams by send time, not by frame and
deadline. A block spanning two frames delays the first frame's recovery
past its deadline.
- It would also sit beside the frame-level NACK repair that Muninn and
Ratatoskr already run through `gamecult.media_receiver_feedback`, giving
two recovery authorities for one loss.
- The media plane's rule "a media payload fits one datagram" (invariant 6)
removes the one advantage transport FEC would have, which is protecting
fragments.
- The transport stays semantics-free (invariant 9).
- **Not CultMesh.** CultMesh carries state and discovery documents through Odin,
the advertisement and the request. Media records are CultNet wire records on a
live session and are never stored. FEC has no document to live in.
- **Not a new crate.** Authority separation does not buy a package. The media
plane is two files in `cultnet-rs` today, and every consumer (Muninn,
Ratatoskr, StreamPixels' vendored copy) already links it.
What the module owns:
- the scheme id;
-`protect(frame_records, policy) -> send-ordered wire records` for video;
- the `(k, m)` choice, which is policy and belongs to the producer (Q8);
- when to give up, which is the receiver's deadline (invariant 1);
- sockets.
---
## Identity, lifecycle and authority (0b)
| Kind | What names it | What happens to it over time | Who decides |
|---|---|---|---|
| Video parity shard `gamecult.media_video_parity_shard.v3` | `(stream_id, session_id, frame_id, block_index, parity_index)`; the key extends today's (`C media_stream_wire.rs:92-110`) | Emitted with its frame's group, and dropped with the group at the deadline. Never repaired, never cached for repair. v2 is **deleted**, not kept beside it. | Producer emits. CultLib codec defines the bytes. Receiver consumes until the frame deadline. |
| Audio parity shard `gamecult.media_audio_parity_shard.v1` | `(stream_id, session_id, base_packet_id, parity_index)` | Emitted after its k-th data packet. It expires with the block's latest deadline. | Same. |
| FEC scheme id (e.g. `rs-gf256-v1`) | A string on each parity record | Changes only with a new schema version. A KAT pins it. | CultLib. |
| `(k, m)` policy | Carried per parity record (`block_data_count`, `parity_count`) | Fixed per stream in the first cut. Adaptive only if Q8 rules so. | Producer (Muninn). |
| Latency budget | `gamecult.media_stream_request.v1.latency_budget_ms` (key 11) | Fixed for a request. A new request restarts the child (teardown-map L533). | **Consumer** asks. Producer honours it, or refuses in `detail`. Default per Q7. |
| Keyframe request | `requested_keyframe` edge on feedback | Counted per receiver. It triggers at most one IDR per cooldown. | Receiver asserts. Producer's gate decides actuation (Cut 6). |
| Encoder bitrate (live) | Process-local, no record | Adjusted within `[floor, ceiling]`. Reported in telemetry. | Producer's controller (Cut 6, Q6). |
| HID edge | Unknown until Q1 | — | — |
---
## Cut 0: correct the Muninn maps against git (docs only)
Repo Muninn, `main`. Hands, doc-only. Nothing is deleted from history. Superseded
claims are marked as history in place and not left as two live designs.
Corrections to `docs/teardown-map.md` @`cee7b9c`:
| Line | Says | Git says |
|---|---|---|
| 1-3 | "(pre-rebuild)", dated 09-09, body at `Odin\crates\muninn-daemon` | Live repo `GameCult/Muninn`. `main.rs` is 15,134 lines and `media_packetizer.rs` 2,633. |
| 50, 65 | "19 muninn.* schemas… in odin-core", "20 symbols" | The four media schemas moved to CultLib (`gamecult.*`). 21 odin-core symbols (`main.rs:27-37`). |
| 463-465 | "Muninn now holds only the producer half" | `AudioPacketBuffer` and the whole-stream helpers remain (B9). Cut 1 makes the sentence true. |
| 611 | CultLib `main``05e0925` | Contract unchanged since `c2a9a6e`. `main` is `069ecc3`. |
| 615-642 | "The one thing blocking a clean Muninn build… uncommitted `[patch]`… `Cargo.lock` untracked" | Resolved (L684-686). `Cargo.lock` is tracked (`60ed6b2`). Mark as history. **Add:** odin-core comes from `3e96c6c`, which is reachable only through the attic tag (B11). |