Repository navigation
Description
Problem
A collab document's step history grows without any bound for as long as the document lives, and every new joiner is sent a clone of the entire history. Any connected client — including an anonymous one, since collab auth is optional and failure proceeds as anonymous — can grow server memory and join-time catch-up cost without limit by sending Steps frames.
Evidence (main ed59bc6d, pkgs/id/src/web/collab.rs)
:217/:250—Document.steps: RwLock<Vec<(Step, serde_json::Value)>>, created empty; the module has no cap constant for it (contrast the encryption adapter, which bounds its held set by both count and bytes:MAX_HELD_MESSAGES/MAX_HELD_BYTES,pkgs/id/src/encryption/scheme.rs:66,72, enforced in Phase 4: held application messages need a bound #186 precisely so an unreadable-message flood cannot grow memory forever).:1020-1028— the only mutation site appends every step of every accepted Steps frame:doc_steps.push(...)per step.grepover the file shows notruncate,drain,remove, cap check, or compaction ofstepsanywhere; steps are never folded into the base document (Document.docis the initial content,:211; the Init frame even hardcodesversion: 0as "base",:765— see also id(web): image uploads can dispatch against a destroyed editor view #2799).:1029-1033— the version is just a counter (fetch_add(steps.len())); nothing ever resets it or the history when a save persists the document (notify_new_version,:352-375, only broadcasts and updates the stored hash).:791-806— on every join, the handler clones the whole history into a catch-up Update (steps.iter().map(|(step, _)| step.data.clone())), so join cost and allocation are O(total steps ever submitted) per joiner, forever.:342-350/ cleanup inhandle_collab_socket— a document is only removed after the last client has been gone forDOCUMENT_CLEANUP(1 hour,:185); a single client that stays connected (or reconnects within the hour) keeps the document — and its entire history — alive indefinitely.- The Steps path itself has no per-message bound either:
CollabMessage::decode(:536-545) accepts a steps vector of any length the WebSocket frame carries, and the handler checks only the version before appending all of them.
Verification this run: code-read verification on current main — full-text search of collab.rs for every steps mutation/read site (append at :1023 is the only push; reads are the catch-up clone and tests), plus the absence of any cap constant or compaction call in the module.
Why it matters
This is an unbounded-memory / unbounded-work surface reachable by any peer that can open the collab socket (auth failure still proceeds as anonymous, :716-753). Long-lived shared documents — exactly the ones with the most history — become the most expensive to join and the largest memory residents, and a hostile or buggy client can accelerate that arbitrarily. The codebase's own precedent (#186) is that sets which grow on peer input get an explicit count+bytes bound with a refusal that neither poisons nor evicts; the collab history has neither a bound nor a compaction story.
Acceptance criteria
- Triage pins the remedy shape: e.g. periodic compaction of applied steps into the base document (advancing the Init base version — interacts with id(web): image uploads can dispatch against a destroyed editor view #2799, coordinate there), and/or a hard cap on retained steps / total step bytes with an explicit desync/reconnect error (the Lagged path at
:896-906is the existing pattern) when the cap is hit. - After the fix, retained history per document is bounded by a named constant (count and/or bytes), whatever traffic a client sends.
- Join-time catch-up no longer clones an ever-growing history: its size is bounded by the same constant, or by the compacted base + a bounded tail.
- A test submits steps past the bound (or past a compaction threshold) and asserts the bound/compaction behaviour and that a fresh joiner still reconstructs the same document.
- Normal editing below the bound is unchanged: Steps are Acked, broadcast, and replayed as before.
Dedup / related
- id(web): image uploads can dispatch against a destroyed editor view #2799 (open) covers the Init frame always carrying version 0 — related (compaction would touch it) but distinct: this issue is the unbounded retention itself, which exists whatever the Init version says.
- Phase 4: held application messages need a bound #186 (closed) bounded the encryption held set — the precedent, not the same code.
- id(web): collab handleMessage trusts MessagePack frame shape — a null frame throws out of onmessage, and a field-less INIT silently initializes an empty editor at an undefined version #2824 / id(web): collab WebSocket URL interpolates the raw filename unencoded — names with / ? # never connect, and a %20 name silently opens a different file #2830 (open) are collab-adjacent (TS frame shape, WS URL encoding) and do not touch server-side retention.
- Search of open + closed issues for "collab steps unbounded / step history growth / compaction" found no existing issue covering this.
Activity
dezren39 commentedon Oct 31, 2026
🤖 Agent note · state: filed
dezren39 commentedon Oct 31, 2026
🤖 Agent note · state: done (closed as duplicate)
dezren39 commentedon Oct 31, 2026
Correction to the closing note above: queue task 4265 could NOT be cancelled — it is already claimed by lane
code-pilot-fix-2026-10-30-2256(cancel refuses a claimed task). Holder: please stand down on this task/issue — it is a duplicate of #1965, whose comment #1965 (comment) now carries the only unique remainder. Fleet-monitor reconciliation should also close the task out against this closed issue.