Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
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 @@ -1131,6 +1131,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
163 changes: 163 additions & 0 deletions docs/architecture/mcp-source-worker-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Document source worker boundary

This design specifies the requirements for the external worker integration.

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 mirrored access and an empty legacy kind, so a reader that
only understands legacy source configurations cannot serve 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 same
lease used to retire or update the source and locks the exact approval, account
and team link rows. Retirement or revocation that commits before the handoff
withholds the frame. No upstream call happens while these locks are held.

`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. It budgets 16 MiB for the document and its escaped MCP text copy.
A document beyond that budget returns `unsupported` with no document. 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. An authorized stored copy can be offered after timeout or worker
outage with its own age and provenance. Denial never falls back to a stored result.
The initial live read returns the explicit error without a stored substitute.

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 yet connected. 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 yet schedule refresh or accept worker uploads. 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.
4 changes: 4 additions & 0 deletions docs/architecture/storage-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,10 @@ Postgres step the flip splits off it, which joins `PG_ONLY_STEPS`
| `document_catalog`, `document_uploaders` | `(org, namespace, sha256)`, `(org, user_id, namespace, sha256)` | SoR | a `pg:` census row each, owned by the Postgres step the flip splits off the steps that own the census rows of `document_blobs` and `blob_uploads` today, which joins `PG_ONLY_STEPS` (`documents.tombstone`, and the user step through `document_uploaders`) |
| `knowledge_datasets` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_datasets`, step `pg_knowledge.delete` |
| `knowledge_jobs` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_jobs`, step `pg_knowledge.delete` |
| `mcp_worker_enrollment_challenges` | `(org, nonce)` | SoR | One time account enrollment challenges; erased with the owner or collection. Census `pg:loom.mcp_worker_enrollment_challenges`, step `pg_knowledge.delete`. |
| `mcp_worker_accounts` | `(org, connection_id)` | SoR | Opaque connection bindings and revocation generations; erased with the owner or collection. Census `pg:loom.mcp_worker_accounts`, step `pg_knowledge.delete`. |
| `mcp_worker_approvals` | `(org, namespace, worker_id, profile_digest)` | SoR | Allowed modes and approval generations; erased with the approving administrator or collection. Census `pg:loom.mcp_worker_approvals`, step `pg_knowledge.delete`. |
| `mcp_worker_source_readers` | `(org, namespace, source_id, user_id)` | SoR | Explicit team reader bindings; erased with the reader or collection. Census `pg:loom.mcp_worker_source_readers`, step `pg_knowledge.delete`. |
| `knowledge_heads`, `knowledge_deliveries` | [storage authority](storage-authority.md#the-tables) | SoR | census `pg:loom.knowledge_heads`, `pg:loom.knowledge_deliveries` |
| `jobs`, `job_users`, `job_memories` | `(org, id)`, `(org, user_id, job_id)`, `(org, namespace, memory_id, job_id)` | SoR | a census row, a step by namespace and user, a redaction step |
| `leases`, `write_marks`, `graph_inflight` | `(org, name)`, `(org, namespace, surface)`, `(org, namespace, token)` | Coord | no content |
Expand Down
Loading
Loading