Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Data stores and schemas

Source: https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-store/src/event_types.rs, https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-events/src/event_store/mod.rs, https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-store/src/tags.rs, https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-sync/src/fileops.rs, https://github.com/developing-today/code/blob/main/pkgs/id/test-vectors/schema.json

This chapter is the inventory of named, versioned formats a reader, operator or implementer will meet on disk or on the wire: about 35 of them. Paths are relative to the data directory unless stated; the data directory itself is covered in Configuration and environment.

The blob and name store (id-store)

ItemValue
Implementationiroh-blobs FsStore: a redb database plus data files.
Path.iroh-store/; the iroh-docs store lives under .iroh-store/docs/.
Open ruleSingle-opener: the redb file lock admits one process.
Ephemeral formAn in-memory variant backs id serve --ephemeral and the other --ephemeral paths.
Node keyThe .iroh-key file family sits alongside the store, in the data directory.

A “file” in ID is a name (an iroh-blobs tag) pointing at an immutable blob hash, plus TagStore metadata. That model is implemented once, in FileOps (below), and shared by the CLI, the REPL, the meta protocol and the web layer.

The tag store and registry

ItemValue
Backingiroh-docs α/Ω namespace pairs: a global namespace, a node-private namespace, and custom paired or single namespaces.
Registry file.iroh-meta/registry.json
Registry versionREGISTRY_VERSION = 1 (crates/id-store/src/tags.rs). The file records the namespaces and one-time migration completion.
ValuesArbitrary bytes. Display and wire forms use lossy UTF-8, plus value_b64 where binary fidelity is required; see WebSocket protocols.

Other named hash domains in id-store: id.name-candidate/v1, id.name-curation/v1, id.location-tombstone/v1, and id.local-claim.v1 (the tag-claims hash domain).

The graph index

ItemValue
Backingredb.
Tablesgraph_spo, graph_pos, graph_osp, graph_index_meta.
Sort profileaddress-asc/v1.

Sidecar snapshots

ItemValue
Head filehash.metadata.
Snapshot fileshash.metadata.<hex digest of content id>.
Record formatCBOR records with RECORD_VERSION = 1.
Head domainid.sidecar-head/v1.

The event store (id-events)

ItemValue
Fileevents.redb, in the event-store directory (CLI --event-store, default events in the data directory). The temporary write name is events.redb.tmp.
Format markerid.events.store.v9, stored in the meta table. id.events.store.v8 is also accepted: a v8 store is a v9 store with no bodies table and nothing else different.
Key encodingBig-endian, so one author’s events sort in sequence order.
Chain rowsA fixed 41-byte encoding: next sequence (big-endian u64) ‖ head hash (32 bytes) ‖ frozen flag (0/1).

Tables: 17

events            hashes            chains            forks
groups (multimap) proof_ids         proof_headers     waiting
waiting_by_dep (multimap)           meta              blocks
writer_set_bodies actions           device_ops        applied
bodies            tag_fold

The blocks table holds the operator block list. It is data, not configuration: no server-config key writes it (see Configuration and environment).

The event wire format

Every event is a p2panda-core Header<ChainExt> in canonical CBOR (crates/id-store/src/chain.rs):

FieldRule
Domain tagid.events.v1
Operation IDBLAKE3 over the received bytes.
Signaturesverify_strict.
ChainExt{kind, group, after}.
afterAt most 32 hashes (MAX_AFTER).
kind1–64 bytes, NFC-normalised.

Ingest outcomes are accepted, duplicate, fork, waiting and refused — the same five outcomes the hosted bridge returns in The hosted Worker API.

Event-kind constants

About 25 kind values are named as constants across id-store, id-events and id-core:

chat.message.v1        chat.anchor.v1         document.put
document.remove        media.put              media.remove
note.create            note.revise            note.link
tag.set                tag.clear              session.checkpoint
identity               issuer.rotation        device.add
device.revoke          attestation.genesis    attestation.claim
attestation.witness_decision                 attestation.objection
idset.writer           idset.rescind          chained.message

In addition, the group operation kinds are carried by id_events::groups — group create, member and role operations, validated in the event store’s resolve and ingest paths. The group commands that produce them are in Groups, documents, claims and keys.

The directory journal (id-directory)

ItemValue
Filedirectory.jsonl, in the server-config directory.
FormatOne JSON DirectoryEntry per line. Serde-tagged on the field entry, snake_case. Replayed through the same apply path as live changes, so replay and live writes cannot diverge in effect.
Secrets ruleAccount secrets enter only as SHA-256 digests. The account key domain is id-account-v1.

DirectoryEntry kinds: 17

account_signed_up       account_keyed           account_verified
account_key_added       account_key_removed     account_email_confirmed
account_email_removed   group_created           group_updated
group_visibility        group_deleted           member_set
tier_set                friend_requested        friend_accepted
friend_removed          friend_removal_noted

Supporting enums in the same records: Member, tagged on kind, with variants account and group; Level with variants access, read, write, manage, moderator, admin; Tier with variants anonymous, registered, verified.

Keyset files

FileContent
.id-keyset.jsonlJSONL key records for the server identity.
.id-keyset-client.jsonlJSONL key records for the client identity.

Signed artifacts

Envelope wire types live in id-sync::artifact and are re-exported by id-directory.

ItemValue
Kinds: 4friend_remove, home_declared, document, tag. Their wire-name constants are FRIEND_REMOVE, HOME_DECLARED, DOCUMENT, TAG.
Signed-bytes profileid-artifact-serde-json/v1 (the LEGACY_PROFILE constant).
Signed bodySignedBody{author, seq, prev, kind, body, after} serialised as compact serde_json. The after field is omitted when empty.
HashSHA-256, hex.
SignatureEd25519, hex.

The profile is pinned by a conformance vector file; see “Test vectors” below.

Listing, suspension and delisting records

No listing, suspension or delisting record kind exists in crates/id-directory. That family lives in three other places:

LocationFormat
crates/id-sync/src/registry.rsSigned registry lists: a canonical-CBOR body with a registry-key Ed25519 signature. Entries are RegistryEntry{announcement, included_at, registry_seq}, where announcement is verbatim and world-key-signed. Delistings are Tombstone{world_id, removed_at, reason, registry_seq}; reason is at most 200 characters. The policy statement is at most 2000 characters. Unlisted worlds are refused at inclusion and skipped on import.
crates/id-caps/src/declaration.rsProvider declaration lifecycle: Filed → Admitted → Live → Suspended / Superseded / Stale → Tombstoned. Suspension is registry state; the provider’s contents are unchanged. Signing domains: id.provider-manifest.v1, id.provider-withdrawal.v1, id.host-attested-provider:.
crates/id-worlds/src/program_gallery_admission.rsGallery listing decisions and transparency entries (removal, refusal, reinstatement) behind the routes in The web UI: pages and HTTP API.
crates/id-sync/src/federation/slices/b02_key_revocation.rsKey suspension records: operator maintenance suspension, bounded or indefinite.

FileOps and the archive naming rule

FileOps (crates/id-sync/src/fileops.rs) is the single put/rename/copy/delete implementation for the CLI, the REPL, the meta protocol and the web UI.

Archive naming

When a rename or replace archives the old file, the archive name is:

{name}.archive.{unix-ts}
  • On a same-second collision, the suffix is bumped — {ts+1}, then {ts+2}, and so on — until the name is free. The claim happens under an in-process lock.
  • The shape {stem}.archive.{digits}, where the digits fit a u64, is a reserved namespace at the writer: such names are refused as user files, with the error ReservedArchiveName. Non-numeric lookalikes such as a.archive.notes stay valid user names.

Archive and identity metadata keys

KeyPlaced onMeaning
archive.rename—Records a rename archive relationship.
archive.replaceThe live nameNames the archives the live name owns.
archive.ownerThe archiveNames the archive’s owner.
name, file, pathThe fileIdentity keys, refreshed on rename and copy.
originThe fileStamped at first write.

Archives are dropped only with their owner. There is no per-archive delete.

Delete semantics

FileOps::delete is a hard delete of the name, its metadata and its archives. The blob bytes survive until garbage collection. The web layer’s soft-delete/restore pair (/api/delete, /api/restore) is built on top of FileOps and is not FileOps behaviour.

Other id-sync formats

FormatValue
Envelope ALPN/id-envelope/1
Record-store envelope domainid-sync/record-store-envelope/v1
Bridge authentication domainid.bridge-auth.v1 (the hosted bridge in The hosted Worker API)
Federation record storefederation/record_store.rs, with RecordStatus, and slices B01–B09, B15–B24, B28, B31, B32 covering key lifecycle and revocation, the replay guard, signature suites, signer binding, rejection events, conflict reports, sync scope, anti-entropy, peer priority, fanout budget, query grants and privacy, signed receipts, request identity, result dedup, loop inform, routing state, topology probe, takeover response, peer classes, and the ingest gate.

The tag registry

Covered above with the tag store: .iroh-meta/registry.json, format registry.json v1 (REGISTRY_VERSION = 1), recording namespaces and one-time migration completion.

Hosted Durable Object SQLite schema

The hosted Worker’s UserDO (see The hosted Worker API) uses SQLite with SCHEMA_VERSION = 3:

TablesGroup
meta, kv, blobsCore object state: metadata, per-user KV, blob references.
bridge_events, bridge_chains, bridge_forks, bridge_proof_ids, bridge_proof_headers, bridge_waiting, bridge_waiting_by_dep, bridge_metaThe bridge store: the signed-object sync peer state, mirroring the native event store’s table roles.

Two related proof-of-concept schemas, neither a production format:

SchemaValue
worker-poc WorldObject journalAn unversioned SQLite journal table; the source of truth for that PoC.
d1-journal-poc journal headerVersion 1; entries include created and caps_granted. A D1 bookmark is not a stream cursor.

Program bundles and world formats

FormatMagic / version
Program bundle (.idpb files)Magic line developing-today/id-program-bundle/v1 followed by \n.
World snapshotMagic IDWS.
World replication frameMagic id-world-replication/v1 followed by \n.
World module signature domaindeveloping-today/id-world-module/v1 followed by a NUL byte.
Program-registry ALPN/id-program-registry/1.

Keys, invites and presence

FormatMagic / version
Key envelope (also the backup envelope)Magic IDKEY.
InviteMagic IDINV, version 2.
Presence frameMagic id-presence/v1 followed by \n.
Peer announcement frameMagic id-peer-announcement/v2 followed by \n.

Remaining named domains and versions

FormatValue
Match-audit formatVersion 0; domains id.match-audit.v0/header, id.match-audit.v0/entry, id.match-audit.v0/footer.
Boundary evidence domainid.boundary.evidence.v1.
Boundary declaration hash domainid.boundary.declaration.v1.
Currency receipt domainid.currency.receipt.v1.
Array address format (id-core)FORMAT_VERSION 0x01.
Typed value format (id-core)FORMAT_VERSION 0x02.
Config schemaid-config version 1, plus the negotiation transcript domain id-config/negotiation-transcript/v1; see Configuration and environment.

Test vectors

pkgs/id/test-vectors/ contains exactly 3 files. They are conformance fixtures, not stores.

FileSchema / content
schema.jsonA JSON Schema (draft 2020-12) titled “ID/Atlas shared conformance test vectors”, with schema_version const 1. port_kind is one of record_store, blob_store, event_log, world_store, object_bucket, message_stream, request_transport. Operations are negotiate, append, read, ack. Negotiation outcomes are granted, unsupported_capability, version_mismatch.
atlas-content-hash-v1.json"schema": "atlas-content-hash-compatibility-v1". It records the Atlas chunks.content_hash field as producer_unavailable with empty vectors, and states the interop claim verbatim: “forbidden: do not equate Atlas chunks.content_hash with any ID ContentId profile”.
legacy-artifact-signatures.json"schema": "id-atlas-signed-artifact-profiles/v1". It pins the legacy id-artifact-serde-json signed-bytes definition, the SHA-256 hash rule and the Ed25519 signature rule, using a test-only Ed25519 key (seed = 32 × 0x07). The file itself warns that this key is never a production key.

Worked example

Toy data: a node stores one file, renames it twice in the same second, and an operator reads the resulting on-disk state.

> put report.txt report
> rename report report-v2
> rename report-v2 report-final

What exists afterwards:

PlaceEntry
.iroh-store/One blob (the toy bytes), referenced by the live name report-final; the redb name index holds the archive names below.
Tag storereport-final carries the identity keys name, file, path and the first-write origin key, plus archive.replace naming its archives.
Archive namesreport.archive.1700000000 and report-v2.archive.1700000000, each carrying archive.owner. Because both renames landed in the same second, the second archive’s suffix was bumped until free if the first claim collided.
Name refusalA later attempt to store a user file literally named report.archive.1700000000 is refused with ReservedArchiveName; report.archive.notes would be accepted.
events.redbThe meta table reads id.events.store.v9; the rename operations appear as events whose headers are canonical CBOR under the domain tag id.events.v1.
directory.jsonlUnchanged by file operations: it records account, group, member, tier and friend entries only — 17 kinds, none of them a file kind.