The IR contract for Continuum. The canonical machine-readable schema lives at
schema/cir.fbs; this document describes the runtime
wire format that Graph::serialize() emits.
Graph::serialize() emits a compact binary envelope.
u32 magic = 0x31495243 // "CIR1"
u16 version = 1
u64 node_count
repeat node_count times:
u64 node_id
u8 node_kind
string debug_name // u64 len + bytes
u64 input_count
u64[input_count] inputs
Type out_type // tagged union
u8 effect_bits
Payload payload // tagged union
Tagged unions are encoded as:
Type:u8 idxthen variant payload0TensorType:u64 ndim,i64[ndim] shape,u8 dtype,u8 device1TokensType:string vocab_id,i32 max_len,string model_family2SchemaType:string canonical_json,u64 schema_hash3EffectType:u8 bits
Payload:u8 idxthen variant payload0TensorOpPayload:string op_name,u64 n_attrs,i64[n_attrs] attrs1TokenOpPayload:string op_name,string model_id,f32 temperature,i32 max_tokens2PromptOpPayload:string template_id,u64 n_slots,u64[n_slots] slot_inputs3ToolOpPayload:string tool_name,string input_schema_json,string output_schema_json4ControlOpPayload:u8 kind,u64 n_branches,u64[n_branches] branch_entries
- Node kinds: TensorOp, TokenOp, PromptOp, ToolOp, ControlOp
- Type lattice: TensorType, TokensType, SchemaType, EffectType
- Effects: Pure, Idem, Net, Mut, Stoch bitset
Conformance is enforced by C++ tests:
- serialize -> deserialize -> semantic equality checks
- binary layout parser checks for envelope/tag correctness
- Golden CIR corpus under
tests/data/cir/: one.cirfile perNodeKind(and representative type/payload variants).CirCorpusTest.GoldenFilesRoundtripByteIdenticaldeserializes each file and re-serializes to a byte-identical result. CI fails on drift unless you regenerate the corpus (./build-tests/tests/cpp/gen_cir_corpus) and document the migration when bumping the CIR version.