Skip to content

Design: one guarded door — every gossip claim enters through its table (pkgs/id presence + peers) #4502

Closed
6 of 6 issues completed

Description

@dezren39

Design doc: files/designs/code-id-gossip-admission.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main 381fecb60 — every defect below re-verified present at the cited sites this pass (2026-11-02); chat_presence.rs md5 at audit HEAD matches the md5 in the origins' laptop probes.

Summary

pkgs/id's gossip plane carries two kinds of self-signed claim — presence heartbeats (chat_presence.rs, #2809) and peer announcements (crates/id-core/src/discovery.rs) — and each kind is supposed to be admitted through a table whose guards canonicalise and bound it. The discovery module states the principle outright (on PeerDiscovery::update): the freshness and ordering checks live in the table "so every caller gets them (the serve.rs receive loop needs no trust logic of its own)". Presence never got the same treatment, and even discovery has one caller that bypasses its table. Five filings are one defect with five addresses:

The contract

A gossip claim is stored only in the form its table's guards produce — canonical, scoped, and bounded — and every ingest path, constructor, receiver, and one-shot collector alike, enters through those guards. There is no second door.

Recorded decisions (full reasoning, alternatives and risks in the design doc):

  1. Lists are sets, capped by distinct count, canonicalised once at admission — one canonicalisation step shared by PresenceHeartbeat::new and PresenceTable::update_at: deduplicate first-seen, apply the membership filter (receipt path), then cap at MAX_HEARTBEAT_CHANNELS. typing is deduplicated after filtering to the stored channels, making it a true subset: typing.len() ≤ channels.len() ≤ 64 for every stored heartbeat, however it arrived. A stored heartbeat never contains duplicates in either list. (Pins the shared-helper shape neither origin fixed — two private copies of the rule are how the paths diverged.)
  2. The presence table is bounded exactly as the discovery table is — MAX_PRESENCE_NODES = 1_000, named beside MAX_HEARTBEAT_CHANNELS / PRESENCE_TTL_SECS, aligned with MAX_PEERS. At capacity a new node is admitted only by evicting an entry already past its TTL (oldest such, ties by key bytes — mirroring PeerDiscovery::update); if every entry is fresh, the new node is refused; an existing node always refreshes (subject to the ordering guard). This pins id(chat-presence): PresenceTable has no node-count bound — every distinct self-signed key is stored for a full TTL, so minted keys grow serve's memory without limit #4004's open eviction choice: not refuse-all-new (dead entries would lock out legitimate nodes for a full TTL), not evict-soonest-expiring (a flood could churn live entries out early); stale-only eviction means fresh minted keys displace nothing still live.
  3. Membership scoping is wired, not documented away — id(chat-presence): receipt never scopes heartbeats to sender membership — update_scoped has no production caller, serve stores channels unscoped #4363 offers two endings (wire update_scoped, or correct the doc); this design records wire it: the doc states the intended id(chat): presence heartbeat protocol over gossip (ephemeral, TTL-based) #2809 property, the read side already implements its half, and presence becomes load-bearing the moment the chat layer names channels — wiring receipt after that leaves a window where rosters are read from an unscoped table everyone believes is scoped. The predicate is backed by the receiver's own group fold for the channel (GroupView member set — serve already folds group logs in its group-warnings path); a channel the receiver holds no fold for scopes to empty (membership the receiver cannot see cannot be confirmed). run_gossip_loop gaining the membership source/predicate as a parameter is part of the phase. Sender side unchanged — serve's own heartbeat still names no channels, which is precisely why the wiring lands now.
  4. No side doors: a collector uses the table, not a raw map — discover_via_gossip collects through a temporary PeerDiscovery and reads back its non-stale peers. id(peers): --gossip collection bypasses the announcement freshness/ordering guards — replayed, ancient and far-future announcements are reported as discovered peers #4377 leaves the shape open ("or a shared helper it uses"); this design pins through the table — re-implementing freshness/ordering in peers.rs creates the second copy whose divergence is this design's subject (the collector's hand-rolled MAX_PEERS guard at peers.rs:460–462 copied the capacity rule and missed the other two). With both sources freshness-checked, the cmd_peers merge order stops mattering for correctness.
  5. The unscoped door is dispositioned, not left ambient — PresenceTable::update remains only if the closing audit names a production caller that legitimately needs the transport view; otherwise it is removed or made crate-private in the audit phase. A public unscoped admission path beside the scoped one is how id(chat-presence): receipt never scopes heartbeats to sender membership — update_scoped has no production caller, serve stores channels unscoped #4363 happened.

Phased breakdown

Phases adopt the five filed origins as sub-issues (no parallels); Phase 5 is a new closing-audit issue, gated on Phases 1–4.

Open questions (in the design doc, not filed)

Whether decode_frame itself should refuse oversize frames or the gossip layer's bound suffices once stored form is bounded (Phase 5 dispositions the layering); the sender-side mirror rule when the chat layer starts naming channels (that layer's own design question); a hypothetical third gossip claim kind enters through this contract, no phase filed for it.

Related

Design doc (full problem/evidence/alternatives/risks): files/designs/code-id-gossip-admission.md (goal workspace). Origins: #4404, #3991, #4004, #4363, #4377. Siblings, not duplicates: #2898 / #4000 (reconstruction is admission — the journal restore gate; this is the gossip receipt gate), #2944 (discovery table authentication/bounds — its landed MAX_PEERS rule is decision 2's embodiment), #1552 (closed — the serve announcement guards #4377's collector bypasses).

Filed by the design architect (pass 39, 2026-11-02): design issue for the pkgs/id gossip-admission contract — the pass-38 standing candidate, originated on its recorded trigger (#4404, the fourth presence/receipt filing). The five origin issues are adopted as its phases — triage of each origin should record the phase structure and the decisions above rather than re-filing or re-scoping. Phase 5's closing audit is filed separately and gated on Phases 1–4.

Acceptance criteria

  • The design records, on this issue or a linked doc: the single guarded entry point every gossip claim passes through, the table it enters, and the invariants the guard enforces.
  • Migration path for existing gossip claim sites in pkgs/id presence (and any sibling callers) is enumerated.
  • A linked implementation issue (or native sub-issues per protocol section 11) exists before this design is treated as done — a design with no implementation link is not finished work.

Activity

  1. added
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    epicMeta-issue grouping multiple items (org Project Type=Epic)
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Design architect, pass 39 (2026-11-02): this issue is the design of record for the pkgs/id gossip-admission contract. The five origin issues are adopted as its phases and linked as sub-issues: Phase 1 = #4404 + #3991 (canonical lists at admission), Phase 2 = #4004 (bounded table), Phase 3 = #4363 (scoped receipt in serve), Phase 4 = #4377 (peers collector through its table), Phase 5 = #4503 (closing gossip-ingest inventory + contract statement, gated on Phases 1–4, status/blocked).

    The five recorded decisions are in the issue body and the design doc (files/designs/code-id-gossip-admission.md, goal workspace). This design is the pass-38 standing candidate originated on its recorded trigger: #4404 was the fourth presence/receipt filing. Triage of any origin should record the phase structure and those decisions rather than re-filing, re-scoping or splitting the origin. Register entry added to files/potential-projects.md (status: proposed). No user/review: every origin carries explicit acceptance with verified probes, and the open rulings (shared canonicalisation, the MAX_PRESENCE_NODES eviction policy, wiring scoping over doc correction, collector-through-the-table) are the architect's recorded decisions in the doc.

  3. added
    priority/normalOrdinary priority (the default)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 2, 2026
  4. 46 remaining items

  5. added
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 8, 2026
  6. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: blocked
    task: 12692 (repo-health-code-pilot; worker repo-worker-code; lane 9aca43b4-5439-4939-9f71-323f5d32521b)
    by: openchamber-scheduled-lane
    at: 2026-11-08T11:24:15Z
    reason_class: packet_defect
    blocker: task title, body, acceptance, and test requirement define triage of #4502, but payload.kind is small_fix and dedupe_key is repo-health:v1:fix:developing-today/code:issue:4502. The task cannot be safely executed as written; no code or worktree changes made.
    verified: #4502 and #4004 remain OPEN; PR #4160 is OPEN and Drew-authored, untouched; Phase 5 issue #4503 remains OPEN and its work is already routed/parked. Labels now reflect blocked state.
    resume: correct/re-enqueue the packet with consistent kind, dedupe key, and acceptance before retry.

  7. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    Phase 5 closing audit — task 13859 (2026-11-12, current origin/main d7ad9d05ef)

    Gate: all five origins are CLOSED: #4404, #3991, #4004, #4363, #4377. #4004 closed with PR #4160 MERGED. Its latest visible checks include failures in parity, pm-stack tests, and mcpx-test unit/e2e; this audit records the merged state and does not claim those checks are green.

    Contract and production ingress inventory

    The admission statement is now in pkgs/id/src/chat_presence.rs (module docs, lines 12–42); PeerDiscovery::update cross-references it in pkgs/id/crates/id-core/src/discovery.rs:473–481.

    Production path Decode / ingest Disposition
    Serve presence receiver commands/serve.rs:2640 calls chat_presence::decode_frame; receive_presence_heartbeat verifies signature, folds the receiver's groups, then calls PresenceTable::update_scoped (serve.rs:2479–2519, 2506) Through the presence table's freshness, ordering, membership, canonical-list, and node-cap guards.
    Serve peer-announcement receiver serve.rs:2651–2658 calls SignedPeerAnnouncement::decode_frame, then PeerDiscovery::update Through the signed, size-capped peer frame decoder (peer_announcement.rs:13, 54–71) and the table's freshness, ordering, name, and count guards (id-core/discovery.rs:473–505).
    id peers --gossip collector commands/peers.rs:583–681, decoder at 660, admission at 662–668/686–721 Through the same PeerDiscovery::update guards, with a separate --max-peers cap.
    Local/remote RPC and recursive crawl query_local_peers 322–346, query_remote_peers 432–469, crawl_peers 475 onward Deliberately a separate trust surface, not gossip ingestion: results are read from the selected server, never inserted into the local PeerDiscovery table, and are used only for this CLI output. read_capped_response, offer_peer, and merge_capped bound the response/output. Combined mode merges RPC before gossip; offer_peer keeps the row with the newer advertised timestamp, so stale gossip cannot replace a fresher RPC row. This is presentation freshness, not authentication—an RPC peer can report a false future timestamp, which can win the ephemeral output.
    Other decode_frame definitions in pkgs/id id-events/event_store/range.rs:555 (event range-sync) and id-worlds/world/replication.rs:629 (replication envelope) Non-gossip sync protocols; neither decodes a gossip claim or writes the gossip discovery/presence tables. No additional production gossip decoder caller was found outside serve and commands/peers.

    Required dispositions

    1. PresenceTable::update: no production callers existed (the only production receipt was already update_scoped). Removed the unscoped public entry point; deterministic tests continue through update_at.
    2. RPC crawl/list paths: deliberately unguarded as described above; they do not admit gossip claims into local state. The combined merge is timestamp-aware for display, but not a provenance/authentication guarantee.
    3. Other decode_frame callers: the two non-gossip protocol decoders above are outside the gossip admission contract; no other production gossip callers exist outside serve and peers.
    4. Frame-size bound: owned by the gossip transport. pkgs/id/Cargo.lock pins iroh-gossip 0.101.0; both gossip claim paths use Gossip::builder().spawn without a custom config. That version's default Config::max_message_size is 4096 bytes. Presence decode_frame has no second local cap; the module doc records that dependency and requires a matching decoder cap if transport configuration changes. Therefore the frame is bounded today; no unowned/unbounded layer or follow-up was found.

    Evidence and verification

    • git diff --check — pass.
    • cargo check --lib through ~/tools/fleet-build-lock did not complete within the 10-minute command window while other fleet builds held the build slots; no compiler result is claimed.
    • cargo fmt --manifest-path pkgs/id/Cargo.toml --all -- --check reported formatting diffs across many untouched files (including existing lines in chat_presence.rs); no mass formatting was applied.
    • Source-only audit; no other behavior changed. The only behavior/API disposition is removal of the unused unscoped PresenceTable::update entry point.
  8. added and removed
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    on Nov 13, 2026
  9. 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) 15225 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.

  10. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Agent note — task 15225 re-triage: epic complete, closing #4502 (lane any-b)

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-insepicMeta-issue grouping multiple items (org Project Type=Epic)epic/id-programReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobstatus/donestatus/triagedTriaged and routed (see agent note)task/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions