Skip to content

Protocol, registration, complete lifecycle ​

Understand which frames are legal at each point in a Sidecar session. Authentication, readiness and activation establish different conditions, so the receive loop must enforce the current state.

Version scope: these source-level examples target v2.0.0.alpha.14. Use the Plugin SDK for current Wasm plugin authoring.

Define sender, validator, publication, and retirement for every phase. Versions, frame constants, and feature bits are compatibility contracts, not adjustable author settings.

Bootstrap to activation ​

text
Host                         Sidecar
bind/start child ───────────→ read one-use stdin proof
authenticate first 32 bytes ← Bootstrap.ConnectAsync
HELLO ─────────────────────→ version/features check
      ←───────────────────── WELCOME
      ←───────────────────── REGISTER_BEGIN / ITEM* / END
      ←───────────────────── STATE_SNAPSHOT_BEGIN / ITEM* / END
READY ─────────────────────→ complete admitted registration/state
ACTIVATE ──────────────────→ execute granted behavior

Host publishes no partial mirror before all declarations, hashes, references, targets, and snapshot values pass. Do not start activation-owned behavior during construction/registration. Zero states still require an empty snapshot.

Features ​

FeatureBitEnables
BinaryPayloads1Binary Command/Query/Event
Streams2Stream registration/messages
Health4Ping/Pong
Unregistration8Explicit unregister exchange
Nxml16Shared NXML schema 3
AutomaticFunctions32Build catalog and NFP3
Pages64Standalone/onboarding pages; also requires Nxml

WELCOME confirms the intersection; missing fields mean None. Bits are independent: Streams do not additionally require BinaryPayloads; typed State also works independently. Toggle needs BinaryPayloads for its Boolean Command.

Every registration kind ​

KindValueMeaning
Command/Query1/2Effect/one-off result
State/Event3/4Current fact/occurrence
UiModule/Resource5/6Hashed finite document/content
UiPatch7Finite caption
EventCatch/EventListen8/9Granted event match/observe
IntentCatch/IntentWait10/11Granted intent catch/one-shot wait
FunctionPatch12Finite program at explicit target
Stream13Credit-controlled output

RegisterItem TLVs: 1 Kind(U32), 2 SemanticId(Str), 3 Flags(U32), 4 CodecId(U32), 5 Payload(Bytes), 6 ContentHash(Bytes), 7 RequiredResources(Str), 8 TargetSemanticId(Str), 9 ResultCodecId(U32). Optional fields depend on kind; omitted result codec means zero.

Command/Query declare argument/result codecs; State/Event declare values; Stream declares open-argument/chunk codecs. Extension bytes/hash/target must match Host admission.

Per-kind numeric IDs ​

For Command set, State text, Query echo, State enabled in that order: Command set=1, Query echo=1, State text=1, State enabled=2. Tables are per kind/session, not one global ordinal or semantic hash. Reconnect registers/snapshots/resolves again. Reactivation within the same registration is distinct from a new session.

Complete 32-byte frame header ​

OffsetSizeField
04Magic 0x53584350, little-endian bytes 50 43 58 53
42Header version 1
62Protocol version 1
82Message type
102Traits
1216Assigned correlation GUID, library Guid byte convention
284Payload length, ≤16 MiB

Use SidecarFrameCodec; cross-language implementations must compare bytes with library fixtures instead of inserting UUID text/different ordering. For GUID 00112233-4455-6677-8899-aabbccddeeff, bytes are 33 22 11 00 55 44 77 66 88 99 aa bb cc dd ee ff; --recipes checks the fixed example. Every frame, including controls, needs an assigned correlation. Validate headers before allocation.

Compressed/Final are known traits; current Transport does not automatically compress/decompress. Unknown message/version/undefined bits reject. Unknown TLV skipping is not permission to execute unknown frames.

TLV and message numbers ​

Each field has u16 ID, u8 tag, u16 length, then bytes. IDs are ascending/unique; unknown fields skip by length while required fields/types remain checked. A single string/Bytes/value is ≤65535 bytes, regardless of the larger frame limit. Field tags are Boolean1/U32-2/U64-3/I64-4/F64-5/Str6/Bytes7/Id128-8; these are distinct from value codecs0–6. Wrong tags on known fields reject.

MessageValue
Hello/Welcome1/2
RegisterBegin/Item/End8/9/10
Ready/Activate/Deactivate11/12/13
StateSnapshotBegin/Item/End14/15/18
HealthPing/HealthPong16/17
Cancel19
Unregister/Unregistered20/21
Crash/Error/Shutdown24/25/30
CommandRequest/Result64/65
QueryRequest/Result66/67
StateDelta/Event/HookSignal72/73/74
StreamChunk/Open/End/Credit80/81/82/83

JSON is for configuration/diagnostics, not production data-plane object exchange. No CLR objects, reflection names, or fixed memory-struct ABI.

Budgets ​

ItemDefault/bound
Discovery/native image/signature64/512 MiB/64 KiB
Supervisor candidate bootstrap/admission30s
Session handshake/registration/shutdown10s/30s/2s
Registrations/semantic ID/aggregate4096/256 characters/32 MiB
SnapshotSeparate 32 MiB, exact State coverage
Pending writes64
Pending Command/QueryDefault 1024
Command/Query timeoutDefault 30s; positive explicit values within .NET timer bounds
Stream/Health timeout30s/5s, maximum 5 minutes
Streams16/session, 16 queued chunks/stream, 4 MiB total
Health32 pending plus shared admission
Best-effort CANCEL/creditSeparate 100ms

Host may lower budgets; the peer cannot raise them. Deadlines cover send plus response, not just response wait.

Teardown and failure ​

Withdraw local grants before ordered DEACTIVATE; exchange UNREGISTER/UNREGISTERED if negotiated, then SHUTDOWN and await exit. Synchronous Dispose is not proof of joined async teardown; await ShutdownAsync/DisposeAsync when required.

Cancellation before IO admission preserves an unused connection. Interrupted frame IO can leave partial bytes and closes the transport rather than reusing it. Crash is terminal; structured Error may end only its correlated exchange. Every terminal path completes pending work, and late results cannot resurrect closed sessions.

Implementation references ​

Current registration chunking and pressure deactivation ​

The registration codec splits large module payloads into 60 KiB chunks: field 5 first, then consecutive IDs starting at 1024. The per-TLV 65535-byte bound remains; it is not the entire NXML bundle limit. Hash the fully reassembled payload.

Critical memory pressure may cooperatively DEACTIVATE a session, retiring activation leases, UI and exchanges while preserving registration. Recovery uses ACTIVATE in the same session; retain its numeric mapping. Manually stopped packages are not restarted. See NXML pages and NFP3.

Check your result ​

Exercise invalid invocation, failed authentication, deactivation/reactivation and shutdown with outstanding work. Check that stale correlations cannot complete a new session’s request.

Site documentation: CC BY-SA 4.0. Imported SDK documents: Apache-2.0 as marked.