Skip to content

Document sources: the design for sources on any namespace, many links, connected accounts and mirrored access - #539

Merged
zlareb1 merged 113 commits into
mainfrom
docs/document-sources
Nov 12, 2026
Merged

zlareb1 merged 113 commits into
mainfrom
docs/document-sources

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

...

Why

Document sources live only on a repository's trunk code namespace, so a team's meeting notes and documents have no place to go. A source holds 20 ids at most, and no op can change them. One shared credential reads everything, so a person cannot bring in their own drive, and every reader of the namespace reads everything synced. docs/architecture/document-sources.md is the contract the implementing pull requests build on.

Design

  • Any namespace. A source can be registered on any active namespace. The NOT_A_CODE_NAMESPACE refusal goes. A source ends with its namespace: delete, collection delete, erasure and repository removal all retire it. Sync state stays in loom.code_index_state.
  • Items and links.
    • A source holds up to 300 items: Drive folders (optionally recursive), files, shared drives, filters the server builds (never a raw query) and the recordings folder; Notion pages and databases; Linear projects.
    • knowledge.source.parse_links turns pasted links into items and names each link it cannot read. knowledge.source.update adds and removes items.
    • One document per address, owned by one source, as today. A second source that reaches it counts it skipped and writes it once the owner's document is retired.
  • Credentials. Three modes:
    • shared: as today.
    • connected: a person's own OAuth account. Its state is bound to the subject and it accepts read scopes only. Only its owner changes its items. It stops on disconnect, on SCIM deactivation and on the owner check at each turn.
    • crawl: domain-wide delegation over listed people or a group's members. Registering one needs an org-wide role, and the probe requires the store to refuse write scopes.
  • Access.
    • Every connected and crawl source is mirrored.
    • A mirrored document lives in a random acl-<hex> companion namespace. No token opens it through the gate, and only a platform admin's erasure.request can name it.
    • Only read legs that apply the check read it. A path nobody taught the check, and an N-1 replica, show none.
    • The model has four parts: the companion namespace no grant opens; the file's permission list on the mirrored document's own row; a read check that admits only a reader the list names, while the source's last complete listing is within a stale bound, and fails closed on anything it cannot read; and every sync turn reading the lists again, rewriting a changed one without re-embedding. Link-only shares admit nobody; groups are read through the crawl's directory.
    • A person's own collection or namespace holds no source.
    • The page has the threat model and the guarantees the implementing pull requests hold for erasure, audit, restores and rolling upgrades.
  • Rolling upgrades.
    • A source N-1 must not touch is stored with kind empty. On a trunk namespace N-1's check answers credential_invalid (off a trunk, its check and rotate answer NOT_A_CODE_NAMESPACE), its rotate fails before writing, and its turn ends before any request.
    • The new modes wait for a fleet-wide schema check.
    • A rollback first erases the mirrors.
  • Meetings. Meet transcripts and notes come in through the Drive sync, and transcripts are written as timed sections. recording keeps zoom only (a break).
  • Issues. The Linear issue feed is a later design of its own. The page lists what it has to answer: a tenant predicate, the contract's required tables and ids, LOOM_TRACKER_ORG, and private rows.

Refinements to the brief, with reasons

  • Store groups resolve through the crawl's directory read, not through Loom's SCIM groups. loom.principal_groups holds a service's end users (user:<id>), not people's emails.
  • A connected account reads no directory, so through it a group share admits nobody.
  • drive.file with the picker is not offered, because it cannot read a folder's later files or the recordings folder.
  • A Notion connected source is mirrored and, with no page permissions to read, its list names the owner whose account listed the page, so each page shows to its owner only.
  • Two sources that reach one file share one document with one owner, its tag, as the sync does today, not a record of every source that reaches it. The second source counts the file skipped and writes it once the owner's document is retired: at its next complete listing when mirrored, at its next full listing for a namespace source. No source reads whether another is live; an address is free when no document is there. A per-address record of every source needed its own states, retirement ordering and crash recovery, and each review found a new race in them. The cost is a document missing between the owner's retirement and the other source's next listing of the file. In a mirror, ownership goes by a source-id:<id> tag on each document (only N writes mirrors), so a later source of the same name owns none of an earlier one's documents, and a stopped mirrored source's cleanup retires by that tag.
  • The permission list is a column of the mirrored document, not a table of its own. A separate per-address table outlived its document on retention, on a retirement racing a read from another replica, and for a file whose content was not fetched yet, and each fix needed another sweep or ordering rule. On the document, the list goes with every retirement and erasure, and with a retention drop under the ClickHouse authority, and only the owning source's turn writes it.
  • A namespace's erasure covers its mirror as one more name under the same scope, so status, listing and audit stay as today; a mirror's rows are deleted in either mode, since no token can read or restore them.
  • After a restore, mirrors are erased, not restored: a restored copy cannot be trusted to say who may read. Owners and crawl admins add their sources again.
  • The page is frozen at that model. The erasure of a person's connected accounts and crawl entries, a stopped source's cleanup, lists from several accounts of one source, and restores are stated as guarantees the implementing pull requests design against: review rounds on a step-by-step spec of them kept finding one more ordering case each time, and their mechanics are checked best against the code that implements them.
  • The issues feed is split out. The tracker plane's contract and tenancy need their own changes.

Scope and risk

Documentation only. The page describes ops, tables, settings and routes that the implementing pull requests add.

Compatibility, rollout and rollback

  • Wire: none in this pull request.
  • Operator steps: none.
  • Rollback: revert.

Tests

  • tests/unit/test_doc_links.py and tests/unit/test_public_copy.py pass.
  • scripts/codegen/docs_reference.py --check passes.
  • Prettier finds nothing to change on the page.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 29 commits November 12, 2026 07:59
…, connected accounts and mirrored access

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t rows for N-1, owned tracker feed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…cess rows, owner rule for connected only, issues as their own design

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… per account, owner-only item changes, auth-off and erasure-race rules

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…y by their own listings, newest evidence wins, mirrors kept

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…gs, no token reads a mirror, crawl erasure and group bounds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… refuses mirror scopes, pseudonymous crawl exclusions

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…lists written on change, listing ahead of content, crawl erasure rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…atched to their own source's listing, shared listings, listing share of the pass

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…stopped sources' rows by the holds trigger, a listings cursor, owner check stops

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…pped crawl accounts, the pass split against today's bounds, pseudonymous audit subjects

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…on erasure, positive-evidence expansion drops, keyed audit hashes, the pass split stated

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…keeps its start bound, cleanup from inactive registry rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…-up rule, why some pseudonyms are unkeyed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ed holds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…n reads live rows sequentially and re-checks under the lease

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…n reads live rows sequentially and re-checks under the lease

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…kes pending_delete, re-checks before it opens one

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e, a new hold re-reads its document, every row write checks the registration

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…irement keeps a holder's readers rows, access rows follow holds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ers and access rows back, deletions keep the replaced version

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t retires only with no hold left, row versions defined

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e access-row version case, first-listing defined

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…al from holds, the drop-before-read order

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…holds, retirements read dropped holds so a cut run finishes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…te's write path and its version check

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…olds block retirement

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ith holds, kept holds settle with their document

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 26 commits November 12, 2026 09:08
… and keep every org-wide read, an acl- saga and a reused name from naming a mirror

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the sync and erasure write under a mirror, capture hooks skip mirrored turns, and an erased name gets a new mirror

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ate-read failures drop mirrored results without a marker, capture hooks stop for a session that saw a mirrored answer, and an erasure refuses a new source

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s, a domain only through the identity provider's claim, reads_as_creator only from a session, and mirrored config is empty

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ion, old plugins are refused only where a mirror exists, and a crawled person reads only files they own or are named on

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…er-only list its own shape, and let a mirror leg answer only a client that honours the flag

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…g is left to the sync, capture ops refuse a hook that ignores the flag, and the dashboard and assistant declare it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nt honours the flag, the assistant's answer token reads as its caller, and a removal's retirement has its own bound

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t ops stop for a session that saw the flag, the switch also shuts the legs, and N reports an N-1 heartbeat beside a mirror

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t each while any mirror exists, name the maintenance workers, and state the N-1 residual

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…er's org and list it as a break, and fold or mask marked spend in the export and SQL views

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e registry by who picks the content, end an empty mirror, and group the unit tests by the part they pin

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…est the classes against what the hooks send, fail the refusal closed, and end a mirror only by erasure

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…rted from it inherits the flag, and the refusal's lifetime is worded one way

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… insights.query included; recall credit follows the mark; the flag also lives in the session's state; the refusal's latch is a named row

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… erase refuses while it is on, the mask covers every field an admitted item can shape, and a marked request writes no recall credit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… included, bound exception 1 to admitted items, give the latch its own table, and erase it last

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ccept the differencing residual, list the hook-sent reads, and split the long bullets

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…to stored rows, match a connected owner by subject, and let the namespace copy win

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s; a child's flag reaches its parent; a namespace copy carries only its own chunks; the probe rules split by case

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…obe names no item to a non-owner, the reader's own lookups are per-request reads, and the declaration is the transport's

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s it on every mirrored namespace, its answer token's reading is fixed by the bridge, and spend waits for the check

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tted, the assistant's chat route is marked and flagged like assistant.ask, and the answer token's reads-as claim is one mechanism

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he accepted cost names every hook stopping, and the front end's token record is an operator-only spend row

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the hook cost says reads included, knowledge.reads and ui.vitals tests cover flagged answers with nothing admitted, and two paragraphs are rewrapped

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ive mirrored source, with a test for one listed but inactive, and the cost.summary cost names marked reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit ccbc78d into main Nov 12, 2026
38 checks passed
@zlareb1
zlareb1 deleted the docs/document-sources branch November 12, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant