Skip to content

feat(whatsapp-store): store whatsmeow state encrypted in Postgres - #8537

Merged
404Wolf merged 1 commit into
mainfrom
wolf/wa-5-store
Oct 27, 2026
Merged

404Wolf merged 1 commit into
mainfrom
wolf/wa-5-store

Conversation

@404Wolf

@404Wolf 404Wolf commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

A linked device's Signal sessions, identity keys, pre-keys and app state
are as sensitive as the account itself, and whichever session-service
replica holds an account's lease must be able to pick it up after another
releases it. They belong in Postgres, encrypted per account and fenced
by the lease.

What

  • crates/whatsapp_store_pg: implements every whatsmeow::store trait for
    one account. Each value is sealed with AES-256-GCM under a per-account
    data key wrapped by KMS (associated data = account | store | key); every
    write checks the account's lease_epoch. The threat model is the crate
    doc comment in src/lib.rs. A fake KMS (fake-kms feature) backs tests.
  • Migration 20261027062649_whatsapp_store: device, store values,
    pre-keys, app-state MACs, privacy tokens, event buffer and outgoing
    events, all cascading from whatsapp_linked_account (layer 4).
  • SQLx cache entries; regenerated workspace-hack and closures.

Stack

WhatsApp linked devices, one layer per PR. Merge bottom-up; each PR is based on the one below it, so its diff is only its own layer. Layers 1-9 are wolf/whatsmeow-rs as of the split; layers 10-16 are the later work on that branch, regrouped by topic. The audit fixes are folded into the layers that own the code they fix. The schema is three migrations in its final shape: layer 4's 20261027061310_whatsapp_linked and 20261027061311_validate_entity_whatsapp_group_type, and layer 5's 20261027062649_whatsapp_store; no later layer adds a migration.

  1. feat(whatsmeow): port the whatsmeow linked-device client to Rust #8527 whatsmeow client port (merged)
  2. feat(whatsmeow-signal): implement whatsmeow's Signal protocol with libsignal #8534 Signal protocol + fake server (merged)
  3. feat(auth): record whether a user credential is a Macro API JWT #8535 API-JWT credential origin
  4. feat(whatsapp): add WhatsApp group entities and the linked-account API #8536 WhatsApp group entity + DSS API
  5. feat(whatsapp-store): store whatsmeow state encrypted in Postgres #8537 encrypted Postgres store ← this PR
  6. feat(whatsapp-session): run linked WhatsApp accounts in a session service #8538 session service + infra
  7. feat(sdk): add WhatsApp linked groups to the SDK #8539 SDK
  8. feat(web): link WhatsApp accounts and open shared WhatsApp groups #8540 web + desktop
  9. test(whatsapp): run the linked-device fleet end to end and document it #8541 end-to-end tests + docs
  10. feat(whatsmeow): trace connects, IQs and messages without leaking JIDs #8724 whatsmeow telemetry + error redaction
  11. feat(whatsapp): own groups personally, follow WhatsApp, push changes #8725 personal groups, live refresh, push, share by mention, NOTIFY traces
  12. feat(whatsapp): open WhatsApp groups in External as channel chats #8726 web: groups as channel conversations in External
  13. feat(whatsapp): list every chat, import history and fix sender identity #8727 sender identity, chat list, history import
  14. feat(whatsapp): import and render every WhatsApp message type #8728 every message type
  15. feat(whatsapp): add disappearing, community and direct chats to Macro #8729 disappearing, community and direct chats
  16. feat(whatsapp): list members in the side panel, wait quietly to import #8853 side-panel members, quiet waits to import

Previous: #8536 · Next: #8538

@404Wolf
404Wolf requested a review from a team as a code owner October 22, 2026 16:23
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
Walkthrough

[!WARNING]
Review details and warnings were omitted to fit the comment limit.

Priority: Normal

Merge Risk: Moderate · previous review 42249

Several issues should be fixed before merging. A full inbound event backlog can stall WhatsApp message processing for an account. API tokens can change who can see a group. The migration could block access to the shared entity table while it validates a constraint. Account or group deletion can fail when send history exists.

Pre-merge checks: Passed 4
Check name Status Explanation
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.
Title check Passed The title "feat(whatsapp-store): store whatsmeow state encrypted in Postgres" uses a conventional commits prefix and is 65 characters, under the 72-character limit. It matches the main change: the new…
Description check Passed The description explains the why (linked-device Signal sessions and app state are sensitive and must move with the lease), the what (the whatsapp_store_pg crate, AES-256-GCM sealing with KMS-wrapped p…
Full details: Title check

Explanation

The title "feat(whatsapp-store): store whatsmeow state encrypted in Postgres" uses a conventional commits prefix and is 65 characters, under the 72-character limit. It matches the main change: the new crates/whatsapp_store_pg crate persists whatsmeow store state in Postgres, encrypted per account and fenced by lease epoch.

Full details: Description check

Explanation

The description explains the why (linked-device Signal sessions and app state are sensitive and must move with the lease), the what (the whatsapp_store_pg crate, AES-256-GCM sealing with KMS-wrapped per-account keys, lease_epoch write checks, the fake-kms feature, and the store migration), and the stack of dependent PRs. It is directly related to the changeset.

✨ Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch wolf/wa-5-store
  • 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

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

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 22, 2026 17:16
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 22, 2026 18:24
@404Wolf
404Wolf force-pushed the wolf/wa-5-store branch 3 times, most recently from e55c04d to ae0171a Compare October 22, 2026 20:23
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 22, 2026 21:01
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 22, 2026 23:15
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 22, 2026 23:57
@404Wolf
404Wolf force-pushed the wolf/wa-4-group-entity branch from 0a5d1c5 to 6e490b4 Compare October 23, 2026 19:48
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 23, 2026 19:48
@404Wolf 404Wolf closed this Oct 23, 2026
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 24, 2026 05:11
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 26, 2026 16:17
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 26, 2026 17:45
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 26, 2026 19:45
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 26, 2026 21:11
@404Wolf
404Wolf force-pushed the wolf/wa-4-group-entity branch from 3465e7e to d935a2a Compare October 27, 2026 01:10
@404Wolf
404Wolf force-pushed the wolf/wa-5-store branch 2 times, most recently from 0c9895a to dc3858e Compare October 27, 2026 09:34
@404Wolf
404Wolf force-pushed the wolf/wa-4-group-entity branch from d935a2a to 2e278e1 Compare October 27, 2026 09:34
@404Wolf 404Wolf changed the title feat(whatsapp-store): store whatsmeow device state in Postgres, encrypted per account feat(whatsapp-store): store whatsmeow state encrypted in Postgres Oct 27, 2026
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 27, 2026 09:35
@404Wolf 404Wolf closed this Oct 27, 2026
@404Wolf 404Wolf reopened this Oct 27, 2026
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 27, 2026 10:41
@404Wolf
404Wolf force-pushed the wolf/wa-4-group-entity branch from 2e278e1 to e027528 Compare October 27, 2026 10:45
@404Wolf
404Wolf changed the base branch from wolf/wa-4-group-entity to main October 27, 2026 10:47
@404Wolf
404Wolf changed the base branch from main to wolf/wa-4-group-entity October 27, 2026 10:47
Base automatically changed from wolf/wa-4-group-entity to main October 27, 2026 11:19
Why:

A linked device's Signal sessions, identity keys, pre-keys and app state
are as sensitive as the account itself, and whichever session-service
replica holds an account's lease must be able to pick it up after another
releases it. They belong in Postgres, encrypted per account and fenced
by the lease.

What:

- `crates/whatsapp_store_pg`: implements every `whatsmeow::store` trait for
  one account. Each value is sealed with AES-256-GCM under a per-account
  data key wrapped by KMS (associated data = account | store | key); every
  write checks the account's `lease_epoch`. The threat model is the crate
  doc comment in `src/lib.rs`. A fake KMS (`fake-kms` feature) backs tests.
- Migration `20261027062649_whatsapp_store`: device, store values,
  pre-keys, app-state MACs, privacy tokens, event buffer and outgoing
  events, all cascading from `whatsapp_linked_account` (layer 4).
- SQLx cache entries; regenerated `workspace-hack` and closures.
@404Wolf
404Wolf merged commit caea779 into main Oct 27, 2026
35 checks passed
@404Wolf
404Wolf deleted the wolf/wa-5-store branch October 27, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant