@ -23,21 +23,21 @@ The state resolution algorithm for version 2 rooms uses the following
definitions, given the set of room states
definitions, given the set of room states
{*S*< sub > 1< / sub > , *S*< sub > 2< / sub > , …}:
{*S*< sub > 1< / sub > , *S*< sub > 2< / sub > , …}:
Power events
** Power events.**
A *power event* is a state event with type `m.room.power_levels` or
A *power event* is a state event with type `m.room.power_levels` or
`m.room.join_rules` , or a state event with type `m.room.member` where
`m.room.join_rules` , or a state event with type `m.room.member` where
the `membership` is `leave` or `ban` and the `sender` does not match the
the `membership` is `leave` or `ban` and the `sender` does not match the
`state_key` . The idea behind this is that power events are events that
`state_key` . The idea behind this is that power events are events that
might remove someone's ability to do something in the room.
might remove someone's ability to do something in the room.
Unconflicted state map and conflicted state set
** Unconflicted state map and conflicted state set.**
The *unconflicted state map* is the state where the value of each key
The *unconflicted state map* is the state where the value of each key
exists and is the same in each state *S* < sub > *i*</ sub > . The *conflicted
exists and is the same in each state *S* < sub > *i*</ sub > . The *conflicted
state set* is the set of all other state events. Note that the
state set* is the set of all other state events. Note that the
unconflicted state map only has one event per `(event_type, state_key)` ,
unconflicted state map only has one event per `(event_type, state_key)` ,
whereas the conflicted state set may have multiple events.
whereas the conflicted state set may have multiple events.
Auth difference
** Auth difference.**
The *auth difference* is calculated by first calculating the full auth
The *auth difference* is calculated by first calculating the full auth
chain for each state *S* < sub > *i*</ sub > , that is the union of the auth
chain for each state *S* < sub > *i*</ sub > , that is the union of the auth
chains for each event in *S* < sub > *i*</ sub > , and then taking every event
chains for each event in *S* < sub > *i*</ sub > , and then taking every event
@ -45,11 +45,11 @@ that doesn't appear in every auth chain. If *C*<sub>*i*</sub> is the
full auth chain of *S* < sub > *i*</ sub > , then the auth difference is
full auth chain of *S* < sub > *i*</ sub > , then the auth difference is
∪ *C*< sub > *i*< / sub > − ∩ *C*< sub > *i*< / sub > .
∪ *C*< sub > *i*< / sub > − ∩ *C*< sub > *i*< / sub > .
Full conflicted set
** Full conflicted set.**
The *full conflicted set* is the union of the conflicted state set and
The *full conflicted set* is the union of the conflicted state set and
the auth difference.
the auth difference.
Reverse topological power ordering
** Reverse topological power ordering.**
The *reverse topological power ordering* of a set of events is the
The *reverse topological power ordering* of a set of events is the
lexicographically smallest topological ordering based on the DAG formed
lexicographically smallest topological ordering based on the DAG formed
by auth events. The reverse topological power ordering is ordered from
by auth events. The reverse topological power ordering is ordered from
@ -71,7 +71,7 @@ events using Kahn's algorithm for topological sorting, and at each step
selecting, among all the candidate vertices, the smallest vertex using
selecting, among all the candidate vertices, the smallest vertex using
the above comparison relation.
the above comparison relation.
Mainline ordering
** Mainline ordering.**
Given an `m.room.power_levels` event *P* , the *mainline of* *P* is the
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
list of events generated by starting with *P* and recursively taking the
`m.room.power_levels` events from the `auth_events` , ordered such that
`m.room.power_levels` events from the `auth_events` , ordered such that
@ -96,7 +96,7 @@ events: for events *x* and *y*, *x* < *y* if
same `origin_server_ts` , but *x* 's `event_id` is *less* than *y* 's
same `origin_server_ts` , but *x* 's `event_id` is *less* than *y* 's
`event_id` .
`event_id` .
Iterative auth checks
** Iterative auth checks.**
The *iterative auth checks algorithm* takes as input an initial room
The *iterative auth checks algorithm* takes as input an initial room
state and a sorted list of state events, and constructs a new room state
state and a sorted list of state events, and constructs a new room state
by iterating through the event list and applying the state event to the
by iterating through the event list and applying the state event to the