Skip to content

Commit 3367f56

Browse files
committed
Reading pass
1 parent bb44a63 commit 3367f56

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

proposals/2716-batch-send-historical-messages.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Here is what scrollback is expected to look like in Element:
6161

6262
**Content fields:**
6363

64-
- `m.historical` (`[true|false]`): Used on any event to indicate they were
64+
- `m.historical` (`[true|false]`): Used on any event to indicate that it was
6565
historically imported after the fact
6666
- `m.next_chunk_id` (`string`): This is a random unique string for a
6767
`m.room.insertion` event to indicate what ID the next "chunk" event should
@@ -208,8 +208,9 @@ breakdown which incrementally explains how everything fits together.
208208
this as `?chunk_id`
209209
1. A "chunk" event is added to the end of the chunk. This is the event that
210210
connects to an insertion event by `?chunk_id`.
211-
1. If `?chunk_id` is not specified (usually for the first chunk), create base
212-
"insertion" event as a jumping off point from `?prev_event`.
211+
1. If `?chunk_id` is not specified (usually only for the first chunk), create a
212+
base "insertion" event as a jumping off point from `?prev_event` which can
213+
be added to the end of the `events` list in the response.
213214
1. All of the events in the historical chunk get a content field,
214215
`"m.historical": true`, to indicate that they are historical at the point of
215216
being added to a room.
@@ -236,14 +237,14 @@ breakdown which incrementally explains how everything fits together.
236237

237238
#### Basic chunk structure
238239

239-
Here is the starting point how the historical chunk concept look like in the
240-
DAG. We're going to build from this in the next sections.
240+
Here is the starting point for how the historical chunk concept looks like in
241+
the DAG. We're going to build from this in the next sections.
241242

242243
- `A` is the oldest-in-time message
243244
- `B` is the newest-in-time message
244245
- `chunk0` is the first chunk we try to import
245-
- Each chunk of messages is older-in-time than the last (`chunk1` is older than
246-
`chunk0`, etc)
246+
- Each chunk of messages is older-in-time than the last (`chunk1` is
247+
older-in-time than `chunk0`, etc)
247248

248249

249250
![](https://user-images.githubusercontent.com/558581/126577416-68f1a5b0-2818-48c1-b046-21e504a0fe83.png)
@@ -290,18 +291,18 @@ flowchart BT
290291

291292
#### Adding "insertion" and "chunk" events
292293

293-
Next we add "insertion" and "chunk" events so it's more presriptive on how each
294+
Next we add "insertion" and "chunk" events so it's more prescriptive on how each
294295
historical chunk should connect to each other and how the homeserver can
295296
navigate the DAG.
296297

297298
- With "insertion" events, we just add them to the start of each chronological
298299
chunk (where the oldest message in the chunk is). The next older-in-time
299300
chunk can connect to that "insertion" point from the previous chunk.
300-
- The initial "insertion" event could be from the main DAG or we can create it
301-
ad-hoc in the first chunk so the homeserver can start traversing up the chunk
302-
from there after a "marker" event points to it.
301+
- The initial base "insertion" event could be from the main DAG or we can
302+
create it ad-hoc in the first chunk so the homeserver can start traversing up
303+
the chunk from there after a "marker" event points to it.
303304
- We use `m.room.chunk` events to indicate which `m.room.insertion` event it
304-
connects to by its `m.next_chunk_id` field
305+
connects to by its `m.next_chunk_id` field.
305306

306307
![](https://user-images.githubusercontent.com/558581/127040602-e95ac36a-5e64-4176-904d-6abae2c95ae9.png)
307308

@@ -338,7 +339,7 @@ flowchart BT
338339
</details>
339340

340341

341-
The structure of the insertion event would look like:
342+
The structure of the insertion event looks like:
342343
```js
343344
{
344345
"type": "m.room.insertion",
@@ -354,7 +355,7 @@ The structure of the insertion event would look like:
354355
```
355356

356357

357-
The structure of the chunk event would look like:
358+
The structure of the chunk event looks like:
358359
```js
359360
{
360361
"type": "m.room.chunk",
@@ -374,34 +375,34 @@ The structure of the chunk event would look like:
374375
#### Adding marker events
375376

376377
Finally, we add "marker" events into the mix so that federated remote servers
377-
can also navigate and to know where/how to fetch historical messages correctly.
378+
also know where in the DAG they should look for historical messages.
378379

379380
To lay out the different types of servers consuming these historical messages
380381
(more context on why we need "marker" events):
381382

382383
1. Local server
383-
- This can pretty much work out of the box. Just add the events to the
384-
database and they're available. The new endpoint is just a mechanism to
385-
insert the events.
384+
- This pretty much works out of the box. It's possible to just add the
385+
historical events to the database and they're available. The new endpoint
386+
is just a mechanism to insert the events.
386387
1. Federated remote server that already has all scrollback history and then new
387388
history is inserted
388389
- The big problem is how does a HS know it needs to go fetch more history if
389390
they already fetched all of the history in the room? We're solving this
390391
with "marker" events which are sent on the "live" timeline and point back
391392
to the "insertion" event where we inserted history next to. The HS can
392393
then go and backfill the "insertion" event and continue navigating the
393-
chunks from there.
394+
historical chunks from there.
394395
1. Federated remote server that joins a new room with historical messages
395-
- We need to update the `/backfill` response to include historical messages
396-
from the chunks
396+
- The originating homeserver just needs to update the `/backfill` response
397+
to include historical messages from the chunks.
397398
1. Federated remote server already in the room when history is inserted
398399
- Depends on whether the HS has the scrollback history. If the HS already
399400
has all history, see scenario 2, if doesn't, see scenario 3.
400401
1. For federated servers already in the room that haven't implemented MSC2716
401402
- Those homeservers won't have historical messages available because they're
402-
unable to navigate the "marker"/"insertion" events. But the historical
403-
messages would be available once the HS implements MSC2716 and processes
404-
the "marker" events that point to the history.
403+
unable to navigate the "marker"/"insertion"/"chunk" events. But the
404+
historical messages would be available once the HS implements MSC2716 and
405+
processes the "marker" events that point to the history.
405406

406407

407408
---
@@ -424,23 +425,17 @@ To lay out the different types of servers consuming these historical messages
424425
timeline and misses the "marker" and expects to see the historical
425426
messages. They will be missing the historical messages until they can
426427
backfill the gap where they left.
427-
- A "marker" event is not needed for every chunk/batch of historical messages.
428-
Multiple chunks can be inserted then once we're done importing everything, we
429-
can add one "marker" event pointing at the root "insertion" event
428+
- A "marker" event is not needed for every chunk of historical messages added
429+
via `/batch_send`. Multiple chunks can be inserted then once we're done
430+
importing everything, we can add one "marker" event pointing at the root
431+
"insertion" event
430432
- If more history is decided to be added later, another "marker" can be sent to let the homeservers know again.
431433
- When a remote federated homeserver, receives a "marker" event, it can mark
432434
the "insertion" prev events as needing to backfill from that point again and
433435
can fetch the historical messages when the user scrolls back to that area in
434436
the future.
435-
- We could remove the need for "marker" events if we decided to only allow
436-
sending "insertion" events on the "live" timeline at any point where you
437-
would later want to add history. But this isn't compatible with our dynamic
438-
insertion use cases like Gitter where the rooms already exist with no
439-
"insertion" events at the start of the room, and the examples from this MSC
440-
like NNTP (newsgroup) and email which can potentially want to branch off of
441-
everything.
442-
443-
The structure of the "marker" event would look like:
437+
438+
The structure of the "marker" event looks like:
444439
```js
445440
{
446441
"type": "m.room.marker",
@@ -498,8 +493,8 @@ This doesn't provide a way for a HS to tell an AS that a client has tried to
498493
call `/messages` beyond the beginning of a room, and that the AS should try to
499494
lazy-insert some more messages (as per
500495
https://github.com/matrix-org/matrix-doc/issues/698). For this MSC to be
501-
properly useful, we might want to flesh that out. Another related problem with
502-
the existing appservice query APIs is that they don't include who is querying,
496+
extra useful, we might want to flesh that out. Another related problem with
497+
the existing AS query APIs is that they don't include who is querying,
503498
so they're hard to use in bridges that require logging in. If a similar query
504499
API is added here, it should include the ID of the user who's asking for
505500
history.
@@ -565,9 +560,6 @@ via SS API.
565560

566561
## Unstable prefix
567562

568-
Event types, event content fields, and the API endpoint are all using the
569-
unstable prefix `org.matrix.msc2716`:
570-
571563
**Endpoints:**
572564

573565
- `POST /_matrix/client/unstable/org.matrix.msc2716/rooms/<roomID>/batch_send`

0 commit comments

Comments
 (0)