refactor(webapp): delete the relay, and everything it needed to survive - #244
Merged
Merged
Conversation
The co-editing relay never parsed a frame, so nobody owned the document — and
every property that needs an owner had to be faked somewhere else:
- a seed CLAIM taken under the room lock, because two clients seeding one
file build two documents whose merge duplicates every character
- seedClaimGrace, because a claim that produced nothing left every later
joiner holding a blank document the editor would then write to the file
- maxRoomBytes and a rebuild-from-scratch, because an append-only log grows
without bound while a document does not
- a resync frame and a replay-the-whole-log reconnect, because there was no
state vector to diff against
- an announce/re-announce dance, because awareness is relayed and never
logged, so nobody could be discovered late
- solo mode, which let a client that lost the relay edit its own COPY of a
shared document and then overwrite a teammate — six characters of a real
user's work (#234)
The hub owns it now. None of the above is disabled; it is gone, because the
property each piece was faking is simply true.
internal/webapp/collab.go 441 lines, deleted with its two tests
lib/collab.ts a provider, now a thin y-websocket wrapper
/api/config collab.held removed: with one transport there is
nothing to choose, and a capability flag
nobody reads is exactly the "new
mechanism replacing one that went away"
this stage forbids
Solo survives only as NO LIVE COLLABORATION: a hub that cannot serve the route
leaves the editor open and saving through upload/content. That is deliberately
not a second CRDT path — a client editing its own copy of a shared document is
the thing that caused the data loss in the first place.
Two things found while deleting.
A stale If-Match carrying IDENTICAL content is not a conflict, it is a late
arrival. The check ran before the no-op check, so three clients sharing one
document produced two conflict copies of text nobody disputed. A conflict is a
disagreement; ordering the checks the other way is the whole fix.
stream_guard_test.go exercised the streaming guard THROUGH /collab. The guard
matters more than ever — it is what stops an unflushable writer handing back
an empty 200 a client retries forever — so it now targets /events, the hub's
remaining long-lived stream. A websocket is an upgrade, not a stream this
guard applies to, which is the same distinction compression draws.
e2e/concurrent-edit.spec.ts changed meaning with the architecture: it used to
assert a relay-less editor's work was PRESERVED BESIDE a teammate's, and now
asserts they CONVERGE — every character both typed, in the file, no conflict
copy needed. The stress spec agrees: 1 path, 2 versions, where it reported
three paths and two conflict copies this morning.
Conflict copies and If-Match stay. They guard the file against writers that
never touch a CRDT at all — an agent, the CLI, a device syncing — and removing
the relay does not close that door.
Stage 4 of docs/collab-provider-prd.md, which completes it. Full module: 12
packages ok.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
If-Matchstay: they guard the file from writers that never touch a CRDT at all.What was deleted, and why each existed
The relay never parsed a frame, so nobody owned the document. Every property that needs an owner was faked somewhere else:
seedClaimGracemaxRoomBytes+ rebuildNone of it is disabled. It's gone, because the property each piece was faking is now simply true.
Two things found while deleting
A stale
If-Matchwith identical content is not a conflict, it's a late arrival. The check ran before the no-op check, so three clients sharing one document produced two conflict copies of text nobody disputed. Ordering them the other way is the whole fix.stream_guard_test.gotested the streaming guard through/collab. That guard matters more than ever — it's what stops an unflushable writer handing back an empty 200 a client retries forever — so it now targets/events. A websocket is an upgrade, not a stream this guard applies to, which is the same distinction compression draws.A test that changed meaning
concurrent-edit.spec.tsused to assert a relay-less editor's work was preserved beside a teammate's. It now asserts they converge: every character both people typed, in the file, no conflict copy needed.What stays, deliberately
Conflict copies and
If-Match. They guard the file against an agent, the CLI, or a device syncing — writers that never touch a CRDT — and removing the relay doesn't close that door.Verification
Full module: 12 packages ok. Editor e2e: 26 passed including two-person co-editing and the three-editor stress soak. Both architecture diagrams updated and parse-checked — the
collabRoomnote was the largest single block of "why this is hard" in either file, and is now one note about a hub that owns the document.🤖 Generated with Claude Code