From 45440197defab29b6ff408b3e5a7a51d49de7972 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 1 Jun 2022 15:02:31 +0100 Subject: [PATCH 01/15] Better description of the mainline of a PL event. --- content/rooms/fragments/v2-state-res.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index e666d7f8c..cd73e2ade 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -82,10 +82,15 @@ selecting, among all the candidate vertices, the smallest vertex using the above comparison relation. **Mainline ordering.** -Given an `m.room.power_levels` event *P*, the *mainline of* *P* is the -list of events generated by starting with *P* and recursively taking the -`m.room.power_levels` events from the `auth_events`, ordered such that -*P* is last. Given another event *e*, the *closest mainline event to* +Let *P* = *P*0 be an `m.room.power_levels` event. +Starting with *i* = 0, repeatedly fetch *P**i*+1, the +`m.room.power_levels` event in the `auth_events` of *Pi*. +Increment *i* and repeat until *Pi* has no `m.room.power_levels` +event in its `auth_events`. +The *mainline of P*0 is the list of events + [*P*n , ... , *P*1, *P*0]. + +Given another event *e*, the *closest mainline event to* *e* is the first event encountered in the mainline when iteratively descending through the `m.room.power_levels` events in the `auth_events` starting at *e*. If no mainline event is encountered when iteratively From e2d8cfcfd7755def5f328448776aa391ff173c00 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 1 Jun 2022 15:25:43 +0100 Subject: [PATCH 02/15] Opinionated: improve def of the closest event to e ``iteratively descending through the `m.room.power_levels` events in the `auth_events`-starting at *e*.`` was also unclear to me. Unfortunately this is now more symbol-dense and I'm not sure if it's a net improvement. --- content/rooms/fragments/v2-state-res.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index cd73e2ade..b2e94fea5 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -90,11 +90,13 @@ event in its `auth_events`. The *mainline of P*0 is the list of events [*P*n , ... , *P*1, *P*0]. -Given another event *e*, the *closest mainline event to* -*e* is the first event encountered in the mainline when iteratively -descending through the `m.room.power_levels` events in the `auth_events` -starting at *e*. If no mainline event is encountered when iteratively -descending through the `m.room.power_levels` events, then the closest +Given another event *e* = *e0* we can compute a similar list of +`m.room.power_level` events + [*e*0, *e*1, ...], +where *e*j* + 1* is the `m.room.power_levels` event in the +`auth_events` of *ej*. The *closest mainline event to e* +is the first event *ej* which belongs to the mainline of *P*. +If no event *ej* belongs to the mainline of *P*, then the closest mainline event to *e* can be considered to be a dummy event that is before any other event in the mainline of *P* for the purposes of condition 1 below. From 8d6e32815c5a6b94d179431784e3afccf2a3f081 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 1 Jun 2022 15:53:39 +0100 Subject: [PATCH 03/15] Changelog --- changelogs/room_versions/newsfragments/1107.clarification | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/room_versions/newsfragments/1107.clarification diff --git a/changelogs/room_versions/newsfragments/1107.clarification b/changelogs/room_versions/newsfragments/1107.clarification new file mode 100644 index 000000000..50e36c129 --- /dev/null +++ b/changelogs/room_versions/newsfragments/1107.clarification @@ -0,0 +1 @@ +More explicitly define the mainline of a power event and the mainline ordering of other events. From 91da0e186bdcdc86a109bf648f55515ecdf73f60 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 6 Jun 2022 12:50:51 +0100 Subject: [PATCH 04/15] correct spelling of `power_levels` Co-authored-by: Denis Kasak --- content/rooms/fragments/v2-state-res.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index b2e94fea5..d130c1497 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -91,7 +91,7 @@ The *mainline of P*0 is the list of events [*P*n , ... , *P*1, *P*0]. Given another event *e* = *e0* we can compute a similar list of -`m.room.power_level` events +`m.room.power_levels` events [*e*0, *e*1, ...], where *e*j* + 1* is the `m.room.power_levels` event in the `auth_events` of *ej*. The *closest mainline event to e* From c2d55eed84b4cae3880099397fca0644a5ed2d88 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 6 Jun 2022 13:48:13 +0100 Subject: [PATCH 05/15] Rework the mainline ordering more dramatically. This has undergone a fairly large rework, so needs careful inspection. --- content/rooms/fragments/v2-state-res.md | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index d130c1497..f470e4bdd 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -88,28 +88,35 @@ Starting with *i* = 0, repeatedly fetch *P**i*+1, the Increment *i* and repeat until *Pi* has no `m.room.power_levels` event in its `auth_events`. The *mainline of P*0 is the list of events - [*P*n , ... , *P*1, *P*0]. + [*P*n , ... , *P*1, *P*0], +ordered from oldest to newest. -Given another event *e* = *e0* we can compute a similar list of -`m.room.power_levels` events - [*e*0, *e*1, ...], +Let *e* = *e0* be another event (possibly another +`m.room.power_levels` event). We can compute a similar list of events + [*e*1, ..., *em*], where *e*j* + 1* is the `m.room.power_levels` event in the -`auth_events` of *ej*. The *closest mainline event to e* -is the first event *ej* which belongs to the mainline of *P*. -If no event *ej* belongs to the mainline of *P*, then the closest -mainline event to *e* can be considered to be a dummy event that is -before any other event in the mainline of *P* for the purposes of -condition 1 below. +`auth_events` of *ej*, and where *em* has no +`m.room.power_levels` event in its `auth_events`. (Note that this second list +may be empty, because *e* may not cite an `m.room.power_levels` event in its +`auth_events` at all.) + +Now compare these two lists as follows. +* Find the smallest index *j* ≥1 for which *ej* belongs to the + mainline of *P*. +* If *j* exists, then *ej* = *Pi* for some unique index + *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater + than any integer. +* In both cases, the *position of e in the mainline of P* is *i*. The *mainline ordering based on* *P* of a set of events is the ordering, from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if -1. the closest mainline event to *x* appears *before* the closest - mainline event to *y*; or -2. the closest mainline events are the same, but *x*'s +1. the position of *x* in *P*'s mainline is **greater** than + the position of *y* in *P*'s mainline. +2. the positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or -3. the closest mainline events are the same and the events have the +3. the positions of the events are the same and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`. From 4ecd8a8a24ce8ae02aae855906b5622841c2ba03 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 6 Jun 2022 14:13:14 +0100 Subject: [PATCH 06/15] Minor typographical tweaks looks better in Firefox. I am sad to be writing a poor man's TeX though. --- content/rooms/fragments/v2-state-res.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index f470e4bdd..bd824eb1c 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -95,13 +95,13 @@ Let *e* = *e0* be another event (possibly another `m.room.power_levels` event). We can compute a similar list of events [*e*1, ..., *em*], where *e*j* + 1* is the `m.room.power_levels` event in the -`auth_events` of *ej*, and where *em* has no +`auth_events` of *ej* and where *em* has no `m.room.power_levels` event in its `auth_events`. (Note that this second list may be empty, because *e* may not cite an `m.room.power_levels` event in its `auth_events` at all.) Now compare these two lists as follows. -* Find the smallest index *j* ≥1 for which *ej* belongs to the +* Find the smallest index *j* ≥ 1 for which *ej* belongs to the mainline of *P*. * If *j* exists, then *ej* = *Pi* for some unique index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater @@ -112,8 +112,8 @@ The *mainline ordering based on* *P* of a set of events is the ordering, from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if -1. the position of *x* in *P*'s mainline is **greater** than - the position of *y* in *P*'s mainline. +1. the position of *x* in the mainline of *P* is **greater** than + the position of *y* in the mainline of *P*. 2. the positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or 3. the positions of the events are the same and the events have the From dbf66b93b9d234b463db2941cb76bfb542a40682 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 8 Jun 2022 18:26:21 +0100 Subject: [PATCH 07/15] Batch of suggestions, thanks Denis Co-authored-by: Denis Kasak --- content/rooms/fragments/v2-state-res.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index bd824eb1c..e1dd6f5e7 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -94,7 +94,7 @@ ordered from oldest to newest. Let *e* = *e0* be another event (possibly another `m.room.power_levels` event). We can compute a similar list of events [*e*1, ..., *em*], -where *e*j* + 1* is the `m.room.power_levels` event in the +where *e*j*+1* is the `m.room.power_levels` event in the `auth_events` of *ej* and where *em* has no `m.room.power_levels` event in its `auth_events`. (Note that this second list may be empty, because *e* may not cite an `m.room.power_levels` event in its @@ -103,8 +103,8 @@ may be empty, because *e* may not cite an `m.room.power_levels` event in its Now compare these two lists as follows. * Find the smallest index *j* ≥ 1 for which *ej* belongs to the mainline of *P*. -* If *j* exists, then *ej* = *Pi* for some unique index - *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater +* If such a *j* exists, then *ej* = *Pi* for some unique + index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater than any integer. * In both cases, the *position of e in the mainline of P* is *i*. @@ -113,7 +113,7 @@ from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if 1. the position of *x* in the mainline of *P* is **greater** than - the position of *y* in the mainline of *P*. + the position of *y* in the mainline of *P*; or 2. the positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or 3. the positions of the events are the same and the events have the From ac5c4779376423074ef00189d4373dbe1780f6c1 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 8 Jun 2022 18:35:28 +0100 Subject: [PATCH 08/15] Note that e_0 may not be in the second list; typo fix Co-authored-by: Denis Kasak --- content/rooms/fragments/v2-state-res.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index e1dd6f5e7..a9cc386e0 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -94,9 +94,10 @@ ordered from oldest to newest. Let *e* = *e0* be another event (possibly another `m.room.power_levels` event). We can compute a similar list of events [*e*1, ..., *em*], -where *e*j*+1* is the `m.room.power_levels` event in the +where *e**j*+1 is the `m.room.power_levels` event in the `auth_events` of *ej* and where *em* has no -`m.room.power_levels` event in its `auth_events`. (Note that this second list +`m.room.power_levels` event in its `auth_events`. (Note that the event we +started with, *e0*, is not included in this list. Also note that it may be empty, because *e* may not cite an `m.room.power_levels` event in its `auth_events` at all.) From c411d258f5a8799c251d78a8408aac9b69d582c9 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 17:19:35 +0100 Subject: [PATCH 09/15] Update changelogs/room_versions/newsfragments/1107.clarification Co-authored-by: Travis Ralston --- changelogs/room_versions/newsfragments/1107.clarification | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/room_versions/newsfragments/1107.clarification b/changelogs/room_versions/newsfragments/1107.clarification index 50e36c129..79b31fef6 100644 --- a/changelogs/room_versions/newsfragments/1107.clarification +++ b/changelogs/room_versions/newsfragments/1107.clarification @@ -1 +1 @@ -More explicitly define the mainline of a power event and the mainline ordering of other events. +For room versions 2 through 10: More explicitly define the mainline of a power event and the mainline ordering of other events. From fe979ee50fa9536cb4403f8391f3a2d29289d4b5 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:10:44 +0100 Subject: [PATCH 10/15] say "mainline position" rather than "position in the mainline of P" Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- content/rooms/fragments/v2-state-res.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index a9cc386e0..f43b0a9ee 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -113,11 +113,12 @@ The *mainline ordering based on* *P* of a set of events is the ordering, from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if -1. the position of *x* in the mainline of *P* is **greater** than - the position of *y* in the mainline of *P*; or -2. the positions of the events are the same, but *x*'s +1. the mainline position of *x* is **greater** than + the mainline position of *y* in the mainline of *P* (i.e. the auth chain of +*x* is based on an earlier event in the mainline than *y*); or +2. the mainline positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or -3. the positions of the events are the same and the events have the +3. the mainline positions of the events are the same and the events have the same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s `event_id`. From 5945937ffdf602d48cd2acd6452f081146b5dcc3 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:11:10 +0100 Subject: [PATCH 11/15] Another "position in the mainline" -> "mainline position" Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- content/rooms/fragments/v2-state-res.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index f43b0a9ee..b9e131f98 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -107,7 +107,7 @@ Now compare these two lists as follows. * If such a *j* exists, then *ej* = *Pi* for some unique index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater than any integer. -* In both cases, the *position of e in the mainline of P* is *i*. +* In both cases, the *mainline position* of *e* is *i*. The *mainline ordering based on* *P* of a set of events is the ordering, from smallest to largest, using the following comparison relation on From 9231ca623ce7d17e552e29690e5e0d92e7afde08 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:16:49 +0100 Subject: [PATCH 12/15] Enumerate the mainline with ascending indices; drop older/newer comment --- content/rooms/fragments/v2-state-res.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index b9e131f98..ceb132e2d 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -88,8 +88,8 @@ Starting with *i* = 0, repeatedly fetch *P**i*+1, the Increment *i* and repeat until *Pi* has no `m.room.power_levels` event in its `auth_events`. The *mainline of P*0 is the list of events - [*P*n , ... , *P*1, *P*0], -ordered from oldest to newest. + [*P*0 , *P*1, ... , *Pn*], +fetched in this way. Let *e* = *e0* be another event (possibly another `m.room.power_levels` event). We can compute a similar list of events From e2f389584ba76472888a60d386efcd9731c515a9 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:38:35 +0100 Subject: [PATCH 13/15] Explicitly say that we want mainline positions from P Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- content/rooms/fragments/v2-state-res.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index ceb132e2d..c9dc26241 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -109,7 +109,7 @@ Now compare these two lists as follows. than any integer. * In both cases, the *mainline position* of *e* is *i*. -The *mainline ordering based on* *P* of a set of events is the ordering, +Given mainline positions calculated from *P*, the *mainline ordering based on* *P* of a set of events is the ordering, from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if From 00e225b662c51ba563ec6d776772d82f4cf0be91 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:39:35 +0100 Subject: [PATCH 14/15] More fixes. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- content/rooms/fragments/v2-state-res.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index c9dc26241..d3e012410 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -114,8 +114,8 @@ from smallest to largest, using the following comparison relation on events: for events *x* and *y*, *x* < *y* if 1. the mainline position of *x* is **greater** than - the mainline position of *y* in the mainline of *P* (i.e. the auth chain of -*x* is based on an earlier event in the mainline than *y*); or + the mainline position of *y* (i.e. the auth chain of + *x* is based on an earlier event in the mainline than *y*); or 2. the mainline positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or 3. the mainline positions of the events are the same and the events have the From f243e8b65abd107ad344f9172839fa5f55009b36 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 18:52:29 +0100 Subject: [PATCH 15/15] Indentation fix --- content/rooms/fragments/v2-state-res.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index d3e012410..1384c98fe 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -115,7 +115,7 @@ events: for events *x* and *y*, *x* < *y* if 1. the mainline position of *x* is **greater** than the mainline position of *y* (i.e. the auth chain of - *x* is based on an earlier event in the mainline than *y*); or + *x* is based on an earlier event in the mainline than *y*); or 2. the mainline positions of the events are the same, but *x*'s `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or 3. the mainline positions of the events are the same and the events have the