Repository navigation
factory: character-level co-editing relay — live documents as opaque Yjs updates (E7) - #2636
Merged
Merged
Conversation
santoshkumarradha
force-pushed
the
w2/e7-docs
branch
from
November 13, 2026 18:50
0f7dbe8 to
173fe8a
Compare
… Yjs updates Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
…ngine relays them and the protocol says so Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
santoshkumarradha
force-pushed
the
w2/e7-docs
branch
from
November 13, 2026 19:39
50a3fe2 to
bb20828
Compare
This was referenced Nov 13, 2026
Merged
ZeroPoint95
pushed a commit
that referenced
this pull request
Nov 24, 2026
…Yjs updates (E7) (#2636) Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
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.
Bottom line: The organization server now relays and stores the live co-editing documents (Yjs, Google-Docs style) described in WAVE2.md §4.4. It keeps each document as an append-only log of opaque updates and never parses Yjs. Two engines on one real server measured p50 0.56 ms, max 0.95 ms from update to the other engine's relay. Against the real
codeaf factory servebinary on localhost: p50 1.3 ms, p95 9 ms, max 113 ms. The target was < 500 ms.What it does
internal/factory/docs,internal/factory/serve/docs.go, wire ininternal/factory/api/docs.go). Per document it keeps the log plus the latest client-made snapshot. The server stampsseq/by/atitself. Routes:GET /v1/docs/{doc}?since=POST …/updates {base_seq, update, seed?}PUT …/snapshot {seq, state}POST …/awareness {client, state|null}, with a 30 s TTLGET …/events?since=, a per-doc SSE stream (doc.updatewith id = seq,doc.snapshot,doc.awareness,doc.removed,doc.lagged)can:viewreads, follows and sends awareness;editsends updates and snapshots.ws/<id>/page/<pid>requirespidto be one of the workstream's pages. An archived workstream's pages are read-only. A private page is 404 to the operator.canvas/<id>/frame/<fid>is 404 until E4 callsSetCanvasDocAccess.org_docs. Methodsfactory.org_doc_read,_send,_snapshot,_aware,_followand_unfollow. Eventsfactory.org_doc_update,factory.org_doc_awarenessandfactory.org_doc_closed. The follower keeps the last relayed seq and reopens from it after a drop ordoc.lagged, so it never skips an update. The 409 reasons (seeded,reset,snapshot_needed) reach the desk asdetail.reason.Decisions
/v1/events. That stream is a durable 200-event window that is fsynced and rewritten on every append, and keystrokes would flush job and workstream events out of it.compact:true. Past 5000 updates or 2 MiB, new updates get 409snapshot_neededuntil a snapshot arrives. A kept snapshot drops the prefix it covers. This bounds both the disk and a newcomer's read, which must fit the engine's 8 MiB answer.Retry-After: 1.seed:trueis accepted only into an empty doc, so two desks opening a page for the first time cannot both insert itsbody_md./pages/{pid}/versions {body_md,state,reason}. Restore answers{body_md,state}and the restorer applies it as a normal update. On page delete, E2 callsh.dropDoc(...).Contract
I edited WAVE2.md §4 (point 4, "E7 as built") in place at
~/work/teams-wave/WAVE2.md; that file is outside the repo.docs/design/app-v3/PROTOCOL.mdhas the same contract.Proof
internal/factory/docscovers the store (stamping, snapshot replacing its prefix, seed, ahead/reset, soft and hard compaction, drop) and the hub (a lagging reader is ended rather than skipped, awareness TTL lapse, token buckets, remove).internal/factory/serve/docs_test.gouses the org scene (santosh, abir, mia, operator). It covers access by owner, team, share, view-only, private, archived, hidden and canvas; stamping; snapshots; the rate limit; and a real-HTTP SSE stream with replay, live updates, awareness and drop.cmd/codeaf/appfactory_org_docs_test.goruns two engines (alice, bob) against one realserve.Handlerover HTTP. It covers seed refusal with its reason, follow, 50 measured live updates, awareness, snapshot and unfollow.