Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9218a27
Register protected live reads through provisioned source workers
zlareb1 Nov 24, 2026
382029a
Test live document delivery after an in-flight revocation
zlareb1 Nov 24, 2026
47fdeef
Enforce provisioned source worker capability limits
zlareb1 Nov 24, 2026
e99260f
Resolve exact worker scope before account enrollment
zlareb1 Nov 24, 2026
43642ce
Plan bounded scheduled and manual source refresh
zlareb1 Nov 24, 2026
876664c
Revert "Plan bounded scheduled and manual source refresh"
zlareb1 Nov 24, 2026
939c7ac
Gate experimental worker reads on knowledge authority
zlareb1 Nov 24, 2026
80f6c18
Fence protected live delivery against worker revocation
zlareb1 Nov 24, 2026
e6a9a26
Document and classify the live source operation
zlareb1 Nov 24, 2026
85528c3
Qualify live revocation ordering on hosted Postgres
zlareb1 Nov 24, 2026
577669d
Separate live read authority and Postgres fence test steps
zlareb1 Nov 24, 2026
15ac4a2
Fix approval revocation and separate live payload policy
zlareb1 Nov 24, 2026
8517725
Refuse narrowed credentials for live source reads
zlareb1 Nov 24, 2026
5804a3a
Refresh protected MCP source reads against main
zlareb1 Nov 26, 2026
e14ca16
Fence live source retirement through response delivery
zlareb1 Nov 26, 2026
e85db41
Check team authority before revealing source selection
zlareb1 Nov 26, 2026
8081b7e
Complete live publication setup within its own budget
zlareb1 Nov 26, 2026
701374b
Let live source responses wait for the publication lease
zlareb1 Nov 26, 2026
a47a773
Test the source worker configuration limits
zlareb1 Nov 26, 2026
d48461c
Merge remote-tracking branch 'origin/main' into feat/mcp-worker-live-…
zlareb1 Nov 26, 2026
3122802
Bound each fenced response body send
zlareb1 Nov 26, 2026
22ec4fb
Check live source authority once per fenced body chunk
zlareb1 Nov 26, 2026
4784da9
Bound live worker document output before publication
zlareb1 Nov 26, 2026
a3d7cbc
Bound echoed metadata for live worker responses
zlareb1 Nov 26, 2026
7f436d4
Keep live response metadata valid and private
zlareb1 Nov 26, 2026
87da251
Validate live request IDs before MCP refusals
zlareb1 Nov 28, 2026
484c095
Merge main into the live source worker branch
zlareb1 Nov 28, 2026
7be337e
Merge the adoption docs update into the live source worker branch
zlareb1 Nov 28, 2026
6adc74a
Reject live MCP calls without a request ID
zlareb1 Nov 28, 2026
1897e2e
Wait for fixture grants in the audience SDK example
zlareb1 Nov 28, 2026
85a70db
Merge main into the live source worker branch
zlareb1 Dec 1, 2026
9e9960c
Generate the Go SDK for knowledge.source.live
zlareb1 Dec 1, 2026
af4a030
Live reads report budget and deadline failures as such
zlareb1 Dec 1, 2026
095888e
Oversized plain text is unsupported; the delivery fence keeps one ref…
zlareb1 Dec 1, 2026
d9ef3cf
Merge main into the live source worker branch
zlareb1 Dec 1, 2026
5f77253
Regenerate the reference and SDKs for live output descriptions
zlareb1 Dec 1, 2026
7074ad8
Live read docs state the contract and its delivery limit
zlareb1 Dec 1, 2026
6552505
Live reads name their source like other source ops
zlareb1 Dec 1, 2026
2683abf
Live frames share a Postgres source lock instead of the source lease
zlareb1 Dec 1, 2026
dbf10b2
Live frames reread the whole source row with sequential consistency
zlareb1 Dec 1, 2026
d02b49f
Test that source writes hold the Postgres source lock
zlareb1 Dec 1, 2026
cb4b8c9
Worker authority reads answer 503 on a Postgres outage
zlareb1 Dec 1, 2026
8d3e8a1
Plain worker authority reads take one round trip and map outages
zlareb1 Dec 1, 2026
0bd1e73
Test the 503 for plain worker authority reads; state handoff outages
zlareb1 Dec 1, 2026
020ea4d
Classify live read failures from the real error; name worker bounds
zlareb1 Dec 1, 2026
ab36b6d
Worker grants outlast a live read across a second boundary
zlareb1 Dec 1, 2026
e7a709e
Merge main into the live source worker branch
zlareb1 Dec 1, 2026
779900e
The live status description leads with a one-line summary
zlareb1 Dec 1, 2026
0e6cf04
Keep the live status summary in one sentence within lint width
zlareb1 Dec 1, 2026
f283862
Say why the enrollment capacity is not a setting
zlareb1 Dec 1, 2026
4cc59bc
Drop the repeated live authority lookup; state the timeout ceilings
zlareb1 Dec 1, 2026
683bcc1
Drop an unreachable worker route check from the live read
zlareb1 Dec 1, 2026
ad46215
Drop the impossible route swap from the live read test
zlareb1 Dec 1, 2026
639bf16
Use the module's mock imports in the live read test
zlareb1 Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ jobs:
run: >-
pytest -q
tests/integration/test_pg_authority.py
tests/integration/test_mcp_worker_pg_fence.py
tests/integration/test_pg_durable_publish.py
tests/integration/test_pg_pipeline_metrics.py
tests/integration/test_knowledge_pg_heads.py
Expand Down
184 changes: 184 additions & 0 deletions docs/architecture/mcp-source-worker-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# 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 and what stored
copies and refresh still require.

Loom serves stored document search and explicit live document reads through its
existing MCP endpoint. 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, schedules, access policy, selected
copies and their normal erasure lifecycle. 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.

Enrollment matches a short worker-signed statement to a challenge issued for
the authenticated owner and current approved profile. The statement contains
opaque connection metadata only. Loom verifies the worker's separate enrollment
key, consumes the challenge with the link write, and never uses an enrollment
statement to authorize a read. A newer connection generation replaces older
authority without erasing a copy or moving it to another account.

## 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. 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 profile entries.
Each entry lists a `digest`, approved `modes`, and optional `team_access`. A
collection approval cannot add an organization, profile, mode or team permission that
the operator did not allow.

The `trust_ca_file`, `client_certificate_file` and `client_key_file` entries
configure mutual TLS. `grant_key_file` names Loom's Ed25519 key for signing
requests. `enrollment_verifier_file`, when present, names the worker's separate
public Ed25519 key. 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. The release must qualify
mixed builds before enabling worker registration or copy writes.

## 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.
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 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, and
a source write holds one for as long as its source lease, so a burst of live reads
behind a write can use up to the replica's pool for at most the frame deadline. 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.

`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. It has a separate read deadline and admission limit from refresh work, 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 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.

## 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. The worker has a separate key for
signing its statement about the current account. Neither the challenge nor the
statement includes the token or endpoint. Loom verifies the statement and
checks approval again under the same store locks as it consumes the challenge.
A retired generation cannot be restored by replaying a proof. Team readers
still enroll their own accounts separately for the selected source.

The Postgres enrollment records contain only scoped identity, provenance,
bindings, generation and expiry. Expired challenges can be removed in bounded
batches. Account revocation retains its generation fence until erasure. Enable
writes only when owner erasure and worker approval take the same authority
locks and every runnable eraser covers these tables.

## Requirements for stored copies

Worker copy writes and stored read authorization are not connected. Before they
are, imports must use the existing original, document, chunk, extraction, indexing and
accounting paths. The identity of a copy is its source UUID and the exact scoped
resource identity. A display link is provenance only. The copy's stable source
URI is never an outbound fetch target. Refresh must retain the copy identity while
updating content or receipt time.

Team collection membership is only one requirement. A reader also needs current
upstream permission evidence for their own connection to the exact resource.
Evidence binds the reader, collection, source and selection generation, worker,
connection generation, resource identity and expiry. An import receipt from one
reader cannot authorize another. Missing, expired, denied or disconnected
evidence fails closed. Evidence from reading current content cannot establish
access to historical content unless the approved upstream contract covers it.
Apply the same check to search, direct reads, originals, contextual results and
publication. Derived memory and cached results must not extend access.

## Requirements for refresh and retirement

The runtime does not schedule refresh or accept worker uploads. Before it does, Loom
must schedule and claim bounded refresh jobs. Each claim targets one worker and
the approved source revision, with a lease and a monotonically fenced attempt.
The worker must upload an idempotent completion for the exact claim. The server
must check the fence, deadline, registration and current connection before
accepting writes and advance the checkpoint only for an accepted result. “Sync now”
requests the same work as a schedule. Interruptions leave copies and originals
intact; stale completion does not renew permission or replace a copy. Partial
pages, missing items, timeouts and ambiguous errors do not prove deletion.

The refresh metadata queue must remain separate from ingestion jobs. It must
leave ingestion fairness and extractor scheduling intact. Postgres must commit
the accepted receipt with the document head and its delivery obligation. Index
delivery can recover after that commit. A deployment without Postgres knowledge
authority refuses worker refresh; ordinary ingestion still follows its configured
store. Install the queue schema and its erasure support before allowing writes,
and admit work only when every runnable eraser can remove the queue's rows.

Disconnect must invalidate live reads, claims and permissions without erasing
stored bytes. The existing erasure pipeline handles a separate deletion request. Older
builds must retain opaque registrations and must fail closed on worker-authorized
copies. Keep manual import available throughout the transition. A native source
keeps its stored copies, provenance and originals through upgrade. Reuse a copy
identity only when the owner authorizes a replacement connection and the old and
new resource identities have a verified one-to-one binding. An unmapped copy
keeps its old address and erasure history. Deployment requires compatible builds,
an approved worker binding and a separate operator cutover.
Loading
Loading