From 5db8d08bf7c5e2a46bf4714f596145d15820fffa Mon Sep 17 00:00:00 2001 From: mxandreas Date: Mon, 23 Nov 2026 15:10:55 +0200 Subject: [PATCH] Fix the description of the `allowed_lifetime_min` retention option (#20520) The config documentation said `allowed_lifetime_min` bounds a room's `min_lifetime`. It actually sets the minimum allowed value for `max_lifetime`: purge jobs raise a room's `max_lifetime` to `allowed_lifetime_min` when it is lower (`synapse/handlers/pagination.py`), and `synapse/rest/client/retention.py` reports both `allowed_lifetime_*` options as bounds on `max_lifetime`. `docs/message_retention_policies.md` already describes this correctly. --- changelog.d/20520.doc | 1 + docs/message_retention_policies.md | 20 ++++--------- .../configuration/config_documentation.md | 7 ++--- schema/synapse-config.schema.yaml | 29 ++++++++----------- 4 files changed, 20 insertions(+), 37 deletions(-) create mode 100644 changelog.d/20520.doc diff --git a/changelog.d/20520.doc b/changelog.d/20520.doc new file mode 100644 index 0000000000..7da201671f --- /dev/null +++ b/changelog.d/20520.doc @@ -0,0 +1 @@ +Fix the documentation of the `allowed_lifetime_min` and `allowed_lifetime_max` retention options, and remove the `min_lifetime` retention option, which Synapse doesn't act on, from the documentation. diff --git a/docs/message_retention_policies.md b/docs/message_retention_policies.md index 01f67c952a..92b33cddf8 100644 --- a/docs/message_retention_policies.md +++ b/docs/message_retention_policies.md @@ -18,13 +18,6 @@ it was sent to the room. If a room doesn't have a message retention policy, and there's no default one for a given server, then no message sent in that room is ever purged on that server. -MSC1763 also specifies semantics for a `min_lifetime` parameter which -defines the amount of time after which an event _can_ get purged (after -it was sent to the room), but Synapse doesn't currently support it -beyond registering it. - -Both `max_lifetime` and `min_lifetime` are optional parameters. - Note that message retention policies don't apply to state events. Once an event reaches its expiry date (defined as the time it was sent @@ -72,14 +65,13 @@ the configuration file and adding these sub-options: ```yaml default_policy: - min_lifetime: 1d max_lifetime: 1y ``` -Here, `min_lifetime` and `max_lifetime` have the same meaning and level -of support as previously described. They can be expressed either as a -duration (using the units `s` (seconds), `m` (minutes), `h` (hours), -`d` (days), `w` (weeks) and `y` (years)) or as a number of milliseconds. +Here, `max_lifetime` has the same meaning as previously described. It +can be expressed either as a duration (using the units `s` (seconds), +`m` (minutes), `h` (hours), `d` (days), `w` (weeks) and `y` (years)) or +as a number of milliseconds. ### Purge jobs @@ -185,9 +177,7 @@ moderator needs to send a state event in that room with the type In this event's content, the `max_lifetime` parameter has the same meaning as previously described, and needs to be expressed in -milliseconds. The event's content can also include a `min_lifetime` -parameter, which has the same meaning and limited support as previously -described. +milliseconds. Note that over every server in the room, only the ones with support for message retention policies will actually remove expired events. This diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 675f29b9e1..2f45425ce5 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -1169,13 +1169,11 @@ This setting has the following sub-options: This setting has the following sub-options: - * `min_lifetime`: Minimum message retention time of the default message retention policy. Synapse doesn't take this option into account yet. Defaults to `null`. - * `max_lifetime`: Maximum message retention time of the default message retention policy. Defaults to `null`. -* `allowed_lifetime_min`: Retention policy limit. If set, and the state of a room contains a `m.room.retention` event in its state which contains a `min_lifetime` that's beyond this bound, Synapse will cap the room's policy to these limits when running purge jobs. Defaults to `null`. +* `allowed_lifetime_min`: Retention policy limit: the minimum allowed value for `max_lifetime`. If set, and the `max_lifetime` that applies to a room is below this bound, Synapse will use this value instead when running purge jobs. This applies both to a room's explicit retention policy (its `m.room.retention` state event) and to the default policy used when the room has none. Defaults to `null`. -* `allowed_lifetime_max`: Retention policy limit. If set, and the state of a room contains a `m.room.retention` event in its state which contains a `max_lifetime` that's beyond this bound, Synapse will cap the room's policy to these limits when running purge jobs. Defaults to `null`. +* `allowed_lifetime_max`: Retention policy limit: the maximum allowed value for `max_lifetime`. If set, and the `max_lifetime` that applies to a room is above this bound, Synapse will use this value instead when running purge jobs. This applies both to a room's explicit retention policy (its `m.room.retention` state event) and to the default policy used when the room has none. Defaults to `null`. * `purge_jobs` (array|null): Server admins can define the settings of the background jobs purging the events whose lifetime has expired under the `purge_jobs` section. @@ -1202,7 +1200,6 @@ Example configuration: retention: enabled: true default_policy: - min_lifetime: 1d max_lifetime: 1y allowed_lifetime_min: 1d allowed_lifetime_max: 1y diff --git a/schema/synapse-config.schema.yaml b/schema/synapse-config.schema.yaml index 5765586956..c868280e36 100644 --- a/schema/synapse-config.schema.yaml +++ b/schema/synapse-config.schema.yaml @@ -1418,14 +1418,6 @@ properties: Default message retention policy. If set, Synapse will apply it to rooms that lack the `m.room.retention` state event. properties: - min_lifetime: - oneOf: - - $ref: "#/$defs/duration" - - type: "null" - description: >- - Minimum message retention time of the default message retention - policy. Synapse doesn't take this option into account yet. - default: null max_lifetime: oneOf: - $ref: "#/$defs/duration" @@ -1438,20 +1430,24 @@ properties: - $ref: "#/$defs/duration" - type: "null" description: >- - Retention policy limit. If set, and the state of a room contains a - `m.room.retention` event in its state which contains a `min_lifetime` - that's beyond this bound, Synapse will cap the room's policy to these - limits when running purge jobs. + Retention policy limit: the minimum allowed value for `max_lifetime`. + If set, and the `max_lifetime` that applies to a room is below this + bound, Synapse will use this value instead when running purge jobs. + This applies both to a room's explicit retention policy (its + `m.room.retention` state event) and to the default policy used when + the room has none. default: null allowed_lifetime_max: oneOf: - $ref: "#/$defs/duration" - type: "null" description: >- - Retention policy limit. If set, and the state of a room contains a - `m.room.retention` event in its state which contains a `max_lifetime` - that's beyond this bound, Synapse will cap the room's policy to these - limits when running purge jobs. + Retention policy limit: the maximum allowed value for `max_lifetime`. + If set, and the `max_lifetime` that applies to a room is above this + bound, Synapse will use this value instead when running purge jobs. + This applies both to a room's explicit retention policy (its + `m.room.retention` state event) and to the default policy used when + the room has none. default: null purge_jobs: type: ["array", "null"] @@ -1518,7 +1514,6 @@ properties: examples: - enabled: true default_policy: - min_lifetime: 1d max_lifetime: 1y allowed_lifetime_min: 1d allowed_lifetime_max: 1y