Skip to content

id(chat-presence): HEARTBEAT_INTERVAL (25s) is defined and documented but never used — serve broadcasts presence on the 30s announcement cadence #4777

Closed

Description

@dezren39

Problem

pkgs/id documents a 25-second presence heartbeat cadence that nothing in the repo actually runs.

  • pkgs/id/src/chat_presence.rs:68 defines pub const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(25); with the doc: "How often a node broadcasts its presence heartbeat. Two to three heartbeats land inside one TTL window, so a single dropped gossip message never flickers a live node stale." (PRESENCE_TTL_SECS is 75, chat_presence.rs:64.)
  • A repo-wide search for HEARTBEAT_INTERVAL returns exactly one hit — the definition itself (verified this run two ways: a full-tree grep on the laptop checkout at origin/main c128305, and gh search code, which returns only pkgs/id/src/chat_presence.rs). The constant is never used.
  • The only presence broadcast in the codebase is in pkgs/id/src/commands/serve.rs (the PresenceHeartbeat::new + encode_frame broadcast at ~:1925/:1934), and it sits inside the peer-announcement task, whose timer is tokio::time::interval(ANNOUNCE_INTERVAL) (serve.rs:1878). ANNOUNCE_INTERVAL is 30 seconds (pkgs/id/crates/id-core/src/discovery.rs:317).

So the effective heartbeat cadence is the 30s announcement cadence, not the documented 25s. The resilience the doc relies on is thinner than stated: with a 75s TTL, a 25s cadence tolerates two consecutive dropped broadcasts before a live node flickers stale (stamps at 0/25/50/75s); at 30s only one drop is tolerated (stamps at 0/30/60s, then nothing until 90s, past the 75s expiry).

Why it matters

The constant is public (pub mod chat_presence, lib.rs:167) and reads as the contract for presence timing; the #2809 design band (TTL 75s inside 60–90s) was paired with this interval. Either the serving code should honour it, or the constant and its doc should stop promising a cadence the system does not have — a silent mismatch here is exactly the kind that later debugging trusts and loses time to.

Acceptance criteria

  • Presence heartbeats in id serve are broadcast on the documented cadence: either a dedicated timer driven by HEARTBEAT_INTERVAL in the gossip loop, or HEARTBEAT_INTERVAL is removed/redefined so the named cadence and the actual cadence are the same value from one source.
  • A test or assertion pins the wiring (e.g. the broadcast loop's interval equals HEARTBEAT_INTERVAL), so the constant cannot silently become dead again.
  • The doc comment on the interval and the TTL resilience claim match the shipped behaviour.

Found by new-issue-creator-code-b, 2026-11-03 run (read-verified at origin/main c128305).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 3, 2026
  2. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b run, 2026-11-03T06:31Z
    • Found via: filed this run
    • Task: Filed this issue — HEARTBEAT_INTERVAL (25s, chat_presence.rs:68) is never used; serve's only presence broadcast rides the 30s ANNOUNCE_INTERVAL loop (serve.rs:1878, discovery.rs:317), so the documented cadence/resilience does not hold.
    • Expectation: effort s — wire the broadcast to the documented interval (or align the constant/doc to one source) with a pinning test; done when the acceptance criteria on the issue hold.
    • Links: queue packet packet-4777-fix.json (repo-health-code-pilot)
  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 3, 2026
  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · correction

    • Agent: queue worker (repo-worker-code), lane code-k
    • Session / ID: task 6781
    • Correction: the test count I reported earlier for PR Fixes #4777: broadcast presence heartbeats on HEARTBEAT_INTERVAL #4778 ("65 passed") was wrong. The actual delivered output of cargo test --lib -- presence in pkgs/id was: 19 passed / 0 failed in the id lib test binary (including the new presence_heartbeat_period_is_the_documented_interval test and all chat_presence tests matching the filter) and 0 tests run in id_core. The conclusion is unchanged — all filtered tests passed — only the number was misstated. Sorry for the noise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions