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 crates

Source: primary sources are pkgs/id/Cargo.toml, pkgs/id/src/lib.rs, and the per-crate manifests and lib.rs files under pkgs/id/crates/. This chapter is complete without following those links; they record provenance only.

The id code lives in one Cargo workspace rooted at pkgs/id/. The workspace has 17 members: the root package id plus 16 crates under pkgs/id/crates/. Default members are 15: the root plus 14 crates. id-native-shell and id-hw-shell are workspace members but not default members, so a plain cargo build in pkgs/id/ never acquires the Bevy desktop dependencies or the hardware-shell code. The 16 sub-crates declare 228 pub mod items in total across their lib.rs files; the root adds 26 modules of its own code plus about 90 re-exported modules (see The id facade crate).

The workspace is the product of a numbered split of one original crate, recorded in the crate doc headers as umbrella issue #3447: Phase 1 extracted id-core (#3447), step 1 extracted id-caps (#4403), steps 2a and 2b extracted id-store and id-events (#4405), step 3 extracted id-sync (#4406), step 4 extracted id-groups (#4407), step 5 extracted id-worlds (#4408), steps 6b and 6c extracted id-directory and id-web (#4409), and step 7b extracted id-cli (#4411). Four crates are not split products: id-config (slice 9111-01, #10178), id-currency-registry (F1 and F2 of #2062, #2317 and #2318), id-render (#7918, decision records #5849 and #5855), and id-import-notion (slice 1, #8419). The two shells are separate consumers, covered in Guest apps and shells as consumers.

Dependency direction

Production [dependencies] edges only; dev-dependencies are named where they matter.

  • id-core has 10 production dependents: every other split crate plus the facade.
  • id-caps depends on id-core. id-store depends on id-core. id-events depends on id-core and id-store. id-groups depends on id-core, id-events, and id-store. id-sync depends on id-core, id-events, and id-store.
  • id-directory depends on id-caps, id-core, id-events, and id-sync. It does not depend on id-worlds; id-worlds depends on id-directory, because WorldCore holds a directory::Directory as persisted state.
  • id-worlds depends on id-caps, id-core, id-directory, id-events, id-groups, id-store, and id-sync. id-web depends on all of those plus id-worlds. id-cli depends on the same set as id-worlds, plus optional id-web.
  • The facade id depends on id-caps, id-cli, id-core, id-currency-registry, id-directory, id-events, id-groups, id-store, id-sync, and id-worlds, plus optional id-web.
  • Both shells production-depend on the facade only, each with default-features = false, features = ["world"]. Each shell also dev-depends on id-worlds with the sandbox feature for its test harness.
  • id-config has no production dependent anywhere in the workspace. The facade names it only under [dev-dependencies], for the invariant tests in pkgs/id/tests/. ARCHITECTURE.md states that only the root depends on id-config; the code disagrees — that root edge is a dev-dependency, not a production dependency (disagreement LIB-4).
  • id-currency-registry depends on nothing and its only production dependent is the facade.
  • id-render and id-import-notion depend on nothing and have no dependents, but both are default members and both carry maintained integration test suites. ARCHITECTURE.md calls them candidates for removal or for documenting as unused; no code, manifest, or test marks either crate deprecated or slated for removal (disagreement LIB-11).

The seventeen members

id (root, the facade). Purpose: the published library surface and the id binary; the root Cargo.toml description, “A peer-to-peer file sharing CLI built with Iroh”, predates the worlds, directory, and currency surface (disagreement LIB-13). Public modules: 26 modules of its own code in pkgs/id/src/, plus about 90 modules re-exported from sub-crates at id:: paths. Key types and functions: Cli, Command, the cmd_* command functions, open_store, StoreType, load_or_create_keypair, and the constants KEY_FILE, CLIENT_KEY_FILE, SERVE_LOCK, STORE_PATH, and META_ALPN. Features: default = ["sandbox", "world"], plus sandbox, world, ssh, web, dht, and currency-poc-tb. Dependents: id-native-shell and id-hw-shell in production; id-store dev-depends on it for tests. Full treatment: The id facade crate.

id-core — 58 public modules. Purpose: foundation leaf modules (Phase 1 of the split, #3447); everything depends on these modules and they depend on almost nothing. Key types and functions: the constants KEY_FILE = ".iroh-key", CLIENT_KEY_FILE = ".iroh-key-client", SERVE_LOCK = ".iroh-serve.lock"; discovery (PeerDiscovery, PeerInfo, PeerAnnouncement); tuple, canonical_cbor, frames (MAX_FRAME_BYTES), membership, holders, signed_envelope, and the graph record model. Features: default = ["world", "sandbox"], plus web, test-utils, and test-provider. Dependents: all ten production consumers in the workspace. Full treatment: The data crates.

id-caps — 18 public modules. Purpose: the capability catalog, execution limits, and the declarative world manifest (split step 1, #4403). Key types and functions: the provider catalog in world_caps (entries include time.now, chat.say, kv.get, blob.put, http.fetch); world_limits (RuntimeLimits); agent_delegation (AgentId, Role, Delegation, JoinGrant, verify_join); the Roc library-import gate family (library_manifest, library_resolution, library_gate, library_attach); and mcp_bridge / mcp_policy. Features: default = ["sandbox"], plus the test-only test-provider. Dependents: the facade, id-cli, id-directory, id-web, and id-worlds. Full treatment: Worlds and capabilities as a library.

id-store — 26 public modules. Purpose: the store layer — store traits, blob store, event headers, documents, tags, and search (split step 2a, #4405). Key types and functions: store::{StoreType, open_store, load_or_create_keypair} with STORE_PATH = ".iroh-store"; chain::{ChainExt, Event, sign}; tags, tag_index, and tag_claims; documents::{DocumentRef, DOCUMENT_KIND}; and search. Features: none beyond default = []. Dependents: the facade, id-cli, id-events, id-groups, id-sync, id-web, and id-worlds. Full treatment: The data crates.

id-events — 12 public modules. Purpose: the event store, group projection, writer sets, and sync gating (split step 2b, #4405). Key types and functions: EventStore and Ingest; the attestation family (GenesisAgreement, ResultClaim, sign_genesis, sign_claim, compute_state); the deterministic group projection in groups::fold (GroupView, Projection); writer sets in idset (WriterSet, Entry, Excludes); and WorldAccess. Features: none beyond default = []. Dependents: the facade, id-cli, id-directory, id-groups, id-sync, id-web, and id-worlds. Full treatment: The data crates.

id-groups — 3 public modules. Purpose: the group policy and enforcement remainder — group actions and log, local warnings, the blob gate, and group encryption (split step 4, #4407). The group model itself lives in id-events; this crate holds blob_gate::{BlobPolicy, Request, decide}, the encryption family built on p2panda-encryption’s DataScheme, and groups::{actions, log, warnings}. Features: none beyond default = []. Dependents: the facade, id-cli, id-web, and id-worlds. Full treatment: The data crates.

id-sync — 21 public modules. Purpose: log sync, the meta protocol, file operations, envelopes, and artifacts (split step 3, #4406). Key types and functions: protocol::{META_ALPN, MetaRequest, MetaResponse} with META_ALPN = b"/iroh-meta/3"; log_sync (SyncProtocol); transfer; artifact; envelope_outbox::Outbox; announcement::{Announcement, SignedAnnouncement}; and the federation family. Features: default = [], plus opt-in dht (off by default) and test-utils. Dependents: the facade, id-cli, id-directory, id-web, and id-worlds. Full treatment: The data crates.

id-directory — 15 public modules. Purpose: the home-server directory — directory, views, auth, mail, invites, and seitan admission (split step 6b, #4409). Key types and functions: Directory (new, open, replay, append, sign_up, add_key, verify_account), Account, Group, Member, DirectoryEntry, Actor, and the BoundaryGate trait; the seitan V2 admission protocol; and the keyset and recovery family. Features: none beyond default = []. Dependents: the facade, id-cli, id-web, and id-worlds. Full treatment: The data crates.

id-worlds — 31 public modules. Purpose: the world runtime, sessions, sandbox, and cross-world authority (split step 5, #4408); at 75 .rs files it is the largest crate in the workspace. Key types and functions: sandbox::{Sandbox, WorldInstance, GuestCall, CallStats, CallMetrics}; world::{WorldCore, WorldHandle}; shell_contract; program_bundle; guest_burn; and account_charge::{WorldChargeConfig, WorldAccountRegistry, ChargeMode}. Features: default = [], plus sandbox (adds wasmtime), ssh, and test-utils. Dependents: the facade, id-cli, and id-web in production; both shells dev-depend on it. Full treatment: Worlds and capabilities as a library.

id-web — 2 public modules. Purpose: the web layer — HTTP and WebSocket server, routes, templates, and markdown (split step 6c, #4409). Only gallery and world_ws are declared pub mod; the rest of the surface is private modules behind curated re-exports. Key types and functions: create_router, create_router_for_app, create_program_router, WebInterface, WebMode, WebSecurity, SeitanState, and PublicationMounts. Features: default = [], plus sandbox. Dependents: the facade (optional, under the facade web feature, re-exported as id::web) and id-cli (optional, under its web feature).

id-cli — 19 public modules plus 3 bridge modules. Purpose: the command-line application layer (split step 7b, #4411): cli (argument parsing), commands (subcommand implementations), repl, and server_config, plus shared support modules. Key types and functions: Cli, Command, KeyCommand, KeysetCommand, TagCommand; the cmd_* functions; option structs ServeOptions, ServeInfo, PeekOptions, PeersOptions, SearchOptions, ReplContext; MetaClient (the local-versus-remote chooser, defined at crates/id-cli/src/meta_client.rs:31); MetaProtocol, MetaRequest, MetaResponse, FindMatch, TaggedMatch, MatchKind; and run_repl. Features: default = ["sandbox", "world"], plus world, sandbox, ssh, web, and dht. Dependents: the facade only. The command surface itself is documented in The id command line.

id-config — 1 public module. Purpose: the versioned configuration contract and its hard invariants (slice 9111-01, #10178). Public modules: resolve only, re-exporting resolve::{LayerOverride, ResolutionInput, ResolveError, ResolvedLayers, resolve}; everything else is defined at the crate root. Key types and functions: CONFIG_SCHEMA_VERSION = 1; FIXED_GATE_IDS (the 5 ids signature-verification, validation, replay-protection, authorization, tenant-scope); ConfigDocument (parse, validate, resolve); ResolvedConfig (canonical_json); ConfigError (12 variants); Mode, SyncScope, Tier, Ceilings, and field_class. The doctrine in the crate header is literal: the five fixed admission gates can never be disabled by configuration, ceilings only narrow, validation is fail-closed, and resolution is deterministic. Features: none. Dependents: none in production; the facade dev-depends on it only. One further disagreement: crates/id-config/src/negotiation.rs exists on disk but is never declared in the crate’s lib.rs, so the published crate does not contain it; its only compilation is by path from the facade’s tests/config_downgrade.rs (disagreement LIB-5). The configuration surface is documented in Configuration and environment.

id-currency-registry — 5 public modules. Purpose: the currency control-plane registry (F1 of #2062, #2317; account factory F2, #2318): the Postgres schema and migrations for ledger_allocation, currency, currency_issuer, and account, plus the monotonic, never-recycled ledger-u32 allocator. Public modules: allocator, factory, grants, registry, store. Key types and functions: Allocator and AllocError; Registry, RegistryError, CurrencyRecord, CurrencyStatus, SupplyPolicy; Factory, FactoryError, CurrencyAccounts, AccountCluster, AccountSpec, AccountKind, CreateOutcome; the Store trait with InMemoryStore; and the MIGRATION_0001_UP / MIGRATION_0001_DOWN constants. The ratified split is 0x00000001..=0x000FFFFF for tenancy and system, 0x00100000.. for currencies; ledger 0 is never allocated. Features: default = [] only. Dependents: the facade only, which composes it in pkgs/id/src/currency/gateway_poc.rs.

id-render — 10 public modules. Purpose: the rendering pipeline compiler core (#7918): parse and vocabulary validation of semantic markup, then a five-stage pipeline over one target-neutral intermediate representation — parse, validate, compose, lower per target, emit artefact plus coverage report. Public modules: assertion_vocabulary, compose, gui_table, lower, lower_gui, lower_native, native_table, tooling, vocabulary, web_table; parse and validate are private modules whose functions are wrapped at the crate root. Key types and functions: Document, Element, Node, Span, BuildError; parse, validate, parse_and_validate, compose_document, lower_document, lower_document_native, lower_document_gui. Features: none. Dependents: none; it is a default member with six integration test files.

id-import-notion — 0 public modules. Purpose: Notion importer manifest and inventory primitives (slice 1, #8419): durable inventory and resume primitives, with the API transport injected by callers. The whole crate is one src/lib.rs of 1,241 lines. Key types and functions: NOTION_API_VERSION; the NotionApi transport trait; crawl_inventory; Inventory, InventoryObject, Stage, Outcome; and Manifest (new, verify_resume_identity, record_progress, validate_inventory_reconciles, save_atomic, load). A bearer token is never accepted by or serialized from Manifest. Features: none. Dependents: none; it is a default member with its own integration test, crates/id-import-notion/tests/recorded_inventory.rs.

id-native-shell — 7 public modules. Purpose: the native reference shell (F13.6, design #788): a Bevy desktop client speaking the F13.1 shell contract. Public modules: audio, events, form, providers, render, scene, widget, plus a private session module whose surface is re-exported at the crate root. Features: none. Production dependency: the facade with features = ["world"], plus Bevy 0.19 and iroh. Dependents: none; not a default member. Full treatment: Guest apps and shells as consumers.

id-hw-shell — 0 public modules. Purpose: the ESP32-class hardware shell spike (more-shells v1 slice 3, #10929): the presence, journal-head, and confirm/act subset of the F13.1 shell contract. The whole crate is one src/lib.rs of 996 lines. Key types and functions: CONTRACT_NAME = "shell", CONTRACT_VERSION = 1, capability_statement(), HwShell, PresentedChoice, SelectableField, and HwError. Features: none. Production dependency: the facade with features = ["world"]. Dependents: none; not a default member. Full treatment: Guest apps and shells as consumers.

Embedding examples from real call sites

The shipped binary is itself a facade consumer: pkgs/id/src/main.rs:10-13 imports id::{Cli, Command, PeekOptions, PeersOptions, SearchOptions, ServeOptions, cmd_find, cmd_get_multi, cmd_gethash, cmd_id, cmd_list, cmd_migrate_tags, cmd_peek, cmd_peers, cmd_put_hash, cmd_put_multi, cmd_search, cmd_serve, cmd_show, cmd_tag, run_repl}, and pkgs/id/src/main.rs:202 calls id::cli::normalize_args(std::env::args_os()).

The integration suite is the largest consumer: use id:: occurs 165 times under pkgs/id/tests/. One import block in pkgs/id/tests/first_app_poc.rs:33-45 spans three crates entirely through facade paths — id-store (chain, documents, tag_claims), id-events (event_store, idset), and id-core (waiting).

Direct crate paths are also in use where the facade does not re-export a crate. pkgs/id/src/currency/gateway_poc.rs:120-125 imports id_currency_registry::{AccountCluster, AccountKind, AccountSpec, ClusterError, CreateOutcome, Factory, FactoryError, InMemoryStore, Registry, RegistryError, Store, SupplyPolicy} directly, because the facade exposes nothing from id-currency-registry at id:: paths. The three config test files under pkgs/id/tests/ (config_invariants.rs, config_precedence.rs, config_downgrade.rs) consume id_config:: directly for the same reason.