Skip to main content

Module retention

Module retention 

Source
Expand description

Delivery-window retention (design: docs/mail4agent/messenger-model.md, “Server is a router”). The server is not an archive: a message event is only needed until every live device of every joined member has fetched it.

  • record_device_ack — a /sync?since=s<N> proves the device holds every event up to stream id N (additive table device_acks).
  • retention_report — how many message events a purge would drop.
  • purge_delivered_events — drops them. NOT scheduled anywhere: the owner decides when to switch it on (it changes what /rooms/{id}/messages can return, see the design doc).

Only non-state events of CLOSED rooms are ever touched: plaintext public channels live in pub_events (crate::public_channels) and are excluded here by construction and by predicate. Only non-state events are ever touched. State, keys, membership and to-device queues are untouched here.

Structs§

RetentionPolicy
Retention knobs.
RetentionReport
What a purge would do right now.

Constants§

PURGE_BATCH
Most events one purge pass removes (keeps the DB lock short).

Functions§

create_retention_schema
device_acks DDL. Called from init_messenger_db.
purge_delivered_events
Deletes eligible message events (and rows pointing at them). Returns how many events were removed.
record_device_ack
Records that device_id has received everything up to stream_id. Monotonic: an older token never moves the ack back.
retention_report
Counts message events and how many a purge would delete.