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

The data crates

Source: primary sources are the lib.rs and Cargo.toml files of pkgs/id/crates/id-core/, pkgs/id/crates/id-store/, pkgs/id/crates/id-events/, pkgs/id/crates/id-sync/, pkgs/id/crates/id-directory/, and pkgs/id/crates/id-groups/. This chapter is complete without following those links; they record provenance only.

Six crates hold the data layer under the world runtime: id-core (foundation leaves), id-store (blobs, chains, documents, tags, search), id-events (the event store and the group projection), id-sync (log sync, the meta protocol, envelopes, artifacts), id-directory (the home-server directory), and id-groups (group policy and enforcement). All six are reachable through the facade at id:: paths (see The id facade crate and the map in The crates). The on-disk formats these crates own are inventoried in Data stores and schemas.

id-core — 58 public modules

Purpose (from its Cargo.toml): “Foundation leaf modules of the id crate (Phase 1 of the pkgs/id crate split, #3447)”. Its lib.rs states the layering rule directly: the modules here are the crate’s leaves — everything in the binary crate depends on them, and they depended on almost nothing in it. At 79 .rs files it is the largest leaf crate by file count after id-worlds and id-cli.

Public modules: abuse, access, admission_gate, append_list, append_list_client, array_address, array_order, array_shorthand, block_list, boundary, boundary_surfaces, canonical_cbor, connectivity, content_id, discovery, durable_write, frames, graph (with submodules append_list, attribute, cross_signing, cursor, delegation, deletion, query, record, space_binding, term, version), hash_profile, hex, holders, id_namespace, id_shape, id_uri, id_uri_format, id_uri_parse, intranet, ip_evidence, iroh_hash, json_unique, key_envelope, location_ref, membership (with submodules body, frontier, gate, layer), namespace_definition, numeric_order, numeric_value, port, rejection, residency, residency_inventory, sanctions, sanctions_store, seed_phrase, signed_envelope, swarm, sync_method, text, time, transport_advertisement, triples, tuple, typed_value, and waiting. Feature-gated modules: petname, screen_codec, and world_presentation under world; qr under web; test_forgeries under any of test or the test-utils feature. The crate root also re-exports pub use unicode::is_format_char.

Key types, functions, and constants: KEY_FILE = ".iroh-key", CLIENT_KEY_FILE = ".iroh-key-client", SERVE_LOCK = ".iroh-serve.lock"; is_node_id (a 64-hex check); discovery (PeerDiscovery, PeerInfo, PeerAnnouncement, Defaults, resolve_config, defaults_provenance, MAX_PEERS — the facade re-exports 17 items from this module alone); port (the 9110 port contract vocabulary, re-exported onward by id-store, id-events, and id-worlds); tuple (sort-preserving encoding); canonical_cbor; frames (MAX_FRAME_BYTES); membership; holders; waiting; signed_envelope; key_envelope; seed_phrase; and the graph record model.

One disagreement concerns this crate’s re-export list. ARCHITECTURE.md lists the root’s id-core re-exports as 12 modules — abuse, access, connectivity, discovery, frames, holders, membership, rejection, residency, sync_method, tuple, waiting — plus constants and is_node_id. The code in pkgs/id/src/lib.rs also re-exports admission_gate unconditionally, petname and world_presentation under world, and qr under web (disagreement LIB-6). The full facade list is in The id facade crate.

Features: default = ["world", "sandbox"]; world adds rmp-serde and gates petname, screen_codec, and world_presentation; sandbox = []; web adds qrcode and gates qr; test-utils = []; test-provider = [] (test-only, for the #1061 exit proof). Dependents: all ten production consumers — the facade, id-caps, id-cli, id-directory, id-events, id-groups, id-store, id-sync, id-web, and id-worlds.

Embedding example: the facade binary calls this crate by its direct path at pkgs/id/src/main.rs:195 — let provenance = id_core::discovery::defaults_provenance(); — and the integration suite reaches the same modules through facade paths, for example id::waiting::WaitingLimits in pkgs/id/tests/first_app_poc.rs.

id-store — 26 public modules

Purpose (from its Cargo.toml): “Store layer of the id crate: store traits, blob store, event headers, documents, tags and search (pkgs/id crate split step 2a, #4405)”. Its lib.rs records two vocabularies it owns for layering reasons: the event store’s own types (event_types, range) sit below the event-store implementation in id-events, and the op vocabularies the signed header embeds (chat, notes, note_links, session_checkpoint, issuer_rotation, policy) live with chain::ChainExt, which carries them as fields.

Public modules: admission, chain, chat, chat_anchor, content_store, documents, event_types, graph_index, identity, issuer_rotation, media, namespace_registry, note_blocks, note_checkpoints, note_links, notes, numeric_registry, policy, range, search, session_checkpoint, store, store_traits, tag_claims, tag_index, and tags; plus pub use id_core::{port, content_id} and pub use store::STORE_PATH.

Key types and functions: store::StoreType (Persistent(FsStore) or Ephemeral(MemStore)), open_store, and load_or_create_keypair, with STORE_PATH = ".iroh-store"; chain::{ChainExt, Event, sign} — the signed event-header chain; store_traits, including EventStoreBackend, the consumer seam consumed via SharedEventStore; the admission hooks PrepareHook, OutboxHook, Reauthorizer, OperationLedger, MemoryOperationLedger, PrepareDecision, and OpState; the tag model in tags, tag_index, and tag_claims; documents::{DocumentRef, DOCUMENT_KIND}; and search, media, and the notes family.

Features: default = [] only. Dependents: the facade, id-cli, id-events, id-groups, id-sync, id-web, and id-worlds. This crate also dev-depends on the facade: its store_traits tests run against the real EventStore, and a comment in crates/id-store/Cargo.toml states that production code in id-store never names the facade.

Embedding example: the facade lib.rs quick-start is this crate’s surface reached through id:: paths — open_store(false).await?, store.as_store().blobs().add_bytes(…), store.as_store().tags().set(…). The tag commands in Tutorial: organise a library with tags and claims write into this crate’s tag store.

id-events — 12 public modules

Purpose (from its Cargo.toml): “Events layer of the id crate: event store, group projection, writer sets and sync gating (pkgs/id crate split step 2b, #4405)”.

Public modules: attestation (with attestation/v1), event_store (with submodules anchors, author_events, chat, claims, documents, ingest, range, resolve, sync, validity, waiting_rows, writer_set), event_sync, graph_admission, groups (with submodules delegation, event, fold, friendship, policy, wire), idset (with submodules expand, project, view), local_claims, local_events, pull_policy, residency_routes, residency_sync, and world_access; plus pub use id_core::port.

Key types and functions: EventStore (behind the Storage / FileStorage file seam) and Ingest; the attestation family — GenesisAgreement, ResultClaim, MatchState, sign_genesis, sign_claim, compute_state, SignError, and in v1 WitnessDecision, Objection, sign_witness_decision; the group model with the deterministic groups::fold projection — GroupView, Projection, Refusal, FoldError, DeviceGrant, friendship_id; writer sets — idset::{WriterSet, Entry, Excludes} and idset::view::expand_set; WorldAccess; and LocalEvents, surfaced to command code through the id-cli bridge module local_events.

Features: default = [] only. Dependents: the facade, id-cli, id-directory, id-groups, id-sync, id-web, and id-worlds.

Embedding example: pkgs/id/tests/first_app_poc.rs:33-45 imports event_store::{EventStore, Ingest} and the idset projection through facade paths in the same import block as the id-store modules, and the worked example in pkgs/id/examples/first-app-poc/README.md records that the PoC’s counted did-it view is an id-events / id-store composition, not new protocol code.

id-sync — 21 public modules

Purpose (from its Cargo.toml): “Sync layer of the id crate: log sync, the meta protocol, file operations and the meta client wire half (pkgs/id crate split step 3, #4406)”. Step 3c added the friend-envelope and artifact family (envelope, envelope_net, envelope_outbox, artifact), seamed to worlds and the directory through host::SessionHost and artifact::ArtifactSink.

Public modules: announcement, artifact, bridge, bridge_http, chained_message, dht, envelope, envelope_net, envelope_outbox, fanout_answer, federation (the module plus record_join, record_store, exchange_net, and slices b01 to b32), fileops, graph_frontier, host, log_sync, meta_client, protocol, registry, relay_gate, relay_ingest, and transfer. One further module, hex, is pub(crate).

Key types and functions: protocol::META_ALPN = b"/iroh-meta/3" and the MetaRequest / MetaResponse wire types; log_sync (p2panda log-sync sessions and the range-sync bridge; SyncProtocol); transfer (server-to-server file transfer, #5345, re-exported by the facade at id::transfer and exercised by Tutorial: store, share and fetch a file between two nodes); artifact (signed artifacts, push and pull); envelope_outbox::Outbox (an append-only journal, replayed on open); announcement::{Announcement, SignedAnnouncement} (sign and verify); dht (the opt-in mainline lookup policy); and the federation family (the #9106 federation exchange).

One naming trap is documented in the survey and worth repeating: this crate’s protocol module is the wire half of the meta protocol. The facade-facing MetaProtocol, FindMatch, and TaggedMatch surface lives in id-cli’s protocol module, not here. A second disagreement sits in this crate’s own lib.rs, which states that the MetaClient enum composition stays in the facade until step 7. Step 7b (#4411) has landed: pub enum MetaClient is defined at crates/id-cli/src/meta_client.rs:31, and the facade only re-exports the meta_client module from id-cli (disagreement LIB-10). The code behaviour is that MetaClient — the enum that chooses between a running server and the in-process local node — lives in id-cli.

Features: default = []; dht = ["dep:iroh-mainline-address-lookup"], off by default, with the facade forwarding its own dht feature here; test-utils = []. Dependents: the facade, id-cli, id-directory, id-web, and id-worlds.

Embedding example: id-cli’s serve code wires this crate’s surfaces into the running node, and the facade re-exports transfer at id::transfer; the id send command in Tutorial: store, share and fetch a file between two nodes is the user-visible end of that module.

id-directory — 15 public modules

Purpose (from its Cargo.toml): “Directory layer of the id crate: home-server directory, views, auth, mail, invites and seitan admission (pkgs/id crate split step 6b, #4409)”. It depends downward on id-core, id-caps, id-events, and id-sync, and never on id-worlds; the dependency runs the other way because WorldCore holds a directory::Directory as persisted state. The directory cluster used to live in id-worlds, which now re-exports these modules from this crate (disagreement LIB-8, covered in Worlds and capabilities as a library).

Public modules: directory (with directory/replica and directory/validate), directory_auth, directory_log, directory_mail, directory_view, invite, invites (with event and invitation), keyset, keyset_file, recovery, recovery_flow, recovery_relay, recovery_view, restored_key, and seitan (with accept, admit, derive, freshness, and token).

Key types and functions: Directory (new, open, replay, replay_read_only, append, sign_up, sign_up_keyed, add_key, remove_key, confirm_email, account_for, verify_account), Account, Group, Member, DirectoryEntry, Actor, and the BoundaryGate trait; the seitan V2 admission protocol (HMAC-SHA512 invite derivation with a scrypt stretch, per the facade Cargo.toml comments); and the keyset and recovery family (keyset, keyset_file, recovery, recovery_flow, recovery_relay, recovery_view, restored_key).

Features: default = [] only. Dependents: the facade, id-cli, id-web, and id-worlds.

Embedding example: id-worlds consumes this crate as persisted world state — WorldCore holds a directory::Directory — and re-exports directory, directory_auth, directory_mail, and directory_view so moved code keeps its historical paths. The web layer consumes the same crate for its directory routes (see The web UI: pages and HTTP API).

id-groups — 3 public modules

Purpose (from its Cargo.toml): “Groups layer of the id crate: group actions and log, local warnings, blob gate and group encryption (pkgs/id crate split step 4, #4407)”. Its lib.rs is explicit about the boundary: the group model does not live here. Model, fold, policy, friendship, and writer-set vocabulary are owned by id-events; this crate is the policy and enforcement remainder over that model.

Public modules: blob_gate; encryption (with submodules history, notice, ordering, roster, scheme, welcome); and groups (with submodules actions, log, warnings), which re-exports the id_events::groups model at the same paths.

Key types and functions: blob_gate::{BlobPolicy, Request, decide, decide_with_blocks, decide_with_local, blob_events, blob_events_with_blocks} — the decision of who may fetch or observe a blob, taken over the WorldAccess trait from id-events; encryption — group encryption on p2panda-encryption’s DataScheme, with a session adapter, causal ordering, history modes (HistoryMode, HistoryRequest, HistoryAnswer), and welcome chunking bounded by id_core::frames::MAX_FRAME_BYTES; and groups::actions (user group actions), groups::log, and groups::warnings (local size and churn warnings).

This crate’s lib.rs carries the stale FoldedWorlds sentence recorded as disagreement LIB-9: it parks FoldedWorlds in the facade pending step 5, but step 5 has landed and the type is defined at crates/id-worlds/src/blob_gate.rs:36. The code behaviour is that id-groups owns the gate policy (BlobPolicy, Request, decide) and id-worlds owns the FoldedWorlds implementation of the gate’s world trait.

Features: default = [] only. Dependents: the facade, id-cli, id-web, and id-worlds.

Embedding example: command code reaches the gate through the id-cli bridge module, which re-exports id_groups::blob_gate::{BlobPolicy, Request, decide} alongside id_worlds::blob_gate::{FoldedWorlds, RefreshingWorlds} — one import site, two owner crates, matching the policy/implementation split above.