Skip to content

Commit a4cba60

Browse files
committed
Clarify introduction and add content queries
Signed-off-by: Johannes Marbach <[email protected]>
1 parent 2654cf3 commit a4cba60

File tree

1 file changed

+85
-21
lines changed

1 file changed

+85
-21
lines changed

proposals/4301-event-capability-negotiation.md

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
# MSC4301: Event capability negotiation between clients
22

33
Matrix allows clients to exchange both built-in and custom events with other clients in rooms. There
4-
is, however, no way for a client to understand what types of events the other clients in a room are
5-
able to understand. This is problematic as a compatibility mismatch means that the recipient user
6-
might only be able to see a fallback representation of an event or, in the worst case, nothing at
7-
all. At the same time, the sender is left wholly unaware of the recipient's experience.
4+
is, however, no way for a client to tell what types of events the other clients in a room are able
5+
to understand. This is problematic as a compatibility mismatch means that the recipient user might
6+
only be able to see a fallback representation of an event or, in the worst case, nothing at all. At
7+
the same time, the sender is left wholly unaware of the recipient's experience.
8+
9+
A glaring example of this occurs when Matrix is used to exchange [FHIR] resources, e.g. via
10+
[MSC4302]. These resources can be subject to complex customizations via so called *profiles* which
11+
affect rendering and processing logic. For a client that aims to send FHIR resources into a room, it
12+
is, therefore, crucial to know whether or not the recipients in the room can actually work with the
13+
specific FHIR profiles it is going to use. The usual Matrix approach of designing new events to
14+
include backwards-compatible fallbacks is not feasible in this case. The only apparent fallback is
15+
transmitting FHIR resources as generic JSON or XML files. Such files are not (easily) human-readable
16+
and will appear mostly impractical to recipients, however.
817

918
[MSC4300] partially addresses this problem by enabling clients to communicate the result of
1019
processing a specific event back to the sender. This lets senders determine after the fact whether
1120
the events they have sent were understood by other clients or not.
1221

13-
The present proposal goes a step further and introduces a scheme for clients to query whether other
14-
clients understand an event type *ahead* of actually sending that event. This allows clients to
15-
efficiently negotiate compatible event types resulting in the best possible experience for all
16-
participants.
22+
This proposal goes a step further and introduces a scheme for clients to query whether other clients
23+
understand an event *ahead* of actually sending it. This allows clients to efficiently negotiate
24+
compatible event types resulting in the best possible experience for all participants.
1725

1826
## Proposal
1927

@@ -25,7 +33,13 @@ properties in `content`:
2533

2634
- `m.request.status` (object, required): Generic information about the request as per [MSC4300].
2735
- `m.request.event_capability` (object, required): Information about the event capability request.
28-
- `types` (array, required): A list of event types for which the sender wishes to request support.
36+
- `events` (array, required): A list of objects containing details about the events being queried.
37+
- `type` (string, required): The type of the event.
38+
- `content` (array): An optional list of objects describing additional requirements for
39+
properties inside the `content` of the event.
40+
- `key` (string, required): The dot-separated path of the property (analogous to `key` in
41+
`event_match` [push rule conditions]).
42+
- `value` (string, required): The exact value of the property.
2943

3044
``` json5
3145
{
@@ -37,24 +51,57 @@ properties in `content`:
3751
"from_device": "RJYKSTBOIE",
3852
"lifetime": 90_000, // 90s
3953
},
40-
// I'd like to send any of these event types into this room.
54+
// I'd like to send any of these events into this room.
4155
// Which of these do you understand?
4256
"m.request.event_capability": {
43-
"types": [
44-
"m.pizza.margherita",
45-
"m.pizza.salami",
46-
"m.pizza.hawaii"
57+
"events": [
58+
// How about m.fhir containing advanced rendering SDC questionnaires v4?
59+
{
60+
"type": "m.fhir",
61+
"content": [{
62+
"key": "m\.fhir\.structure_definition.url",
63+
"value": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-render"
64+
}, {
65+
"key": "m\.fhir\.structure_definition.version",
66+
"value": "4.0.0"
67+
}]
68+
},
69+
// Or if you don't know v4, maybe you support v3?
70+
{
71+
"type": "m.fhir",
72+
"content": [{
73+
"key": "m\.fhir\.structure_definition.url",
74+
"value": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-render"
75+
}, {
76+
"key": "m\.fhir\.structure_definition.version",
77+
"value": "3.0.0"
78+
}]
79+
},
80+
// Or failing that, do you at least understand base SDC questionnaires v4?
81+
{
82+
"type": "m.fhir",
83+
"content": [{
84+
"key": "m\.fhir\.structure_definition.url",
85+
"value": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire"
86+
}, {
87+
"key": "m\.fhir\.structure_definition.version",
88+
"value": "4.0.0"
89+
}]
90+
}
4791
]
4892
}
4993
}
5094
}
5195
```
5296

97+
The requirements expressed through `type` and the elements of `content` are to be combined using
98+
logical AND.
99+
53100
Recipient clients MAY respond to `m.request.event_capability` within its lifetime with the
54101
`m.response.status` event from [MSC4300] and the following additional properties in `content`:
55102

56103
- `m.response.event_capability` (object, required): Information about the event capability response
57-
- `types` (array, required): The subset of event types from `m.request.event_capability` that the
104+
- `events` (array, required): The subset of events from `m.request.event_capability` that the
58105
sending device is able to understand.
59106

60107
``` json5
@@ -67,18 +114,27 @@ Recipient clients MAY respond to `m.request.event_capability` within its lifetim
67114
"status": "success",
68115
"messages": [{
69116
"type": "info",
70-
"m.text": [{ "body": "Refusing to recognise Hawaii as a Pizza style!" }]
117+
"m.text": [{ "body": "Unknown structure definition http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-render" }]
71118
}]
72119
},
73120
"m.relates_to": {
74121
"event_id": "$1",
75122
"rel_type": "m.reference",
76123
},
77-
// These are the event types I understand.
124+
// These are the events I understand.
78125
"m.response.event_capability": {
79-
"types": [
80-
"m.pizza.margherita",
81-
"m.pizza.salami",
126+
"events": [
127+
// I can only do m.fhir with base SDC questionnaires, sorry!
128+
{
129+
"type": "m.fhir",
130+
"content": [{
131+
"key": "m\.fhir\.structure_definition.url",
132+
"value": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire"
133+
}, {
134+
"key": "m\.fhir\.structure_definition.version",
135+
"value": "4.0.0"
136+
}]
137+
}
82138
]
83139
}
84140
}
@@ -96,6 +152,11 @@ events that they are able to understand, for instance, via profiles or state eve
96152
would simplify looking up capabilities but comes with its own technical challenges such as scoping
97153
profiles to devices and rooms or being able to send state events in a room.
98154

155+
Rather than allowing specific requirements on `content` fields, queries could be limited to only
156+
event types. This would noticeably simplify the scheme. However, particularly in the case of FHIR,
157+
it seems impractical to define event types for every possible resource or profile in their various
158+
versions.
159+
99160
## Security considerations
100161

101162
The concerns and remedies around leaking metadata from [MSC4300] apply to this proposal as well.
@@ -110,6 +171,9 @@ and `de.gematik.msc4301.response.event_capability`, respectively. Properties inh
110171
## Dependencies
111172

112173
This proposal builds on [MSC4300] which at the time of writing has not yet been accepted into the
113-
spec.
174+
spec. This proposal does not depend on [MSC4302] but is intended to work in concert with it.
114175

176+
[FHIR]: https://www.hl7.org/fhir/
177+
[MSC4302]: https://github.com/matrix-org/matrix-spec-proposals/pull/4302
115178
[MSC4300]: https://github.com/matrix-org/matrix-spec-proposals/pull/4300
179+
[push rule conditions]: https://spec.matrix.org/v1.16/client-server-api/#conditions-1

0 commit comments

Comments
 (0)