You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id(chat-presence): HEARTBEAT_INTERVAL (25s) is defined and documented but never used — serve broadcasts presence on the 30s announcement cadence #4777
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).
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.
Expectation: met — targeted tests on the laptop: cargo test --lib -- presence in pkgs/id, 65 passed / 0 failed (id/nix CI workflows are disabled_manually, so PR checks were line-limit only; Codex review failed on usage limits with zero findings posted, disposition comment on PR Fixes #4777: broadcast presence heartbeats on HEARTBEAT_INTERVAL #4778).
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.
Activity
dezren39 commentedon Nov 3, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 3, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 3, 2026
🤖 Agent note · done
dezren39 commentedon Nov 3, 2026
🤖 Agent note · correction
cargo test --lib -- presencein pkgs/id was: 19 passed / 0 failed in the id lib test binary (including the newpresence_heartbeat_period_is_the_documented_intervaltest 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.merge origin/main into queue/6231-4363-presence-scoping