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
138 changes: 138 additions & 0 deletions docs/architecture/curator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Curator status

`curator.status` reports what in one namespace needs a person: the proposal queue in counts, the accepted facts with a harm report or a failed graded run, and the served facts whose linked code or source document changed. This page describes what the operation reads, the bound on each read and the codes it answers with.

The answer is computed on every call from rows Loom already holds. The operation stores nothing, calls no model and changes no fact: each finding names the write that fixes it, for a person to run under their own name.

## The caller

The operation needs the admin role on the namespace it addresses. A caller below it is refused with 403 `AUTH_INSUFFICIENT`. The report counts the whole namespace, so a token whose read scope is narrowed to one user or session is refused with the same code, as for the [knowledge gap](knowledge-gaps.md) operations.

| Surface | How |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| HTTP | `POST /v1/curator.status` |
| MCP | the tool `loom_curator_status`, called by name; it is on no toolset |
| SDKs | the generated `curator.status` method of each SDK |
| Command line | `loom curator status --namespace <namespace>` ([without the dashboard](../guides/without-the-dashboard.md#what-a-namespace-needs-from-a-person)) |

The dashboard has no view of the report. Its **Review queue** lists the proposals and the conflicts themselves.

## Input

| Field | Meaning |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sections` | Which of `proposals`, `flagged` and `stale` to compute. Empty, the default, computes all three. A section that was not asked for is `null` and makes no read. Another name is a validation error. |
| `limit` | The most findings one section lists, 1 to 50, default 20. |

## What each section reads

Every statement names one `(org, namespace)`. A fact's `value` is read only to hash it for [the write its finding names](#the-write-a-finding-names), for the facts a list shows, and no answer holds a value.

### `proposals`

| Field | Read |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pending` | The live rows of `loom.memory` with `status = 'proposed'`. |
| `oldest_days` | The age in whole days of the oldest of them, 0 when none is pending. |
| `filed_7d` | The facts with a version in `loom.memory_versions` written as a proposal and a `created_at` in the last 7 days. A fact keeps its `created_at` through every version, so a proposal decided since still counts. |
| `decided_7d` | The `memory.proposal_accept` and `memory.proposal_reject` rows of `loom.audit_log` in the last 7 days: two ranges of its sort key `(org, namespace, event_type, ts)`. |
| `over_scan_cap` | True when `pending` is more than `LOOM_MEMORY_PROPOSALS_SCAN_CAP`, the most proposals `memory.proposals` reads for one listing. The count stays exact. |

[Proposals](../features/memory/writing.md#proposals) describes the queue and its decisions.

### `flagged`

Accepted facts, `status = 'active'`. A conflicted fact is not listed: `conflicts.list` already holds it.

1. The memory ids whose harm reports in `loom.memory_usage_totals` sum to more than zero, most reports first. A report is a `negative` outcome recorded with `memory.outcome`, `memory.outcome_run` or `run.complete`; a retraction (`run.retract_credit`) subtracts it.
2. The keys named in `memories_used` by the runs of `loom.agent_runs` graded `fail`, the key of the most runs first. A run counts once for a key, and a run regraded to `pass` no longer counts.
3. The current status of each of those ids, by the read `memory.statuses` makes, and the live accepted rows under those keys.

The list holds the harm reports first, then the failed runs, cut at `limit`.

### `stale`

Served facts, `status` `active` or `conflicted`.

1. The namespace's code links in the state `changed`, `unresolved` or `missing`, made from the fact as it is now, into repositories whose code namespace the caller may read, one per fact, newest check first.
2. The live rows tagged `source-changed`, newest write first. [Decision extraction](../features/tasks-and-decisions.md#extract-decisions-from-a-document) sets the tag on a decision that its source document no longer states.

The list holds the stale links first, then the tagged facts, cut at `limit`.

## Findings

A finding carries the fact's `memory_id` and `memory_key`, a `code`, the code's `title`, a `count`, a `ref` and the write that fixes it in `apply`. The titles are in `server/memory/domain/curator.py` (`FINDING_TITLES`), so every surface prints the same words.

| Code | Title | Section | `count` | `ref` |
| ---------------- | ----------------------------- | --------- | ------------------------------------------ | ---------------------------------------------------------------------- |
| `harm_reported` | Reported harmful | `flagged` | The harm reports left after retractions. | |
| `graded_fails` | Relied on by runs graded fail | `flagged` | The runs graded `fail` that named the key. | |
| `stale_link` | Linked code changed | `stale` | 0 | The linked file, then `::` and the definition when the link names one. |
| `source_changed` | Source document changed | `stale` | 0 | |

A fact can be listed under more than one code.

## The write a finding names

`apply` has the shape `namespace.tune` gives its drafts:

| Field | Value |
| --------------- | ------------------------------------------------------------------------------------------------------- |
| `op` | `memory.update_by_id` |
| `args` | `org`, the fact's `memory_id`, and `if_match_sha256`, the content hash the report read for it. |
| `args_complete` | `false`: the person adds the new `value`. |
| `required_role` | The role `memory.update_by_id` declares, read from the operation registry. |
| `guard` | States that the write is refused with 409 `PRECONDITION_FAILED` when the fact changed after the report. |

The hash is the `content_sha256` that `memory.get` serves for the fact, which is the one `memory.update_by_id` compares. The stored `content_sha256` column can differ from it: a read serves an object without its null fields, and hashes what it serves. After the sections are read, one read fetches the live revision and this hash of every fact the lists show. It is the read that [`namespace.audit`](../features/namespaces-and-sharing.md#reading-a-namespaces-health) cites its rows with.

That read cites no hash for a high-sensitivity fact, for a value larger than `LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES` (0 cites none), or for a fact revised while it ran. Such a fact is listed with `apply: null`: an empty `if_match_sha256` is no precondition, so the write it would name could overwrite a change made since the report.

A fact that is no longer live when its revision is read is left out, so a list can hold fewer than `limit` findings while a fact is being deleted. Under the [Postgres memory authority](storage-authority.md) a fact is listed only while the ClickHouse row the report read is the live head of its key there.

## Bounds

| Read | Bound |
| ----------------------------- | ---------------------------------------------------------------------------------------------------- |
| Harm reports, failed-run keys | 2,000 each (`SCAN_CAP` in `server/memory/store/curator.py`). The statement asks for one row more. |
| Rows under the failed keys | 2,000. A key is held once by each agent, user and session that wrote it. |
| Statuses of the harmed ids | The ids the harm-report read returned. |
| Stale links, tagged rows | `limit` rows each. |
| Revisions and hashed values | The facts the lists show, `limit` a list, each value at most `LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES`. |
| The whole call | A p99 budget of 1,500 ms (`OP_BUDGETS_P99_MS` in `server/settings/catalog.py`). |

A `flagged` section with a read over its bound answers `unavailable: "too_large"` with no items, because a cut list would read as the whole one. The other sections still answer.

A failed statement fails the call. A repository whose grant could not be read is left out of the stale links, and the answer says so in `degraded` (`identity: code_links_unverified`).

## Limits

- Harm reports and failed runs are counted over the namespace's whole history. A fact keeps its id through a revision, so a revised fact stays listed, with the hash of its current content in `apply`, until its reports are retracted or it is deleted.
- `graded_fails` matches by key: a run records the keys it relied on, so every identity of the namespace that holds the key is listed.
- A namespace that has passed a bound of the `flagged` section keeps answering `too_large` for it: the counts never age out.
- With `limit` or more harm reports, the `flagged` list holds no failed run. Ask again with a larger `limit`, up to 50.
- A stale link into a repository the caller may not read is not listed.

## Source entry points

- `server/memory/api/ops_curator.py` (`curator_status`), `server/memory/api/models_curator.py`: the operation and its wire models.
- `server/memory/app/curator_status.py` (`handle_curator_status`): the sections and the findings.
- `server/memory/store/curator.py`: the statements of the sections, and `SCAN_CAP`.
- `server/memory/store/reads.py` (`statuses_by_ids`): the current status of each id with a harm report.
- `server/memory/domain/curator.py`: the section names, the codes and their titles.
- `server/memory/app/code_link_reads.py` (`stale_links`): the stale link read.
- `server/memory/app/finding_evidence.py` (`revisions_for`): the live revision and served hash of each fact a list shows.
- `sdk/python/loom/cli_curator.py`: the command.

## Invariants

- The operation writes no row and calls no model.
- A statement reads one namespace, and no answer holds a value: a value is read only to hash it.
- A list is whole or absent: a section that could be cut answers `too_large`.
- A write named in `apply` carries the content hash a read of the fact served when the report ran, and a fact with no such hash names no write.

## Related

- [Writing memory](../features/memory/writing.md#facts-that-need-a-second-look)
- [Graded runs](../features/runs.md#graded-runs): `run.grade` and `memories_used`.
- [Operations reference](../reference/operations/curator.md#curatorstatus)
26 changes: 26 additions & 0 deletions docs/features/memory/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,32 @@ contradiction while on trial stores it `conflicted`, and it waits on the **Confl
Learnings have a review of their own:
[learnings review queue](./procedures-and-learnings.md#learnings-review-queue).

## Facts that need a second look

`curator.status` tells a namespace admin what waits for a person: how many proposals are
pending and how long the oldest has waited, the accepted facts with a harm report or a
failed graded run (`flagged`), and the served facts whose linked code or source document
changed (`stale`). It answers with counts, ids and keys, never a value, and changes
nothing.

Each finding names `memory.update_by_id` with the fact's id and, as `if_match_sha256`,
the `content_sha256` that `memory.get` serves for it. Add the new `value` and run it:
the write is refused with 409 `PRECONDITION_FAILED` when the fact changed after the
report. A high-sensitivity fact is listed with no write, because a report cites no hash
of one.

```console
$ loom curator status --namespace support
proposals: 3 pending, oldest 12 days; 5 filed and 2 decided in the last 7 days
flagged: 1
Reported harmful (4): refund-window fix with memory.update_by_id
stale: 0
`loom curator status --namespace support --json` prints each write's arguments.
```

[Curator status](../../architecture/curator.md) describes what each section reads, its
bounds and its codes.

## Typed records

Records are rows with exact fields, for data that has identity (a ticket, a customer).
Expand Down
28 changes: 28 additions & 0 deletions docs/guides/without-the-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,31 @@ are on `agent.account` and `agent.deployment`.

The same roles apply as in the dashboard. Approving a join needs admin on
that namespace. The admin views need an org or platform admin.

## What a namespace needs from a person

`loom curator status` reports, for a namespace you administer, its proposal queue and the
facts that need a second look. The dashboard has no page for this report.

```console
$ loom curator status --namespace support
proposals: 3 pending, oldest 12 days; 5 filed and 2 decided in the last 7 days
flagged: 1
Reported harmful (4): refund-window fix with memory.update_by_id
stale: 1
Linked code changed: upload-backoff (src/uploads/retry.py::retry_upload) fix with memory.update_by_id
`loom curator status --namespace support --json` prints each write's arguments.
```

It prints one line per section and one per finding: why the fact is listed, its key and
the operation that fixes it. No fact's value is printed. `--json` prints the
`curator.status` answer, where each finding's `apply.args` holds the fact's `memory_id`
and the content hash the report read. Pass them to the operation with the new value:

```console
$ loom call memory.update_by_id memory_id=<memory_id> if_match_sha256=<hash> value="Refunds are accepted for 14 days."
```

The write is refused with 409 `PRECONDITION_FAILED` when the fact changed after the
report. In Python the report is `await agent.client.curator.status()`.
[Curator status](../architecture/curator.md) describes what each section reads.
1 change: 1 addition & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ python scripts/codegen/docs_reference.py
| `loom token` | Make, list and revoke your own tokens for CI and agents (`loom token --help`). | |
| `loom connect` | Print the dashboard link to connect your own Google, Notion or Linear account. | |
| `loom pointers` | Print the code pointer block for the task prompt on standard input. | |
| `loom curator` | Report what in a namespace needs a person (`loom curator --help`). | |

<!-- prettier-ignore-end -->
<!-- END GENERATED: cli -->
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ Namespace registration, write marks and bench-namespace GC.
| Variable | Type | Default | Live | Meaning |
| --- | --- | --- | --- | --- |
| `LOOM_NAMESPACE_AUDIT_INDEX_ROW_SCAN_CAP` | `int` | `20000` | live | Most live rows the namespace audit's value scan reads (it is O(total value bytes)); above it that check is skipped and says so. |
| `LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES` | `int` | `65536` | live | Largest value (bytes) namespace.audit, namespace.validate and memory.inspect read to cite a row's content hash; a larger row is cited with none. 0 = cite no hash. |
| `LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES` | `int` | `65536` | live | Largest value (bytes) namespace.audit, namespace.validate, memory.inspect and curator.status read to cite a row's content hash; a larger row gets none. 0 = no hash. |
| `LOOM_NAMESPACE_TUNE_DOCUMENT_SAMPLE` | `int` | `50` | live | Most live documents namespace.tune re-chunks in process to judge the chunk size and stride, picked by a hash of their source_uri; the report states the cap. |
| `LOOM_NAMESPACE_ONTOLOGY_CARDINALITY_TTL_S` | `float` | `60.0` | live | Seconds a namespace's relation cardinalities (one or many) are cached for the triple writer. |
| `LOOM_NAMESPACE_TAXONOMY_TTL_S` | `float` | `300.0` | live | Seconds a namespace's taxonomy is reused: one is four FINAL scans of the namespace (about 20 MB per open on a large namespace) and changes only when the namespace does. |
Expand Down
Loading
Loading