Skip to content

id: design: build-time defaults file — embed network defaults from an optional JSON file instead of only hardcoded consts #5916

Closed

Description

@dezren39

id: design: build-time defaults file — embed network defaults from an optional JSON file instead of only hardcoded consts

Source (raw conversation, verbatim)

From Drew's peer-discovery plan review, OpenCode session ses_2ec427b80ffeuCx6dCuANmiN6c ("Peer discovery plan review"), 2026-03-23:

"add no-gossip. can all the defaults be populated from a json file optional at build so the end result is equivalent hardcoded const? hardcoded -> build defaults file (build flag to replace instead of append -> users can add new values on serve launch (flag to skip defaults no-default-<>)"

Follow-up in the same session, same day, confirming the direction:

"yes no-gossip, built time defaults, and mdns. what is the most efficient way to build a static config file to embed? compile time can't parse this into a const on its own it has to be a string?"

Recovered by the WS-F2 raw-conversation mining pass (2026-11-04). The other two items in that confirmed trio landed: --no-gossip exists in the serve/CLI surface, and mDNS address lookup is wired in the peers command (iroh_mdns_address_lookup). The build-time defaults file did not.

Current state (verified 2026-11-04)

  • Network defaults are hardcoded Rust constants — e.g. the discovery topic/secret pair DEFAULT_TOPIC / DEFAULT_TOPIC_SECRET in the discovery module, consumed as a pair by resolve_config (see id(discovery): resolve_config pairs a CLI topic/secret with the public default for the other half under --no-default-topic #4756 for the cascade and its pairing bug).
  • Runtime overrides exist per-value for some defaults (CLI --topic / --topic-secret / --no-default-topic), resolved by a documented cascade.
  • There is no build-time defaults file: grepping the tree finds no defaults-file mechanism, no build.rs in pkgs/id or id-core, and no issue designs one (the WS-F2 pass searched the full ID issue universe for it).

What to design

  1. File format + contents. A JSON file, optional at build time, that can populate the network defaults today spread across constants: discovery topic + secret, relay set, DNS/discovery endpoints, gossip on/off default, and any other hardcoded network default the audit finds. Building with the file must produce a binary whose effective defaults are equivalent to building with the corresponding constants — the file is a source for the same values, not a second semantics.
  2. Replace vs append. Per Drew's sketch: a build flag chooses whether the file's lists (e.g. relays) replace the built-in lists or append to them. The choice is per-build, recorded, and visible (see 5).
  3. Embedding mechanics. Answer Drew's literal question — "compile time can't parse this into a const on its own it has to be a string?" Options to evaluate: include_str! + lazy parse at first use; a build.rs that parses the JSON and emits typed Rust constants (codegen); include! of a generated source file; or a const-format parser. Criteria: compile-time validation of the file (a malformed defaults file should fail the build, not the first run), binary size/startup cost, and how the Nix build supplies the file (flake input / --cfg / env var — note the crate currently has no build.rs, so adding one is itself a decision).
  4. Runtime composition. How build-time defaults compose with the existing runtime cascade: serve-launch flags can still add values on top, and a --no-default-* style flag can skip the built-in defaults entirely (Drew's "flag to skip defaults"). Precedence must be one documented cascade, consistent with resolve_config's existing steps — and the topic/secret pair must keep resolving as a pair (the id(discovery): resolve_config pairs a CLI topic/secret with the public default for the other half under --no-default-topic #4756 lesson).
  5. Provenance. A built binary should be able to report where its defaults came from (pure constants / defaults file + its hash / replaced vs appended), e.g. in a version/about surface — a distributor shipping a private-network build must be able to prove which defaults are inside it.

Why it matters

Distributors and private deployments (an intranet build with private relays/topics — cf. #5683's intranet mode) currently must patch Rust source to change network defaults. A defaults file makes "same code, different network" a build option instead of a fork, which is exactly the property Drew asked for: end result equivalent to the hardcoded consts, chosen at build time.

Open questions

  • Which defaults are in scope for v1 — discovery topic/secret only, or the full network set (relays, DNS, gossip)?
  • Replace/append granularity: one build flag for all lists, or per-list keys inside the file?
  • Should the file format be the same JSON shape as any runtime config, so one file can serve both build-time and serve-time use?
  • How does the Nix flake expose it (a package variant per defaults file?) without exploding the build matrix?

Relates: #4756 (the resolve_config pairing bug in today's cascade), #5671 (transport fallback — relays are among the defaults), #5674 (wire/transport adapters), #5683 (residency/intranet mode — a consumer of private-network builds). Found by WS-F2 (raw-conversation mining); epic #2056.

Activity

  1. added
    source/creatorFiled by the new-issue-creator job
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 5, 2026
  2. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    WS-F2 addendum — Drew's own cascade sketch, recovered from the v1 message store. The mining pass initially extracted the v2 session_message store; the older v1 part/message tables in the same DB hold at least one user message the v2 store does not, and it is the most design-complete statement of this issue's subject. Same session (ses_2ec427b80ffeuCx6dCuANmiN6c, "Peer discovery plan review", 2026-03-23), verbatim:

    implement all the falgs from built-time description
    const fallback (hardcoded in source) ← used if no JSON file
    ↓
    build defaults ← --replace-defaults flag: use ONLY JSON, skip hardcoded
    ↓
    + CLI --bootstrap, --topic, --topic-secret at serve time
    ↓
    - --no-default-bootstrap, --no-default-topic: skip defaults
    ↓
    effective config

    there are multiple defaults, would you make one file per default type or use section headers? what is efficient

    What this pins down that the issue body left open:

    1. The cascade has four layers, in this order: hardcoded const fallback → build defaults (JSON) → serve-time CLI additions → skip flags subtract → effective config. The issue's §4 should adopt this shape rather than inventing a new one.
    2. --replace-defaults is a build-time flag with exact semantics: use ONLY the JSON, skip the hardcoded consts. (Replace-vs-append in the issue body should be reconciled with this: Drew's sketch says the build flag selects JSON-only vs JSON-over-consts.)
    3. There are multiple default types, not one defaults blob — bootstrap, topic, topic-secret are named separately, with per-type skip flags (--no-default-bootstrap, --no-default-topic). Note the skip layer partially landed: --no-default-topic exists in today's resolve_config cascade (id(discovery): resolve_config pairs a CLI topic/secret with the public default for the other half under --no-default-topic #4756) — it is the build-defaults layer above it that never arrived.
    4. Drew's open question is explicit: one file per default type, or one file with section headers — "what is efficient" — which replaces the issue body's vaguer format question.

    The v1/v2 store divergence itself is recorded in the WS-F2 worklog; the v1 store is being diff-mined to make sure no other dictation exists only there.

  4. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    and removed on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    agent-note:v1

    • task: 10315
    • state: done (triaged; pickup and triage in one pass, lane code-h direct)

    Triage 2026-11-05 (task 10315): design ticket whose direction is already Drew-confirmed — no decision is owed by Drew and none should be re-asked.

    Verified at triage:

    Scoped design order (from the issue's own sections): (1) audit the full hardcoded network-default set and fix the v1 scope question; (2) embedding mechanics decision — compile-time validation is the stated criterion, which favors build.rs codegen over include_str!+lazy parse (a malformed file must fail the build, not first run), with the no-build.rs-today caveat recorded; (3) replace-vs-append flag semantics + provenance reporting; (4) runtime composition with the resolve_config cascade. Implementation follows as a separate ticket once the decision record lands here.

  6. 78 remaining items

  7. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 15243 moved from blocked/parked to queued in the fleet unblock-all pass (worker main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet.

  8. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Agent note — task 15243 re-triage complete (lane any-b)

  9. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Follow-on named — task 15243 triage of #5916

    The fix packet routed by triage task 12396 and promised in the triage note above is enqueued: task 16801 — "Fix #5916: decision record reconciling the landed defaults.conf mechanism with the build-time defaults requirements + small code gaps" (status queued). Issue #5916 keeps queue/queued for task 16801.

  10. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged — design pass scoped; the coherent packet for #5916

    Fresh revalidation (2026-11-14): #5916 OPEN, unheld; the brief is Drew's own requirement, self-contained and still accurate in substance, with one premise corrected below. The other two items of the confirmed trio (--no-gossip, mDNS lookup) have landed; the defaults file has not.

    Verified current state (one correction to the issue's 2026-11-04 snapshot):

    The design pass must settle, in a record linked from this issue (the issue's §1–5 + open questions, restated as the packet):

    1. File format + contents, including the v1 scope decision (topic/secret only vs the full network set) and the equivalence property (file-built ≡ const-built effective defaults) with how it is tested.
    2. Replace vs append: granularity (one build flag vs per-list keys) and where the choice is recorded.
    3. Embedding mechanics — Drew's literal question (string embed + lazy parse vs build.rs codegen of typed consts vs include! vs const-format parsing) against compile-time validation, binary size/startup, Nix supply of the file, and the id-core-vs-root build.rs placement decision.
    4. Runtime composition: one documented cascade consistent with resolve_config (build-time defaults → serve-launch additive flags → --no-default-* skips), pair atomicity preserved.
    5. Provenance: how a binary reports its defaults' origin (consts / file + hash / replaced vs appended).
    6. Whether the JSON shape is shared with runtime config — decide, with reasons.

    Labels synced (per §9): kind/design already set; priority/normal, effort/l added.

    Routing: task 16801 completes as triaged. The design-pass enqueue under the canonical key dedupes against this task while claimed; the follow-on is enqueued immediately after completion and its task id recorded in an addendum below.

    Links: queue task 16801 · relates #4756, #5671, #5674, #5683 · epic #2056

  11. added
    priority/normalOrdinary priority (the default)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    on Nov 14, 2026
  12. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · addendum — design-pass follow-on enqueued

    • Agent: repo queue worker, lane any-c (repo-worker-code) · task 16801

    The design pass scoped in the triage note above is enqueued as queue task 16881 (revived under the canonical key after task 16801 completed). Its packet carries the full brief, including the corrected build.rs premise.

  13. added a commit that references this issue on Nov 14, 2026
  14. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    state: done (fixed_merged — design pass)
    task: 16881 (lane any-d, repo-worker-code)
    issue: #5916 — build-time defaults file for id network defaults

    Design record merged: PR #10346 (2026-11-14T18:53:06Z) adds doc/2026-11-14T19-05-00Z_design_id_build_defaults, settling all six packet questions: (1) JSON typed format + v1 contents (bootstrap, topic/secret pair, web_bindings, relay, gossip) with the equivalence property as a flag-matrix test; (2) replace/append as one in-file build-time mode; (3) embedding = include_str! + one serde parse behind LazyLock — answering Drew's question (yes, a string; codegen and const-parsing rejected with reasons), no new build.rs, Nix supplies the file as source; (4) one documented cascade, pair-atomic at every layer; (5) provenance = SHA-256 of the embedded string, reported at startup/version; (6) no shared shape with runtime config in v1 (serde types reusable later).

    The pass also corrected the record: a defaults mechanism already exists (defaults.conf in id-core, from #3447/#2145) — the design is a migration/hardening of it, and the audit found two live defects the implementation must close: D1 (topic/secret pair can mix sources in the default resolve path — a private topic can pair with the public secret) and D2 (--replace-defaults silently falls back to consts). Implementation follow-on filed as #10345 with the §8 brief and acceptance.

  15. added
    work/assignedQueue worker lifecycle state
    and removed on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepic/id-programReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this itemwork/assignedQueue worker lifecycle state

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions