How it works
Each event’s hash is computed as:- Canonical JSON — keys sorted alphabetically, deterministic serialization
- Content fields — all event data that matters for integrity
- prev_hash — the hash of the previous event in the chain
Content fields (included in hash)
These fields are included in the hash computation:id, schema_version, agent_id, session_id, source, action_type, action_name, action_input, action_output, action_status, error_message, timestamp, duration_ms, labels, metadata, capture_method
Excluded from hash
These fields are not included in the hash:sequence— server-assigned orderinghash— the computed value itselfprev_hash— linked separatelyvalidation_warnings— quality metadata added by the pipeline
Genesis hash
The first event in each chain uses a well-known zero hash as itsprev_hash:
Per-agent chains
Eachagent_id maintains an independent hash chain. This design avoids a single-threaded write bottleneck — agents don’t block each other when writing events.
Server-authoritative sequencing
The SDK sends events with client-side timestamps. The server assigns:sequence— monotonically increasing within each agent’s chainhash/prev_hash— computed server-side to maintain chain integrity
Verification
Verification walks the chain from the genesis event and recomputes each hash:Timing-safe comparison
Hash comparisons usecrypto/subtle.ConstantTimeCompare (Go) to prevent timing side-channel attacks.