* feat: Flatten collaborative state of large documents
Replace edit history in large collaborative state with fresh state once a
document is idle with no open sessions, and when state is over the maximum
length on save. Each replacement increments a state generation that is part of
the collaboration room name, so old state never merges into the new state.
* fix: Refuse to load state of another generation and lock editor during reset
* Remove excessive tests
* fix: Reset rooms on all instances and check state generation during authentication
* refactor: Schedule state flattening only for changed rooms, from PersistenceExtension
* fix: Refuse API text updates applied to state of an earlier generation
* wip
* Route document list queries through findAllWithCtx
Add findAllWithCtx and countWithCtx on Document and Template, unsafe* methods
for system reads, and a lint rule that bans direct list queries. Remove the
cached membership list, accessibleSql and findByIds in favour of one gate.
* Remove test
* Include drafts when loading starred documents
* Scope the access gate to the user's team, move whereToSql to QueryHelper
* Move collection access to Collection.findAllWithCtx
Collection.accessibleIds keeps the cached id list inside the collection gate, and user.collectionIds() is a shortcut to it. List queries use findAllWithCtx and countWithCtx, system reads use the shared unsafe methods, and the admin listing in collections.list is explicit.
* Check permanentDelete for each document in empty_trash
Score-only updates on documents are non-HOT, so every update wrote a new
entry into the full GIN index on ownerIds even though almost all rows have
no owners. Index only rows with owners.
* fix: Remove pins when a document is trashed
Pins on trashed documents were hidden but still counted toward the pin limit and could not be removed.
* fix: Remove pins when a collection is deleted
* fix: Page large document and template text in MCP fetch
* fix: Keep surrogate pairs whole when paging MCP fetch text
* fix: Only include textLength in MCP fetch when text is paged
* fix: Update MCP instructions and skills for paged fetch and template lists
* Prevent adding users as guests when their email matches a workspace domain
* Address review: skip existing users, use transaction, invite team domain emails as members from share popovers