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, an owner-only source’s private copy included (Stored copies and 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, the registration of a source described in
Source registration, while
LOOM_KNOWLEDGE_SOURCE_WORKER_TEAM_READS_ENABLED is on the live team source and its
reader links described in Team sources, and, while
LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED is on, the private copy of an owner-only
snapshot or selected-refresh source. A team source keeps no copy. 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 copies and their confirmations share
knowledge_source_worker_copy_concurrency times knowledge_source_worker_turn_concurrency
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. It confirms the owner’s access only: the worker’s digest is
not compared with the stored copy’s, so a changed resource keeps its copy until the copy
is due again. 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 and enrollment requests each have two slots of their own,
and stored copies and their access checks share knowledge_source_worker_copy_concurrency
times knowledge_source_worker_turn_concurrency slots; none counts 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 a resource realm only for a connection record that declares one, so a team read through an account without one always refuses. A team read also needs the owner’s standing at every check: an active directory account, no revocation since the registration, and the writer role in the collection.
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. A host connection gives authority for the host identity’s own namespace only, and only when an administrator of that namespace, not the agent, assigned the source (assigned sources).
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 as a digest, which team access requires; the bundled source worker attests one for a connection record that declares a realm. The digest keeps the realm itself off the wire, but anyone who can read the account rows can confirm a guessed realm. Loom keeps the digest an account was first enrolled with, so a connection ID cannot gain, change or lose a realm.
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.
The experimental
knowledge.source.worker_accounts
shows a member what to link and which account to register a source on. It pages, up to
50 at a time and ordered by worker and digest, through the profiles the routes file
provisions for the organization that the collection actively approves with at least one
mode the provision still allows. Loom reads the collection’s active approvals in that
order and keeps each one whose profile the routes file still provisions, so a page costs
reads in proportion to the collection’s approvals, not to the size of the provision.
Each entry gives the approved modes and team access within that provision, whether the
worker has an enrollment key, and the caller’s own account on the profile: whether it is
linked, its connection ID and its generation as exact decimal text, 0 when the caller
has none. When the caller holds several accounts on one profile, the entry shows the
linked account written last, else the account written last. A member never sees a
profile the collection does not approve, an approval generation, or another subject’s
account. The caller check is the one knowledge.source.worker_enroll runs, and it runs
again after the reads. It refuses tokens restricted to one user or session. denied
means what it means for knowledge.source.worker_enroll. unavailable means only that
the deployment has no routes file or Postgres authority, or that the runtime stopped
during the read. Where an enrollment would answer unavailable because the collection
does not approve the profile or the worker has no enrollment key, this list answers
ok, with the profile left out or with enrollment_configured false. The cursor is the
last entry shown, and a next page is returned exactly when another listed profile sorts
after it.
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).
knowledge.source.list and knowledge.source.inspect describe the registration in its
worker entry. Every reader of the namespace sees its mode, interval_seconds and
resource_count, but never the resource ids. Its owner, while they still hold the
writer role there, and the namespace’s administrator also see worker_id and
profile_digest. Only the owner sees connection_id and connection_generation
(exact decimal text), since they name the owner’s account. A listing reads the caller’s
grants and subject once, and only when it holds a registration. A failed read withholds
only the fields it gates, and this entry marks the request as serving private detail
only when it carries them; knowledge.source.inspect’s mirror plan marks a request on its
own whenever the namespace has active mirrored sources. The entry carries no approval
generation, route or credential, and it is null for every other source, including one
assigned to a worker subject.
A registration with team_access has the current_team_access reader policy and is
described in Team sources; every other one has owner_only. An owner-only
snapshot or selected_refresh registration, the latter with its interval_seconds (300
to 86400), answers unavailable unless LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED is on,
since only then does the sync keep its copy. 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.
Team sources
A writer shares a live source with the collection by registering it with team_access.
The preview and the registration answer unavailable for it unless
LOOM_KNOWLEDGE_SOURCE_WORKER_TEAM_READS_ENABLED is on, the routes file provisions the
profile’s live mode with team access, the collection’s approval has team access, and the
owner’s account attests a resource realm. A snapshot or selected_refresh registration
with team_access answers unavailable whatever the settings: a team source keeps no copy.
The preview’s disclosure says that another member reads only through their own account. The
owner reads the source as an owner-only one.
Another member reads it through their own account only. The operator provisions that account
for them, with their own upstream credential and the realm of the owner’s account (source
worker). The member enrolls it in the collection on the
source’s worker and profile with knowledge.source.worker_enroll, then links it to the
source with the experimental
knowledge.source.worker_link,
which names the collection, the source name and the account’s connection ID. The caller
check is the one knowledge.source.worker_enroll runs, at the viewer role. Then Loom reads
the source row and requires an active, unpaused live registration with the
current_team_access policy that the caller does not own, whose profile the routes file
still provisions for team reads, and the owner’s standing. It runs the caller check again.
In one Postgres authority transaction that holds the namespace’s knowledge lock shared, it
reads the erasure ledger, then the approval, the owner’s account and the caller’s account
with their rows locked. The approval must be active, approve live with team access and
carry the registration’s generation. The owner’s account must be active at the registered
generation. The caller’s account must be active on the same worker and profile, with the
same resource realm as the owner’s. Loom then writes the caller’s link
(loom.mcp_worker_source_readers) at the source’s selection generation, naming that account
and its generation. It answers ok with the link’s generation; the same link sent again is
answered as it stands, so reads in flight keep their scope, and a link after the reader
enrolled a newer account generation replaces the old link. denied covers every refusal of
the caller, of the source and of either account, a realm mismatch included, so it shows
nothing about other subjects’ accounts. overloaded means a writer holds a row it reads, or
another link of the caller’s landed first; either may be retried. unavailable comes only
after the caller check: the deployment has no routes file or Postgres authority, or serves
no team reads.
A linked reader reads the owner’s exact selection live with knowledge.source.live, which
checks for every read and frame: the reader’s standing; that the deployment serves team
reads; the current_team_access policy; the reader’s active link at the source’s selection
generation; the reader’s and the owner’s accounts, active at their generations on the
source’s profile, with the same non-empty realm; the owner’s standing; and the approval with
team access at the registered generation. Only then does it check the selected resource, so
a member without that authority gets the same denied for a selected and an unselected ID.
The worker reads with the reader’s own connection; the owner’s account answers no request
made for a reader. A reader sees only what their own upstream account returns, and never
another reader or the owner’s connection. The owner’s standing is checked as the reader’s
is, before the worker request, after its reply and before each frame of the response, so a
revocation of either stops the next frame. Its directory reads are those of a copy turn, and
its writer grant is read through the alias cache, as the reader’s role is, so a grant held
under a departed alias counts for at most grant_cache_ttl_seconds.
knowledge.source.worker_unlink
ends a link. A member unlinks their own, the link under their sign-in subject; a collection
administrator unlinks any reader’s by naming any verified spelling of them, ASCII letters in
any case, which ends that reader’s team reads without changing the approval, whose every
write moves its generation and so ends every registration on the profile. Loom reads every
spelling the directory verifies for the named reader, and an administrator ends the links
under every one. A member among them is that reader and ends only the link under their own
subject, since one verified email may tie two accounts; any other member is refused. The
caller check runs again after the source read. In an authority transaction as above, Loom
finds the source’s active links whose subject is one of the spellings to end, folding ASCII
letters only as the directory does, and writes each inactive, comparing its generation; a
link that changed meanwhile answers overloaded, which may be retried. It answers ok once
none of those links is active, whether or not this call removed it, even while team reads
are off, and denied for a caller who may not unlink that reader, a name no worker source
holds, or an erasure that may still reach the collection.
A team reader’s reads stop at the next check when any of these happens: the reader unlinks
or is unlinked, loses the viewer role, is deactivated, or has a token revoked; the operator
revokes or changes the reader’s connection record, which the worker refuses or Loom’s
generation check refuses; the reader’s upstream access ends, which the worker answers
denied; the owner loses standing; the administrator turns team access off or revokes the
approval; the source is removed; the operator turns
LOOM_KNOWLEDGE_SOURCE_WORKER_TEAM_READS_ENABLED off. A SCIM deletion of the reader removes
their accounts and links in every namespace, and one of the owner removes the registration
(Worker account stores).
Command line
loom knowledge source worker-profiles, worker-approve, worker-accounts,
worker-enroll, worker-link, worker-unlink, worker-preview and worker-register
call these eight operations on a running server with the CLI’s token, as an SDK caller does
(CLI reference). Each prints the answer as JSON and exits 1 when
its status is not ok. The preview and the registration read the selection from a
JSON file (--selection-file), and the registration reads the fingerprint and evidence
from the preview’s saved answer (--preview-file). The CLI sends no session protection
declaration, so the server answers these commands denied, as it answers any caller
that does not declare one.
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_subjectswitherase_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
While LOOM_KNOWLEDGE_SOURCE_WORKER_COPIES_ENABLED is on, the sync worker keeps a
private copy of each active, unpaused, owner-only snapshot or selected_refresh
source in its collection’s mirror (source_sync_worker), inside the same private scope
as a connected source’s turn. A copy is a document at the resource’s address
(mcp_identity.resource_uri), written by the sync actor with the source’s source-id
tag and a permission list naming the owner alone; its metadata carries the worker’s
content_sha256 and revision, the selected resource’s id as source_document_id and, as
source_link, the document’s link when display_link accepts it ("" otherwise), which
a search hit’s synced_from reads. No worker subject uploads the copy, so its metadata
names none and the hit’s uploaded_by is "".
A turn reads the collection’s current approval of the registration’s mode and the owner’s
worker account at the registered generation first; one that no longer matches ends the
registration (below). It then needs the owner’s standing: an active directory account, no
revocation since the registration, and a writer grant in the collection. Each worker request
resolves that authority again as a live read does (CurrentRead with the stored purpose),
with the owner as requester: before a copy request and after its reply, and for an access
check also just before it is sent. A resource with no copy, a selected-refresh one whose
interval has passed, or one whose stored row’s metadata has no source_document_id (the
turn’s read of its copies returns that with each row), is read through the worker’s live
path; a reply with the stored digest writes nothing unless the row lacks that key. A copy
written without the keys, a snapshot’s included, gains them on one further read: that read
is a copy request, so it spends the pass’s document bound, and the rewrite chunks and embeds
the copy again (knowledge.upsert embeds every write, unchanged text included). A snapshot
copy whose resource changed upstream since it was copied takes the current text on that
read, and its copied_at moves. A source with more such copies than the bound takes several
passes, its turns marking pass bound reached (the dashboard’s Incomplete) meanwhile. A
copy whose rewrite the store refuses, or whose read for the keys the worker answers
unsupported, keeps its older text, and its entry records refused_at: while that is newer
than its copied_at, it is read again at its refresh interval from the refusal, never on
every turn, and a snapshot’s is not read again for the keys alone; a refused_at older than
copied_at (an older build read the copy since, which moves copied_at and keeps the
entry) is ignored. A read for the keys that times out, which may be the worker’s and not the
resource’s, keeps the older text too and is tried again half the stale window later
(retry_at); the copy has its access checked meanwhile. The entry’s copied_at is when the
stored text last matched the worker’s, which an access check never moves; a search hit
serves it as the copy’s synced_from.synced_at. A process runs up to
knowledge_source_worker_turn_concurrency worker sources’ turns at once (default 1, one
after another), and a turn sends up to knowledge_source_worker_copy_concurrency copies and
checks at once (default 1, one at a time), in one channel share per worker of the two
settings’ product, which Loom’s live reads never wait on. Once a request ends the turn, no
new one starts; those in flight finish and their answers apply, but an upstream denial
retires its copy only when no other request ended the turn before its authority was read
again. That share guards only Loom’s own channel slots: on the worker, a copy, a check and a
live read take the same read_limits.concurrent and concurrent_per_org slots. Raising
either setting is the operator’s step, sized so that each worker’s concurrent_per_org is
at least the turn concurrency times the copy concurrency plus room for the org’s live reads
and setup proofs, and twice that product where a manual loom knowledge sync runs beside
the background pass (or a lease handover overlaps two passes); below that, live reads answer
overloaded, and a turn whose own request answers overloaded ends. Every other copy whose
access was last confirmed more than half of knowledge_source_acl_stale_seconds ago is
checked with /v1/check-access, which returns the digest only. Resources without a copy go
first, then the stored copies by oldest confirmation, in that order of starting. Copies
count against the pass’s mirror document bound, each taking its place before it is sent and
giving it back when no document arrives, so the copies in flight never spend more than the
bound has left; checks count against its time alone, so a worker source’s turn still starts
once other mirrored sources have used up the bound, and only its due copies wait for a pass
with room. A copy’s address is fixed by its source ID and its resource, and a registration’s
selection never changes, so every stored copy belongs to a selected resource.
Capacity: within the mirrored phase of each knowledge_source_sync pass, which native
mirrored sources share, a process runs up to knowledge_source_worker_turn_concurrency
worker sources’ turns at once, in the order they were last synced, and each turn sends up to
knowledge_source_worker_copy_concurrency copies and checks at once. Among sources last
synced at the same time, such as those never synced, the orgs take turns, and within an org
its namespaces, so one tenant’s many sources never starve another’s. A native mirrored
source’s turn runs alone: the phase waits for the worker turns in flight to finish before it
starts one, and starts none beside it; one past the document bound is skipped without that
wait. Once the phase is out of time or stopped, or a turn raised, no new turn starts; those
in flight finish, and a stop outranks another error. Every stored copy needs a check every
half of knowledge_source_acl_stale_seconds, so the copies one deployment keeps served are
bounded by the mirrored phase time in that window divided by one turn’s time (Loom’s
authority reads, the worker’s upstream session, and the turn’s own registration, standing,
listing and state reads and writes). The copy concurrency divides a turn’s request time only
for a source with that many resources due; the turn concurrency overlaps whole turns, so it
also helps sources of one resource each. The turns of one namespace still write their sync
state one at a time: callers of a namespace’s sources lease in one process queue for it in
order, within its wait, rather than poll the lease store against each other. Every request
in flight and every turn’s own reads draw on the process’s Postgres and ClickHouse pools, so
keep the product of the two settings well within pg_pool_max_size and ch_pool_maxsize: a
request that waits for a Postgres connection past pg_statement_timeout_ms fails its turn.
The worker’s read slots, its upstream or the pools can become the limit first. It stays a
bound. Past that bound the oldest listings lapse and those copies stop being served, which
fails closed; a turn the bound cuts reads pass bound reached, and a source the phase does
not reach keeps its last state. A selected_refresh copy is read again at most once a pass
and spends the mirror document bound even when its digest is unchanged, so
interval_seconds is the least time between copies, not a schedule. This feature is
experimental and off by default. A dispatched workflow measures the bound on one hosted
runner
(source worker copy capacity).
Of the worker’s answers, only its report that the upstream refused the account retires a
copy at once: a 403 whose body is exactly
{"status": "denied", "reason": "upstream_access"}, read whole within 256 bytes, which
the worker sends only for the upstream’s own HTTP 403 to the resource request itself,
the resources/read or the mapped read’s tools/call
(source worker responses); a 403 to
initialize, tool discovery, the GET stream or the closing DELETE stays a plain
denied. Even then the registration, the owner’s standing, the approval and the worker
account are read again and must still hold. Any other denied ends the turn with every
copy kept: a grant the worker refused (a rotated or mismatched grant key, a clock
outside the grant’s lifetime), Loom’s own check of authority that changed during the
turn, or a reply that failed validation. A worker build that names no reason never
causes a retirement on a denial; its copies stop being served once their access goes
unconfirmed past the stale window. A copy answering unsupported follows the lapsing
rule below with either build. reconnect, overloaded and unavailable end the turn
and keep every copy, and a stored copy whose request keeps ending turns keeps every copy
of the source unserved until it answers or the source is removed, which fails closed;
timeout and unsupported keep that resource’s copy and let the turn go on. A
timeout may be the upstream’s or the worker’s, so it never retires a copy. A stored
copy that answers unsupported once its confirmation would lapse before the next pass
(older than knowledge_source_acl_stale_seconds less
knowledge_source_sync_interval_seconds; only a copy whose check fell due can have a
peer confirmed since, so none goes before half the window) is retired before it can hold
back the listing of the others, its state noting copy_unconfirmable, but only when
another copy was confirmed after its own check fell due, which shows the failure is the
resource’s, and with the registration and the owner’s authority read again and still
holding, in a turn no other refusal ended. Removal, namespace retirement, owner erasure
and the end of a registration (below) also retire every copy of the source. A resource
left without a copy, denied by the upstream or unsupported, is read again only after its
refresh interval or, for a snapshot, half of knowledge_source_acl_stale_seconds; one
that timed out or answered any other refusal, after half of
knowledge_source_acl_stale_seconds. The mirror read gate needs a listing no older than
knowledge_source_acl_stale_seconds, and the turn records the listing at the oldest
confirmation among the stored copies, so a copy whose access was not confirmed in that
window stops every copy of the source being served until it is confirmed or retired.
Nothing confirms a copy while the owner’s standing, the approval or the worker account
fails, so they fail closed together.
An approval or worker account read that no longer matches the registration (the
collection’s approval at another generation or gone, the owner’s worker account
inactive or at another generation) ends the registration, since nothing restores that
generation: under the namespace’s source lease, once a read there confirms it, the row
goes inactive, its copies are queued for retirement and its sync state reads
owner_inactive, as for a connected source whose owner left
(source_sync_connected.ensure_current). A read that fails, a routes file that does not
provision the profile in that process, and a lost writer grant or directory standing
keep the registration and every copy, unserved once the stale window passes.
The mirror read gate admits a worker source’s copies to its owner alone: the latest row of the name must be the same registration the request first read, still copied, the reader’s own sign-in subject must be its owner with the viewer role, and the approval and the owner’s worker account must be current. Any other reader, a changed registration or a failed check admits no copy. While copies are on, the gate’s registration read returns only worker rows whose stored registration names an owner-only copy mode, so a live worker source costs a reader nothing.
knowledge.source.remove, namespace retirement and owner erasure queue the source’s
copies for the knowledge_source_retire worker before its row goes inactive or is
deleted; that worker deletes them as it deletes a mirrored folder source’s copies, and
an active row of the same source ID stops it. A namespace erasure purges the mirror with
every copy in it.