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

Configuration and environment

Source: https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-config/src/lib.rs, https://github.com/developing-today/code/blob/main/pkgs/id/config/id-config-v1.schema.json, https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-cli/src/server_config/mod.rs, https://github.com/developing-today/code/blob/main/pkgs/id/crates/id-core/src/defaults.json

ID has five distinct configuration surfaces, and they are not interchangeable:

SurfaceFormWho reads it
Environment variablesProcess environment, 66 named variablesThe id binary, its crates, benches and tests
The id-config v1 documentJSON, parsed in memoryThe id-config crate; no file location, no loader
The server-config fileTOML, operator-chosen pathid serve --server-config <path>
Embedded defaults.jsonJSON, compiled into the binaryServe/peers discovery and web bindings
[interfaces.web] in app.tomlTOML, per appThe web layer, for one app’s route and socket

Environment variables: the complete table

66 named variables are read across the tree: 29 production/build, 20 bench, 17 test. The production set is given in full below, with read site and the behaviour when the variable is unset. Bench and test variables are summarised by family. A further six hosted-Worker bindings, one dynamic credential scheme, and three variables the process writes follow the tables; none of those are counted in the 66.

Production and build variables (29)

#NameRead siteDefault behaviour when unset
1ID_WEB_TOKENclap env for --web-token, crates/id-cli/src/cli/mod.rsNo web gate token; the web UI is ungated (and serve warns). See The web UI: pages and HTTP API.
2ID_WEB_COOKIE_SECUREclap env for --web-cookie-secure, cli/mod.rsfalse.
3ID_WEB_MAX_IDENTITIEScrates/id-web/src/identity.rs (MAX_IDENTITIES_ENV)10000. The value none means unbounded. 0 or an unparsable value warns and falls back to 10000.
4ID_WORLD_ADMIN_TOKENclap env in cli/mod.rs and throughout cli/world.rs (values hidden)World admin frames and invites are disabled unless the flag is given.
5ID_WORLDclap env in cli/world.rs, on many subcommandsUnset. One subcommand (world replica) defaults it to lobby.
6ID_WORLD_CAPABILITYclap env in cli/world.rs (values hidden)The capability must come from the --capability flag.
7ID_WORLD_SOURCE_ONLYclap env for --world-source-only, cli/mod.rsfalse.
8ID_GALLERY_DIRclap env in cli/mod.rs and cli/gallery.rsNo gallery is served.
9ID_GALLERY_ACCEPT_PUBLISHclap env, cli/mod.rsfalse. Requires a gallery directory.
10ID_ROC_BINclap env in cli/mod.rs and cli/world.rs; env::var in id-web world bridge, id-worlds compile, and serveFalls back to a roc binary found on PATH or in roc-home candidates.
11ID_ROC_PLATFORMclap env in cli/mod.rs and cli/world.rs; env::var in world commands and serveFalls back to ./examples/roc-world.
12ID_WORLD_COMPILE_CACHE_DIRcrates/id-cli/src/commands/serve.rsUnset or empty: the shared compiled-world cache is disabled. The cache is opt-in.
13ID_WORLD_COMPILE_CACHE_LRU_BYTEScommands/serve.rsThe id-worlds cache default, 2 GiB. An unparsable value falls back to the default.
14ID_APPS_DIRcommands/serve.rs (var_os)Falls back to the built-in apps root.
15ID_PUBLICATIONS_FILEcrates/id-cli/src/publications.rs (var_os)Falls back to the default publications file path.
16ID_SHELL_FILE_READ_ROOTcrates/id-native-shell/src/main.rsThe native shell file-read root is not additionally restricted or configured by environment. See id-native-shell.
17RUST_LOGsrc/main.rsWhen no CLI log level is set, the filter is debug plus noisy-module filters. Log-level resolution order is in The id command line.
18LOG_LEVELsrc/main.rsParticipates in log-level resolution; unset means ignored.
19DEBUGsrc/main.rsA truthy value raises the log level in resolution; unset means ignored.
20ID_LOG_FORMATsrc/main.rs (structured logging)Historical plain-text stderr logging. Recognised values: text, json.
21ID_LOG_FILEsrc/main.rsNo log file.
22ID_LOG_FILE_LEVELsrc/main.rsThe log file uses the main level.
23ID_LOG_TZsrc/main.rsThe default timestamp timezone.
24HOMEid-worlds compile, world commands, CLI integration test helperUsed for roc-home candidates and home resolution; the test falls back to /home/user.
25PATHid-worlds compile and world doctor (split_paths)An empty path list.
26TIGERBEETLE_POC_BINARYsrc/currency_poc/harness.rs (BINARY_ENV, var_os)Proof-of-concept harness only: no external TigerBeetle binary.
27CARGO_MANIFEST_DIRbuild.rs, plus compile-time env! in tests and helpers".".
28CARGO_FEATURE_WEBbuild.rsUnset means the web feature is off and the build script skips the web asset step.
29PROFILEbuild.rs"".

Notes on the logging set: an unrecognised ID_LOG_FORMAT or ID_LOG_TZ value, or a log file that cannot be opened, warns on stderr and logging continues without that piece. Blank flag and environment values count as unset in log-level resolution.

Bench variables (20), by family

All are read only by benches/world_bench.rs.

FamilyVariablesDefault behaviour
Guest burn / framesID_BENCH_GUEST_BURN_CONCURRENCY, ID_BENCH_FRAME_EVENTSHelper-parsed; unset means the committed bench value.
ProvenanceID_BENCH_MACHINE_CLASS (default fleet-laptop), ID_BENCH_GIT_SHA (falls back to GITHUB_SHA, then a computed value), GITHUB_SHA, ID_BENCH_TOOLCHAIN (default unknown), ID_BENCH_RESULTS (default results.jsonl)As stated.
Many-worldsID_BENCH_MW_IDLE_WORLDS (1000), ID_BENCH_MW_ACTIVE_WORLDS (100), ID_BENCH_MW_EVENTS_PER_SECOND (20), ID_BENCH_MW_DURATION_SECS (10)Parsed by one helper with the stated literal defaults.
StressID_BENCH_STRESS_TIER, ID_BENCH_STRESS_SEED, ID_BENCH_STRESS_OUT, ID_BENCH_STRESS_MEM_PART (all), ID_BENCH_STRESS_IDLE_WORLDS, ID_BENCH_STRESS_ACTIVE_WORLDS, ID_BENCH_STRESS_ACTIVE_EVENTS, ID_BENCH_STRESS_HOT_EVENTS, ID_BENCH_STRESS_HOT_MEMBERSParsed by one helper with a per-tier default.

Test variables (17), by family

Read only in tests, test helpers, or test configuration. None affects a production run.

VariablesWhere
ID_FED_NODE_Bid-sync substrate transport test; unset means the test peer B is absent.
BAKEOFF_RESULTSid-store graph-encoding bakeoff; unset means no results file is written.
CARGOid-store store-traits test; default cargo.
SCREEN_PARITY_GENERATEid-core screen parity test; unset means the parity corpus is not regenerated.
ID_TEST_FAKE_SHid-worlds compile test helper, also set by flake.nix; unset means the real shell.
TERRITORY_WASMid-worlds sandbox test; unset means the test module is not loaded.
ID_IDENTITY_PROBE_PATHid-web identity tests; unset means the probe is not run.
WORKER_POC_REFERENCE_OUTWorker PoC reference test; unset means the reference JSONL is not written.
PROPTEST_CASES, PROPTEST_RNG_SEEDProperty tests; unset means the proptest default case count and a random seed.
ID_BINARY, ID_TEST_EXAMPLES_DIR, ID_TEST_APPS_DIRCLI integration tests; unset means the built binary path and the in-tree examples/apps directories.
ID_TUPLE_FUZZ_CASESTuple property tests; unset means the default case count.
ID_E2E_WORLD_ADMIN_TOKENPlaywright config (TypeScript); unset means the config-file fallback token.
UPDATE_EXPORT_FIXTUREHosted-worker export test (TypeScript); unset means the fixture is not regenerated.
Playwright runner variables: TEST_PORT (4173), NIX_BUILD_TOP, PLAYWRIGHT_VM_TEST, CHROMIUM_BASE_URL, FIREFOX_BASE_URL, CIRead by e2e/playwright.config.ts, as coded there.

Hosted-Worker bindings (not process environment)

The hosted Worker reads Cloudflare Env bindings, not process environment variables: USERS, BLOBS, USER_CEILING_BYTES, BRIDGE_WAITING_PER_AUTHOR, BRIDGE_WAITING_TOTAL, BRIDGE_WAITING_MAX_AGE_MS, plus test-only TEST_USERS. They are specified in The hosted Worker API.

The dynamic env:<VAR> credential scheme

One reader names no fixed variable. The EnvCredentialResolver in src/foreign_libsql.rs resolves any credential reference string of the form env:<VAR> from configuration, looking up <VAR> in the process environment. The variable name is data, not code, so no name can be listed for this reader. (Its own test uses TEST_LIBSQL_TOKEN.) A configuration that carries env:MY_TOKEN therefore reads the variable MY_TOKEN at resolve time; the secret value itself never appears in the configuration.

Variables the process writes

Three variables are set by ID, not read by it. When id serve --world-mail-command <PROG> runs a confirmation-mail command, the child process receives:

NameContent
ID_MAIL_TOThe recipient address for that confirmation.
ID_MAIL_SUBJECTThe confirmation subject.
ID_MAIL_BODYThe confirmation body.

These are set in crates/id-directory/src/directory_mail.rs during construction of the child’s environment. That construction is the only production set_var path in the tree.

The id-config v1 document

The id-config crate defines the canonical versioned configuration contract: a ConfigDocument in JSON. The crate has no file location and no loader. ConfigDocument::parse(&str) parses a JSON string in memory, validate() checks the hard invariants, and resolve() produces a deterministic ResolvedConfig, serialised with canonical_json(). A deployment that uses this document supplies the string itself; there is no path the crate opens.

The JSON Schema twin lives at pkgs/id/config/id-config-v1.schema.json and is kept in lockstep with the Rust types by pkgs/id/tests/config_invariants.rs. Companion modules cover layered resolution (LayerOverride, ResolutionInput, ResolvedLayers) and protocol negotiation, whose transcript domain is id-config/negotiation-transcript/v1.

The document has 10 top-level keys and 29 leaf keys. Every struct is deny_unknown_fields: an unknown key rejects the document. Validation is fail-closed throughout.

KeyType / valuesDefault / rule
schema_versionu32Required. Must equal 1, else the document is rejected with UnsupportedSchemaVersion.
config_idstringRequired, non-empty.
revisionu64Required.
modesingle-node | hosted-tenant | federated-relayRequired. Seeds the behaviour defaults below.
protocol_versionsstring arrayRequired, non-empty, duplicate-free. The resolved form is sorted.
ceilingsobjectRequired. Every field must be ≥ 1, else ZeroCeiling.
ceilings.max_hopsu32Hard cap on relay hops.
ceilings.max_bytesu64Hard cap on a single-operation payload.
ceilings.max_time_msu64Hard cap on single-operation wall-clock time.
ceilings.max_fan_outu32Hard cap on delivery targets.
gatesobjectDefault: all true. Setting any gate to false rejects the document with FixedGateDisabled.
gates.signature_verificationbool, const trueOne of the five fixed gate IDs: signature-verification, validation, replay-protection, authorization, tenant-scope. Gates are mechanism, not behaviour.
gates.validationbool, const trueAs above.
gates.replay_protectionbool, const trueAs above.
gates.authorizationbool, const trueAs above.
gates.tenant_scopebool, const trueAs above.
behaviorobjectDefault: empty. Every field None means “inherit the previous plane”.
behavior.max_hopsu32, optionalMust fit the applicable (possibly narrowed) ceiling.
behavior.sync_scopemetadata | full, optional—
behavior.tiercold | warm | hot, optionalTier labels never authorise access.
overridesarray of scoped overridesDefault []. Applied in scope-name order. A duplicate scope rejects the document.
overrides[].scopestringRequired, non-empty.
overrides[].ceilingsobject: max_hops?, max_bytes?, max_time_ms?, max_fan_out?May only narrow a ceiling. Widening is rejected with CeilingWidened; it is never clamped.
overrides[].behaviorobjectSame shape and rules as behavior.
extensionsmap of string to JSONDefault {}. Keys must be namespaced, matching ^[^./\s]+([./][^./\s]+)+$ (for example example.com/experiment). Values are retained verbatim in the resolved output and are never executed.

Field classes: mechanism fields are schema_version, config_id, revision, protocol_versions, ceilings, gates. Behaviour fields are mode, behavior, overrides, extensions. The ResolvedConfig adds provenance: for each behaviour field, one of mode:<mode>, document, or override:<scope>.

Mode behaviour defaults

Modemax_hopssync_scopetier
single-node1metadatacold
hosted-tenant3fullwarm
federated-relay5fullhot

Worked example

A toy document, and what resolution does to it:

{
  "schema_version": 1,
  "config_id": "toy-node",
  "revision": 4,
  "mode": "single-node",
  "protocol_versions": ["v1"],
  "ceilings": {"max_hops": 4, "max_bytes": 1048576, "max_time_ms": 5000, "max_fan_out": 8},
  "behavior": {"tier": "warm"},
  "overrides": [
    {"scope": "relay", "ceilings": {"max_hops": 2}}
  ]
}

Resolution: behaviour starts from the single-node defaults (max_hops 1, metadata, cold), the document’s behavior.tier replaces tier with warm (provenance document), and the relay override narrows that scope’s max_hops ceiling to 2. Changing the override to "max_hops": 9 would reject the whole document with CeilingWidened, because 9 widens the document ceiling of 4. Adding "gates": {"validation": false} would reject it with FixedGateDisabled.

On-disk configuration: the server-config TOML

id serve --server-config <FILE> loads an operator server-config file (ServerConfig::load, in crates/id-cli/src/server_config/). Every table is optional; an empty file is valid. A malformed file fails startup, naming the parse error. Loading the file needs a build with the world feature; see serve and publications.

The file has 23 named keys, including 5 [budgets] keys.

KeyDefault / rule
[create] users[]With [create] absent, anyone may create a group.
[create] groups[]As above.
[create] min_roleUnset means any member may create.
[[users]] keyA provisioned user entry.
[[users]] idThe user’s 64-hex Ed25519 public key.
[[users]] aliasOptional. Users are provisioned at startup, idempotently.
[[groups]] keyA provisioned group entry.
[[groups]] nameThe group name.
[[groups]] creatorA user key; that user becomes Admin.
[[groups]] aliasOptional.
[[groups.members]] userA member entry for the group above it.
[[groups.members]] roleOne of pull, read, write, manage, admin.
[policy] freshness_window_seconds300 (5 minutes).
[policy] pull_policyopen. The other value is members.
[budgets] app_inbound_bytes_per_hour20 GiB/h: 21474836480.
[budgets] app_inbound_bytes_per_second32 MiB/s: 33554432 (the 1-second window of BudgetPolicy::default in id-core); see WEB-14 below.
[budgets] per_peer_bytes_per_hour100 MiB/h: 104857600.
[budgets] per_peer_burst_bytes_per_minute8 MiB/min: 8388608 (the 60-second window of BudgetPolicy::default in id-core); see WEB-14 below.
[budgets] per_ip_bytes_per_hour250 MiB/h: 262144000.
[[budgets.counterparty]] peerA per-peer override entry.
[[budgets.counterparty]] bytes_per_windowReplaces — does not stack with — the per-peer limits for that peer.
[[budgets.counterparty]] window_secondsThe override window.
[[budgets.counterparty]] messages_per_windowOptional.
[residency], [[boundaries]]Optional tables; their shapes are owned by server_config/boundaries.rs.

The operator block list is explicitly not configuration: it lives in the event store’s blocks table (see Data stores and schemas), not in this file.

Two budget keys the module documentation omits (WEB-14)

The server_config/mod.rs header documents three [budgets] keys. The parser implements five, adding app_inbound_bytes_per_second and per_peer_burst_bytes_per_minute. An operator reading only the module documentation cannot discover those two live knobs. That is disagreement WEB-14; both keys are listed in the table above because the parser accepts them.

Worked example

A toy server-config file:

[create]
min_role = "write"

[[users]]
key = "alice"
id = "0123abcd0123abcd0123abcd0123abcd0123abcd0123abcd0123abcd0123abcd"
alias = "Ada (toy)"

[[groups]]
key = "toy-club"
name = "Toy Club"
creator = "alice"

[[groups.members]]
user = "alice"
role = "admin"

[policy]
freshness_window_seconds = 300
pull_policy = "members"

[budgets]
per_peer_bytes_per_hour = 104857600

At startup, user alice and group toy-club are provisioned idempotently, group creation requires role write or above, pulls are restricted to members, and each peer is budgeted at 100 MiB per hour.

Embedded defaults.json

crates/id-core/src/defaults.json is embedded at compile time with include_str!. Its shipped content is:

{"mode":"append","topic":"id-peer-discovery-v1","topic_secret":"id-public-discovery-v1"}

The schema is the Defaults struct in crates/id-core/src/discovery.rs, deserialised with deny_unknown_fields, so an unknown key fails the parse. Verified against the checkout, it has 7 keys — the survey’s count of 6 is one short; the code is the side documented here:

KeyType / defaultMeaning
bootstrapstring array, default []Bootstrap node IDs.
topicstring, optionalThe gossip discovery topic. Must be supplied together with topic_secret.
topic_secretstring, optionalThe gossip discovery topic secret. Must be supplied together with topic.
web_bindingsstring array, default []Web listener bindings, replaced wholesale by --web-listen.
relayrelay policy selector, default N0The relay policy used for connections.
gossipbool, default trueWhether gossip discovery is enabled by default.
modeappend or replace, default appendHow these defaults combine with the hardcoded constants: append keeps the built-in list defaults and appends the file values; replace uses the file lists instead.

Precedence, lowest to highest: hardcoded constants, then defaults.json, then CLI flags, then the runtime skip flags --no-default-bootstrap and --no-default-topic, which discard the file’s bootstrap IDs or topic values and fall back to the constants. The id --version long form prints which defaults source is in force, as a provenance line naming the file’s SHA-256 and mode.

[interfaces.web]: per-app web binding

Each app’s app.toml may carry an [interfaces.web] table, read by web_interface_from_app_toml in crates/id-web/src/app_interface.rs. It has 3 keys:

KeyDefaultRule
mode—adapter: host surfaces render the app. direct: the app ships its own frontend; accepted by the parser but not adapter-bound.
route/world (for the default world app)Must start with /, be a valid axum pattern, differ from socket, and not collide with the host-reserved route list.
socket/ws/world (for the default world app)Same rules as route.

The host-reserved route list is mirrored against the main router and the world bridge routes in The web UI: pages and HTTP API, so an app cannot claim a host path.

Data directory layout (paths, not a config file)

The data directory is the current directory by default. --data-dir <path> selects one; --new [NAME] creates .iroh/<NAME>/ under the current directory and uses it. All data paths are relative to it: .iroh-store/, .iroh-key, .iroh-serve.lock, .iroh-meta/, .id-worlds/<NAME>/. --ephemeral uses in-memory stores instead. The formats at those paths are specified in Data stores and schemas.

Other on-disk configuration locations:

FileLocation
App manifestsapp.toml per app, under ID_APPS_DIR or the built-in apps root.
Gallery directory--gallery-dir / ID_GALLERY_DIR: verified <content-hash>.idpb bundle files plus an operator/ folder holding collections, tags and admission decisions.
Directory journaldirectory.jsonl in the server-config directory.
Keysets.id-keyset.jsonl and .id-keyset-client.jsonl.

Serve, web and world defaults that act as configuration

These CLI defaults are configuration in effect; the flags themselves are specified in serve and publications and World commands: administering and verifying.

SettingLiteral default
--weboff
--port3000
--bind127.0.0.1
--web-tokenunset (no gate)
--web-cookie-securefalse
--world-namelobby
--world-checkpoint-every1000; 0 means never trim
--world-max-open256
--world-max-sessions1024
--world-idle-secs600
--world-boot-window-secs600
--world-cap-policydeny
Gossip topic (hardcoded fallback)id-peer-discovery-v1
Gossip topic secret (hardcoded fallback)id-public-discovery-v1