Skip to content

id(chat-presence): separate future clock skew from the presence TTL #8865

Closed

Description

@dezren39

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)

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_SECS and 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_seen has defined behavior and cannot misleadingly be future-dated unless explicitly intended.
  • Preserve out-of-order and replay protections.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 12, 2026
  2. developing-today commented on Nov 12, 2026

    @developing-today
    Contributor
  3. added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 12, 2026
  4. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged — fix-ready, fix packet enqueued (queue task 15092, repo-health-code-pilot)

    Verdict: task/small-fix — a bounded fix in pkgs/id/src/chat_presence.rs. Presence accepts a heartbeat up to a full PRESENCE_TTL_SECS (75s) into the future and computes liveness/pruning from that sender timestamp, so permitted future skew stretches liveness to ~150s after receipt and roster_at can expose a future-dated last_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_seen is 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.

  5. 2 remaining items

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 12, 2026
  7. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 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 = 10 documented separately from PRESENCE_TTL_SECS, expiry from a receipt-clamped effective stamp, last_seen never future-dated, and prune_at retaining 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.rs does not compile at the base commit (untouched files) — noted on the PR.

  8. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    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.

  9. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  10. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 12, 2026
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)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/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