Skip to content

docs(adr): record decision on per-device envelopes (0001) - #689

Open
kosisochukwu1234 wants to merge 1 commit into
codebestia:devfrom
kosisochukwu1234:docs/adr-0001-per-device-envelopes
Open

kosisochukwu1234 wants to merge 1 commit into
codebestia:devfrom
kosisochukwu1234:docs/adr-0001-per-device-envelopes

Conversation

@kosisochukwu1234

Copy link
Copy Markdown

Summary

Records the architectural decision to store one message_envelopes row per recipient device rather than a single shared ciphertext per message in docs/adr/0001-per-device-envelopes.md.

Details Covered

  • Context & Motivation: Multi-device cryptographic isolation, Phase-1 sealed-box and Signal Double Ratchet compatibility, and self-sync requirements across sender sibling devices (Multi-device self-sync (sender's own other devices) #188, Migrate send_file_message and ask_assistant to ciphertext + envelopes #337).
  • Decision: Atomic transaction-bound persistence via insertMessageEnvelopes, sibling-device coverage checks (fetchSiblingDeviceIds, findMissingSiblingDeviceIds) in apps/backend/src/lib/messageFanout.ts, targeted realtime delivery (deliverMessage), and uniform fan-out shapes for server-authored messages (buildBroadcastEnvelopes).
  • Alternatives Considered & Rejected:
    • One shared conversation ciphertext with a static shared key.
    • User-level envelopes (encrypting only to the recipient user).
    • Dual-pipeline routing (shared ciphertext for file/bot messages vs envelopes for text).
  • Consequences & Operational Costs:
    • Linear database growth ($O(\text{messages} \times \text{devices})$) mitigated by the background cleanup job in apps/backend/src/services/envelopeGc.ts.
    • Sibling-device enforcement on send and edit, rejecting payloads missing sibling envelopes with device_set_mismatch.
  • Exception for MLS Groups: Notes that MLS group messages store a single ciphertext per epoch on messages without per-device envelopes, referencing the next ADRs (docs/adr/0006-mls-for-groups.md / docs/adr/0002-signal-dms-mls-groups.md).

Closes #641

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