Skip to main content

Decision

Extend the shared Meet document transport and TipTap bindings into a Docs-scoped Cloudflare Worker and SQLite Durable Object room. Hold enablement until Docs has one content writer per document and a tested recovery path. Meet already co-edits its primary document and checkpoints into workspace_documents. Standalone Docs opens that table through a JSON editor and REST autosave. Sharing the table leaves the two editors competing for the same content if both are writable.

Repository evidence

Docs integration

  1. Authorization and isolation. Authenticate the workspace session and resolve the document, membership and current edit permission before minting a ticket. Bind the audience, workspace, document, room epoch, actor, role and expiry. Start with authenticated editors only. Keep existing public views on the JSON projection. Give the Worker a separate service identity and restrict origins. Validate tickets again on renewal and use a revocation fence for removal, permission loss, deletion and epoch changes, including sockets already open. Load testing must include permission expiry while idle.
  2. One writer and one seed. Atomically select a content mode and epoch against the row revision. Bootstrap a Y.Doc once from persisted content by parsing legacy JSON strings, JSON objects and empty content with the Docs TipTap schema. Use the same fragment in the editor and projector and prove round-trip parity for citations, inline metadata, images, tables and Markdown import. While the room owns content, reject all REST content writes, including delayed requests and the retry button, with an actionable conflict. Keep metadata updates on REST. Check ownership inside the content transaction so concurrent PATCH, deletion and mode changes cannot race the guard. Exclude Meet-owned rows from the Docs pilot. For those rows, resolve one writer or expose a read-only Docs view before admitting them.
  3. Durable state and publication. Persist accepted CRDT updates before acknowledging durability. Coalesce them in the room for up to one second, use bounded compaction, and keep a durable cursor and dirty marker. Project the latest durable cursor to workspace_documents.content on a 30-second minimum cadence while dirty. Atomically compare epoch, cursor and hash in the database. A retry after a lost response returns the same result. A stale epoch, deleted row, unsupported schema or conflicting write ends the attempt and surfaces a recoverable state. Define separate UI states for offline edits, room durability and workspace publication. Existing readers, search and exports may lag by the checkpoint cadence. A user action requiring fresh content can wait for its target cursor within the same budget.
  4. Presence and offline. Reuse Awareness and collaboration carets. Bind display identity to the authenticated connection and use document-scoped aliases. Coalesce cursors, remove them on expiry or disconnect and reserve durable storage for content. For the first pilot, retain pending edits while the tab lives, reconcile with the room on reconnect, and show an unsent state plus a download path before closing. Add browser persistence only after per-user/workspace/epoch isolation, quotas, logout cleanup, revocation and stale-epoch recovery are tested. Reconnecting to a new epoch can recover drafts into a copy after permission checks. Keep old updates out of the current room.
  5. Version history. Meet’s checkpoint revision orders synchronization. The inspected standalone PATCH writes a row without an immutable revision. Use the Docs history contract when available, keeping checkpoint cursors and user-visible revisions independent. A named save or an explicitly defined history interval captures a durable cursor into an immutable JSON snapshot once, with authenticated attribution. A restore should first preserve the current revision, then serialize the restore through the room as a new revision under a fresh epoch, with stale clients fenced before rejoining. Use the same ownership guard if Office revisions ship before co-editing, and verify REST-only edit/history behavior for documents outside the pilot.

Pilot cost and shutdown gates

Treat these as starting limits for a private pilot. Enforce a finite admission lease, at most 20 allowlisted rooms and eight sockets per room, a 64 KiB inbound update, a 512 KiB merged snapshot, and a bounded update journal and resync payload. Charge all accepted messages and recipients against operation and byte budgets before merging or sending. Bound admission and renewal, awareness, outbound messages and logging separately. Throttle presence first, then stop accepting edits with a visible capacity status. Track daily room and pilot-wide operation budgets, including rejected-work overhead. Set their numeric limits from counted runtime evidence before enablement. Keep the Worker route allowlisted and time-limited to bound ingress exposure. Use one scheduled deadline per room, at most one checkpoint in flight, and at most three reserved outbound checkpoint attempts over two minutes per failure episode, including while editors are connected. Persist reservations before outbound work. Rejoins, duplicates and restarts cannot refill the episode. Successful cursor advancement clears it. Use an explicit operator recovery path for exhausted state. Empty clean, exhausted, stopped and expired rooms schedule no further work. Model idle baseline, active rooms and sustained failure using actual billed requests, fanout, duration, alarm invocations, storage reads/writes and downstream checkpoint calls. Record the envelope at approved capacity in the adoption runbook before enabling the Worker. See the Cloudflare cost and stop controls. Use a service ingress switch and a durable stop epoch. The authenticated stop operation persists the fence, closes sockets, cancels alarms and leaves accepted updates recoverable. Each upgrade, message, retry, outbound call and alarm reschedule checks it. The database checks the same epoch at commit time so a request already in flight cannot publish after fencing. Stop must work with Web ingress disabled. A controlled handoff can pause edits, drain the durable cursor under the old ownership, verify the published hash, then fence and return the row to REST in a new epoch. An emergency stop freezes writes for recovery if any acknowledged edit remains unpublished. Preserve that state until a reviewed recovery reconciles it.

Phased acceptance

Main risks are dual authority, schema drift, reconnect loss, stale access and bill amplification from presence or retry loops. Keep standalone REST editing as the default until the pilot gates and recovery drill pass.