Repository navigation
Description
Finding
PR #4160's PresenceTable capacity eviction selects its victim by effective stamp only. That defeats the replay watermark the table's own pruning path maintains: a future-stamped heartbeat that is evicted once its effective stamp ages past the TTL — while its sender stamp still passes the freshness bound — can be replayed and re-inserted with a later effective stamp, resurrecting the node past its receipt-based expiry. prune_at was explicitly written not to do this (#8865); the eviction path added by #4160 was not given the same guard.
Worked timeline (current main, pkgs/id/crates/id-cli/src/chat_presence.rs; PRESENCE_TTL_SECS = 75 at :110, MAX_FUTURE_SKEW_SECS = 10 at :124):
- At receipt time
T, a heartbeat stampedT+10(inside the skew allowance) is accepted; its effective stamp is clamped toT(:395). - At
T+76, the entry is expired by effective stamp (76 > 75), so at capacity it is the eviction candidate (:406-424, filter at :409). Its sender stamp is only 66s old, soprune_atwould have retained it as a replay watermark (:556-571, retain rule at :569). - The evicted entry is gone, so a replay of the same heartbeat at
T+76passes the freshness bound (:356: age 66 ≤ 75), finds no existing entry to pin the effective stamp (:396-400 applies only when an entry exists), and is re-inserted with effective stampmin(T+10, T+76) = T+10. - The node now reads Live until
T+85— 10s (one full skew allowance) past the documented bound: "no claim can outliveeffective_ts + PRESENCE_TTL_SECS— at most one TTL from receipt — no matter when copies of it arrive" (:335-337).
Evidence
- PR: fix(id): bound PresenceTable with stale-only eviction #4160 fix(id): bound PresenceTable with stale-only eviction #4160 (MERGED, head
6b99c3a175d2eb603efd73fdf7bbbeda3e47efbf, mergeccdfacd24537f74b851e6ecef978bb9c945d728c, confirmed ancestor of main, compare behind=0) - Verified on main
ef16105eebb6d865960cde9f6bc1094b355000ee,pkgs/id/crates/id-cli/src/chat_presence.rs: eviction filter :406-424 (effective stamp only);prune_atwatermark rationale :556-571; freshness bound :356-360; effective-stamp pinning for existing entries :395-400; invariant statement :335-337. - fix(id): bound PresenceTable with stale-only eviction #4160's own tests (
node_count_bound_evicts_oldest_expired_entry_at_capacity, now at :1230) use a past-stamped victim (age 80 at eviction) whose replay would fail the freshness bound anyway — the future-stamped victim case is not covered. - Dedupe: all-state searches for
PresenceTable eviction,presence eviction replay, andPresenceTablereturned only 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 (the bound request, CLOSED by fix(id): bound PresenceTable with stale-only eviction #4160), fix(id): bound PresenceTable with stale-only eviction #4160 itself, and the Design: one guarded door — every gossip claim enters through its table (pkgs/id presence + peers) #4502 design umbrella — none covers eviction-vs-watermark interaction. Source-traced from the three code sites above; no runtime repro (the window needs a full 1,000-entry table plus a replay inside the skew-extended window).
Why it matters
The effective-stamp machinery (#8865) exists precisely so replayed gossip cannot extend a node's claimed liveness past one TTL from receipt. The capacity bound (#4004) exists for the adversarial case — a flood of minted keys filling the table. Combined, an attacker who can fill the table can force eviction of a future-stamped victim and then replay that victim's captured heartbeat to keep it "live" past its receipt-based expiry, in skew-sized increments of table churn. Narrow (≤10s per cycle, needs a full table), but it silently breaks a stated invariant in exactly the adversarial conditions both mechanisms were built for.
Acceptance criteria
- Capacity eviction never removes an entry whose sender stamp still passes the freshness bound (the
prune_atwatermark rule), OR a replayed heartbeat can never gain a later effective stamp than its first acceptance earned — one of the two, with the invariant at :335-337 holding under both prune and eviction. - A regression test mirrors the timeline above: fill the table, insert a future-stamped (within skew) heartbeat, advance past effective-stamp expiry but not sender-stamp expiry, force a capacity admission, replay the heartbeat, and assert the node does not read Live past its original
effective_ts + PRESENCE_TTL_SECS. - Existing presence tests still pass, including
node_count_bound_*and the id(chat-presence): separate future clock skew from the presence TTL #8865 replay/skew tests.
Filed by pr-diff-review-b (Lane B PR diff review, run 2026-11-13 09:18 CST) from review of PR #4160.
Activity
developing-today commentedon Nov 13, 2026
CODE-3176
dezren39 commentedon Nov 13, 2026
agent-note:v1
Agent: pr-diff-review-b
State: filed
Repo: developing-today/code
Source PR: #4160 (#4160, merged ccdfacd)
Finding: PresenceTable capacity eviction (chat_presence.rs:406-424 on main) picks its victim by effective_ts only, so a future-stamped heartbeat evicted after effective expiry — while its sender stamp still passes freshness — can be replayed and re-inserted with a later effective stamp, living until original effective+85s instead of +75s, breaking the :335-337 invariant; prune_at (:556-571) explicitly retains such entries as replay watermarks (#8865), eviction does not.
Verified against main: ef16105 (contents reads of chat_presence.rs; PR merge confirmed ancestor, compare behind=0)
Evidence: hidden_files/pr-review-b-2026-11-13-0918/issue-presence-eviction-body.md + diff-4160.patch
dezren39 commentedon Nov 13, 2026
🤖 Agent note · picked up + triaged inline — Agent: queue worker (repo-worker-code), lane code-a — task 16122 (triage) for issue #9579.
Fresh revalidation (2026-11-13T16:28Z): issue #9579 OPEN, no held / user/owned / do-not-merge / do-not-auto-edit labels; PR #4160 MERGED (merge ccdfacd) and ancestor of main per the packet evidence. No competing PR found in the packet or issue state.
Triage (inline, per the lane runbook): work kind small-fix (task/small-fix replaces task/triage) — the defect is one guarded branch in the
update_ateviction path inpkgs/id/crates/id-cli/src/chat_presence.rs, plus one regression test. Priority low stands (narrow window: ≤10s per cycle, needs a full 1,000-entry table plus a replay inside the skew window — but it breaks a stated #8865 invariant under the adversarial flood conditions #4004's bound addresses). Effort s stands. kind/bug already present.First concrete step: mirror
prune_at's watermark rule in the capacity-eviction victim filter — never evict an entry whose sender stamp still passes the freshness bound at the eviction instant; fall back to the existing expired-by-effective-stamp victim only among watermark-safe entries, and if none qualifies, keep the current no-eviction behavior for that admission.Acceptance check: the issue's regression timeline as a test (full table + future-stamped heartbeat + advance past effective-but-not-sender expiry + capacity admission + replay → node does not read Live past original effective_ts + PRESENCE_TTL_SECS), and all existing chat_presence tests pass, including node_count_bound_* and the #8865 replay/skew tests.
Continuing to the fix in this same claim.
Merge pull request #9584 from developing-today/queue/16122-9579-prese…
dezren39 commentedon Nov 13, 2026
🤖 Agent note · done — Agent: queue worker (repo-worker-code), lane code-a — task 16122 (triage → small-fix, fixed in the same claim) for issue #9579.
PR #9584 MERGED at 2026-11-13T16:36:20Z, merge commit 6d6d7e8; issue #9579 CLOSED by the merge; fix commit 2c0b332 verified as an ancestor of origin/main.
What changed (
pkgs/id/crates/id-cli/src/chat_presence.rsonly): the capacity-eviction victim filter now requires the sender stamp to also be pastPRESENCE_TTL_SECS— exactly theprune_atreplay-watermark rule (#8865) — so an entry whose sender stamp still passes the freshness bound is never evicted, and a capacity admission with no watermark-safe victim is refused. Doc comments at the bound bullet and the eviction site state the rule.Tests (laptop, fleet-build-lock): new regression
node_count_bound_never_evicts_a_watermark_live_entry_9579mirrors the issue timeline and passes (it discriminates: on the old filter the admission evicts the victim and the replay reads Live one skew allowance past the receipt-based bound); chat_presence 27/27; full id-cli crate 671 + 7 + 7 passed, 0 failed;cargo fmt --checkclean. Codex review on PR #9584 failed to run (Codex usage limits, fleet-wide) and produced no findings; CodeRabbit completed NEUTRAL with no findings.dezren39 commentedon Nov 13, 2026
🤖 Agent note · done (already_done) — Agent: queue worker (repo-worker-code), lane code-a — task 16137 (small_fix follow-on of triage task 16122) for issue #9579.
This follow-on packet was created at task 16122's completion, but the fix had already landed inside that same claim: PR #9584 MERGED 2026-11-13T16:36:20Z (merge commit 6d6d7e8) and issue #9579 is CLOSED. Fresh verification this claim: issue state CLOSED; fix commit 2c0b332 is an ancestor of origin/main; the regression test
node_count_bound_never_evicts_a_watermark_live_entry_9579is present inchat_presence.rson origin/main. No duplicate work performed.