Skip to content

Commit f7b3903

Browse files
anoadragon453clokeprichvdh
authored
Clarify how to make use of unstable prefixes in your MSC (#4024)
Co-authored-by: Patrick Cloke <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 0c09204 commit f7b3903

File tree

1 file changed

+88
-13
lines changed

1 file changed

+88
-13
lines changed

README.md

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,94 @@ like help with writing spec PRs, feel free to join and ask questions in the
184184

185185
#### Unstable prefixes
186186

187-
*Unstable* prefixes are the namespaces which are used before an MSC has
188-
completed FCP (see above). While the MSC might propose that a `m.space` or
189-
`/_matrix/client/v1/account/whoami` endpoint should exist, the implementation
190-
cannot use a *stable* identifier such as `/v1/` or `m.space` prior to the MSC
191-
being accepted: it needs unstable prefixes.
192-
193-
Typically for MSCs, one will use `org.matrix.msc0000` (using the real MSC
194-
number once known) as a prefix. For the above examples, this would mean
195-
`org.matrix.msc0000.space` and
196-
`/_matrix/client/unstable/org.matrix.msc0000/account/whoami` to allow for
197-
breaking compatibility changes between edits of the MSC itself, or indeed
198-
another competing MSC that's attempting to add the same identifiers.
199-
187+
"Unstable prefixes" are the namespaces which are used by implementations while
188+
an MSC is not yet accepted.
189+
190+
For instance, an MSC might propose that a `m.space`
191+
event type or an `/_matrix/client/v1/account/whoami` endpoint should exist.
192+
However, implementations cannot use these *stable* identifiers until the MSC
193+
has been accepted, as the underlying design may change at any time; the design is
194+
*unstable*.
195+
196+
Instead, an MSC can define a namespace such as `org.matrix.msc1234` (using the real
197+
MSC number once known) which is added to the stable identifier, allowing for
198+
breaking changes between edits of the MSC itself, and preventing clashes with other
199+
MSCs that might attempt to add the same stable identifiers.
200+
201+
For the above examples, this would mean using `org.matrix.msc1234.space` and
202+
`/_matrix/client/unstable/org.matrix.msc1234/account/whoami`. It is also fine to
203+
use more traditional forms of namespace prefixes, such as `com.example.*` (e.g.
204+
`com.example.space`).
205+
206+
Note: not all MSCs need to make use of unstable prefixes. They are only needed if
207+
implementations of your MSC need to exist in the wild before your MSC is accepted,
208+
*and* the MSC defines new endpoints, field names, etc.
209+
210+
#### Unstable feature flags
211+
212+
It is common when implementing support for an MSC that a client may wish to check
213+
if the homeserver it is communicating with supports an MSC.
214+
Typically, this is handled by the MSC defining an
215+
entry in the `unstable_features` dictionary of the
216+
[`/_matrix/client/versions`](https://spec.matrix.org/v1.6/client-server-api/#get_matrixclientversions)
217+
endpoint, in the form of a new entry:
218+
219+
```json5
220+
{
221+
"unstable_features": {
222+
"org.matrix.msc1234": true
223+
}
224+
}
225+
```
226+
227+
... with a value of `true` indicating that the feature is supported, and `false`
228+
or lack of the field altogether indicating the feature is not supported.
229+
230+
#### When can I use stable identifiers?
231+
232+
[According to the spec
233+
process](https://spec.matrix.org/proposals/#early-release-of-an-mscidea): once
234+
an MSC has been accepted, implementations are allowed to switch to *stable*
235+
identifiers. However, the MSC is still not yet part of a released spec version.
236+
237+
In most cases, this is not an issue. For instance, if your MSC specifies a new
238+
event type, you can now start sending events with those types!
239+
240+
Some MSCs introduce functionality where coordination between implementations is
241+
needed. For instance, a client may want to know whether a homeserver supports
242+
the stable version of a new endpoint before actually attempting to request it.
243+
Or perhaps the new event type you're trying to send relies on the homeserver
244+
recognising that new event type, and doing some work when it sees it.
245+
246+
At this point, it may be best to wait until a new spec version is released with
247+
your changes. Homeservers that support the changes will eventually advertise
248+
that spec version under `/versions`, and your client can check for that.
249+
250+
But if you really can't wait, then there is another option: the homeserver can
251+
tell clients that it supports *stable* indentifiers for your MSC before it
252+
enters a spec version, using yet another `unstable_features` flag:
253+
254+
```json5
255+
{
256+
"unstable_features": {
257+
"org.matrix.msc1234": true,
258+
"org.matrix.msc1234.stable": true
259+
}
260+
}
261+
```
262+
263+
If a client sees that `org.matrix.msc1234.stable` is `true`, it knows that it
264+
can start using stable identifiers for the new MSC, and the homeserver will
265+
accept and act on them accordingly.
266+
267+
Note: While the general pattern of using the text ".stable" has emerged from
268+
previous MSCs, you can pick any name you like. You need only to clearly state
269+
their meaning, usually under an "Unstable prefixes" header in your MSC.
270+
271+
See
272+
[MSC3827](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3827-space-explore.md#unstable-prefix)
273+
for a good example of an MSC that wanted to use such a flag to speed up
274+
implementation rollout, and how it did so.
200275

201276
#### Room versions
202277

0 commit comments

Comments
 (0)