ADR-0108: A change event names the document and the tab that made it
Status: Accepted · Date: 2026-08-30 · Track: 006 phase 03
Context
The canvas is the first surface where two members work on the same document
at the same time. Until now a block another member moved existed only in the
database until somebody reloaded, and the only sign of the other person was a
409 (000027's version CAS) with nobody's name on it.
Publishing block.changed raises three questions the presence slice did not
have to answer, because presence is a fact about connections and this is a fact
about a document that the reader may also be writing.
- What does the event carry — the block, or the news that a block changed?
- What does the writing tab do with its own event? Every publisher broadcasts to the whole workspace, and that includes the connection belonging to the tab that just made the change and has already rendered it optimistically.
- How many events is one write? A reorder touches every block on the page.
Decision
1. The event names the document, never the block. block.changed carries
workspace_id, link_id and origin — no settings, no type, no content — and
the consumer refetches the biolink it already reads. This is ADR-0107's rule one
surface over: a payload here would be a second place deciding what a member may
read, in parallel with the workspace-scoped endpoint that already decides it and
is already tested. It also means the event cannot go stale in flight, cannot
arrive out of order in any way that matters, and cannot leak a field the
endpoint would have withheld.
2. origin is a TAB, not an account. The event carries the writer's per-tab
session id — the X-Session-ID that 003 stream D already sends on block writes
to scope undo/redo — and the consumer ignores an event whose origin is its own.
The tempting alternative is to suppress by user id, and it is wrong for the reason ADR-0107 gave for presence one unit over: a member's second tab is a second reader, and suppressing by account would leave it showing a page its owner has already changed elsewhere — the exact reload this phase exists to remove. Suppressing by tab is what makes the writer's own optimistic state safe (a refetch landing mid-drag visibly snaps a block back) and keeps every other connection live.
Consequences worth stating plainly:
- The reorder call now sends
X-Session-IDtoo. It records no history event — the header is read here for the origin, andundoableSessionis reused so "default", the poisoned legacy pool shared by every tab that has no id of its own, identifies nobody and suppresses nothing. - A write with no session id — an API client rather than a canvas — publishes with an empty origin, and every canvas refreshes. That is correct: nothing on screen made that change.
- The origin reaches every member of the workspace. It is inert as a
credential: history is scoped to
(user_id, workspace_id, session_id)with the user id taken from the token, so another member's session id names a tab and authorises nothing.
3. One event per write, never one per row. The reorder handler publishes once, after the loop, naming the document. Phase 01 measured a 200-event burst on one connection delivering 17: the bus drops over a 16-slot buffer rather than blocking, silently. A per-row reorder would therefore arrive as a partial truth — which, for an event whose whole content is "refetch", is indistinguishable from arriving correctly, and would be found much later as a canvas that sometimes shows the old order.
Consequences
- The canvas is live for every member of the workspace and for every other tab of the same member, with no new endpoint and no new transport: the outbound SSE stream phase 01 measured carries this comfortably, which is why this phase and not cursors.
- Realtime stays best-effort.
SetRealtimeunset publishes nothing and every write still succeeds; a dropped event costs a stale canvas until the next write or reload, never a lost edit — the database and its version CAS remain the record of what happened. - The consumer refetches a whole document to apply one block's change. That is the price of an event that carries nothing, and it is bounded by the same endpoint the editor already calls on load. If it ever stops being cheap, the fix is a narrower endpoint, not a fatter event.
- Attribution — who changed it — is deliberately not here.
originnames a tab so a client can ignore itself; it is not a display fact, and no column yet records who last wrote a block. That is phase 03's second row, and it takes a stored fact and its own decision.
Alternatives rejected
- Ship the block in the event. Fewer round trips, and a second definition of what a member may read — the thing ADR-0107 was written to prevent.
- Suppress the echo by user id. Simpler, and it breaks the member's own second tab, which is one of the two cases the feature exists for.
- Suppress nothing. Correct in the end state, since every write publishes and the server is the record — but it means the writing tab refetches over its own optimistic state, and an in-flight reorder can visibly snap back.
- Publish per affected block on reorder. Truthful per row, and measured to arrive as a fraction of itself.
Source: docs/decisions/0108-a-change-event-names-the-document-and-the-tab-that-made-it.md