Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
98 changes: 78 additions & 20 deletions docs/architecture/document-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ An agent that runs beside an account host has no person to own a source and no
credential Loom may hold: the host's tool channel adds the credential to each call. So a
namespace administrator assigns the source instead, with
`knowledge.source.worker_assign`: the row names the worker subject whose own token syncs
the source (`worker_subject`, an agent's subject `sa:<trust>:<agent>`), the reader that
the source (`worker_subject`: an agent's subject `sa:<trust>:<agent>`, or a service
account's that is no agent's, for
[a shared namespace](#where-an-assigned-source-lives)), the reader that
subject runs (`reader`), the host's id of the connection (`ref`) with its `generation`,
the digest of the reader profile the administrator approved (`profile_digest`), and the
documents: 1 to 1,000 ids (`selection: selected`) or one container the worker lists on
Expand All @@ -160,7 +162,10 @@ audience is the namespace's, the assignment fixes it where it is made:
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| The caller is not the namespace's administrator | 403, the op's role refusal |
| The caller is the worker subject | 403 `SOURCE_WORKER_SELF_ASSIGNED` |
| `worker_subject` is not an agent's subject, or the namespace is not its own | 422 `SOURCE_WORKER_NAMESPACE` |
| An agent's `worker_subject`, and the namespace is not that agent's own | 422 `SOURCE_WORKER_NAMESPACE` |
| Any other `worker_subject`, and the namespace is an agent's own | 422 `SOURCE_WORKER_NAMESPACE` |
| Any other `worker_subject`, and the namespace takes no shared source | 422 `PERSONAL_NAMESPACE` or `NAMESPACE_INACTIVE`, as for `add` |
| No `worker_subject` | 422 `SOURCE_WORKER_NAMESPACE` |
| The agent has lent the namespace to another agent (`grants.share_agent`) | 409 `SOURCE_WORKER_NAMESPACE_SHARED` |
| A live process reports a schema below the migration that adds `worker_subject` | 503 `OVERLOADED`, retry after 30 s |
| No source of that name | the name and quota checks of `add`, then one row; `created: true` |
Expand All @@ -173,14 +178,42 @@ audience is the namespace's, the assignment fixes it where it is made:
| Another `generation`, `profile_digest`, `selection`, items, bound or pause | one version row, same `source_id`; `changed: true`; the copies stay |
| Another `worker_subject`, `reader` or `ref` | 409 `SOURCE_REPLACED`: remove the source, then assign the new one |

The namespace's own is the directory row the agent's trust made: active, tagged for the
trust and owned by the agent. A share is a live grant the agent made to another subject:
the admin grant the agent's namespace starts with is none, and a grant an administrator
made on the namespace is that administrator's decision and refuses nothing. The other
way round, `grants.share_agent` answers 409 `NAMESPACE_HOLDS_ASSIGNED_SOURCE` while the
namespace holds an active assignment, and both run under the namespace's source lease,
so neither lands beside the other. An assigned source counts against the namespace's
source quota (`LOOM_KNOWLEDGE_SOURCES_MAX_PER_NAMESPACE`), not a person's.
An assigned source counts against the namespace's source quota
(`LOOM_KNOWLEDGE_SOURCES_MAX_PER_NAMESPACE`), not a person's.

### Where an assigned source lives

The worker subject's kind decides the namespace, and the subject's form decides the
kind: `sa:<trust>:<agent>` is an agent's subject, and any other subject is not.

| Worker subject | Namespace | Who reads the copies | What its claim reads |
| ---------------------------------------------------------- | ------------------------ | --------------------------------------------------------------- | ------------------------------------ |
| An agent's | That agent's own, only | The agent, and whoever an administrator granted the namespace | The agent's own namespace |
| Any other: a service account that runs a worker for a team | A shared namespace, only | Every reader of the namespace, as for a source `add` registered | The org's rows that name the subject |

**An agent's own namespace** is the directory row the agent's trust made: active, tagged
for the trust and owned by the agent. A share is a live grant the agent made to another
subject: the admin grant the agent's namespace starts with is none, and a grant an
administrator made on the namespace is that administrator's decision and refuses
nothing. The other way round, `grants.share_agent` answers 409
`NAMESPACE_HOLDS_ASSIGNED_SOURCE` while the namespace holds an active assignment, and
both run under the namespace's source lease, so neither lands beside the other.

**A shared namespace** is one no workload trust made for an agent, which takes a shared
source. Its directory row carries no trust's tag, the mark a trust sets on each agent's
namespace and no caller can set; a released agent's namespace keeps the tag and is
refused too. It passes the checks of `knowledge.source.add`: never a person's own place,
never an inactive namespace. A namespace with no directory row is shared. The share rule
does not apply: the namespace's readers are the audience, whoever granted them. So a
source whose upstream not every reader of the namespace may read is not assigned to a
shared namespace: it stays a source a person owns.

The assignment does not prove what a subject string names. Only a service account
calling as itself is answered a turn ([who is answered](#a-worker-subjects-turn)), so a
source that names a person is stored, shown, and never synced. No row names a subject
that is no agent's in an agent's namespace: the assignment refuses it, and a trust
never makes an agent's namespace over a name that holds an active source, which counts
as a namespace in use.

Only the subject that assigned a source changes it, an org administrator included: the
source is managed where it was turned on. `knowledge.source.list` and `inspect` show it
Expand All @@ -203,10 +236,19 @@ Loom runs no reader and holds no credential: the worker lists and fetches.
**Who is answered.** A claim is answered by assignment alone, not by a namespace role; a
commit needs the writer role on the source's namespace and then the assignment. The
caller is a worker subject when its verified token is a service account's own token,
carries no impersonation and no read narrowing, and belongs to the body's `org`. A claim reads
only the caller's home namespace, with one bounded statement over the registry on the
sorting key prefix `(org, namespace)` and one over the sync states of that namespace,
and keeps the active rows whose `worker_subject` is the caller. A caller that is no
carries no impersonation and no read narrowing, and belongs to the body's `org`. An
agent's claim reads only the agent's own namespace, with one bounded statement over the
registry on the sorting key prefix `(org, namespace)` and one over the sync states of
that namespace, and keeps the active rows whose `worker_subject` is the caller: a row
that names the agent in another namespace is never offered. A subject that is no
agent's has no namespace of its own, so its claim reads the org: one statement over the
registry on the sorting key prefix `org` that answers only the active rows whose
`worker_subject` is the caller, by namespace and name, 2,000 at most and without their
items, and one statement over the sync states of those rows. Neither is repeated per
namespace. Before a turn starts, that claim reads the due source's whole row and offers
it only at the version the first read answered and while it still names the caller. A
worker subject is offered at most 2,000 sources: a team with more runs another worker
under another subject. A caller that is no
worker subject, or one with no source, is answered `status: none` exactly as a worker
with nothing due, so the answer never says whether a source exists. A commit names its
namespace, so the transport first requires the writer role there and refuses a caller
Expand Down Expand Up @@ -377,9 +419,11 @@ draws from: `source.worker.poll` for `claim` and `stored` (20 burst, 2 per secon
namespace; 200 and 40 per org) and `source.worker.write` for `commit` and `put` (40
burst, one per two seconds per namespace; 200 and 20 per org), so a fleet of agents that
each poll one namespace is bounded by the org and never by one agent's readers. A claim
names no namespace, so its handler draws the poll's buckets on the caller's home
namespace before it reads anything; the other three are drawn by the transport, as for
any op that names a namespace.
names no namespace, so its handler draws the poll's buckets before it reads anything.
An agent's claim draws the namespace bucket on the agent's own namespace. The claim of
a subject that is no agent's draws it on a slot per subject, `source-worker:<subject>`,
a name no namespace can have, so one worker's polls spend no other's. The other three
ops are drawn by the transport, as for any op that names a namespace.

### Removing an assigned source

Expand Down Expand Up @@ -537,9 +581,11 @@ Three bounds decide how an org with thousands of assigned sources behaves:
requests of `source.worker.write`: 200 at once and 20 a second for the org at the
defaults, however many workers send them. A turn's polls, one `claim` and its `stored`
pages of up to 500 copies, draw `source.worker.poll`: 200 at once and 40 a second. A
fleet that sends under those rates is never refused by the org. Every read of a
`claim` names its caller's home namespace; it still reads the whole index granule
those rows are in, which the org's other sources share.
fleet that sends under those rates is never refused by the org. Every read of an
agent's `claim` names its caller's home namespace; it still reads the whole index
granule those rows are in, which the org's other sources share. The `claim` of a
subject that is no agent's reads the org's registry rows once and draws the
namespace tier on a slot of its own per subject.
- **Sources that expire together are retired a page of the queue a pass.** The scan
queues what it reaches in its 15 seconds, each expiry under its namespace's source
lease, and the queue then retires 40 entries. An entry queued behind the queue's
Expand Down Expand Up @@ -2095,6 +2141,10 @@ The redirect URI to register with each store is
([a worker subject's turn](#a-worker-subjects-turn)).
- No copy of an assigned source is retired on the evidence of a listing that was
partial, failed or empty.
- An agent's token claims no source outside the agent's own namespace, and a subject
that is no agent's is assigned no source inside one
([where an assigned source lives](#where-an-assigned-source-lives)). A claim that
reads the org answers only rows that name the caller's own subject.

## Source entry points

Expand Down Expand Up @@ -2362,6 +2412,14 @@ Each implementing pull request lists its own; these pin the model:
and a disconnect stop the person's sources and retire their mirrored documents;
`namespace.delete` and `collection.delete` retire the namespace's sources and clear
their credentials.
- Unit and integration: `tests/unit/test_assigned_source.py`,
`tests/unit/test_source_worker_ops.py`, `tests/integration/test_source_worker_turn_ch.py`
and `tests/integration/test_cross_principal_leakage.py`: a subject that is no agent's
is assigned a source only outside agents' namespaces and an agent's subject only in
its own; a service account claims its sources in two namespaces with one registry
read and one state read, and never another subject's; a person named as worker
subject claims nothing; a reader of the shared namespace finds the copy, and a
principal of another namespace or org sees neither the source nor the copy.
- Integration: `tests/integration/test_document_worker_load.py`: 200 assigned sources of
one org import, expire together, are retired by the queue and import again with no
request refused by an org bucket; an org whose write bucket is empty does not refuse
Expand Down
27 changes: 17 additions & 10 deletions docs/architecture/mcp-source-worker-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,14 @@ 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](document-sources.md#a-source-a-worker-syncs-for-an-agent)).
credential export. A host connection gives authority only where an administrator of the
namespace, not the worker subject, assigned the source: in the agent's own namespace
for an agent's subject, or in a shared namespace for a service account that is no
agent's
([where an assigned source lives](document-sources.md#where-an-assigned-source-lives)).
An agent's claim reads the agent's own namespace alone. The claim of a service account
that is no agent's reads the org's rows that name it, in whichever shared namespace each
was assigned.

### The host backend

Expand All @@ -230,7 +234,7 @@ calls it and gives it:
| `list_tools(ref)` | The tool definitions the connection advertises. The reader checks them against the mapping's pinned digests before it calls a tool. |
| The mappings | A directory of [read mappings](source-mapping.md), one a JSON file. The worker claims only a source whose `profile_digest` is the digest of one of them. |
| The allow-list | The ids of the connections the host allowed for indexing. |
| The home namespace | The host identity's own namespace, the only one whose sources the worker syncs. |
| The home namespace | The one namespace whose sources the worker syncs: the host identity's own for an agent's subject, one shared namespace for a service account that is no agent's. |

Both functions raise `ReaderError` with one of the reader's
[failure codes](source-mapping.md#failure-codes) and nothing else. Turning the host's own
Expand Down Expand Up @@ -271,11 +275,14 @@ registrant removes the source or the
[copy age bound](document-sources.md#copies-of-a-connection-nobody-verified) passes.

The trust of a host connection: anything that holds the host identity's token can upload
a copy under a source assigned to that identity. Four things bound it. A claim reads the
home namespace alone, and the backend refuses any other. Only the subject that assigned
a source changes its registration, and the worker subject never assigns one to itself. A
turn writes inside its source's key range (`source-doc:<source id>:`) and nowhere else.
Every hit of a copy names the uploader as `uploaded_by` in its `synced_from`.
a copy under a source assigned to that identity. Four things bound it. The backend syncs
the home namespace alone: an agent's claim reads no other, and a source that the claim
of a service account that is no agent's answers from another shared namespace is
refused `tool_not_allowed`, so such an account run beside a host is assigned sources in
that one namespace. Only the subject that assigned a source changes its registration,
and the worker subject never assigns one to itself. A turn writes inside its source's
key range (`source-doc:<source id>:`) and nowhere else. Every hit of a copy names the
uploader as `uploaded_by` in its `synced_from`.

The host never puts a server its platform runs for itself in the allow-list: the list
holds what a person turned on for indexing. The worker drops its own route to Loom, the
Expand Down
10 changes: 10 additions & 0 deletions docs/architecture/rolling-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,16 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
never reads it and it waits for a retirement pass of N, and `copies_expired_at` is a
key of the state row N-1 never reads for a worker row. The scan's position in the
worker's resume cursor is an exception to rule 4, described there.
N assigns a source to a subject that is no agent's, in a shared namespace
([where an assigned source lives](document-sources.md#where-an-assigned-source-lives)),
and offers that subject its sources across the org. The row has the shape of every
assigned row, so N-1 lists it, retires it on `remove` and expires its copies as it
does an agent's. N-1 refuses to make or change one with 422
`SOURCE_WORKER_NAMESPACE` and answers that subject's claim `none`, since it reads
only an agent's own namespace; a worker routed to N-1 polls again, and its `stored`,
`put` and `commit` on a turn N opened are served by both builds. No gate holds the
rollout. After a rollback below N such a source is never claimed: its copies are
served until the copy age bound retires them, or until its registrant removes it.
The mixed-version gate does not check this rule.

82. **The `primer`, `pin` and `unpin` sections of `curator.status`** (no migration): N
Expand Down
Loading
Loading