Repository navigation
Description
Problem
Presence accepts a heartbeat timestamp up to a full PRESENCE_TTL_SECS into the future, then computes liveness and pruning from that sender-provided timestamp. A node whose clock is ahead can therefore remain reported live for nearly two TTLs after its heartbeat is received, despite the documented TTL describing how long a heartbeat keeps a node live.
Evidence (current main 12b3fb6b29914f9f675558ea3d9e27f13ca31487)
pkgs/id/src/chat_presence.rs:61-63sets the presence TTL to 75 seconds.PresenceTable::update_at(:277-280) accepts a heartbeat as far as 75 seconds in the future.liveness_atandprune_at(:330-335, 440-446) usenow.saturating_sub(heartbeat.ts) <= PRESENCE_TTL_SECS. Thus, with receiptnow=1000and acceptedts=1075, the node is live immediately and throughnow=1150: up to 150 seconds after receipt.roster_at(:384-398) uses the same age calculation for liveness and typing; it also exposes the sender's future timestamp aslast_seen(:390-393).- The tests reject
u64::MAX(:688-690) but do not cover the accepted future-skew boundary or expiry relative to receipt time. - The id(chat): presence heartbeat protocol over gossip (ephemeral, TTL-based) #2809 protocol contract specifies a 60–90 second TTL but does not define a future-clock-skew allowance. Reviewed 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 and Design: one guarded door — every gossip claim enters through its table (pkgs/id presence + peers) #4502 as adjacent presence work; neither tracks this timestamp/expiry behavior.
Why it matters
Clock skew—or a self-signed heartbeat with a future timestamp—can make an absent member appear online substantially longer than the advertised TTL. Future last_seen values and typing indicators can also mislead roster consumers.
Suggested fix
Define a future-skew allowance independently of the liveness TTL, and make the expiry contract explicit. Consider tracking local receipt time for presence expiry while retaining the signed sender timestamp only as metadata, or another policy that prevents permitted future skew from extending liveness beyond the documented bound. Apply the same rule consistently to liveness, typing, roster output, and pruning.
Acceptance criteria
- Document the maximum future-skew allowance separately from
PRESENCE_TTL_SECSand define whether expiry is measured from sender timestamp or local receipt. - Add boundary tests at the allowed skew and just beyond it.
- Test that an accepted future-dated heartbeat cannot keep liveness/typing past the documented bound from receipt; ensure
last_seenhas defined behavior and cannot misleadingly be future-dated unless explicitly intended. - Preserve out-of-order and replay protections.
Activity
developing-today commentedon Nov 12, 2026
CODE-2677
dezren39 commentedon Nov 12, 2026
🤖 Agent note · triaged
Verdict:
task/small-fix— a bounded fix inpkgs/id/src/chat_presence.rs. Presence accepts a heartbeat up to a fullPRESENCE_TTL_SECS(75s) into the future and computes liveness/pruning from that sender timestamp, so permitted future skew stretches liveness to ~150s after receipt androster_atcan expose a future-datedlast_seen.Priority:
priority/normal(stands) — per Drew's priorities brief line 5 (everything else by usefulness): this is a real correctness bug, but it does not stall the fleet (line 1 reserves the top band for fleet-stalling breakage) and it is not part of the ID design-track expedite set (line 2). Effort:effort/s(stands). Kind:kind/bug(already present).First concrete step: add a failing boundary test in the chat_presence tests — a heartbeat received at now=1000 with ts=1075 currently stays live through now=1150 — then define a future-skew allowance independent of
PRESENCE_TTL_SECS.Acceptance check for the fix: the skew allowance is documented separately from the TTL with an explicit expiry basis (sender timestamp vs local receipt); boundary tests pass at the allowed skew and just beyond it; an accepted future-dated heartbeat cannot keep liveness/typing past the documented bound from receipt and
last_seenis not misleadingly future-dated unless explicitly intended; out-of-order and replay protections preserved and existing chat_presence tests pass.Duplicate check: the issue records #4004/#4502 reviewed as adjacent presence work — neither tracks this timestamp/expiry behavior; no canonical duplicate. Queue check at triage: no live task for this issue in repo-health-code-pilot under any segment.
2 remaining items
fix(id): retain presence entries as replay watermarks until the sende…
dezren39 commentedon Nov 12, 2026
🤖 Agent note · parked (CI wait)
Done so far: PR #8881 (head d7619c5) implements the fix in
pkgs/id/src/chat_presence.rs:MAX_FUTURE_SKEW_SECS = 10documented separately fromPRESENCE_TTL_SECS, expiry from a receipt-clamped effective stamp,last_seennever future-dated, andprune_atretaining entries as replay watermarks until the sender stamp expires. Targeted tests:cargo test -p id --lib chat_presence— 23 passed (incl. 4 new #8865 tests). Codex review: first round P2 (replay-after-prune resurrection) fixed in d7619c5 and replied on the thread; re-review of the new head completed with no findings.Resume: read PR #8881 check state fresh; if green, merge (squash per repo practice) and complete task 15092 as fixed_merged; if a check fails, fix forward on branch
queue/15092-8865-presence-skew. Known unrelated blocker for a full-suite run:tests/probe_attestation_sign.rsdoes not compile at the base commit (untouched files) — noted on the PR.dezren39 commentedon Nov 12, 2026
state: parked (CI wait)
lane: code-d (task 15092, resumed from prior CI park)
pr: #8881 head d7619c5 — MERGEABLE, diff in scope (pkgs/id/src/chat_presence.rs only)
codex: re-review of head d7619c5 completed, has_unresolved_findings=false; round-1 P2 fixed and thread replied last shift
tests: cargo test -p id --lib chat_presence 23/23 (prior shift, laptop)
ci: original check set was CANCELLED en masse at 2026-11-12T08:06Z/08:48Z (fleet-wide cancellation event, tracked on #8866); the one FAILURE was the mcpx-test ci-ok aggregator over cancelled jobs. This shift re-ran the id workflow (run 43179052880); after a 5-minute poll it is still in_progress with no failures.
next: when PR #8881 checks complete green, merge PR #8881 and complete task 15092 as fixed_merged; issue #8865 closes via the PR.
fix(id): separate future clock skew from the presence TTL (#8865) (#8881
dezren39 commentedon Nov 12, 2026
🤖 Agent note · done