CDT trace format (rewrite)¶
CDT is the debug trace container used by crimson dbg record|diff|bisect|focus|tick|entity|query.
It is rewrite tooling format, not an original Crimsonland asset/container format.
This spec describes the current on-disk contract implemented by src/crimson/dbg/schema.py
and src/crimson/dbg/trace.py.
Versioning¶
trace_format_version: container/envelope version (1currently)trace_schema_version: channel payload schema version (7currently)- container and schema versions are independent
File layout¶
TRACE_MAGICbytes:b"crimson_debug_trace_v1\n"<u32le trace_format_version>- one
METAchunk - zero or more
TICKchunks - one
FOTRchunk - trailer
<8-byte magic, u64le footer_offset>
Trailer magic is b"CDTFTR1\n".
Chunk envelope¶
Each chunk has a fixed header followed by a compressed payload:
- Header struct:
<4siiIIIQ> - Fields in order:
kind(META,TICK,FOTR)start_tick(i32)end_tick(i32)flags(u32)compressed_len(u32)uncompressed_len(u32)checksum64(u64, blake2b-64 of uncompressed bytes)
Payload encoding:
flags & CHUNK_FLAG_ZSTDmust be set (zstd compressed payload)flags & CHUNK_FLAG_MSGPACKmust be set (msgpack encoded payload)
Msgpack payload types¶
METApayload:TraceMetaTICKpayload:TickBlockFOTRpayload:TraceFooter
TickBlock contains ordered TickRecord rows:
tick_indexelapsed_msdt_ms_i32mode_idphase_markerschannels(ReplayTickChannels)
Tick rows are required to be non-decreasing by tick_index.
Channel contract (schema v7)¶
Required channels in both compared traces:
checkpointsim_stateentity_samplesrng_streamtiming_samples
Canonical typed payloads are defined in src/crimson/replay/checkpoints.py
and src/crimson/dbg/canonical_channels.py:
checkpoint->ReplayCheckpointsim_state->SimStateSnapshotentity_samples->EntitySamplesSnapshotrng_stream->list[RngStreamRow]timing_samples->list[TimingSampleRow]
phase_markers remain list[str] in the durable trace contract.
Raw Frida capture may hold richer structured phase-marker payloads, but finalize flattens them to names in the trace row.
Diff contract¶
dbg diff compares traces by tick and returns the first divergent tick.
For that tick, it reports all channel mismatches in deterministic order:
checkpointrng_streamsim_stateentity_samplestiming_samples
Mismatch payload format:
- top-level
mismatch.kind = "tick_mismatch" - top-level
mismatch.detail.mismatch_count - top-level
mismatch.detail.mismatches[] - each row has
kind,channel, anddetail
This enables correlating divergence across channels at the same tick instead of failing after the first channel-level mismatch.