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 the live read, the collection approval operations described in Collection approvals, the account link described in Account enrollment and the registration of an owner-only live source described in Source registration. No operation links a team reader or registers a snapshot or selected-refresh source; the checks those need ship uncalled, and 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. The preview runs the proof inline: the TypeScript SDK waits up to 300 seconds for it, and a Python, Go, Ruby or Rust SDK caller or an MCP client needs a timeout above 242 seconds for a full selection. 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 Loom’s own capacity; the worker’s own limit can still refuse a check. 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, and a proof needs its concurrent and concurrent_per_org to be at least 2 with room for the org’s live reads: below that, every proof of two or more resources answers overloaded (source worker).

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.

Collection approvals

Two experimental operations let a collection administrator approve worker profiles. knowledge.source.worker_profiles pages through the profiles the routes file provisions for the organization, up to 50 at a time, ordered by worker and digest. Each entry gives the provisioned modes and team access, the modes and team access the collection approves within that provision, whether the worker has an enrollment key, whether the stored approval is active even when the provision no longer allows any of its modes, and the approval generation as exact decimal text, 0 when the collection has none. It returns opaque identifiers only, never origins, certificates, keys or upstream credentials. The pages also hold the collection’s active approvals of profiles the routes file no longer provisions, in the same order, with no provisioned or approved modes and their stored generation, so the administrator can revoke them. The cursor is the last entry shown, and a next page is returned exactly when a provisioned profile or such an approval sorts after it. knowledge.source.worker_approve sets the approved modes and team access of one profile, or revokes the approval with an empty mode list, and names the generation the administrator read. It applies only to that generation and answers the new one. When another change landed first it answers stale, and the caller reads the list again before retrying.

Both answer one status. denied covers every refusal of the caller, an unprovisioned mode or team access, and a collection that an unfinished namespace erasure may reach, so the answer does not show whether another collection or approval exists. Both run the administrator check in Worker provisioning first; only then does unavailable say that the deployment has no routes file or no Postgres authority, and the list then reads no approvals, so it never makes up a generation 0. After its read the list runs the administrator check again, and answers unavailable if the runtime stopped meanwhile. Both refuse tokens restricted to one user or session. An approval is written in the namespace’s scope transaction, which a namespace erasure’s delete waits for, once Postgres’s erasure ledger shows no unfinished erasure that may reach the namespace.

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. 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.

The experimental knowledge.source.worker_enroll runs this enrollment for the caller. It names the collection, the worker and profile digest the collection approves, and the opaque connection ID and generation the operator gave the caller for their worker account; the owner is always the authenticated caller. The caller needs the viewer role in the collection, the role a live read needs, since a linked account serves only its owner’s live reads there, and the same protected session under their own sign-in as an approval; it refuses a token whose write scope leaves the collection out and tokens restricted to one user or session. The approval must be active with at least one mode the routes file still provisions. The caller check runs again before the worker request and after its reply. Each write transaction reads the erasure ledger, as an approval does, and locks the approval row. A link answers ok with the connection ID and generation only. denied covers every refusal of the caller, a statement that does not match, an approval that changed meanwhile and a connection ID that another account or collection holds, so it shows nothing about them. overloaded means the caller’s own enrollment of this account is still in flight, this Loom process’s two enrollment slots for the worker are taken, or the worker answers that it is busy. timeout means the worker did not answer in time or the enrollment ran past 29 seconds, a second before the 30 seconds its challenge lives. Both may be retried as they are. unavailable, answered only once the caller check passes, means the deployment has no routes file or Postgres authority, the collection does not approve the profile, the worker has no enrollment key, or the worker failed to answer.

Source registration

Two experimental operations let a collection writer register a live source on their own linked account: the role knowledge.source.add needs for a source on the caller’s own account, since a registration writes the collection’s source registry. knowledge.source.worker_preview names the collection, the source name, the worker and profile digest the collection approves, the opaque connection ID of the caller’s account linked there, the mode, and the exact ordered selection of at most 240 resource identities. Loom resolves the collection’s current approval within the routes file and the caller’s active account under it, checks the collection, the erasure ledger, the name and the quotas as knowledge.source.add does for a source on the caller’s own account, mints the source ID and runs the selection proof through the worker. It writes nothing. It answers the reader policy, whether Loom stores a copy, what the mode reads and keeps, the selection’s size, a fingerprint of the registration, the proof’s grant sealed under the deployment’s root secret as opaque evidence, and when that evidence expires, at most 300 seconds after the proof’s oldest check.

knowledge.source.worker_register takes the same fields with the fingerprint and the evidence. Any server process may answer it: it opens the evidence, which names the source name and the source ID the preview minted, and refuses one it did not seal or sealed for another name. Under the namespace’s source lease it checks the collection, the erasure ledger, the name and the quotas again, then the caller. In a Postgres authority transaction that holds the namespace’s knowledge lock shared, it reads Postgres’s erasure ledger, then the approval within the routes file and the account with their rows locked, and recomputes the registration from what it read. The evidence must bind the same organization, collection, account and its generation, approval generation, ordered selection and source ID, and must not have expired; the recomputed fingerprint must equal the preview’s. It then writes the source row as a worker registration (mcp_worker_source.encode_worker_source) with the owner as owner_subject and created_by, through the one store writer that writes an active worker row, and answers the source ID and name only. The transaction ends once the write has landed or can no longer land: when the insert answers, at once, and when it raised with its send unanswered, only once that send can no longer run, at most the source lease’s TTL and its send bound later, however the request ends. Owner erasure deletes the owner’s accounts under that knowledge lock taken exclusively before it reads the registry, so either it removed the account first and the registration answers denied, or it waits behind the transaction and its registry scan finds the row. A wait that outlasts its statement timeout answers 503 with nothing deleted, and a retry finds the account and erases it. That hold has a cost, for up to the source lease’s write bound plus the send bound after an unanswered insert: owner and namespace erasure of the collection wait behind it or answer a retryable 503; Postgres queues new shared requests for the knowledge lock behind a waiting exclusive one, so the collection’s enrollment and approval writers can stall for up to their statement timeout on each attempt; and the source lock stays exclusive, so live reads of every source in the collection wait or are refused. It is accepted because it follows only a ClickHouse insert that went unanswered, it is bounded, every refusal it causes may be retried, and erasure needs it: a fence released sooner lets an erasure miss a row that lands later. knowledge.source.live serves the source to its owner from then on. The registration’s audit row records the caller. Its owner or the namespace’s administrator removes it with knowledge.source.remove, namespace retirement writes it inactive, and its owner’s erasure deletes it (document sources).

Only live is registered, with the owner_only reader policy: a snapshot or a selected refresh needs a stored copy and its refresh, and team access a linked team reader, neither of which ships, so each answers unavailable. Both operations answer one status. The caller check of Collection approvals at the writer role runs first; denied covers its refusal, an account the caller has not linked there, an erasure that may still reach the collection and a proof the worker refuses, so it shows nothing about other collections or accounts, and unavailable comes only after it: no routes file or Postgres authority, no active approval with a provisioned live mode, or a worker that failed to answer. name_taken means an active source, or a removed worker source, holds the name; any other refusal the add makes of a new source is answered as the add answers it. The preview’s overloaded means a proof on that worker is already running on this server process, or the worker itself is at capacity (it answers 429; the bundled worker’s per-org limit is shared by every Loom process, live reads and the org’s other collections, and its total by every org it serves), and timeout that the proof ran past its deadline; both may be retried. The registration answers stale when the evidence is not one this deployment sealed for that name, has expired, or no longer matches the current approval, account or selection, or when the fingerprint differs; the caller previews again. Its overloaded means another change to the collection’s sources holds the lease, or that a writer holds the account or approval row. A worker source counts with connected sources, as a source on a person’s own account, toward the namespace’s and the person’s quotas. Both refuse tokens restricted to one user or session.

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. The same owners’ worker sources in the source registry go next, by the same cutoff on when each was registered, each namespace’s under its source lease and Postgres source lock, so a frame whose handoff follows the delete finds no source (owner erasure).
  • 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?