Applies the Q-A1/Q-A2 rulings (one public meaning: Acknowledged means
delivered). Adds Cut 1b (every session ending drops what it owed; flush is
bound to its session) and Cut 1c (how a new generation is recognised,
blocked on new Q-A6). Probes at 3bf1c0c reproduce G1, G1b, G2 and G3 in
all four runtimes. Kotlin trails as Cut K pending Q-A5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 KiB
CultNet RUDP: Acknowledged means delivered, one watermark owns ordered delivery, and a write belongs to its session
Status: cut map, Imagination pass 2, 2026-09-30, committed by Self. Pass 2 re-maps every cut against
main at 3bf1c0c and applies the operator rulings below.
Rulings (operator, 2026-09-30).
-
Q-A1 (a): Delivered is derived at the sender from a correct receiver's cumulative watermark. The wire does not change.
-
Q-A2: "I think this is telling us we don't actually need both received and delivered."
- There is one public meaning: Acknowledged means delivered.
- Receipts go Pending, then Acknowledged (delivered), or Invalidated. No public Received state exists.
- Retransmission still stops on each packet's own ack, so resending stays bounded.
- Flush waits for Acknowledged.
-
Scope added from the stray-packet Soul passes 3 and 4: session generation. A restarted client on the same endpoint and payload is locked out. A reconnect on the same transport treats a new server session's frames as duplicates. The ending paths disagree about owed writes. One rule: a write belongs to the session it was issued in. Pass 2 maps this as Cut 1b (the ending rule) and Cut 1c (how a new generation is recognised), separate from Cut 1 (§8 says why).
-
Open: Q-A3 (expiring reliable traffic next to ordered traffic), Q-A4 (porting receipts), Q-A5 (Kotlin), and a new Q-A6 (how a new generation is recognised; blocks Cut 1c only).
-
Body. CultLib
mainat3bf1c0c("Merge RUDP stray-packet hardening across all four runtimes"). Everyfile:lineis against it unless it names another revision.- Since pass 1's base
d85877a7, onlyrudp.rsandrudp.tsmoved among the transport files.CultNetTransport.cs,transport.py,CultMesh.kt,cultmesh-rs,cultmesh-ts,peer.ts, the two TS publishers anddocs/cultnet-transport-parity.mdare byte-identical tod85877a7. rudp.rsmoved +6 lines from:283and +12 from:596.rudp.tsmoved only after:824.- Odin pins
3bf1c0c(Odin crates/odin-core/Cargo.toml:14-17).
- Since pass 1's base
-
Base of every cut.
mainat3bf1c0cor later. -
Scope. The RUDP session and socket transports in all five runtimes: C#
src/GameCult.Networking/CultNetTransport.cs, Rustpackages/cultnet-rs/src/rudp.rs(pluspackages/cultmesh-rs), TypeScriptpackages/cultnet-ts/src/rudp.ts(plus the two hand-rolled publishers), Pythonpackages/cultnet-py/src/cultnet_py/transport.py, and Kotlinpackages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt. Q-A5 decides whether Kotlin is in. Until it is ruled, every cut is mapped for four runtimes and Kotlin trails (§ Sequencing). -
Wire. This map changes no byte on the wire (§1). Cut 1c changes the default initial sequence, which is a value, not a format.
The ends (operator, 2026-09-30)
- A frame the peer has buffered but not delivered must not look delivered. Today an ordered frame that arrives behind a gap is held and acknowledged; if the session ends it is lost, and the sender saw "Acknowledged".
- Resending stays bounded. The sender stops retransmitting a packet when the peer acknowledges that packet, exactly as today. Delivery-only acknowledgement was rejected: "I don't like the possibility of unbounded resending on an unresponsive peer application. TCP sounds like it has the right idea."
- One public meaning: Acknowledged means delivered to the peer's application boundary (§2). Unordered reliable frames are delivered on receipt. Receipts go Pending, then Acknowledged, or Invalidated.
- A write belongs to the session it was issued in. When that session ends, a write not yet Acknowledged is Invalidated. It is never carried into, retransmitted in, or acknowledged by a later session.
The finding that shapes this map
Self's first proposal put a second acknowledgement on the wire: a per-channel "delivered through N" watermark beside the received ack. Probing the receivers changed the picture in two ways.
1. The ordered receivers are broken in every runtime, and the break is bigger than the session-end case.
A held frame is not only lost at session end. In a live session it can be stranded forever, or dropped,
while the sender sees it acknowledged. The per-channel next pointer (CultNetTransport.cs:918,
rudp.rs:196, rudp.ts:160, transport.py:424, CultMesh.kt:2643) has been patched twice (436654de
added the first-use initialisation, 4335ab10 added the skip over other channels' sequences) and is still
wrong:
- P1: a gap filled by another channel strands the ordered channel. Ordered
o1, reliableuon another channel (lost),o2,o3. Whenuarrives, onlyu's channel is drained.o2ando3are never delivered, and the sender's pending set is empty. The same holds with two ordered channels (P1b). - P6: a channel first used after other traffic loses frames.
C1,C2on a new channel, thenXon another.Xarrives, thenC2, thenC1. The channel initialises itsnextfrommin(highest+1, frame), soC2is delivered first andC1is dropped as old (frame.sequence < next). It was acknowledged. - Both reproduce at
3bf1c0cin C#, Rust, TS and Python (pass 2), and did atd85877a7, Odin's old pina8aeddacand Muninn's pinc2a9a6e5(pass 1).
2. Once the receiver is correct, "delivered" is not new information. A conforming receiver holds an
ordered frame for exactly one reason: some reliable sequence below it has not arrived. When the last
missing sequence arrives, the same Receive call drains the held frames, before the acknowledgement is
built. So:
An ordered frame is delivered exactly when every reliable sequence up to its last one has been acknowledged.
The sender already knows that. It is the sender's own acknowledged-through watermark: one below the lowest sequence that is still pending, queued or abandoned. TCP's cumulative ACK means the same thing, "every byte below N is in the receive buffer", and it sits beside SACK. Here the sender can compute the cumulative value itself, because every sequence is acknowledged individually and removed from its pending set. The operator ruled this (Q-A1 a), and then ruled that the per-packet ack is not a public meaning at all (Q-A2): it only stops retransmission.
The derivation is sound only if nothing the receiver acknowledged is later dropped while the session lives, and nothing one session acknowledges is credited to another. The probes found these places where that fails:
| # | Where an acknowledged frame is lost, or credited to the wrong session | Runtimes | Fixed by |
|---|---|---|---|
| P1, P1b | A cross-channel gap strands the ordered channel | all five | Cut 1 |
| P6 | Late channel initialisation drops the earlier frame | all five | Cut 1 |
| P5 | A reliable fragment set is evicted after its fragments were acknowledged | Rust, TS, Python (C# and Kotlin have no eviction) | Cut 2 |
| P8 | A retransmit more than 4,096 sequences behind the receiver's highest counts as a duplicate: acknowledged and dropped | all five | Cut 3 (the sender never lets its span reach it) |
| G2 | After connect() again on the same transport, a new server session's frames are duplicates of the old one's sequences: acknowledged and dropped |
C#, Rust, TS, Python | Cut 1c |
| G3 | A write left owed when a session ends is retransmitted into the next session and delivered there, and in Rust its receipt reads Acknowledged |
Rust (local disconnect(), timeout); C#, TS, Python (every ending) |
Cut 1b |
And places where the sender loses track, or is locked out, without the receiver's help:
| # | Sender-side lie or lockout | Runtime | Fixed by |
|---|---|---|---|
| G1 | A restarted client on the same endpoint and Connect payload gets an Ack, never an Accept, and stays unconnected | Rust hub, C# listener and C# server mode, TS and Python server mode (Rust server mode resets on every Connect instead) | Cut 1c |
| G1b | C# and Python server-mode transports drop a Connect from any endpoint but the first, so a client that restarts on a new port is locked out for good | C#, Python | Cut 1c |
| P2 | An expired reliable packet leaves a permanent hole. Ordered frames after it are held forever, and flush_reliable succeeds (outstanding 0) |
Rust (the only runtime with reliable expiry) | Cut 4 reports it honestly; Q-A3 decides the real fix |
| P9 | A receipt for an expiring send reads Acknowledged once the packet expires unacknowledged |
Rust | Cut 4 |
| P10 | send_reliable with a full window queues the frame, then returns an error ("receipts require a non-empty reliable packet set"), so a caller that retries sends it twice |
Rust | Cut 4 |
Probe evidence
Everything ran on Yggdrasil through ygg-verify.sh, from local-only probe branches in throwaway
worktrees. Each probe commit survives on the Yggdrasil mirror as refs/verify/<sha>.
Pass 1 (base d85877a7 and the pins; mirror CultLib-imag-ack):
de2bdfe8,09318d13,03eac6ff: Rust session and socket probes (packages/cultnet-rs/tests/probe_ack.rs).b70a69ca,2320a4e5,7fe5d726: the C#, TS and Python probes (ProbeAckTests.cs,probe-ack.test.ts,probe_ack.py).f0e7136c: the Rust probes at Odin's old pina8aeddac.bf8fc826: all four at Muninn's pinc2a9a6e5.db7d2886: the prototype, the Rust receiver rebuilt on one watermark plus sender-derived receipt states (about +130/−125 inrudp.rs). ItsReceived/Deliveredreceipt states are superseded by Q-A2; its receiver is what Cut 1 builds.
Pass 2 (base 3bf1c0c; mirror CultLib-imag-ack2):
a383e27d, then1519a20a(the C# server-mode G1 probe acknowledges the Accept before the restart, so it tests a restart and not a lost Accept): the pass-1 probe files restored unchanged, pluspackages/cultnet-rs/tests/probe_gen.rs,packages/cultnet-ts/test/probe-gen.test.ts,packages/cultnet-py/tests/probe_gen.pyandtests/GameCult.Networking.Tests/ProbeGenTests.cs.- Rust and C# G1 run over real loopback UDP (hub, listener, server-mode transport), with the restarted
client bound to the first client's exact address. Python G1 runs over UDP against the server-mode
transport. TS G1 calls
acceptConnecton the connected session, which is what the socket transport does for a same-endpoint Connect (rudp.ts:1034-1049calls it without a reset, andrudp.ts:249-251answers it as a repeat). G2 and G3 are session-level: the socket transports'connect()iscreate_connectand nothing else (rudp.rs:1874-1883,CultNetTransport.cs:1836-1846,rudp.ts:891-897,transport.py:994-998).
| # | Probe | Pass 1 (d85877a7, pins) |
Pass 2 (3bf1c0c) |
Prototype db7d2886 |
|---|---|---|---|---|
| P1 | o1, reliable u lost, o2, o3; then u, then o3 |
Delivered [o1, u]; o2, o3 never; sender pending []. Rust, C#, TS, Python; same at both pins |
Same, all four | [o1, u, o2, o3] |
| P1b | A1, B1 (second ordered channel) lost, A2, A3 |
[A1, B1], all four |
Same, all four | [A1, B1, A2, A3] |
| P6 | C1, C2 on a new channel, then X; arrival X, C2, C1 |
[C2]; C1 dropped. All four |
Same, all four | [C1, C2, X] |
| P2 | Rust: reliable media with expiry 1 ms, lost; then s1, s2 on schema |
Nothing delivered. Sender outstanding 0, expired 1, no resends | Same | Unchanged (held behind the hole). Cut 4 makes the sender say so |
| P3 | s1 lost, s2 arrives and is acknowledged |
s2 not delivered, but acknowledged: sender pending [s1] only |
Same | Receipt for s2 stays short of delivered until s1 arrives |
| P4 | Rust: s0 delivered, s1 lost, then a 5 MiB ordered frame in 60 kB fragments |
RUDP ordered hold buffer is full: the session is refused. With no gap, delivered |
Same | The prototype held every ordered frame, so a 5 MiB frame was refused even with no gap: hold only what is not yet deliverable (Cut 1) |
| P5 | 3-fragment reliable frame, 2 fragments acked; 70 lossy fragment sets; last fragment arrives | Rust, TS, Python: never delivered, sender pending [] |
Same, Rust, TS, Python | Unchanged (Cut 2) |
| P7 | An Ack with flag bit 0x10, a nonzero sequence field, or a 5-byte payload |
Decoded and applied in Rust, C#, TS, Python | Same, all four | n/a |
| P8 | Reliable g lost while 4,200+ later sequences are sent and acked; then g arrives |
g not delivered, and acknowledged. All four |
Same, all four | Unchanged (Cut 3) |
| P9 | Rust socket: send_reliable("media") with expiry 1 ms, never read |
Pending, then Acknowledged |
Same | Pending |
| P10 | Rust socket: 40 schema sends, then send_reliable |
Error "receipts require a non-empty reliable packet set", after the frame was queued | Same (the probe's ? fails on that error) |
Not addressed (Cut 4) |
| G1 | Client A connects, sends one ordered frame (acknowledging the Accept), and exits. Client B, a fresh session with the same initial sequence, binds A's exact address and sends the same Connect payload five times | n/a | Locked out. Rust hub (payload "svc" and empty): 5 Acks, 0 Accepts, B unconnected, the hub still holds A's generation. C# listener: same, no PeerDisconnected. C# server mode: 5 Acks. Python server mode: 5 Acks. TS session: the answer is an Ack. Rust server mode (control): B gets an Accept and its frame is delivered, because it resets on every Connect |
Not probed |
| G1b | C# and Python server mode: a third client on a new port sends a Connect | n/a | No reply; the datagram is counted dropped | Not probed |
| G2 | Client connects to server 1 (initial sequence 1) and receives old1..3. Server 1 is gone; the client connects again on the same session to server 2 (initial sequence 1), which sends new1, new2 |
n/a | new1, new2 never delivered, and acknowledged (server 2's pending set empties). C#, Rust, TS, Python |
Not probed |
| G3 | Client sends one ordered write that is lost; the session ends; the client connects to a new server; the client's resends run | n/a | Owed after the end, and delivered in the next session: C#, TS, Python on peer Disconnect, local disconnect and timeout; Rust on local disconnect and timeout. Rust on peer Disconnect: owed 0, nothing delivered (5f1e883d) |
Not probed |
| G3R | Rust socket: send_reliable, the write is lost, disconnect(), connect() on the same transport to a new peer |
n/a | Receipt Pending after the disconnect; the write is delivered to the new peer; receipt Acknowledged (the Soul R1 shape) |
Not probed |
Suites on the prototype db7d2886 (pass 1; baseline 03eac6ff was all green):
cultnet-rs: 110 + 4 + 24 pass;tests/cultnet.rs51 pass and 2 fail. Both failures are test shape, not mechanism:rudp_session_suppresses_duplicates_and_delivers_reliable_ordered_payloads_in_sequence(tests/cultnet.rs:1000) hands the receiver an Accept with sequence 91 from a sender whose data starts at 1. That handshake is impossible. Under a watermark seeded by the Accept, every data sequence is "already below" it. The test must use a consistent handshake.rudp_ordered_channel_tracking_is_bounded(:2655) sends 256 ordered channels with no gap. The prototype keeps state only for channels with held frames, so nothing is refused. The bound becomes "channels with held frames", and the test must hold frames behind a gap.
cultmesh-rsdid not compile only because the prototype added a status variant. Under Q-A2 the status enum keeps its three variants, so that break does not recur.
Wire compatibility (P7). Every decoder ignores flag bits 4-7 and byte 35. Every session ignores an
Ack's sequence field and payload (CultNetTransport.cs:1177, rudp.rs:578-592, rudp.ts:397,
transport.py:612, CultMesh.kt:2738). Every decoder rejects an unknown packet type
(CultNetTransport.cs Enum.IsDefined, rudp.rs packet_type_from_code, rudp.ts:1313,
transport.py:1212, CultMesh.kt fromCode) and an unknown version byte. So:
- An additive watermark would fit in an Ack: flag bit 4 set, the value in the Ack's unused sequence field, zero extra bytes. Old peers apply the ack and ignore the rest. Q-A1 ruled it out; it stays the known place to put a FORWARD-TSN notice if Q-A3 is ever B.
- A new packet type or a version bump is not additive: old peers refuse the datagram and count it dropped.
- No capability negotiation is needed under this map, because nothing on the wire changes.
Authority map
- Owner of ordered delivery (receiver): the session's contiguous received-through watermark
R.- Every reliable sequence up to
Rhas been received since the peer state was last reset. - A held ordered frame whose first sequence is at most
R + 1is delivered, in sequence order, in the same call that advancedR. Ris seeded by the handshake.AcceptConnectseeds it with the Connect's sequence, and receiving the Accept seeds it with the Accept's sequence. A session connected without a handshake (Rustassume_connected,rudp.rs:243, test-only today) seeds it from its first reliable packet.- It advances in
RememberReceivedand resets with the rest of the peer state (ResetPeerState).
- Every reliable sequence up to
- Owner of retransmission (sender): the pending and queued sets, as today. A sequence leaves them when an ack names it. Retransmission stops there. This is not a public meaning.
- Owner of Acknowledged (sender): the acknowledged-through watermark
A, one below the lowest sequence that is pending, queued or abandoned in the current generation. An ordered send is Acknowledged whenAreaches its last sequence. A reliable unordered send is Acknowledged when every one of its sequences is acked. - Owner of the session boundary: the session's generation. One primitive ends a generation: the
session stops being connected, every write not yet Acknowledged is Invalidated and dropped from pending
and queued, and the generation counter advances. Every ending path calls it: a peer's Disconnect, a
local disconnect, a timeout and a refused packet (Cut 1b), and from Cut 1c a client's
connect()on a session that already had a peer, and a server accepting a Connect that does not repeat the current one.- What was learned from the peer (
R, the received set, held frames) is forgotten only where both sides start fresh: a refusal (as today) and, from Cut 1c, a non-repeated handshake. Forgetting it at a one-sided ending (a timeout the peer did not see) would let the peer's retransmits be delivered twice.
- What was learned from the peer (
- Owner of "is this Connect a repeat": the session, from the Connect's sequence (Cut 1c; Q-A6).
- Inputs. Received sequences and handshake packets (receiver); acks, expiry and ending events (sender). Nothing else.
- Outputs. Delivered frames, in order (receiver). Receipt status and flush completion (sender).
- Derived, not owners.
- The per-channel
nextmap is deleted, not demoted:_orderedNextSequenceByChannel(CultNetTransport.cs:918),ordered_next_sequence_by_channel(rudp.rs:196),#orderedNextSequenceByChannel(rudp.ts:160),_ordered_next_sequence_by_channel(transport.py:424),orderedNextSequenceByChannel(CultMesh.kt:2643). expectedSequenceIfUninitializedand its equivalents are deleted (CultNetTransport.cs:1151,rudp.rs:540,rudp.ts:375,transport.py:595,CultMesh.kt:2728).PendingOrderedFrame.NextSequenceis deleted (rudp.rs:160-163and equivalents).OutstandingReliablePacketCountstays, and means "not yet acked in this generation". It is a retransmission count, not a delivery claim.- Rust
session_scope: Uuid(rudp.rs:135,:179,:206, rotated at:345and:601) is no longer an owner. It is replaced by the generation (Cut 1b) and then by receipts resolved at their source (Cut 4). - TS
#generation,#endedGenerationand#endGenerationin the socket transport (rudp.ts:830-831,:937-940) are no longer owners; the session's generation replaces them. DisconnectReason/disconnect_reason/#endedReasonare report-only: why the last generation ended. They no longer gate flush.
- The per-channel
- Forbidden writers.
- No path delivers an ordered frame except the drain after
Radvances. - No receive path drops a frame whose sequence it acknowledged while the generation lives.
- No sender path reports Acknowledged except through
A(or the unordered rule). - No ending path leaves a write owed. No path retransmits a write into a generation after the one it was issued in.
- No transport decides whether a Connect repeats: not by payload (Rust hub
rudp.rs:1637-1647, C# listenerCultNetTransport.cs:2670-2688), not byConnected(C#:2226-2236, Pythontransport.py:1047-1053, TSrudp.ts:249-251,:1031-1049), and not by resetting on every Connect (Rust server moderudp.rs:2105-2116).
- No path delivers an ordered frame except the drain after
- Shared paths. Accept, reliable data, fragments, duplicates and retransmits all advance
RthroughRememberReceivedand then call the drain. Direct sends, fragmented sends, queued promotion and resends all feed the pending and queued sets thatAreads. Every ending path goes through the one generation primitive. - Deletion line.
DeliverOrdered,DrainOrderedandSkipReceivedNonChannelSequencesand their equivalents go before the drain is added:CultNetTransport.cs:1628-1700,rudp.rs:1138-1246,rudp.ts:737-800,transport.py:868-920,CultMesh.kt:2939-2978. The transport-level repeat decisions above go before the session's is added.
The design, question by question
1. Where Acknowledged comes from (Q-A1 a, ruled)
- Derived at the sender from
A(§ The finding). No wire change. - Why it is sound after Cuts 1-3. A conforming receiver:
- drops nothing it acknowledged while the session lives (P1, P6: Cut 1; P5: Cut 2; P8: made unreachable by Cut 3);
- holds an ordered frame only while a sequence below it is missing (Cut 1);
- drains held frames in the call that fills the last gap, before it acknowledges (Cut 1).
- So every sequence up to
sacked meansswas delivered.
- And after Cuts 1b and 1c, an ack can only be credited to the generation that issued the write (G3, G2).
- Mixed versions. A new sender with an old receiver can be wrong only when that receiver strands a
frame (P1, P6). That needs reliable traffic on more than one channel of one session. The C#, TS, Python
and Kotlin socket transports send reliably only on
schema(CultNetTransport.cs:2372-2376,rudp.ts:1254-1262), so they cannot trigger it. Rust sends reliablemedia/audiotoo (rudp.rs:2523-2562channel_send_options). The pass-1 Eyes survey found no live session that mixes those withschema: Muninn's media session carries noschematraffic, and neither does Sleipnir's HID stream. The old receiver loses such frames today in any case. Bumping the pin is the fix. - Every Odin-bound publisher's receiver is Odin. Acknowledged means delivered for Idunn health, presence and catalog publishing only once Odin pins a CultLib with Cuts 1-3.
2. What "delivered to the application" means
- Delivered means the frame left the session's hold and was handed to the transport's application
boundary. That boundary is:
- C#: enqueued in the socket transport's
_deliveredFrames(read byTryReceiveOnce), or returned inCultNetRudpReceiveResult.Deliveredfrom a bare session; - Rust: pushed to
delivered_frames(rudp.rs:2147) or the hub'spending_events, or handed to the document server's sink (cultmesh-rs/src/rudp_document_server.rs:343-360), which acknowledges only after the sink accepted; - TS: the
"frame"event was emitted (rudp.ts:1076-1082); - Python and Kotlin: the delivered queue.
- C#: enqueued in the socket transport's
- It is not "consumed". The operator rejected application-driven acknowledgement, and TCP's cumulative ACK has the same boundary: in the receive buffer, readable, not read.
- A listener or sink that throws or rejects has still been delivered to. The handler-rejection paths from the stray-packet work end the session, which is the application's answer, not the transport's.
3. The public API (Q-A2, ruled: one meaning)
- Rust receipts (the only runtime that has them):
CultNetRudpReliableSendStatuskeeps its three variants,Pending,Acknowledged,Invalidated(rudp.rs:146-150). No variant is added, removed or renamed.Acknowledgedchanges meaning from "every packet was acked" to "delivered".- The visible difference: an ordered send behind a missing sequence reads
Pendinguntil the gap fills (P3), where today it readsAcknowledged. - Every external caller already means delivered, so none changes code:
cultmesh-rs/src/lib.rs:832and:892,tests/rudp_stray_packets.rs:309,cultmesh-rs/tests/rudp_document_server.rs:408,415, CodexConnectorsrc/idunn_health.rs:727-745, Ghostlightcrates/ghostlight-dungeon/src/idunn_health.rs:1126-1145.
- The visible difference: an ordered send behind a missing sequence reads
- A receipt is resolved once, by its session. It becomes
AcknowledgedwhenApasses its last sequence (ordered) or when all its sequences are acked (unordered). It becomesInvalidatedwhen its generation ends first. After that it never changes.- Mechanism: the receipt carries its sequences, whether it was ordered, and a shared status cell
(
Arc<AtomicU8>). The session keeps the unresolved cells, at most one per outstanding send, and writes each once.reliable_send_status(&receipt)(rudp.rs:1931-1936) reads the cell; its signature does not change. - This deletes the session scope (
rudp.rs:135,:179,:206,:283-285,:291-293,:345,:601) and needs no history of ended generations. Today a delivered write readsInvalidatedafter any reset, because the scope rotates (rudp.rs:291-293). The pass-1 design needed a frozen snapshot of one ended epoch and still misreported older ones. PartialEqon the receipt compares its sequences, which are unique within a session object because issued sequences survive resets.
- Mechanism: the receipt carries its sequences, whether it was ordered, and a shared status cell
(
send_reliablereceipts cover queued packets (P10). The receipt lists every sequence the send assigned, not only the ones admitted to the wire (send_many,rudp.rs:456-528, returns only the admitted ones;non_expiring_reliable_receipt,:305-318, refuses an empty set).send_reliablerefuses a channel with reliable expiry (P9). The comment atrudp.rs:1915-1916says this lineage has no expiry, which is false sincebac5be88. Restore the guard it describes.- New:
CultNetRudpSocketTransportConnection::wait_acknowledged(&receipt, timeout) -> Result<()>. It is the ack wait: it pumps receive and resends likeflush_reliableand returns when the receipt isAcknowledged. It fails at once when the receipt isInvalidated, naming the end reason. It replaces the hand-rolled loops atcultmesh-rs/src/lib.rs:806-838and:870-900; CodexConnector and Ghostlight may adopt it at their next bump, and their existing polling stays correct without it.
- Flush: one wait, and it means every send of this generation is Acknowledged.
- A flush belongs to the generation it started in. It fails when that generation ends, whatever comes
after. Rust binds it to the scope today (
rudp.rs:2001-2014) and TS to its transport generation (rudp.ts:911-935). C# (CultNetTransport.cs:1914-1931) and Python (transport.py:1101-1124) check only the disconnect reason, which the next Connect clears (CultNetTransport.cs:1843,:2235;transport.py:997,:1054). Once Cut 1b drops owed writes at every ending, "outstanding is 0" after a reconnect would read as success, so every runtime binds flush to the session's generation in Cut 1b. - When every sent sequence is acked,
Ais the highest sequence sent, so every send is Acknowledged. The only exception is behind an abandoned sequence (Rust expiry). Thereflush_reliable(rudp.rs:1992-2040) fails at once when an ordered send follows the generation's first abandoned sequence: that send can never be Acknowledged, and today flush reports success (P2). - C#
FlushReliable, TSflush, Pythonflush_reliableand KotlinflushReliable(CultMesh.kt:3186) keep their success condition. Their contract text becomes "every reliable frame sent in this session has been delivered to the peer's application". These runtimes have no expiry.
- A flush belongs to the generation it started in. It fails when that generation ends, whatever comes
after. Rust binds it to the scope today (
- Defaults. Plain flush. No parameter. No second flush.
- Compatibility. No signature changes in any runtime except additions (
wait_acknowledged; TSconnectAndWait, §4). The Rust enum is unchanged. No downstream caller has to change code at its next bump.
4. Consumers, each assigned
Surveyed across F:\Projects in pass 1; the rows that moved are re-checked at the revision named. Every
consumer that waits wants delivered, which is now just Acknowledged.
| Consumer | What it waits on today | Change |
|---|---|---|
cultmesh-rs/src/lib.rs:781-838 request_raw_snapshot_from_rudp_catalog (Idunn src/drivers.rs:5527 uses it) |
a hand-rolled loop until Acknowledged, then the response |
Cut 4: wait_acknowledged |
cultmesh-rs/src/lib.rs:870-900 publish_cultnet_message_to_rudp_catalog (Odin odin-daemon) |
a hand-rolled loop until Acknowledged, then disconnect. The doc at :869 claims "application admission" |
Cut 4: wait_acknowledged; the doc says delivered to the document server's sink (rudp_document_server.rs:343-372) |
cultmesh-rs/src/lib.rs:918-938 publish_cultnet_messages_to_rudp_catalog (Ghostlight mesh.rs:323) |
flush_reliable, then drop. Several ordered frames, then close |
None; flush now means it |
cultmesh-ts/src/index.ts:6070-6098 publishRudpDocumentOnce (Heimdall, StreamPixels, Stonks, weksa, Bifrost, VoidBot, Hermodr) |
peer.flush (cultnet-ts/src/peer.ts:109-110), then close |
None. Cut 5 moves its connect-and-wait helper (index.ts:6603-6650) into cultnet-ts |
cultnet-ts/src/idunn-odin-presence-publisher.ts:89-215 publishDocument, behind createIdunnRuntimePresencePublisher. StreamPixels' service runs this: apps/service/scripts/idunn-entry.mjs calls createIdunnRuntimePresencePublisher from its vendored CultLib 30ee8b9, where the file is byte-identical to 3bf1c0c |
a hand-rolled session loop (:186-208) until outstandingReliablePacketCount === 0. It does resend (:205). It drops readyToSend (:198), so promoted queued packets wait for the resend timer. It pins initialSequence: 1 (:103) and never sends a Disconnect, so Odin's hub keeps each publish's peer until it times out (each publish binds a new port, so each is a new peer) |
Cut 5: the socket transport, connectAndWait, send("schema"), flush, close (which sends the Disconnect, rudp.ts:956-969) |
cultnet-ts/src/signed-daemon-health.ts:104-162 publishSignedDaemonHealth (Hermodr, Odin idunn-rudp.cjs) |
a hand-rolled loop: sends the packets sendMany admitted, waits up to 500 ms for the first Ack packet of any content (:146-153), swallows the timeout, closes. Resends run inside that wait (:303) but promoted queued packets are never sent |
Cut 5, as above. Today a write not acked within 500 ms, or any payload over 32 packets, is reported published |
cultnet-ts/src/operation-service.ts |
the operation response | none (the response is the proof) |
C# FlushReliable callers: Gjallar Program.cs:3055-3080 (two ordered frames, flush, dispose) |
flush | None |
Heimdall src/idunn-rudp-health.ts:55-87 (vendored CultLib b6b1d9c, Heimdall d5acc94) |
the first Ack packet | Heimdall's own cut at its bump: call cultnet-ts's publisher after Cut 5 |
CodexConnector idunn_health.rs:727-745, Ghostlight idunn_health.rs:1126-1145 |
Acknowledged |
None required. Optional wait_acknowledged at their next bump |
Muninn main.rs:9446-9458, Sleipnir main.rs:880-904 |
nothing (send and drop) | Follow-up: fire-and-forget health can be silently lost |
Kotlin flushReliable |
no callers | Contract text only |
5. The hold buffer and the 4 MiB cap
- It belongs here, because the held frame is exactly the state this map names.
- Mechanism (P4). Rust caps held ordered frames at 1,024 frames and 4 MiB (
rudp.rs:47-48, checked at:1181-1187). A refusal ends the session. The default payload limit is 16 MiB (rudp.rs:33). With one lost packet under a large ordered transfer, a legal 5 MiB frame is refused and kills the session.- The sender's window counts pending packets, not span or bytes (
rudp.rs:910-942). While one packet stays lost, acked packets keep freeing slots, so the held data behind the gap grows without limit.
- The sender's window counts pending packets, not span or bytes (
- Fix: a sender-side flow window, TCP's receive window without a wire field (Cut 3). A reliable
packet is admitted to the wire only while:
- its sequence is at most 1,023 above the lowest unacked sequence; and
- the payload bytes of sequences above the lowest unacked one stay within 4 MiB, with at least one packet always admissible.
- Otherwise it waits in the existing queue.
- What this buys:
- a conforming sender never makes a Rust receiver hold more than 4 MiB, so the cap stops refusing legal traffic;
- a conforming sender never gets 1,024 sequences ahead of the receiver's highest, so the Rust far-ahead
refusal (
rudp.rs:46, checked at:626-630) never drops its packets; - a conforming sender never leaves a sequence 4,096 behind the receiver's highest, so P8 cannot happen.
The receive-history window stays 4,096 in every runtime (
CultNetTransport.cs:884,rudp.rs:35,rudp.ts:20,transport.py:404,CultMesh.kt:2625).
- What is kept. The cap and the far-ahead refusal stay. They protect against hostile peers.
- Rejected: raising the cap to the payload limit or above (16-64 MiB per hostile session instead of 4); lowering the ordered payload limit to 4 MiB (an API regression for large snapshots).
- Cost. Normal flow never has a span beyond the 32-packet window, so the new limits bind only while a packet is lost.
- Old senders (the pinned and vendored ones) can still trip the Rust cap until they bump.
- Not in scope. C#, TS, Python and Kotlin receivers have no hold cap. Follow-up.
6. Reliable expiry (P2)
- Only Rust has it (
rudp.rs:39,:898-908). An expired packet's sequence never reaches the receiver.Rstops below it, and so did the oldnextpointer. Ordered frames after it are held for the rest of the session. - Today's users. Only Muninn's reliable
audio, and its session carries no ordered traffic.hands/media-fec-cut3(unmerged,4b85a173) deletes theaudioprofile entry and the"audio"send arm. Themediachannel keeps a caller-chosen reliable-with-expiry mode. - This map makes it honest (Cut 4):
- the sender records its generation's first abandoned sequence;
Anever passes it;- ordered receipts after it stay
Pending, and becomeInvalidatedwhen the generation ends; flush_reliablefails at once.
- The real fix is a fork (Q-A3). The literature's answer is PR-SCTP's FORWARD-TSN (RFC 3758): the sender tells the receiver to move its cumulative point past abandoned sequences.
7. Interaction with the merged stray-packet work
The ack cuts build on these behaviours and do not alter them:
- A refusing session ends, and its goodbye is built after the reset (
EndRefusedCultNetTransport.cs:1315-1319,end_refused_sessionrudp.rs:364-367). The refused sequence is never acked, so a refusal never becomes a false Acknowledged. - Issued sequences survive a reset in every runtime (
rudp.rs:341-343,CultNetTransport.cs:1292-1308,rudp.ts:214-227,transport.py:458-471). Cut 1c relies on it: a client's second Connect always carries a new sequence. - One Accept per generation, and a repeated Connect answered with the Accept still owed, or an Ack. Cut 1c keeps the answer and moves the decision of what repeats into the session.
- An ended session fails its flush. Cut 1b generalises the TS and Rust binding to the generation into all four runtimes.
5f1e883dmade a peer's Disconnect end Rust receipts (rudp.rs:596-615) and removed the transport-level Pending→Invalidated override. Cut 1b makes the other ending paths agree with it.- The TS operation service's expiry and handler rejection are above the transport and do not change.
8. Session generation: why it is two cuts, and how a new one is recognised
- Why not inside Cut 1. Cut 1 is a receiver change with a deletion line: one watermark replaces five
per-channel state machines. Its falsifiers are P1, P1b and P6. The generation work touches the ending
paths, the handshake, flush and receipts, and its falsifiers are G1-G3. Both touch
ResetPeerStateand the Accept path, which is a merge cost, not a shared owner. Keeping them apart lets Soul falsify each against its own probes. - Why two cuts. The ending rule (Cut 1b) is ruled and needs no mechanism choice: every ending path drops what it owed. How a new generation is recognised (Cut 1c) needs one (Q-A6). The two are separable because 1b does not forget peer state: the peer may not know the session ended, and forgetting what was received would let its retransmits be delivered twice.
- What must hold after both. A write is Acknowledged or Invalidated within the generation it was issued in. A restarted client is admitted. A new server session's frames are delivered after a reconnect. A retransmitted Connect is still a repeat.
- Recognising a new generation (Cut 1c, Q-A6 recommendation A). The Connect's sequence identifies the
generation, and the initial sequence is random by default, as TCP's initial sequence number is
(RFC 9293 §3.4.1, RFC 6528).
- A Connect repeats exactly when it carries the sequence of the Connect that started the current
generation. Its retransmits do; a client's second
connect()cannot, because issued sequences survive resets; a restarted process almost never does, because it drew a fresh random initial sequence. - A stale duplicate of the accepted Connect, delayed in the network, still repeats: same sequence.
- Anything else ends the current generation and starts a new one, at both ends: the client forgets peer state when it sends a Connect on a session that had a peer, and the server when it accepts a Connect that does not repeat.
- A client honours an Accept only while its Connect is pending, and only if the Accept's ack field names
that Connect. A stale Accept from an earlier generation cannot seed
R. - The initial sequence is drawn from [1, 2^31), which leaves at least 2^31 sequences before the
exhaustion error (
rudp.rs:944-962) in every runtime. An explicitinitial_sequencestill works, for tests. - The Connect payload stays application evidence (the provider layer's
clientSessionId,cultnet-rs/src/provider_session.rs:70-79), carried to the application as today. It no longer decides anything in the transport.
- A Connect repeats exactly when it carries the sequence of the Connect that started the current
generation. Its retransmits do; a client's second
Cuts
Every cut is on CultLib, branch hands/rudp-delivered from main at 3bf1c0c or later, in a worktree
Self creates. Heavy verification runs on Yggdrasil. Each cut starts by committing its probes as failing
tests named for the rule, in every runtime it touches. The pass-1 and pass-2 probe files
(refs/verify/1519a20a on the CultLib-imag-ack2 mirror) are the starting point; they print, so each
must become an asserting test.
Kotlin: every cut below is mapped for C#, Rust, TS and Python. If Q-A5 is A, a trailing Cut K applies
Cuts 1, 1b, 1c and 3 to CultMesh.kt at the anchors given, on the verification host Q-A5 picks.
Negative checks that stay green in every cut:
- the cross-runtime reorder, drop and fragment proofs in the TS interop harness
(
docs/cultnet-transport-parity.md:227-248); - the stray-packet tests (
packages/cultnet-rs/tests/rudp_stray_packets.rs, and their C#, TS and Python equivalents), except the ones each cut names as encoding the old rule; - the codec fixture vectors: no wire byte changes.
Cut 1. One watermark owns ordered delivery (receiver) — ready
- First. Failing tests P1, P1b and P6 in each runtime.
- Deletes first:
- the per-channel
nextmap and its resets:CultNetTransport.cs:918,:1305;rudp.rs:196,:223,:354;rudp.ts:160,:223;transport.py:424,:468;CultMesh.kt:2643; expectedSequenceIfUninitialized:CultNetTransport.cs:1151-1153,rudp.rs:540-543(used at:679),rudp.ts:375-377(used at:450),transport.py:595-599,CultMesh.kt:2728;DeliverOrdered,DrainOrderedandSkipReceivedNonChannelSequences:CultNetTransport.cs:1628-1700,rudp.rs:1138-1246,rudp.ts:737-800,transport.py:868-920,CultMesh.kt:2939-2978;PendingOrderedFrame.NextSequence(rudp.rs:160-163and equivalents).
- the per-channel
- Adds:
R, seeded inAcceptConnect(CultNetTransport.cs:1012,rudp.rs:383,rudp.ts:242,transport.py:485,CultMesh.kt:2667) and on Accept receipt (CultNetTransport.cs:1155,rudp.rs:544,rudp.ts:379,transport.py:601,CultMesh.kt:2730);Radvances inRememberReceived(CultNetTransport.cs:1518,rudp.rs:973,rudp.ts:619,transport.py:809,CultMesh.kt:2891) and resets inResetPeerState;- a reassembled ordered frame is delivered at once when its first sequence is at most
R + 1and its channel holds nothing below it. Otherwise it is held. The caps apply only to what is held: the prototype held everything and so refused a 5 MiB frame with no gap; - after every reliable receipt (data, fragment, duplicate, Accept), drain every channel's held frames
whose first sequence is at most
R + 1, in sequence order; - Rust only: the 64-channel cap (
rudp.rs:42) counts channels with held frames.
- Tests changed:
packages/cultnet-rs/tests/cultnet.rs:1000(consistent handshake) and:2655(hold frames behind a gap). The equivalents in the other runtimes are whatever the change breaks. Each must be read before it is edited, because a test that encodesmin(highest+1, frame)encodes P6. - Verification:
- P1, P1b and P6 pass in every runtime;
- the full suites:
cargo testincultnet-rsandcultmesh-rs,dotnet test tests/GameCult.Networking.Tests,npm testincultnet-ts, the Python suite; - the TS interop harness across runtimes;
- negative grep:
rg -n "orderedNextSequence|ordered_next_sequence|expectedSequenceIfUninitialized|expected_sequence_if_uninitialized|SkipReceivedNonChannel|skip_received_non_channel" src packagesreturns nothing; - mutation testing on the diff: cargo-mutants, Stryker.NET, StrykerJS, and mutmut for Python.
- Ledger. Per runtime about −70 and +40. Across four, about −280 and +160.
Cut 1b. A write belongs to the session it was issued in: every ending drops what it owed — ready
- First. Failing tests G3 (each ending path: peer Disconnect, local disconnect, timeout, refusal) in
C#, TS and Python, and local disconnect and timeout in Rust; G3R in Rust; and in every runtime, a flush
started before a timeout or disconnect fails even after a later
connect()succeeds. - The owner. Each session gets a generation counter and one private primitive that ends the current generation: not connected; pending and queued dropped; generation advanced. In Rust it also invalidates the generation's receipts (by the scope today; Cut 4 moves that into the receipts). It does not touch what was received from the peer (§8).
- Deletes first:
- Rust: the inline clearing in the Disconnect branch (
rudp.rs:596-615) and the scope rotation inreset_peer_state(:345), both replaced by the primitive; the receipt doc that says local endings carry writes (rudp.rs:128-133); the flush's scope capture (:2001-2014), replaced by the generation; - TS: the transport's
#generation,#endedGeneration,#endGeneration(rudp.ts:826-831,:937-940) and their uses inconnect(:895),flush(:913-920),checkTimeout(:949),#endRefusedSession(:976), the server Connect path (:1037-1046) and the disconnect result (:1084).#endedReasonstays, as the report of why; - C# and Python: flush's reliance on the disconnect reason (
CultNetTransport.cs:1924-1929,transport.py:1110-1116). The reason stays, as a report.
- Rust: the inline clearing in the Disconnect branch (
- Adds:
- the primitive, called from every ending path:
- peer Disconnect:
CultNetTransport.cs:1190-1199,rudp.rs:596-615,rudp.ts:406-414,transport.py:619-625; - local disconnect:
CreateDisconnectCultNetTransport.cs:1324-1328,create_disconnectrudp.rs:771-781,createDisconnectrudp.ts:508-515,create_disconnecttransport.py:695-697; - timeout, when it fires:
CultNetTransport.cs:1333-1348,rudp.rs:783-796,rudp.ts:517-526,transport.py:699-706; - refusal, through
ResetPeerState(CultNetTransport.cs:1292-1308,rudp.rs:344-358,rudp.ts:214-227,transport.py:458-471);
- peer Disconnect:
- a read-only generation on each session, which each transport's flush captures at start and fails on
when it changes (
CultNetTransport.cs:1914-1945,rudp.rs:1992-2040,rudp.ts:911-935,transport.py:1101-1124).
- the primitive, called from every ending path:
- Hubs. The Rust hub and the C# listener already discard a peer's session at its end, so its owed writes die with it. No change.
- Tests changed:
tests/rudp_stray_packets.rs:638-690keeps passing unchanged (peer Disconnect already obeys the rule). Tests that expect a write to survive a local disconnect or timeout encode the old rule; read each before editing. - Verification:
- G3 in every runtime: after every ending path, owed 0 and nothing delivered to the next session;
- G3R: the receipt reads
Invalidatedafterdisconnect(), and stays so after reconnecting; - the flush test above in every runtime;
- negative:
rg -n "endedGeneration|#endGeneration" packages/cultnet-ts/srcreturns nothing; a TS reconnect from inside adisconnectlistener still cannot make an ended flush succeed (the case the TS generation pair was written for,rudp.ts:826-829); - mutation testing on the diff.
- Ledger. About −40 and +45 across four runtimes. TS is net negative.
Cut 1c. A Connect's sequence says whether it repeats — blocked on Q-A6
Mapped for Q-A6's recommended answer A. Blocked on Cut 1b (it uses the ending primitive).
- First. Failing tests G1 (the hub, the C# listener, and server mode in every runtime: a restarted
client on the same address and payload is admitted and its frames delivered), G1b (C# and Python server
mode admit a Connect from a new endpoint), G2 (after
connect()on the same session, a new server session's frames are delivered), and a stale Accept (its ack field does not name the pending Connect) is ignored. - Deletes first:
- the transport-level repeat decisions: Rust server mode's reset on every Connect
(
rudp.rs:2105-2116); the Rust hub's payload comparison (rudp.rs:1637-1647); C# server mode's_session.Connectedbranch (CultNetTransport.cs:2226-2236); the C# listener's payload comparison (CultNetTransport.cs:2670-2688); TS'smovedEndpoint/repeatedcomputation (rudp.ts:1011-1049) and the session's ownconnectedshortcut (rudp.ts:249-251); Python'sconnectedbranch (transport.py:1047-1053); - C# and Python server mode's refusal of a Connect from a new endpoint (
CultNetTransport.cs:2212-2216,transport.py:1042-1044), for Connect packets only. Rust and TS already admit it.
- the transport-level repeat decisions: Rust server mode's reset on every Connect
(
- Adds:
- the session records the sequence of the Connect that started its generation, and decides: a Connect
repeats exactly when it is connected and the Connect carries that sequence.
AcceptConnectanswers a repeat asAnswerRepeatedConnectdoes today, and otherwise ends the generation, resets peer state and accepts (CultNetTransport.cs:1012-1059,rudp.rs:383-435,rudp.ts:242-290,transport.py:485-525).AnswerRepeatedConnectstops being public; a public predicate (ConnectRepeats(packet)) serves the hubs, which keep building a fresh session for a new generation and emit Disconnected for the old one (rudp.rs:1648-1690,CultNetTransport.cs:2690-2710); CreateConnecton a session that has had a peer ends the generation and resets peer state first (CultNetTransport.cs:1001-1010,rudp.rs:369-381,rudp.ts:229-240,transport.py:473-483);- on Accept receipt, the session honours it only while its Connect is pending and only if the Accept's
ack field names that Connect (
CultNetTransport.cs:1155-1160,rudp.rs:544-557,rudp.ts:379-390,transport.py:601-604); - the default initial sequence is random in [1, 2^31): Rust
CultNetRudpSessionOptions::default(rudp.rs:104-113), the transport constructors (:1311,:1332) and hub options (:1377); C#CultNetTransport.cs:773,:850,:2404; TSrudp.ts:172; Pythontransport.py:298,:323; - CultLib's own fixed
initial_sequence: 1call sites take the default:cultmesh-rs/src/lib.rs:964,:1409,cultmesh-rs/src/rudp_document_server.rs:432,cultnet-rs/src/cultmesh.rs:259,cultnet-ts/src/signed-daemon-health.ts:116.
- the session records the sequence of the Connect that started its generation, and decides: a Connect
repeats exactly when it is connected and the Connect carries that sequence.
- Tests changed (they encode payload identity or a fixed initial sequence):
packages/cultnet-rs/tests/rudp_server_hub.rs:171-240callsconnect()again with the same payload and expects no replacement. Under this rule that is a new generation. Its retransmit half is already covered byrudp_stray_packets.rs:487(the same Connect packet twenty times), which stays;tests/GameCult.Networking.Tests/NetworkingTests.cs:1507replaces a peer by payload with two sessions at the default initial sequence; it passes under a random default, but must say it relies on distinct sequences;packages/cultnet-ts/test/cultnet.test.ts:2225(another endpoint replaces the peer) stays;- any test that asserts a sequence value with the default initial sequence.
- Verification:
- G1, G1b, G2 and the stale-Accept test in every runtime;
- the retransmit tests stay green:
rudp_stray_packets.rs:487,:511,NetworkingTests.cs:1483,cultnet.test.ts:2119,:2134,test_cultnet.py:1134; - negative grep:
rg -n "SequenceEqual\(connectPayload\)|connect_payload == packet.payload|movedEndpoint" src packagesreturns nothing; - mutation testing on the diff.
- Ledger. About −60 and +70 across four runtimes. Ten call sites lose an explicit initial sequence.
Cut 2. A reliable fragment set is never evicted (receiver: Rust, TS, Python) — ready
- First. Failing test P5 in each of the three.
- Change:
- eviction picks the stalest set that holds no reliable fragment (
rudp.rs:1027-1047,rudp.ts:679-692,transport.py:836-842); - if every pending set holds reliable fragments, the packet is refused and the session ends, as every other refusal does;
- a conforming sender cannot reach that bound: its window keeps at most 32 reliable packets in flight, and the bound is 64 sets.
- eviction picks the stalest set that holds no reliable fragment (
- Verification: P5 delivers the reliable frame.
d3bc6e66's test (lossy fragment sets keep being evicted) stays green.fragment_sets_evictedstill counts evictions. - Ledger. About −3 and +12 per runtime.
Cut 3. The sender's flow window: 1,023 sequences and 4 MiB above the lowest unacked — ready
- First. Failing tests P8 (all runtimes) and P4 (Rust receiver, with a sender from each runtime).
- Change. Admission (
AdmitReliablePackets/PromoteQueuedReliableatCultNetTransport.cs:1439-1490,rudp.rs:910-942,rudp.ts:586-600,transport.py:776-796,CultMesh.kt:2856-2872) admits a packet only while:- the window has a slot (as today);
- its sequence is at most the lowest unacked sequence plus 1,023;
- the admitted payload bytes above the lowest unacked sequence stay within 4 MiB.
- The first packet is always admissible. Expired packets (Rust) do not count as unacked here: they are gone from the wire.
- Contract.
docs/cultnet-transport-parity.md(after:263) states the receive window: a receiver must hold 1,023 sequences and 4 MiB beyond its contiguous watermark, and a conforming sender never exceeds that. - Verification:
- P8:
gis delivered; - P4: the 5 MiB frame is delivered after the gap fills, and the session is never refused;
- the existing large-snapshot tests (
c398bad1) and the fragment interop stay green; - the Rust benchmark or media probe shows no throughput change on a lossless link.
- P8:
- Ledger. About +25 per runtime, and nothing removed.
Cut 4. Rust receipts: Acknowledged means delivered, resolved once; honest expiry and queueing — blocked on Cuts 1 and 1b, and on Q-A3
- First. Failing tests: P3 (the receipt for
s2readsPendinguntils1arrives, thenAcknowledged), P9, P10, P2 (flush_reliablemust fail), and: a receiptAcknowledgedbefore any ending staysAcknowledgedafter the ending and after a reconnect; aPendingone becomesInvalidated. - Deletes first:
- the session scope (
rudp.rs:135,:179,:206,:283-285, the check at:291-293, and what Cut 1b left of the rotations); - the stale comment and the half guard at
rudp.rs:1915-1920; - the hand-rolled status loops at
cultmesh-rs/src/lib.rs:806-838and:870-900.
- the session scope (
- Adds:
- the receipt's status cell and ordered flag; the session's unresolved-receipt list, resolved once
(Acknowledged through
A, Invalidated by the ending primitive); acked_through(A), reading pending, queued and first-abandoned;- first-abandoned, recorded in
purge_expired_reliable(rudp.rs:898-908); - the receipt covers queued sequences:
send_many(:456) reports every sequence it assigned; send_reliable(:1903-1930) refuses a channel with expiry;wait_acknowledged;flush_reliablefails fast when an ordered send follows the first abandoned sequence.
- the receipt's status cell and ordered flag; the session's unresolved-receipt list, resolved once
(Acknowledged through
- Unchanged:
CultNetRudpReliableSendStatus(:146-150),reliable_send_status's signature (:1931), and every caller ofAcknowledged:tests/rudp_stray_packets.rs:309,cultmesh-rs/tests/rudp_document_server.rs:408,415, CodexConnector, Ghostlight. - Changes:
cultmesh-rs/src/lib.rs:832and:892becomewait_acknowledged; the doc at:869says delivered to the document server's sink. - Verification:
- the new tests pass;
rg -n "session_scope" packages/cultnet-rshas no hit;- both suites are green;
- cargo-mutants on the diff.
- Ledger. About −90 (two loops of about 30 each, the scope) and +90 (of which
wait_acknowledgedis about 35).
Cut 5. CultLib-internal TS publishers and the contract text (TS, docs) — blocked on Cut 3, and on Cut 1b in TS
- Changes:
idunn-odin-presence-publisher.ts:89-215andsigned-daemon-health.ts:104-162(with its helpers:244-252,:273-389, except the exportedparseEndpoint:254-271) send throughCultNetRudpSocketTransportConnection:connectAndWait,send("schema"),flush,close. Their hand-rolled session loops are deleted. The presence publisher keeps rejecting acultnet.error.v0response, from the transport'sframeevents during the flush.connectAndWait(payload, timeoutMs)on the TS socket transport, matching C#ConnectAndWait(CultNetTransport.cs:1859-1880). It iscultmesh-ts/src/index.ts:6603-6650waitForRudpConnectedmoved down;createRudpPeer(index.ts:6220-6245) uses it and the cultmesh-ts copy is deleted.- Flush contract text in all runtimes: "every reliable frame sent in this session has been delivered to the peer's application".
docs/cultnet-transport-parity.md:236-240(the control-packet guard paragraph) is replaced by the watermark rule, and:261-272gains: Acknowledged means delivered; a write belongs to the session it was issued in; how a repeated Connect is recognised (after Cut 1c); the receive window (after Cut 3).
- Verification:
runtime-presence-health.test.tsandsigned-daemon-health.test.tsstay green;- a new test drops the first datagram and still publishes;
- a new test publishes a payload over 32 packets whole;
- a new test shows the publisher's peer receives a Disconnect.
- Ledger. About −270 and +50.
Subtraction ledger (estimate, four runtimes)
| Cut | Removed | Added | Other |
|---|---|---|---|
| 1 | ~280 | ~160 | four per-channel state machines become one watermark |
| 1b | ~40 | ~45 | one ending primitive; TS's transport generation pair goes |
| 1c | ~60 | ~70 | four transport-level repeat decisions become one session predicate |
| 2 | ~10 | ~35 | none |
| 3 | 0 | ~100 | a documented receive-window contract |
| 4 | ~90 | ~90 | one public method (wait_acknowledged); the session scope goes; no enum change |
| 5 | ~270 | ~50 | two hand-rolled RUDP loops and cultmesh-ts's connect wait go |
- Source, net: about −195. Tests are extra: about 4 × 10 rule tests.
- Wire: zero bytes.
- Downstream: no caller has to change code at its next bump. Callers that fixed
initial_sequencekeep a deterministic Connect sequence, and with it the restart lockout, until they drop the value. - Kotlin (Q-A5 A): Cuts 1, 1b, 1c and 3 again, about the same size as one runtime each.
Operator questions
Each question stands alone.
Ruled (2026-09-30), recorded so they are not re-asked:
- Q-A1. Where does delivered come from? (a): derived at the sender from the cumulative watermark. No wire change.
- Q-A2. One flush, or a "received" flush beside it? One meaning: Acknowledged means delivered. Receipts are Pending, Acknowledged or Invalidated. Retransmission stops on each packet's own ack. Flush waits for Acknowledged.
Open:
-
Q-A3. Reliable expiry next to ordered traffic (P2). An expired reliable packet leaves a permanent hole, and every ordered frame after it on the same session is held until the session ends.
- A. Report it honestly (Cut 4): ordered receipts after the hole stay
Pendingand becomeInvalidatedwhen the session ends, and flush fails fast. Document "do not send ordered traffic on a session that uses reliable expiry". No live consumer does. - B. PR-SCTP's FORWARD-TSN (RFC 3758). On expiry the sender sends an abandonment notice, which rides
an Ack-typed packet with flag
0x10so that old peers ignore it (P7). New receivers treat the sequence as received with no frame, and acknowledge it. The sender resends the notice until it is acknowledged. That is a new cut in every receiver. Old receivers never acknowledge it, so the resend needs its own bound. - C. Refuse ordered sends on a session after its first expiry.
- D. Delete reliable expiry. Muninn's
audiois its only user andhands/media-fec-cut3retires it. This subtracts, but CultLib would lose partial reliability, which a reasonable consumer can expect. - Recommended: A now. Record B as the complete answer for when a consumer mixes the two.
- Blocks: Cut 4 only. A keeps Cut 4 as mapped (
first_abandonedalone). B adds a wire cut in every receiver before Cut 4. C changes Cut 4'ssend_manyguard. D replaces Cut 4's expiry half with a deletion. Cuts 1, 1b, 1c, 2, 3 and 5 are unaffected.
- A. Report it honestly (Cut 4): ordered receipts after the hole stay
-
Q-A4. Receipts in C#, TypeScript, Python and Kotlin?
- Only Rust has per-send receipts. The other four offer flush and an outstanding count.
- A. Port receipts with the same three states (Pending, Acknowledged, Invalidated) and a
WaitAcknowledged, in this campaign. - B. Record it as a parity gap. Flush covers every surveyed consumer.
- Recommended: B. No consumer outside Rust waits per send. A reasonable C# consumer might want it, but it is additive later, changes no wire byte, and after Cut 4 the Rust design (a status cell resolved once by the session) ports without a second design.
- Blocks: nothing mapped. A adds a cut of about +80 per runtime after Cut 4.
-
Q-A5. Is Kotlin in the campaign?
cultmesh-kotlincarries a fifth RUDP runtime with P1 and P6 (the same code,CultMesh.kt:2939-2978). Its flush has no callers. The stray-packet work did not touch it, so none of those fixes reached it (not probed in pass 2). Its only build path isbuild.ps1, which needs Android Studio'skotlincand JBR on Windows. Yggdrasil has no Kotlin image in the verify list.- A. Include it, as a trailing Cut K that applies Cuts 1, 1b, 1c and 3, verified on a Yggdrasil Kotlin image added first (or on Starfire as a Windows-only job).
- B. Record it as parity debt, with the stray-packet gaps. Mark the parity doc so that nobody reads Kotlin as conforming.
- Recommended: A, with a Yggdrasil Kotlin image. Wire parity is the library's promise. A runtime that strands acknowledged frames should not stay listed as conforming.
- Blocks: Cut K only. Cuts 1, 1b, 1c and 3 proceed in four runtimes either way; pass 1 had Q-A5 blocking their scope, and pass 2 removes that by making Kotlin trail.
-
Q-A6. How does a session recognise a new generation? (new in pass 2) Today a server treats a Connect from a connected endpoint as a repeat by payload (Rust hub, C# listener) or unconditionally (C#, TS and Python server mode), so a restarted client with the same payload is locked out (G1), and a client's second
connect()is not seen as new, so the client cannot safely forget the old server session's sequences (G2). The Connect's bytes are identical for a retransmit and for a restarted process that starts at the same initial sequence, so something has to differ.- A. The Connect's sequence identifies the generation, and the default initial sequence is random in [1, 2^31), as TCP's initial sequence number is (RFC 9293 §3.4.1, RFC 6528). A Connect repeats exactly when it carries the current generation's Connect sequence. No wire change. The default of a public option changes (from 1, or 100 for the C# listener); an explicit value still works for tests, and a caller that fixes it keeps the lockout.
- B. Proof of receipt. A byte-identical Connect repeats until the server has seen the client acknowledge the Accept; after that any Connect is a new generation. No default changes. But a delayed duplicate of the original Connect that arrives after that ack replaces a live session and forgets what it received, so its retransmits are delivered twice.
- C. The application's Connect payload identifies the generation (today's hub rule), and every
client must put a per-process nonce in it, as the provider layer's
clientSessionIddoes. Server mode adopts the same comparison. This leaves G1 as a documented obligation on every caller, including the ones that send an empty payload (cultmesh-rs/src/lib.rs:973, the TS publishers). - Recommended: A. It is the literature's answer, it is robust to delayed duplicates (they carry the accepted sequence), and it moves the decision into the session, deleting four transport-level decisions.
- Blocks: Cut 1c only. Cut 1b (the ending rule) is ruled and does not depend on it.
Not forks, recorded so they are not re-asked:
Acknowledgedkeeps its name and now means delivered. No variant is added or removed.- Delivered means handed to the transport's application boundary, not consumed.
- The 4 MiB cap stays. The sender's window keeps legal traffic under it (§5).
- The receiver's 4,096 receive history stays. The sender's window keeps legal traffic inside it.
- A receipt is resolved once.
Acknowledgedbefore a session ends staysAcknowledged; anything else becomesInvalidatedat the end. - Session generation is its own two cuts, not part of Cut 1 (§8).
Sequencing and blockers
- Done.
hands/rudp-stray-packetsmerged tomainat3bf1c0c. Odin pins3bf1c0c. - Ready for Hands now (base
mainat3bf1c0cor later; four runtimes; Kotlin trails per Q-A5):- Cut 1 (the watermark).
- Cut 1b (the ending rule). Same files as Cut 1 in
ResetPeerStateand the Disconnect branches: land it after Cut 1 on the same branch, or in parallel and rebase the second. - Cut 2 and Cut 3, independent of Cut 1 and of each other, in parallel worktrees. Merge Cut 1 before Cut 3 so that Cut 3's P4 test exercises the new hold path.
- Cut 1c is blocked on Q-A6 and on Cut 1b.
- Cut 4 is blocked on Cut 1 (Acknowledged is sound only against a correct receiver), on Cut 1b (it resolves receipts through the ending primitive), and on Q-A3.
- Cut 5 is blocked on Cut 3 in TS (the socket transport it routes through must carry the window) and on Cut 1b in TS (its flush must be bound to the generation). It does not need Cut 1c, but Cut 5's parity-doc text for repeated Connects waits for it.
- Odin's next pin bump follows Cuts 1-3 (and 1b). Odin is the receiver for every Idunn health,
presence and catalog publisher, so this bump is what makes their Acknowledged mean delivered. Odin uses
publish_cultnet_message_to_rudp_catalogand no receipt type, so Cut 4 never breaks its build. - Parallel campaigns:
hands/media-fec-cut3(unmerged,4b85a173) touchesrudp.rsonly in the imports, the profile'saudioentry (~2374at3bf1c0c) and the"media" | "audio"arm ofchannel_send_options(~2547). None overlaps Cuts 1-4. Either order; the second rebases trivially. Once it lands, reliable expiry is only formediawhen the caller chooses Reliable.- Muninn's own cuts use lossy media plus parity. Its reliable
audiosession has no ordered traffic, so P2 does not bite it. Nothing here blocks Muninn, and nothing in Muninn blocks this. - CultCache publication Cut 4 (
docs/cultcache-publication-cut.md§4) touchesCultNetDatabase.csonly, and needs in-order, exactly-once delivery onschema. The C# socket transports carry one reliable channel (CultNetTransport.cs:2372-2376), so P1 and P6 cannot occur on their sessions. No blocking relation in either direction.
- Vendored TS bumps come after Cut 5, so they pick up honest flushes, the TS window and the rewritten
publishers at once:
- StreamPixels vendors CultLib at
30ee8b9(StreamPixelsorigin/main, gitlink bumped in44a8945). Its service runscreateIdunnRuntimePresencePublisher(apps/service/scripts/idunn-entry.mjs), whose file is byte-identical at30ee8b9and3bf1c0c;30ee8b9also predates the TS stray-packet hardening inrudp.ts. - Heimdall vendors
b6b1d9cand hand-rolls its own publisher (src/idunn-rudp-health.ts:55-87, first-ack wait). At its bump it calls cultnet-ts's publisher instead. - Bumping either after Cut 1c as well also gives them the restart fix; neither needs it, because each publish binds a new port.
- StreamPixels vendors CultLib at
- CodexConnector and Ghostlight need no code change at their next bump. They may switch their
status loops to
wait_acknowledgedafter Cut 4.
Follow-ups outside this campaign
- Hold caps in C#, TS, Python and Kotlin. Their ordered hold buffers and per-channel maps are unbounded against a hostile peer. Rust has caps.
- The document server's per-session payload budget never shrinks (
rudp_document_server.rs:321,:584). After 4 MiB in one session it drops data without acknowledging it, and the sender retransmits until it gives up. - Fire-and-forget health. Muninn
main.rs:9446, Sleipnirmain.rs:880-904and Heimdall's first-ack wait can lose a health record silently. - FORWARD-TSN if Q-A3 is A and a consumer later mixes expiry with ordered traffic.
- Callers outside CultLib that fix
initial_sequencekeep the restart lockout after Cut 1c until they drop the value. Record it in their pin-bump notes. - The P4 probe at the old pins predates its fix, so it proves nothing there. If anyone needs
old-sender-to-new-receiver evidence for the cap, rerun
09318d13's P4 against a pinned sender.