The Cortex Crystal format.
An open specification for content-sealed, fingerprinted snapshots of an agent's cognitive state — precise enough that anyone can implement a compatible sealer or an independent verifier, with no dependency on the Agent Longevity Institute.
Envelope v1
Every crystal (other than a grandfathered session v0, below) is wrapped in a three-field envelope:
{ "kind": <string>, "schema_version": <integer>, "canonical_payload": <JSON value> }- kind — one of:
session,being,skill,legal_matter,composite,history - schema_version — an integer, versioning the shape of
canonical_payloadfor thatkind. - canonical_payload — the actual sealed content (identity, config, memory references, transcript, etc. — whatever that
kindcaptures).
A stored crystal typically carries the resulting content_hash alongside the envelope (and, for auditability, the exact canonical bytes that were hashed, e.g. as sealed_payload), so a verifier never has to guess what was hashed.
Canonical JSON rules
Before hashing, canonical_payload is serialized deterministically so that the same logical content always produces the same bytes (JCS-compatible in practice):
- UTF-8 encoding throughout.
- Object keys sorted lexicographically at every level (recursively — nested objects too).
- No insignificant whitespace: no spaces after `:` or `,`, no line breaks, no trailing newline.
- The result is deterministic — the same logical payload always serializes to the exact same bytes, regardless of the order fields were set in.
Algorithms & tags
sha256 — off-chain content hash
content_hash = sha256(canonical_json(payload)). Stored and transmitted as a raw 64-hex string, 0x-prefixed in transport. This is the fingerprint anyone recomputes to verify a crystal — including this page's own verifier.
keccak256 — on-chain anchor
Anything written to a public ledger's fixed-size storage slot (a manifest root, or a Merkle root for inclusion proofs) is hashed with keccak256, so the anchor is directly verifiable on-chain without any off-chain trust.
Every stored hash carries an explicit algorithm tag (tag_sha256 / tag_keccak256). An untagged hash is read as sha256, for backward compatibility with earlier crystals minted before tagging existed.
The session-v0 grandfather clause
Session crystals captured before this spec existed hash a raw transcript string, not a canonical-JSON envelope. They remain fully verifiable as-is — no re-sealing or migration is required, or ever will be, for a crystal that was validly sealed under its own contract at capture time.
| schema_version | kind | payload hashed | status |
|---|---|---|---|
| 0 | session | Raw transcript string (verbatim, not canonical JSON) | Grandfathered — no migration required |
| 1+ | session | canonical_json(payload) | New captures move here when the capture path is next touched |
| 1 | being / skill / legal_matter / composite / history | canonical_json(payload) | Used from day one |
Verification rule: a verifier resolves (kind, schema_version) to the matching payload-derivation function above, recomputes the hash with the tagged algorithm, and byte-compares. Anything else — regex claim-diffs, prefix checks — is heuristic, not verification.
Worked example
A small being-crystal payload, canonicalized and hashed step by step. Paste the final envelope into the free verifier to confirm it yourself.
1. Source payload (any key order)
{
"kind": "being",
"registration_id": "agent_7f3a",
"system_prompt": "You are a helpful research assistant.",
"config": {
"tools": ["search", "memory"],
"model": "primary"
}
}2. Canonical JSON (sorted keys, no whitespace)
{"config":{"model":"primary","tools":["search","memory"]},"kind":"being","registration_id":"agent_7f3a","system_prompt":"You are a helpful research assistant."}3. sha256 content hash
6a7ae76ec4ae32adf42428ebaaa63bdd99d2fa2bc44d298b0a56f9caef7d6af74. The sealed envelope
{
"kind": "being",
"schema_version": 1,
"canonical_payload": {
"kind": "being",
"registration_id": "agent_7f3a",
"system_prompt": "You are a helpful research assistant.",
"config": {
"tools": ["search", "memory"],
"model": "primary"
}
},
"content_hash": "0x6a7ae76ec4ae32adf42428ebaaa63bdd99d2fa2bc44d298b0a56f9caef7d6af7"
}Optional extension: signed state jump
Full-history verification means replaying every crystal from genesis to confirm each one's hash chains cleanly into the next. That is thorough but O(n) in the number of crystals — expensive for a long-lived agent doing a cold-start resync. The optional signed state jump extension lets an operator's hardware-backed signing key attest, in one signature, that a specific sealed manifest is the current, correct state — permitting single-signature restore verification without replaying the full history (O(1) resync). This mirrors transparency-log / signed-checkpoint patterns used elsewhere for tamper-evident append-only logs.
This is an optional spec extension, not a requirement of v1 — a crystal is fully valid and verifiable under the base contract with no state-jump signature present.