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
5 changes: 4 additions & 1 deletion docs/architecture/memory-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,10 @@ usage fold's counters on `memory` are batched lightweight updates; see
Under the ClickHouse authority, every memory version insert holds a Keeper fence per
identity key. `memory.lock`, `memory.unlock` and `memory.verify` check that the source
row is still the head inside the fence, and answer 503 `ADMISSION_CONTENDED` with
no version written when it moved. All value inserts take the same fences, including
no version written when it moved. `memory.verify` first compares `if_match_sha256`, when
sent, with the hash of the head it read and answers 409 `PRECONDITION_FAILED` on
another; the fence covers a head that moves after that comparison. All value inserts
take the same fences, including
unconditional writes and batches, so the check and insert cannot interleave with another
replica's version insert. A re-read outside the fence provides no such guarantee.
The check compares values and metadata as well as versions, since writers can draw
Expand Down
4 changes: 3 additions & 1 deletion docs/architecture/rolling-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
behind another memory, and the `relations` of `memory.set`, `memory.update` and
`memory.update_by_id` are dropped there, so that write graphs none of the facts it
names. `memory.get_by_id`'s `omit_high_value` does not hold there either: N-1 answers
a `high` row with its value and hash, and audits that read as a sensitive one. N's
a `high` row with its value and hash, and audits that read as a sensitive one.
`memory.verify`'s `if_match_sha256` does not hold on an N-1 replica, which attests or
revokes the row it reads. N's
conflict resolver does not read the `memory.unsupersede` record of an Undo
made on an N-1 replica, or before the upgrade: it carries neither the restored hash
nor the restore version. The restored row then reads as a statement made at the Undo,
Expand Down
3 changes: 2 additions & 1 deletion docs/concepts/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@ so `memory.ask` keeps unattested `external` rows out of its synthesis
extracted fact was drawn from, and `memory.lineage` walks how a shared memory was
promoted.
- **Attestation.** `memory.verify` records who vouched for the content, bound to its
hash. Reads report `verification`: `human` or `process` while the content is unchanged,
hash. A caller that sends `if_match_sha256` attests only the content it read. Reads
report `verification`: `human` or `process` while the content is unchanged,
`stale` once it changes, `none` if never attested. An edit keeps the attestation and
reads as `stale`; it never transfers trust to new content.

Expand Down
12 changes: 12 additions & 0 deletions docs/features/memory/history-and-provenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ actor from the caller's token and the content hash they attested. Address the ro
`memory_id`, or by `namespace` and `memory_key` with the writer identity. It needs writer
on the row's namespace.

Send `if_match_sha256`, the `content_sha256` that `memory.get` or `memory.get_by_id`
returned for the content being attested, and the call attests only that content. A row
that holds other content answers 409 `PRECONDITION_FAILED` with `current_sha256` and
writes nothing: read the row again and attest what it says, never the returned hash
unread. The 409 of a `high` row carries no hash. `revoke=true` takes the same
precondition. Without the field the call attests the row as the server reads it, so an
edit that lands after the caller's read is attested unseen.

```bash
loom call memory.verify memory_id=<memory_id> if_match_sha256=<content_sha256>
```

`memory.get` and `memory.get_by_id` return `verification`, derived from the stored hash
and the row's current one:

Expand Down
10 changes: 6 additions & 4 deletions docs/features/memory/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ async with Agent(org="acme", namespace="support", agent="triage-bot") as agent:
```

`memory.update`, `memory.update_by_id` and `memory.move` (source row) accept the same
precondition. The Python SDK coalesces a burst of `set` calls from one identity into one
`memory.bulk_set` (from the third set inside 200 ms); a coalesced result carries
`coalesced: true` and no `content_sha256`. A set with `if_match_sha256` is never
coalesced.
precondition. [`memory.verify`](./history-and-provenance.md#attestation-memoryverify)
accepts it for the row being attested or revoked, and takes the hash a `memory.get` or
`memory.get_by_id` read returned. The Python SDK coalesces a burst of `set` calls from
one identity into one `memory.bulk_set` (from the third set inside 200 ms); a coalesced
result carries `coalesced: true` and no `content_sha256`. A set with `if_match_sha256`
is never coalesced.

A `memory.set` or `memory.update` that carries the precondition holds a lock on its key
from the check to the insert, so of two writers holding the same hash only one succeeds.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ resend are in each page's Errors section. Each op's kind is in the
| `AUTH_INSUFFICIENT` | 403 | The token's role or namespace access does not cover the op (over MCP the result carries `required_role`). The assistant's refusals carry `reason`: `org_wide`, `narrowed` or `token_expires_soon` with `left_s` ([the assistant's refusals](../architecture/assistant.md#each-callers-own-identity)). | A namespace that does not exist is refused with the same code as one the token may not read, so check the name against `namespace.list_mine` first. Then compare the op's role in the [operations reference](./operations.md) with the token (`GET /v1/whoami`) and ask a namespace admin for a grant. |
| `POLICY_FORBIDDEN` | 403 | A history-policy rule denied the call (`decision`, `determining_rules`, `errors`) with `LOOM_POLICY_MODE=enforce`. | Read `determining_rules`; `errors` tells "denied by policy" from "could not evaluate". See [Tokens and grants](../guides/tokens-and-grants.md). |
| `RESOURCE_NOT_FOUND` | 404 | The addressed row, namespace or document does not exist, or is not visible to the caller. | Check the identity tuple and key. Ops addressed only by an org-wide id answer as for a missing row (`found: false`, `updated: false`, `redacted: false`, `removed: false`) when the caller lacks the op's role on the row's namespace, rather than 404, so they never confirm it exists ([row-scoped operations](../architecture/security.md#row-scoped-operations)). |
| `PRECONDITION_FAILED` | 409 | `if_match_sha256` does not match the live row: another writer changed it. Under the Postgres authority, also an erasure that removed some of a snapshot's memories from the namespace while a `namespace.restore` of it ran. | `detail.current_sha256` is the live hash. Re-read if your change depends on the new value, then resend with that hash; no separate read is needed to retry a blind overwrite. For the restore (no hash), retry it: it leaves out the erased memories. |
| `PRECONDITION_FAILED` | 409 | `if_match_sha256` does not match the live row: another writer changed it. Under the Postgres authority, also an erasure that removed some of a snapshot's memories from the namespace while a `namespace.restore` of it ran. | `detail.current_sha256` is the live hash. Re-read if your change depends on the new value, then resend with that hash; no separate read is needed to retry a blind overwrite. For `memory.verify`, read the row again and attest what it says: resending the returned hash attests content nobody read, and the 409 of a `high` row carries none. For the restore (no hash), retry it: it leaves out the erased memories. |
| `WRONG_CELL` | 409 | The org the call acts in is placed in another [cell](../architecture/cells.md) of this deployment, or in none and the caller is not scoped to it; nothing was written. | Call the org's cell: `detail.cell` names it when this cell knows where the org is placed ('' otherwise), and `GET /cells/lookup?org=` on the router gives its cell and host; a new org reaches a cell through a request with a token of that org. |
| `PINNED_CONFLICT` | 409 | `memory.set` on a key, or close to a fact, that is pinned. A write that does not pin never replaces a pinned memory. `detail.pinned_blocker_id` names the blocking row. | Change it with `memory.update` (keeps the pin) or `memory.pin` (re-pins), or store the new fact under its own key. |
| `IDEMPOTENT_CONFLICT` | 409 | An `Idempotency-Key` (or MCP `_idempotency_key`) reused with a different body for the same op and caller. | Use a new key per distinct request. Resending the original body with the old key replays the stored answer. |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ Fields for every `memory` op: [operations/memory.md](operations/memory.md).
| [`memory.unpin`](operations/memory.md#memoryunpin) | Remove the write-time pin from one live memory. | admin | idempotent | no | yes |
| [`memory.update`](operations/memory.md#memoryupdate) | Key-addressed update: the fact changed or got more specific. | writer | write | yes | |
| [`memory.update_by_id`](operations/memory.md#memoryupdate_by_id) | Update a memory by UUID with an optimistic concurrency check. | writer | idempotent | yes | |
| [`memory.verify`](operations/memory.md#memoryverify) | Attest or revoke, refusing a changed source with retryable 503 `ADMISSION_CONTENDED` without writing a memory version; review the current row before retrying. | writer | idempotent | yes | yes |
| [`memory.verify`](operations/memory.md#memoryverify) | Attest or revoke, refusing content other than `if_match_sha256` with 409 `PRECONDITION_FAILED` and a source that changes during the call with retryable 503 `ADMISSION_CONTENDED`. | writer | idempotent | yes | yes |

### memory_schema

Expand Down
3 changes: 2 additions & 1 deletion docs/reference/operations/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ Update a memory by UUID with an optimistic concurrency check.

## `memory.verify`

Attest or revoke, refusing a changed source with retryable 503 `ADMISSION_CONTENDED` without writing a memory version; review the current row before retrying.
Attest or revoke, refusing content other than `if_match_sha256` with 409 `PRECONDITION_FAILED` and a source that changes during the call with retryable 503 `ADMISSION_CONTENDED`.

`POST /v1/memory.verify` · MCP `loom_memory_verify` · role `writer` · idempotent · audited

Expand All @@ -2506,6 +2506,7 @@ Attest or revoke, refusing a changed source with retryable 503 `ADMISSION_CONTEN
| `session_id` | `str` | `'-'` | The session or conversation the row belongs to; `'-'` for none. |
| `memory_key` | `str` | `''` | With `namespace` and the writer identity, the row to attest when no `memory_id` is sent. |
| `revoke` | `bool` | `False` | True clears the attestation instead of making one. |
| `if_match_sha256` | `str` | `''` | The `content_sha256` `memory.get` or `memory.get_by_id` returned for the content being attested or revoked: another live hash answers 409 `PRECONDITION_FAILED` and writes nothing; '' checks nothing. |
| `actor` | `str` | `''` | Attester recorded when the server runs without auth (`human:` / `process:` + subject); under auth the token decides. |

| Output field | Type | Meaning |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/python-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ whose body has neither, or one the SDK raised itself:
| `AuthInvalid` | `AUTH_INVALID`; status 401 | |
| `AuthInsufficient` | `AUTH_INSUFFICIENT`; status 403 | |
| `NotFound` | `RESOURCE_NOT_FOUND`; status 404 | |
| `PreconditionFailed` | `PRECONDITION_FAILED`; status 409, 412 without a known code | `.current_sha256`: retry without re-reading |
| `PreconditionFailed` | `PRECONDITION_FAILED`; status 409, 412 without a known code | `.current_sha256`: a write retries without re-reading; `memory.verify` and a definition approval read again first |
| `IdempotentConflict` | `IDEMPOTENT_CONFLICT` | |
| `WrongCell` | `WRONG_CELL` | subclass of `PreconditionFailed`; `.org` and `.cell` (the org's cell, or ''): look its host up with the router's `GET /cells/lookup` |
| `BackendUnavailable` | `BACKEND_UNAVAILABLE`, any 5xx, and `NETWORK` (no response) | `cannot reach <base_url>: …`, `no response from <base_url>: …` (a write that broke off, a timeout), or `response from <base_url> cut off: …` |
Expand Down
Loading
Loading