Skip to content

feat(core): expand protocol metadata and shared primitives - #1060

Merged
jlucaso1 merged 7 commits into
mainfrom
agent/core-api-and-protocol-improvements
Jul 21, 2026
Merged

feat(core): expand protocol metadata and shared primitives#1060
jlucaso1 merged 7 commits into
mainfrom
agent/core-api-and-protocol-improvements

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • preserve typed group identity, participant, versioning, suspension, appeal, safety, history, labeling, notification, community, and business-hours metadata without collapsing absent protocol state
  • expand group and community operations with current and legacy participating responses, linked subgroup creation and removal, subgroup metadata, and per-participant promote/demote outcomes
  • expose durable pairwise-session and sender-key operations, session inspection and namespace migration outcomes, batched linked-identifier mappings, and supplied pre-key bundle installation
  • expose signed pre-key rotation, digest validation, server-pool checks, and caller-sized pre-key refreshes while preserving the configured background replenishment size
  • reuse adapters, random state, cache handles, event-owned values, key derivation, and fixed-size output buffers across batch and multi-action paths
  • expose authenticated event-response and poll-vote payloads before schema decoding while keeping authentication and key derivation centralized
  • avoid monotonic clock reads for non-expiring caches and serialize message timestamps as Unix seconds

Why

The group parser previously discarded protocol metadata already present on the wire, used a non-canonical participant alias in group-info responses, and collapsed absent, empty, and explicit-zero states. Community and participant mutations also omitted useful response data and legacy envelopes still used by compatible servers.

Session and sender-key operations were spread across internal call paths. The shared facade now reuses the existing stores, locks, cache, and durability gates. Supplied bundles resolve to the active identifier namespace, failed migration flushes remain retryable, and sender-key deletion is serialized and durable without flushing unrelated cached state.

Pre-key lifecycle operations now share the established single-flight and retry behavior. Explicit refresh counts remain stable across retries, are protocol-bounded, and do not mutate the client's normal replenishment policy.

Cryptographic extraction and expansion setup was repeated across several features. A shared API keeps construction consistent, lets fixed-size callers write directly into final buffers, validates secret sizes before ciphertext processing, and rejects invalid SHA-256 expansion lengths before allocation.

API and compatibility notes

  • Breaking: GroupMetadata and GroupInfoResponse replace ephemeral_expiration / ephemeral_trigger with ephemeral: Option so absence and explicit zero remain distinguishable.
  • Breaking: group promote/demote methods now return each participant's server result instead of discarding it.
  • Breaking: BusinessHoursConfig::open_time and close_time are now Option so always-open and unspecified schedules are not represented as midnight.
  • Breaking serialization change: MessageInfo::timestamp is emitted as integer Unix seconds; the adapter is serialization-only because MessageInfo has no deserialization contract.
  • Group metadata now preserves bounded versioning/settings fields and stores uncommon participant details behind an optional allocation; short labels and aliases use compact strings.
  • Community creation delegates to the canonical group path, while subgroup creation, parent participation, metadata, and linked removal are additive.
  • SignalSessionInfo, SignalSessionMigration, durable sender-key/pre-key operations, explicit signed-key rotation, participant fanout, and batched linked-identifier insertion are additive.
  • Session migration accepts only matching namespace families, reports session and identity outcomes separately, skips no-op flushes, and retries pending durability after transient failures.
  • Additive GroupUpdate scalar fields retain builder defaults so existing builder calls remain source-compatible.

Validation

  • cargo fmt --all --check
  • cargo clippy -p whatsapp-rust -p wacore -p wacore-binary --lib -- -D warnings
  • cargo test -p wacore --lib — 1,155 passed, 1 ignored
  • cargo test -p whatsapp-rust --lib — 1,055 passed, 1 ignored
  • CI: full build/test, all-feature lint, E2E, stable compatibility, release build, format, and Clippy jobs passed
  • CodSpeed: core, protocol, integration, and performance-analysis checks passed
  • binary-size workflow passed with the approved size-increase policy: stripped +34.28 KiB (+0.35%), .text +33.75 KiB (+0.43%), dependency count unchanged; signal implementation text decreased by 4.72 KiB
  • all actionable review threads resolved

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jlucaso1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 956dd21a-400e-4071-bdde-57b011bbfe62

📥 Commits

Reviewing files that changed from the base of the PR and between 234228e and 4e49880.

📒 Files selected for processing (37)
  • src/client.rs
  • src/client/lid_pn.rs
  • src/client/lifecycle.rs
  • src/client/sessions.rs
  • src/client/voip.rs
  • src/features/community.rs
  • src/features/contacts.rs
  • src/features/groups.rs
  • src/features/mex.rs
  • src/features/mod.rs
  • src/features/rotate_key.rs
  • src/features/signal.rs
  • src/handlers/notification/groups.rs
  • src/keepalive.rs
  • src/lib.rs
  • src/lid_pn_cache.rs
  • src/message.rs
  • src/message/special.rs
  • src/prekeys.rs
  • src/request.rs
  • src/retry.rs
  • tests/e2e/tests/groups.rs
  • wacore/binary/src/attrs.rs
  • wacore/libsignal/src/protocol/local_field.rs
  • wacore/libsignal/src/protocol/sender_keys.rs
  • wacore/libsignal/src/protocol/state/session.rs
  • wacore/src/crypto.rs
  • wacore/src/event.rs
  • wacore/src/iq/business.rs
  • wacore/src/iq/contacts.rs
  • wacore/src/iq/groups.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/store/signal_cache.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
📝 Walkthrough

Walkthrough

This PR adds shared cryptographic helpers, expands group, community, prekey, and Signal APIs, separates payload decryption from decoding, updates cache and serialization contracts, strengthens IQ and migration handling, and revises notification propagation, tests, and documentation.

Changes

Protocol and API updates

Layer / File(s) Summary
Shared cryptography and protocol contracts
wacore/src/crypto.rs, wacore/src/{bot_message,download,media_retry,pair,pair_code,secret_enc_addon,shortcake}.rs, wacore/src/voip/*, wacore/libsignal/src/protocol/*
Adds shared MD5, HKDF-SHA256, and Curve25519 helpers, routes existing derivations through them, and centralizes protocol field constants.
Group and community APIs
wacore/src/{iq,stanza}/groups.rs, src/features/{groups,community}.rs, wacore/src/types/events.rs, tests/e2e/tests/groups.rs
Expands group metadata and wire parsing, adds community subgroup operations, linked-group participant actions, richer notifications, and updated ephemeral settings.
Signal, migration, and durability flows
src/features/signal.rs, src/client/{lid_pn,sessions}.rs, wacore/src/store/signal_cache.rs, src/message/special.rs, src/retry.rs
Adds Signal inspection and migration APIs, durable sender-key handling, cached prekey installation, pending distribution retention, and migration-intent tracking.
IQ, prekey, and operational APIs
src/{prekeys,request}.rs, src/features/{rotate_key,contacts}.rs, wacore/src/iq/contacts.rs, src/client/{lifecycle,sessions,voip}.rs
Adds count-aware prekey refresh, generation-aware IQ waiters, signed-prekey failure propagation, profile-picture timeouts, and reusable VoIP rejection.
Payload, cache, and serialization behavior
wacore/src/{event,poll}.rs, src/portable_cache.rs, wacore/src/{time,types/message,iq/business}.rs, wacore/binary/src/attrs.rs
Separates payload decryption from decoding, adds sentinel cache timestamps, preserves absent values, distinguishes optional booleans, and serializes message timestamps as seconds.

Estimated code review effort: 5 (Critical) | ~90 minutes

Possibly related PRs

Suggested labels: breaking-change, api-design

Suggested reviewers: greptile-apps, cubic-dev-ai, ari4ka

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: expanding protocol metadata and shared primitives.
Description check ✅ Passed The description is strongly aligned with the changeset and covers the main protocol, API, and compatibility updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/core-api-and-protocol-improvements

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

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR expands protocol metadata and shared client operations across the core library. The main changes are:

  • Preserves richer group, community, participant, and business-hours metadata.
  • Adds group, community, Signal session, sender-key, and pre-key operations.
  • Reuses shared crypto, cache, adapter, and random-state primitives.
  • Improves migration durability, cache behavior, and timestamp serialization.

Confidence Score: 5/5

This looks safe to merge.

  • The timestamp change now affects serialization only.
  • MessageInfo does not expose a Serde deserialization contract.
  • The added test verifies integer Unix-second output.

Important Files Changed

Filename Overview
wacore/src/types/message.rs Serializes message timestamps as Unix seconds with a serialization-only adapter that matches the type's supported contract.

Reviews (13): Last reviewed commit: "feat(core): expose session and group pro..." | Re-trigger Greptile

Comment thread wacore/src/types/message.rs Outdated
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

📦 Binary size report

Metric main PR Δ
bin size (stripped) 9.59 MiB 9.62 MiB +33.22 KiB (+0.34%) 🔺
bin .text 7.66 MiB 7.69 MiB +32.50 KiB (+0.41%) 🚨
bin allocated (text+data+bss) 9.58 MiB 9.61 MiB +32.16 KiB (+0.33%) 🔺
llvm-lines wacore 472,424 478,624 +6,200 (+1.31%) ⚠️
llvm-lines wacore copies 15,733 15,824 +91 (+0.58%) 🔺
llvm-lines whatsapp-rust lib 667,018 674,459 +7,441 (+1.12%) ⚠️
llvm-lines whatsapp-rust lib copies 21,399 21,677 +278 (+1.30%) ⚠️
deps crates (Cargo.lock) 470 470 0
.text per crate
Crate main PR Δ
.text whatsapp_rust 1.68 MiB 1.69 MiB +14.30 KiB (+0.83%) 🔺
.text wacore 579.11 KiB 596.04 KiB +16.94 KiB (+2.92%) ⚠️
.text wacore_binary 86.70 KiB 87.04 KiB +345 B (+0.39%) 🔺
.text wacore_libsignal 165.54 KiB 160.82 KiB -4.72 KiB (-2.85%) 🎉
.text wacore_appstate 22.36 KiB 22.36 KiB 0
.text wacore_noise 22.54 KiB 22.54 KiB 0
.text waproto 1.74 MiB 1.74 MiB 0
.text whatsapp_rust_sqlite_storage 510.12 KiB 510.12 KiB 0
.text whatsapp_rust_tokio_transport 39.84 KiB 39.84 KiB 0
.text whatsapp_rust_ureq_http_client 10.28 KiB 10.28 KiB 0
.text std 947.80 KiB 949.54 KiB +1.74 KiB (+0.18%) 🔺
.text other deps 1.88 MiB 1.88 MiB +3.93 KiB (+0.20%) 🔺
Top movers (cargo-bloat attribution)
Crate main PR Δ
wacore 579.11 KiB 596.04 KiB +16.94 KiB (+2.92%)
whatsapp_rust 1.68 MiB 1.69 MiB +14.30 KiB (+0.83%)
wacore_libsignal 165.54 KiB 160.82 KiB -4.72 KiB (-2.85%)
metrics_exporter_prometheus (absent) 3.96 KiB +3.96 KiB
std 947.80 KiB 949.54 KiB +1.74 KiB (+0.18%)

🚨 Per-PR size budget exceeded (Δ stripped ≤ 64.00 KiB, Δ .text ≤ 32.00 KiB):

  • bin .text: +32.50 KiB (+0.41%) exceeds the 32.00 KiB per-PR budget

The size-increase-ok label is set, so the gate is not enforced for this PR.

Baseline: ffed9e8da (latest main run) · Head: 7319a6f0d · Graphs

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
wacore/src/types/events.rs (1)

1386-1412: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Consider #[serde(default)] on the new action_index: u32.

Every other new field here (notification_id, participant_username, participant_country_code) is Option<T>, which serde defaults to None on a missing key automatically. action_index is the one non-optional addition with no default — if GroupUpdate derives Deserialize and anything persists/replays serialized event payloads across a version bump, an older blob lacking this field will hard-fail deserialization instead of degrading gracefully.

Given this crate's pre-1.0 stance on breaking API changes, this isn't a blocker, but a one-line #[serde(default)] buys resilience for free.

🛡️ Proposed fix
     /// Zero-based emitted-action index within the source notification.
+    #[serde(default)]
     pub action_index: u32,

Based on learnings from a prior PR review noting this crate is pre-1.0 (0.6.0) and breaking public API changes don't require a compatibility shim under the crate's versioning policy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wacore/src/types/events.rs` around lines 1386 - 1412, Add #[serde(default)]
to the action_index field in GroupUpdate so deserialization of older serialized
payloads missing this field falls back to 0. Leave the existing optional fields
and other GroupUpdate behavior unchanged.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/portable_cache.rs`:
- Around line 236-247: Retain the optimized entry_time behavior for non-expiring
caches, using Instant::ZERO instead of reading the monotonic clock. Add
production monitoring for cache hit rates and capacity-based evictions, and
expose the metrics needed to tune max_capacity across deployments.

In `@wacore/src/crypto.rs`:
- Around line 19-62: Remove the redundant documentation comments above
md5_digest, hkdf_sha256, hkdf_sha256_into, generate_curve_key_pair, and
calculate_curve_signature, or replace them with concise rationale explaining
non-obvious constraints or design decisions; do not restate behavior already
clear from the function names and signatures.

In `@wacore/src/poll.rs`:
- Around line 264-280: Enforce the required message_secret length in
decrypt_poll_vote_payload_with_secret before calling decrypt_addon, matching the
existing event-response validation and failing immediately for invalid lengths.
Reuse the established constant and ensure! pattern rather than adding a
different validation path.

---

Outside diff comments:
In `@wacore/src/types/events.rs`:
- Around line 1386-1412: Add #[serde(default)] to the action_index field in
GroupUpdate so deserialization of older serialized payloads missing this field
falls back to 0. Leave the existing optional fields and other GroupUpdate
behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b76ee408-368b-472d-8e3d-5deb58786a2c

📥 Commits

Reviewing files that changed from the base of the PR and between ffed9e8 and d67c11d.

📒 Files selected for processing (31)
  • src/bot.rs
  • src/features/chat_actions.rs
  • src/features/groups.rs
  • src/features/mod.rs
  • src/handlers/notification/groups.rs
  • src/lib.rs
  • src/portable_cache.rs
  • src/prekeys.rs
  • src/send/mod.rs
  • tests/e2e/tests/groups.rs
  • wacore/src/bot_message.rs
  • wacore/src/crypto.rs
  • wacore/src/download.rs
  • wacore/src/event.rs
  • wacore/src/iq/groups.rs
  • wacore/src/lib.rs
  • wacore/src/media_retry.rs
  • wacore/src/pair.rs
  • wacore/src/pair_code.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/send/group.rs
  • wacore/src/send/tests.rs
  • wacore/src/shortcake.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/store/device.rs
  • wacore/src/time.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
  • wacore/src/voip/mod.rs
  • wacore/src/voip/ssrc.rs

Comment thread src/portable_cache.rs
Comment thread wacore/src/crypto.rs Outdated
Comment thread wacore/src/poll.rs
@jlucaso1

Copy link
Copy Markdown
Collaborator Author

Review follow-up: the outside-diff suggestion for GroupUpdate::action_index was verified and intentionally not applied. GroupUpdate derives Serialize only and is an emitted event type, so #[serde(default)] would not protect any deserialization or replay path. All actionable inline findings have been addressed or resolved.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/client/lid_pn.rs`:
- Around line 849-862: Update migrate_signal_sessions_on_lid_discovery around
migrate_signal_sessions: retain outcome.has_state_changes() solely for deciding
whether to flush signal_cache, but return a narrower outcome flag representing
sessions actually moved into LID so decrypt retry is not triggered when only
identities are discarded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e1efea18-b8a0-47ba-8606-6c2852313077

📥 Commits

Reviewing files that changed from the base of the PR and between d67c11d and 70140c0.

📒 Files selected for processing (19)
  • src/client/lid_pn.rs
  • src/client/sessions.rs
  • src/features/groups.rs
  • src/features/mod.rs
  • src/features/signal.rs
  • src/handlers/notification/groups.rs
  • src/lib.rs
  • src/message.rs
  • src/message/special.rs
  • src/retry.rs
  • tests/e2e/tests/groups.rs
  • wacore/src/crypto.rs
  • wacore/src/event.rs
  • wacore/src/iq/groups.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
💤 Files with no reviewable changes (1)
  • src/message.rs

Comment thread src/client/lid_pn.rs
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 70140c0 to 982687f Compare July 21, 2026 00:56

@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: 982687f65c

ℹ️ 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".

Comment thread src/features/signal.rs Outdated
Comment thread wacore/src/iq/groups.rs Outdated
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 982687f to 0b32f46 Compare July 21, 2026 01:14

@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: 0b32f463b0

ℹ️ 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".

Comment thread wacore/src/types/events.rs
Comment thread src/features/signal.rs
Comment thread src/features/signal.rs
Comment thread wacore/src/iq/groups.rs Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/signal.rs`:
- Around line 222-236: Update delete_sender_key to acquire the same sender-key
chain lock used by sender_key_distribution,
process_sender_key_distribution_cached, encrypt_group_message, and
decrypt_group_message before deleting and flushing the cache. Hold that lock
across both the deletion and flush, preserving the existing durable-return
behavior and error propagation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 75227d89-1039-4427-a40a-6ce5fdf62dde

📥 Commits

Reviewing files that changed from the base of the PR and between 982687f and 0b32f46.

📒 Files selected for processing (19)
  • src/client/lid_pn.rs
  • src/client/sessions.rs
  • src/features/groups.rs
  • src/features/mod.rs
  • src/features/signal.rs
  • src/handlers/notification/groups.rs
  • src/lib.rs
  • src/message.rs
  • src/message/special.rs
  • src/retry.rs
  • tests/e2e/tests/groups.rs
  • wacore/src/crypto.rs
  • wacore/src/event.rs
  • wacore/src/iq/groups.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
💤 Files with no reviewable changes (1)
  • src/message.rs

Comment thread src/features/signal.rs
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 0b32f46 to 9f95c84 Compare July 21, 2026 02:07

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/prekeys.rs (1)

773-775: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Prevent integer overflow in the backoff loop.

Look, if a device stays offline for a day, this Fibonacci sequence is going to integer-overflow u64 and panic. We can't have our clients crashing just because they can't reach the server. Use saturating_add so it maxes out safely.

🛡️ Proposed fix
-                    let next = delay_a + delay_b;
+                    let next = delay_a.saturating_add(delay_b);
                     delay_a = delay_b;
                     delay_b = next;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/prekeys.rs` around lines 773 - 775, Update the Fibonacci backoff
calculation in the loop around delay_a and delay_b to use u64::saturating_add
instead of ordinary addition, preserving the existing sequence while capping at
the maximum value without panicking.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/groups.rs`:
- Around line 628-669: Update the ParticipantRemovalScope::LinkedGroups branch
in apply_participant_removals to avoid clearing the entire group cache;
invalidate only the parent group identified by jid and any known linked
subgroups available through existing group-cache metadata, while preserving
persisted metadata invalidation for each affected group.

In `@src/prekeys.rs`:
- Around line 746-750: Move the tracing::instrument annotations from the outer
pre-key upload wrappers into the inner _with_count methods, and annotate the new
public upload entry points as well so both implicit and explicit count flows
retain spans. In the loop around the result match, remove the wanted-based
branching and call the unified upload method directly, preserving existing
result handling.

In `@wacore/src/secret_enc_addon.rs`:
- Around line 99-105: Replace the manual length-check branch in the
message-secret validation function with anyhow::ensure!, preserving the existing
MESSAGE_SECRET_SIZE condition and error message while removing the explicit if
and Err return.

---

Outside diff comments:
In `@src/prekeys.rs`:
- Around line 773-775: Update the Fibonacci backoff calculation in the loop
around delay_a and delay_b to use u64::saturating_add instead of ordinary
addition, preserving the existing sequence while capping at the maximum value
without panicking.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ab2934fc-6618-47e7-96e0-f56d0c64d26d

📥 Commits

Reviewing files that changed from the base of the PR and between 0b32f46 and 9f95c84.

📒 Files selected for processing (25)
  • src/client/lid_pn.rs
  • src/client/sessions.rs
  • src/features/community.rs
  • src/features/groups.rs
  • src/features/mod.rs
  • src/features/rotate_key.rs
  • src/features/signal.rs
  • src/handlers/notification/groups.rs
  • src/lib.rs
  • src/message.rs
  • src/message/special.rs
  • src/prekeys.rs
  • src/retry.rs
  • tests/e2e/tests/groups.rs
  • wacore/binary/src/attrs.rs
  • wacore/src/crypto.rs
  • wacore/src/event.rs
  • wacore/src/iq/business.rs
  • wacore/src/iq/groups.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/store/signal_cache.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
💤 Files with no reviewable changes (1)
  • src/message.rs

Comment thread src/features/groups.rs
Comment thread src/prekeys.rs Outdated
Comment thread wacore/src/secret_enc_addon.rs Outdated

@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: 9f95c841d0

ℹ️ 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".

Comment thread src/features/groups.rs
Comment thread wacore/src/iq/groups.rs Outdated
Comment thread src/features/rotate_key.rs
Comment thread src/features/community.rs
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 9f95c84 to 8f52281 Compare July 21, 2026 02:32

@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: 8f522817dd

ℹ️ 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".

Comment thread src/client/lid_pn.rs Outdated
Comment thread wacore/src/iq/groups.rs Outdated
Comment thread wacore/src/iq/groups.rs Outdated
@jlucaso1 jlucaso1 added the size-increase-ok Accepted binary-size increase: downgrades the per-PR size gate to a warning label Jul 21, 2026
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 8f52281 to fdb207c Compare July 21, 2026 02:42

@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

// Resolve PN→LID to use the correct Signal session (matches send path)
let encryption_jid = self.client.resolve_encryption_jid(jid).await;
let signal_addr = encryption_jid.to_protocol_address();

P2 Badge Migrate legacy sessions before resolving to LID

When a PN→LID mapping is cached but the valid session still exists only in the PN namespace—the lazy-migration state explicitly supported after startup—this resolves the peer to LID and immediately asks libsignal to encrypt with a nonexistent LID session. decrypt_message, session_info, and validate_session follow the same resolution-only path, while the internal receive pipeline calls try_pn_to_lid_migration_decrypt; migrate or fall back to the PN session before performing these facade operations.


drop(_chain_guard);
self.client.persist_signal_state_pre_wire().await?;
Ok((skdm_bytes, ciphertext.into_serialized().into_vec()))

P1 Badge Preserve the SKDM across a failed durability gate

When the first encryption for a group creates a sender key but persist_signal_state_pre_wire fails, this returns an error without exposing the newly created SKDM while leaving the sender key in the cache. A retry then observes key_exists == true, returns skdm_bytes == None, and produces ciphertext under a key that no participant ever received, so subsequent group messages remain undecryptable until the chain is explicitly rotated or deleted. Keep the distribution pending across this failure or roll back the newly created sender-key state.

ℹ️ 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".

Comment thread wacore/src/iq/groups.rs
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from fdb207c to 00af6fb Compare July 21, 2026 02:53
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from cabd62b to 234228e Compare July 21, 2026 04:42
@jlucaso1

Copy link
Copy Markdown
Collaborator Author

Additional API review in 234228e: call rejection can now be driven from explicit signaling identifiers while preserving the outer routing peer separately from the action call creator, including companion-device signaling. The generated reachout-timelock MEX operation is also exposed as a typed query using its generated name/document constants; null data or account state now returns a payload error, matching the captured client behavior instead of silently producing an absent result. Local validation passed with 1,060 library tests (1 ignored), the focused call-control and MEX regressions, tracing-enabled Clippy with warnings denied, formatting, and diff checks.

@jlucaso1

Copy link
Copy Markdown
Collaborator Author

@codex review

@jlucaso1

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/keepalive.rs (1)

30-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a dedicated test for DuplicateRequestIdFatalFailure.

Every other IqError variant here has its own test_classify_* case; this new arm should, too.

🧪 Proposed test addition
+    #[test]
+    fn test_classify_duplicate_request_id_is_fatal() {
+        assert_eq!(
+            classify_keepalive_error(&IqError::DuplicateRequestId("dup".to_string())),
+            KeepaliveResult::FatalFailure,
+        );
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/keepalive.rs` around lines 30 - 47, Add a dedicated unit test for
classify_keepalive_error that constructs an IqError::DuplicateRequestId value
and asserts it returns KeepaliveResult::FatalFailure, matching the existing
test_classify_* naming and structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/keepalive.rs`:
- Around line 30-47: Add a dedicated unit test for classify_keepalive_error that
constructs an IqError::DuplicateRequestId value and asserts it returns
KeepaliveResult::FatalFailure, matching the existing test_classify_* naming and
structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 56236d2c-cc1c-4f3c-94d3-7d13ecd8bc09

📥 Commits

Reviewing files that changed from the base of the PR and between f3a4b17 and cabd62b.

📒 Files selected for processing (35)
  • src/client.rs
  • src/client/lid_pn.rs
  • src/client/lifecycle.rs
  • src/client/sessions.rs
  • src/features/community.rs
  • src/features/contacts.rs
  • src/features/groups.rs
  • src/features/mod.rs
  • src/features/rotate_key.rs
  • src/features/signal.rs
  • src/handlers/notification/groups.rs
  • src/keepalive.rs
  • src/lib.rs
  • src/lid_pn_cache.rs
  • src/message.rs
  • src/message/special.rs
  • src/prekeys.rs
  • src/request.rs
  • src/retry.rs
  • tests/e2e/tests/groups.rs
  • wacore/binary/src/attrs.rs
  • wacore/libsignal/src/protocol/local_field.rs
  • wacore/libsignal/src/protocol/sender_keys.rs
  • wacore/libsignal/src/protocol/state/session.rs
  • wacore/src/crypto.rs
  • wacore/src/event.rs
  • wacore/src/iq/business.rs
  • wacore/src/iq/contacts.rs
  • wacore/src/iq/groups.rs
  • wacore/src/poll.rs
  • wacore/src/secret_enc_addon.rs
  • wacore/src/stanza/groups.rs
  • wacore/src/store/signal_cache.rs
  • wacore/src/types/events.rs
  • wacore/src/types/message.rs
💤 Files with no reviewable changes (1)
  • src/message.rs

@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: 234228e77e

ℹ️ 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".

Comment thread src/client/lifecycle.rs Outdated
Comment thread wacore/src/store/signal_cache.rs
@jlucaso1
jlucaso1 force-pushed the agent/core-api-and-protocol-improvements branch from 234228e to 4e49880 Compare July 21, 2026 05:00
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jlucaso1

Copy link
Copy Markdown
Collaborator Author

Final review follow-up in 4e49880: disconnect cleanup now preserves response-waiter generations across drained maps, durable sender-key deletion keeps only the target chain locked during backend I/O, and DuplicateRequestId keepalive classification has dedicated coverage. The explicit call-rejection regression now inspects the full outgoing stanza and proves the routing peer remains distinct from call-creator. Validation passed with 1,156 wacore tests and 1,062 whatsapp-rust tests (one ignored in each suite), plus all-target/all-feature Clippy with warnings denied, formatting, and diff checks.

@jlucaso1

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@jlucaso1

Copy link
Copy Markdown
Collaborator Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 4e49880638

ℹ️ 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".

@jlucaso1
jlucaso1 merged commit cd29cef into main Jul 21, 2026
16 checks passed
@jlucaso1
jlucaso1 deleted the agent/core-api-and-protocol-improvements branch July 21, 2026 05:09
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

api-design breaking-change size-increase-ok Accepted binary-size increase: downgrades the per-PR size gate to a warning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant