Skip to content
Loom Docs
Esc
↑↓navigate↵open⌘Jpreview
Product
View as Markdown
On this page

Document source worker boundary

Loom reads one selected document live through an operator-provisioned source worker that holds the upstream credential; this page states that boundary, the…

Loom reads one selected document live through an operator-provisioned source worker that holds the upstream credential; this page states that boundary, the Postgres stores behind it and the fence that guards each delivered frame.

Loom serves stored document search and explicit live document reads over MCP and at POST /v1/knowledge.source.live. Stored search reads indexed copies. A live read asks an approved source worker to read one selected resource under the current caller’s connection. It returns the source link and fetch time. It does not index the result, save it as a memory or record its body as a diagnostic. The client that receives the result controls what it retains.

The source worker owns upstream credentials, outbound MCP requests and account consent. Loom owns source configuration, access policy and the erasure of what it stores; this build keeps no worker copies and schedules no worker refresh. Loom stores opaque worker and connection identifiers, their generations and the approved profile digest. The worker resolves the connection within its own credential authority. Neither side uses the other side’s credential at the upstream endpoint.

This build serves only the live read. No operation writes a collection approval, enrolls an account, runs the selection proof, links a team reader or registers a worker source. The Postgres tables a live read checks ship with their store writers, and the checks the setup operations will use ship uncalled; this page describes what they require. A write to an approval, account or team link row locks that row, which the frame fence locks shared, so a revocation that commits before a frame’s handoff withholds that frame.

The selection proof asks the worker’s /v1/check-access for each selected identity through the owner’s own connection; the worker answers the digest of what it read, never the content. Loom checks the owner’s authority before each request and after each reply, runs two checks at once, gives each 2 seconds, and stamps each with Loom’s clock before the request. A selection holds at most 240 identities, so a proof’s deadline, one 2-second slot per round of two and one for the final authority check, is at most 242 seconds. The resulting setup grant is as old as its oldest check and expires when that check is 300 seconds old, the age setup accepts, which leaves at least 56 seconds to preview and confirm the largest selection. A worker that needs longer for one identity makes the proof answer timeout. A proof reserves two request slots of its own on Loom’s side of the worker for its whole run, so proofs on one worker run one at a time on each server process: a second is refused overloaded before it sends any check, and a proof never fails partway for capacity. Stored-copy confirmations have two slots that proofs never take, and live reads keep max_live_requests, so none of the three refuses another in Loom. The bundled worker admits live reads and access checks through one read limit, so there they share its slots.

A stored-copy confirmation resolves the read with the stored purpose, which accepts only a snapshot or selected-refresh registration and looks up the collection approval by that registration’s mode. The worker’s digest must match the stored revision, which must not change during the check. The evidence carries Loom’s own clock time, not the worker’s fetched_at, and expires within its bounded lifetime.

Worker provisioning

The operator mounts a worker routes file and sets LOOM_KNOWLEDGE_SOURCE_WORKER_ROUTES_FILE to its path. An empty setting leaves the worker directory disabled. Live reads and worker metadata also require Postgres knowledge authority so the store that serves the metadata erases it; without the routes file or that authority a live read answers unavailable. They also require authentication (LOOM_AUTH_REQUIRED) and mirrored sources (LOOM_KNOWLEDGE_MIRRORED_SOURCES_ENABLED, off by default); without either a live read answers denied. Version 1 of the JSON file contains a workers list. Each entry names a worker_id, HTTPS origin, grant issuer, and a profiles map from exact organization names to lists of profile entries. Each entry lists a digest, approved modes (any of live, snapshot and selected_refresh), and optional team_access. A collection approval cannot add an organization, profile, mode or team permission that the operator did not allow, and team access needs a profile with team_access. Only an administrator of the collection, in a protected session under their own sign-in, can change an approval: an impersonated or answer token cannot, and the change applies only to the approval generation the administrator read. Removing an approval needs no provisioned profile. A worker’s optional max_live_requests, 8 by default and at most 64, caps its concurrent live reads on each server process; a read over the cap answers overloaded. Selection proofs, stored-copy checks and enrollment requests each have two slots of their own and do not count against it.

The trust_ca_file, client_certificate_file and client_key_file entries configure mutual TLS; the client key must be an unencrypted PEM. grant_key_file names Loom’s Ed25519 key for signing requests. enrollment_verifier_file, when present, names the worker’s separate public Ed25519 key for its enrollment statements; it cannot be Loom’s grant key, and without it the worker enrolls no account. File paths are relative to the routes file or absolute. These files authenticate communication between Loom and the worker. The operator does not put upstream credentials or upstream endpoint configuration in this file.

A worker source uses the existing source registry. Its versioned configuration contains opaque identifiers and generations. The items hold exact selected resource identities. No new ClickHouse table or upstream credential is needed. A worker source has kind mcp, which is not one of the native kinds, and mirrored access; a build that serves only shared namespace-access sources skips it.

Binding a live read

Loom proves the current caller and collection grant, finds the exact selected resource and resolves the caller’s approved worker connection. It signs a short read grant for that worker. The grant binds the request, operation, organization, namespace, source and selection generation, requester, connection and its generation, profile digest and exact resource identity. The grant is for the worker audience. It carries no credential, URL or tool arguments. The worker accepts grants only from its configured Loom issuer and resolves that exact connection with matching ownership and profile. It rejects an anonymous caller or a grant for another worker, owner, organization, connection or generation. An account belongs to one collection: the source owner’s account and each team reader’s are enrolled in the source’s own collection, and an account in another collection does not serve the read. One connection ID cannot serve two collections, so a worker issues a separate connection for each. For a team source, the reader enrolls a specific connection for the current selection. A different connection for the same endpoint or profile cannot stand in for it. The owner and reader connections must share a verified resource realm before the reader can request access to the selected identity. The bundled source worker attests no resource realm, so with it a team read always refuses and no team source can be set up yet.

The worker validates the current connection before upstream use and before return. Loom checks current source, selection, connection and reader standing again before delivering a result. During each frame handoff, Loom holds the namespace’s Postgres source lock shared, rereads the source row with sequential consistency and refuses the frame if it differs at all from the row the frame’s authority check read, and locks the exact approval, account and team link rows. Every source write holds that lock exclusively alongside its source lease, so a retirement or update that commits before the handoff withholds the frame. Live reads of one collection share the lock, and Postgres queues a new frame behind a waiting write, so a write waits only for the frames already running. No upstream call happens while these locks are held. A frame holds one pooled Postgres connection while it waits for the shared lock and sends, so a burst of live reads behind a write can use up to the server process’s pool for at most the frame deadline. A source write holds its lock on a connection of its own, outside the pool, for as long as its source lease, so writes, nested leases included, never wait on a pool their own locks fill. A write whose insert the server has not answered keeps its lease until that insert can no longer run, and keeps the lock as long, even when its request is cancelled. If a holder’s host disappears, Postgres drops its session over TCP keepalives, so for about a minute source writes of that collection answer overloaded and its live reads wait out their frame deadline and are refused; the keepalives apply only to TCP sessions, not to a Unix socket. A Postgres outage in the lookups before the response, or in a source write’s lock, answers 503; one during a frame’s handoff withholds the response. A build without the lock takes only the source lease when it writes, so during a rolling upgrade a retirement from such a replica can let the one frame already past its reread through; the next frame’s reread stops the response. The same holds if a writer’s Postgres session ends during its write or while it keeps the lock (a failover, a keepalive drop, or its process stopping): the lock is released and a frame can pass its reread before the write lands, and the next frame’s reread stops the response.

knowledge.source.live is experimental. It requires a protected session with a namespace-scoped token, an approved route, and a current source selection. It refuses tokens restricted to one user or session. Registration remains disabled, so this prerequisite does not enable user setup on its own. A live request lives with its API request, so an MCP JSON-RPC batch with other entries refuses the live entry with Send this request individually and answers the rest. A live request has its own read deadline and admission limit, a bounded delivery budget after the read, and no durable payload queue. Loom checks the size of the document before publication. Document text is limited to 4,000,000 UTF-8 bytes, and the encoded document with its escaped MCP text copy to 16 MiB. A document beyond either limit, or an empty one, returns unsupported with no document. Delivery rechecks authority for each 512 KiB chunk within the publication deadline. When that deadline passes during delivery, the client gets a truncated response after the status line, not timeout. A slow client, slow authority reads, a source write holding the source lock, or a revocation between chunks can each cause it. The transports also reject echoed argument names and MCP request IDs that exceed their size limits or cannot be encoded as UTF-8. Loom returns ignored argument names to the caller without logging or caching them. Denial, reconnect, saturation, unavailable and timeout remain distinct outcomes. Team viewers without current source enrollment see the same denial for selected and unselected IDs. Every refusal returns the explicit status, never a stored copy.

Each worker resolves approved profiles to its own endpoint and read mappings. Resource reads and validated tool reads share the same bounds. Caller input and server descriptions cannot expand the accepted operations or outbound addresses. Returned data is evidence for the requested resource only. An account host can implement this worker contract locally if it can resolve the exact requester and connection for the requested operation without an active agent session or credential export. An agent’s own integration does not establish that authority.

Live read statuses

A live read answers one status. ok carries the document. denied means the caller has no current access to the selected resource, or the request is not one this build serves. reconnect means the caller’s upstream connection must be authorized again. overloaded means live read capacity is full, and timeout means the read deadline passed or the worker’s read timed out; both may be retried. unavailable means the worker or the source cannot be reached or failed to answer. unsupported means the document is beyond the live size limits or the source cannot serve it.

Account enrollment

An authenticated owner selects an externally provisioned connection. Loom issues a short challenge for its exact organization, owner, worker, profile, nonce, opaque connection ID and generation, and records it under the collection whose approval it checks; neither the challenge the worker receives nor its signed statement names the collection. The worker signs its statement about the current account with its enrollment key. Neither the challenge nor the statement includes the token or endpoint, and the statement carries opaque connection metadata only. Loom verifies the statement, checks the approval again under the same store locks as it consumes the challenge, and never uses an enrollment statement to authorize a read. An enrollment that fails after its challenge was issued spends that challenge, so the owner can usually retry at once; a spend that fails leaves it to expire. A newer connection generation replaces older authority without erasing a copy or moving it to another account, and a retired generation cannot be restored by replaying a statement. Team readers enroll their own accounts separately for the selected source. A statement may attest the account’s resource realm, which team access requires; the bundled source worker attests none, so no team source can be set up with it yet.

Worker account stores

The Postgres tables hold collection approvals, worker accounts, their enrollment challenges and team reader links. Each row holds scoped identity, provenance, opaque bindings, generations and, for a challenge, its expiry; none holds a credential or an upstream endpoint. Issuing a challenge removes its connection’s consumed and expired ones. Account revocation keeps its generation fence until erasure.

An account, its challenges and a reader link belong to an authenticated person, like a connected account: their subject column holds the canonical sign-in subject, which every key and lookup uses, and the identity tuple’s user_id is -. An approval is the collection’s and names no subject; the approving administrator is its actor. Erasure follows that ownership:

  • A namespace erasure (pg_knowledge.delete) removes every row of the namespace.
  • An owner’s deletion, the canonical-owner lifecycle SCIM deprovisioning runs (connected_accounts.stop_subjects with erase_owner), removes the accounts, challenges and reader links of every owner the deleted user’s spellings name or a verified alias ties to them, in every namespace of every org that holds one (pg_mcp_worker_enrollment.erase_subject). It runs after the connected accounts are stopped and their provider revocations have run, so its failure cannot keep a credential live, and a retry finds the same owners. As for connected accounts, a row written at or after the owner’s revocation cutoff is kept, and an owner with no revocation keeps every row. It takes each namespace’s document lock in sorted order, which a live frame holds shared until its handoff.
  • A user erasure removes none: an end user’s id that equals some subject is another principal.

Stored copies and refresh

Worker copies, refresh and retirement are not built: no store this page lists accepts a worker copy.

Last updated on

Was this page helpful?