Skip to content

fix(id): scope received presence to group membership - #4541

Merged
dezren39 merged 4 commits into
mainfrom
queue/6231-4363-presence-scoping
Nov 3, 2026
Merged

dezren39 merged 4 commits into
mainfrom
queue/6231-4363-presence-scoping

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

received heartbeat
  verify signature (unchanged)
  fold the receiver's groups log
  update_scoped(sender ∈ each channel's member set)
  refuse receipt if the groups log cannot be opened or folded

The serve receipt path now applies the membership filter before storing presence. A channel with no receiver-side group fold is not trusted.

Evidence

  • Before: the receipt verified the signature, then stored the sender's complete channel claim with unscoped PresenceTable::update.
  • After: the regression test signs a heartbeat naming one member channel and one non-member channel; only the member channel is live/typing.
  • cargo test --manifest-path pkgs/id/Cargo.toml --lib received_presence_keeps_only_channels_the_sender_belongs_to — 1 passed.
  • cargo test --manifest-path pkgs/id/Cargo.toml --lib chat_presence — 10 passed.
  • cargo test --manifest-path pkgs/id/Cargo.toml --lib commands::serve — 29 passed.
  • git diff --check origin/main...HEAD — passed. cargo fmt --check is blocked by existing formatting drift across unrelated files (including unrelated serve.rs sections); no unrelated formatting was applied.

Merge Danger

Door: Two-way — reverting restores the old receipt behavior.

Blast Radius: Medium — presence heartbeats for channels absent from or unreadable in the receiver's groups log are now dropped; signature verification is unchanged.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 19:05
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cefc3022-39bf-40f7-b872-e914f0bbb426
Commits

Reviewing files that changed from the base of the PR and between 3c52ac4 and adf06d5.

Files selected for processing: 1
  • pkgs/id/src/commands/serve.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T08:00:38.679660Z
We couldn’t complete this review. Comment @codex review to try again.
adf06d5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cddfaeb186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return false;
}
};
let projection = match log.projection() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cache the group projection outside the gossip receive hot path

With a large group history or frequent presence traffic, every authenticated heartbeat now synchronously reads and parses the entire groups log and rebuilds its projection. GroupLog::projection folds all recorded events, and this runs directly in the same run_gossip_loop receive task that processes peer-discovery announcements, delaying those announcements and potentially causing receiver lag. Even empty-channel heartbeats and expired signed replays incur this work because freshness is checked only later in PresenceTable::update_at. Cache the projection with invalidation when the log changes, and perform cheap heartbeat rejection before loading membership state.

Useful? React with 👍 / 👎.

Resolve serve.rs conflicts: keep #4363 receipt-side membership scoping
(receive_presence_heartbeat via update_scoped) alongside main's web-feature
guard and presence_heartbeat_period (#4777).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant