Skip to content

curator.status reports a namespace's proposal queue and the facts that need a second look - #2199

Open
zlareb1 wants to merge 2 commits into
mainfrom
feat/curator-status
Open

zlareb1 wants to merge 2 commits into
mainfrom
feat/curator-status

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Related: #2152

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

curator.status (experimental, namespace admin) reports what in a namespace waits for 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. Each finding names memory.update_by_id with the fact's id and current content hash, and loom curator status --namespace <namespace> prints the report.

Why

A namespace admin has no one read of what needs a person. Pending proposals are listed by memory.proposals, harm reports sit in the usage totals, failed grades in the runs, stale links in the code link table and a changed source in a tag. Finding the facts to look at again means calling each of them and joining the answers by hand.

curator.status computes the answer on every call from rows Loom already holds. It stores nothing, calls no model and changes no fact.

  • Sections. sections picks from proposals, flagged and stale; empty, the default, computes all three side by side. A section that was not asked for is null and makes no read. Another name is a validation error.
  • proposals is counts only: pending and oldest_days from the live rows of loom.memory with status = 'proposed', filed_7d from the versions written as a proposal in loom.memory_versions, decided_7d from the memory.proposal_accept and memory.proposal_reject rows of loom.audit_log (two ranges of its sort key), and over_scan_cap when pending is over memory_proposals_scan_cap. No value column is read.
  • flagged lists accepted facts (status = 'active'): first those whose harm reports in loom.memory_usage_totals sum to more than zero, most first (harm_reported), then those under a key that runs graded fail relied on, most runs first (graded_fails). A conflicted fact is not listed, because conflicts.list already holds it.
  • stale lists served facts: first those with a stale code link, by the existing code_link_reads.stale_links read (stale_link), then those tagged source-changed (source_changed).
  • The write. Every finding carries apply, in the shape namespace.tune gives its drafts: memory.update_by_id with org, the fact's memory_id and if_match_sha256, args_complete: false because the person adds the new value, and required_role read from the operation registry.
  • The hash in if_match_sha256 is the one memory.get serves, which is what memory.update_by_id compares. The stored content_sha256 column differs from it for an object with a null field, so a write guarded by the column would be refused. After the sections are read, one read fetches the live revision and served hash of every fact the lists show, through finding_evidence.revisions_for, the read namespace.audit cites its rows with. That read cites no hash for a high-sensitivity fact or a value over LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES; such a fact is listed with apply: null, because an empty if_match_sha256 is no precondition.
  • Bounds. The harm-report read and the failed-key read each stop at 2,000 rows (SCAN_CAP, a constant of server/memory/store/curator.py), and so do the rows under the failed keys. A flagged read that reaches its bound answers unavailable: "too_large" with no items, because a cut list would read as the whole one; the other sections still answer. The stale reads ask for limit rows each.

Decisions made while building it:

  • Failed runs are counted per key in one statement (GROUP BY over the non-empty keys of arrayDistinct(memories_used)), so the bound applies to the distinct keys of failed runs and not to the runs. The empty key is dropped where the keys are unrolled, because the alias lint (tests/unit/test_sql_alias_shadow.py) refuses a WHERE on the ARRAY JOIN alias.
  • The harm-report statement groups only the usage totals with harm_count != 0. Every recall, use and evidence event writes a total with no harm, which cannot change the sum.
  • The status of each id with a harm report is read with statuses_by_ids, the read behind memory.statuses, and the handler keeps the ids whose status is active. The report has no statement of its own for it. That read sets select_sequential_consistency = 1, which this report does not need.
  • The scan bound is a module constant with a # not a setting: reason. No setting is added.
  • A fact that is no longer live when its revision is read is left out of its list, so a list can hold fewer than limit findings while a fact is being deleted.

Scope and risk

Touches:

  • server/memory/api/ops_curator.py, server/memory/api/models_curator.py: the operation and its wire models. server/operations/registry.py appends the module.
  • server/memory/app/curator_status.py: the handler. server/memory/store/curator.py: the statements of the sections. server/memory/domain/curator.py: the section names, the codes and their titles.
  • server/operations/dashboard.py: curator.status in NOT_IN_DASHBOARD, with the reason. server/operations/reach_manifest.py (generated).
  • server/settings/catalog.py: OP_BUDGETS_P99_MS["curator.status"] = 1500, and the comment of namespace_report_hash_max_bytes names the new reader.
  • sdk/python/loom/cli_curator.py (new), sdk/python/loom/cli.py, server/cli/login.py: the loom curator status command.
  • Generated: the op tables of the Python, TypeScript, Ruby, Rust and Go SDKs, docs/reference/, loom.example.yaml, schemas/loom-settings.schema.json, the CLI and SDK surface snapshots, and the seven new statement shapes in tests/analyzer/shapes.txt.
  • Docs: docs/architecture/curator.md (new), a section in docs/features/memory/writing.md and one in docs/guides/without-the-dashboard.md.

Left alone: no table, no migration, no worker, no new setting, no dashboard view and no toolset entry. memory.proposals and conflicts.list are left as they are, and stale_links, statuses_by_ids and revisions_for are called as they are.

What could break:

  • Tenant isolation. Every statement names one (org, namespace). The transport admits a namespace admin and refuses a token whose read scope is narrowed below the namespace, as for the knowledge.gaps. operations, before any read. A stale link into a repository the caller may not read is not listed. No answer holds a value: a value is read only to hash it, for at most limit facts a list, and a high-sensitivity fact's hash is not cited.
  • Cost. One call makes at most eleven reads. The status read of the harmed ids and the read of loom.memory FINAL by key send one statement for each 64 KiB of the ids or keys they bind, and every other read is one statement. The largest are those two and the two GROUP BY statements, each bounded as above. Measurements are under Tests.
  • Concurrency. The op only reads. A fact revised after a section read it is cited at its new hash, or listed with no write when it was revised while its hash was read. A fact that left is not listed.
  • Under the Postgres memory authority a fact is listed only while the ClickHouse row the report read is the live head of its key there, which is the citation read's own rule.

Known limits, stated in docs/architecture/curator.md:

  • Harm reports and failed runs are counted over the namespace's whole history. A revised fact stays listed, with the hash of its current content, until its reports are retracted or it is deleted, and a namespace past a flagged bound keeps answering too_large for that section.
  • graded_fails matches by key, because a run records the keys it relied on: every identity of the namespace that holds the key is listed.
  • With limit or more harm reports the flagged list holds no failed run; limit goes up to 50.

Compatibility, rollout and rollback

  • Wire, added:
    • Op curator.status: experimental, role admin, idempotent, read-only. HTTP POST /v1/curator.status; MCP tool loom_curator_status, on no toolset and not under the all listing; a generated method in each SDK (agent.client.curator.status() in Python).
    • Input: org, namespace, sections (list of proposals, flagged, stale; default empty, which computes all), limit (1 to 50, default 20, per section).
    • Output: proposals (pending, oldest_days, filed_7d, decided_7d, over_scan_cap, unavailable), flagged and stale (items, unavailable), each null when not asked for. An item has memory_id, memory_key, code, title, count, ref and apply (the existing TuneApply shape, or null).
    • Codes: harm_reported, graded_fails, stale_link, source_changed; unavailable is "" or too_large.
    • Command: loom curator status --namespace <namespace> [--json].
  • Wire, changed or removed: none. No default changes.
  • Settings: none added. LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES and LOOM_MEMORY_PROPOSALS_SCAN_CAP are read as they are; the first one's description now names curator.status.
  • Tables and migrations: none.
  • Operator steps: none.
  • Rolling upgrade: a replica still on the previous build does not know the op, so a call routed to it fails until that replica is replaced. Nothing is stored, so builds do not disagree on data.
  • Rollback: reverting removes the op, the command and the generated entries. It leaves no rows behind.

Tests

All of it ran against a ClickHouse container and a server from source that were started for this change. The first run, the analyzer run, the test_curator_status.py integration run, make typecheck and the ruff checks below are on the pushed commit. The others ran on the same change before its last rebases onto main, which touched none of its hand-written files, and before review changed the three reads of the flagged section and one test.

  • pytest tests/unit/test_curator_status.py tests/unit/test_cli_curator.py tests/unit/test_sql_alias_shadow.py tests/unit/test_package_contracts.py tests/unit/test_op_transport_contract.py tests/unit/test_tunable_constants.py tests/unit/test_store_names_refused.py tests/unit/test_degraded_unnoted.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py tests/unit/test_agent_instructions.py tests/unit/test_cli_surface_snapshot.py tests/unit/test_op_reach_census.py tests/unit/test_sdk_surface_contract.py tests/unit/test_settings_reference.py tests/unit/test_settings_defaults.py tests/unit/test_live_settings.py tests/unit/test_op_budgets.py tests/unit/test_op_surfaces.py tests/unit/test_sdk_parity.py tests/unit/test_docs_reference.py -n 2: 724 passed.
    • test_curator_status.py drives the handler over a store that answers from lists, then runs each statement on clickhouse local against the real table definitions: which rows count as pending, filed and decided, that a retracted harm report is not read, that a run regraded to pass no longer counts, that a harmed fact whose status is not active is not flagged, and that the hash cited is the served one and not the stored column.
    • test_sql_alias_shadow.py is the lint that failed on the first pushed commit: the failed-key statement tested the ARRAY JOIN alias key in WHERE. The focused runs before it did not select that file.
    • test_cli_curator.py covers the one line per section and per finding, --json, the hint that names the command as it was run, and a refusal printed without the token.
  • The registry-wide contracts (test_op_surfaces.py, test_op_budgets.py, test_op_inputs_after_gate.py, test_op_scope_fields.py, test_read_scope.py, test_read_scope_admission.py, test_mcp_listing_budget.py, test_mcp_toolset.py, test_idempotency_across_transports.py), the generated SDK checks of the five SDKs, test_sdk_parity.py, the SDK surface snapshot (which gains the curator client), the settings reference checks, test_docs_reference.py, test_page_summary.py and test_namespace_audit.py, with -n 2: 1318 passed.
  • pytest tests/unit -k "test_sdk_ or test_cli_ or test_mcp_ or test_docs_ or test_settings_ or test_op_ or test_schema_baseline or test_i18n" -n 2: 5559 passed.
  • pytest tests/analyzer -n 2: 12 passed, with the seven new statement shapes in tests/analyzer/shapes.txt. The status read of the harmed ids is the shape memory.statuses already renders.
  • pytest tests/integration/test_curator_status.py: 5 passed. A writer, an admin of another namespace and an admin token narrowed to one user are refused. The proposal counts follow the queue as proposals are filed and one is rejected. A harmed fact is flagged and memory.update_by_id with the finding's arguments plus a value succeeds, then is refused with 409 PRECONDITION_FAILED once the fact changed; the same write runs for an object with a null field; a high-sensitivity fact is listed with apply: null. A fact with a stale link or the source-changed tag is stale, and a link into a repository the caller may not read is not listed. An empty namespace answers zeros.
  • pytest tests/integration/test_read_ops_never_5xx.py tests/integration/test_read_scope_isolation.py tests/integration/test_restricted_namespace_leakage.py -n 2: 39 passed. pytest tests/integration/test_cross_principal_leakage.py, with one worker: 37 passed, 17 skipped. With two workers that file had 2 teardown errors in test_the_file_lookups_wider_read_serves_only_the_callers_own_rows, where both workers reset the same live setting on one server; the test covers memory.for_file, which this change does not touch.
  • Mutation checks: 19 changes to the handler, the statements and the titles (a bound ignored, a conflicted fact flagged, a retracted report read, a pass run counted, a deleted row read, the stored hash cited, an unguarded write named, a list not cut, a role hard-coded) and 5 to the command each fail a unit test. Two more on the pushed commit each fail a unit test: the status of a harmed id not compared with active, and the empty key kept among the keys of a failed run.
  • make typecheck: the mypy gate reports 0 errors and mypy --strict sdk/python/loom succeeds. ruff check and ruff format --check pass, as do the function-length and secrets gates. The --check run of every generator in make lint passed before review; on the pushed commit every one passed again except the Rust and Go SDK generators, which were not run again: they need rustfmt and gofmt, and the review fixes change no operation or wire model.

Latency, from system.query_log and the client. The namespace held 50,000 accepted facts, 500 pending proposals, 200 facts tagged source-changed, 1,500 facts with a harm report, 21,500 runs of which 1,500 graded fail over 1,800 keys, and 20,300 audit rows of which 300 are proposal decisions. Each section was called 200 times with limit: 50 after 10 warm-up calls, on a shared development machine that was busy with other work.

Whole call p50 ms p99 ms
proposals 112 170
flagged 322 550
stale 229 340
all sections 357 567
Statement p50 ms p99 ms
proposals: pending rows 72 149
proposals: filed in 7 days 19 58
proposals: decided in 7 days 14 47
flagged: harm totals 20 64
flagged: failed runs by key 22 67
flagged: rows of the harmed ids 71 130
flagged: rows under the failed keys 107 183
stale: rows by tag 78 150
findings: live revisions 57 92
findings: values hashed 42 69

The stale-link statement is not in the table: that server had no repository registered, so stale_links returned before its read. The integration test covers its result.

The whole-call rows and three statement rows (harm totals, failed runs by key, rows of the harmed ids) were measured before review changed those three statements, and were not measured again. The harm-report statement and the read of the harmed ids were then compared with the statements they replace, from system.query_log, on a namespace of 50,000 accepted facts, each recalled, of which 1,500 hold a harm report. Each statement returned the same rows as the one it replaces and ran 30 times.

Harm totals Usage totals read_rows memory_usage p50 ms p99 ms
before 5 parts, 201,500 rows 201,500 26.6 MB 55 80
with harm_count != 0 5 parts, 201,500 rows 1,500 4.7 MB 10 16
before 1 part, 50,000 rows 50,000 14.7 MB 17 43
with harm_count != 0 1 part, 50,000 rows 50,000 5.5 MB 10 17
Status of 1,500 harmed ids read_rows memory_usage p50 ms, two runs p99 ms, two runs
loom.memory FINAL by id 50,000 5.9 MB 21, 17 31, 30
statuses_by_ids 50,000 6.8 MB 21, 17 30, 20

With 1,500 ids spread over 50,000 rows every granule of the namespace holds a wanted id, so both reads of the harmed ids read the same rows; the change there removes a statement and does not make the read cheaper at this size. The failed-key statement was not measured again: its test of the empty key moved from WHERE into the array it unrolls.

Tools this machine lacks: the clickhouse binary, rustfmt, gofmt and shfmt. The statement tests ran with the binary copied out of the ClickHouse container, and the Rust and Go generators ran with rustfmt and gofmt from containers at the versions CI pins. No shell file changed, so shfmt was not needed.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked by hand: the handler, the statements and the tests were read line by line against the invariants and the area rules; every statement was run on the real table definitions; the mutation checks above confirm the tests fail when the behaviour changes; the hash a finding cites was compared with the stored column on a live row to confirm they differ for an object with a null field.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version. (No plugin file changed.)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed. (frontend/ is not changed.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code

…t need a second look

A namespace admin had no one read of what waits for a person. `curator.status`
(experimental, admin, read-only) computes it on every call from rows Loom
already holds, stores nothing and calls no model.

- `proposals`: the pending count, the days the oldest has waited, the facts
  filed as a proposal and the decisions of the last 7 days, and whether the
  count is over `memory_proposals_scan_cap`.
- `flagged`: accepted facts with a harm report left after retractions, then
  those that runs graded `fail` relied on. A conflicted fact stays with the
  conflicts list.
- `stale`: served facts with a stale code link, then those tagged
  `source-changed`.

Each finding names `memory.update_by_id` with the fact's id and, as
`if_match_sha256`, the content hash `memory.get` serves, read by the report
citation read. A fact that read cites no hash for (high sensitivity, a value
over `namespace_report_hash_max_bytes`) is listed with no write. A `flagged`
read that reaches its scan cap answers `too_large` with no items, and the
other sections still answer.

The op is served over HTTP, as the MCP tool `loom_curator_status` on no
toolset, by every generated SDK and by `loom curator status`. The dashboard
has no view of it, which `NOT_IN_DASHBOARD` records.

Related: #2152

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 4:33am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 4:33am UTC

Request Review

…no harm and reuse the status read

The failed-key statement drops the empty key where it unrolls the keys of a run, not
in WHERE. The alias lint reads a WHERE on the ARRAY JOIN alias `key` as a filter on a
column the alias shadows, so the statement failed
tests/unit/test_sql_alias_shadow.py. Its result is the same.

The harm-report statement groups only the usage totals whose harm count is not zero.
A recall, use or evidence event writes a total with no harm, which cannot change the
sum, so the result is the same and the statement no longer builds a group for every
fact that was recalled.

The status of each id with a harm report is read with statuses_by_ids, the read
behind memory.statuses. The handler keeps the ids whose status is active.
rows_by_id, its statement shape and its assertions are removed.

test_every_code_has_a_title runs the handler over a namespace with one finding for
each code and compares the listed codes with the title table. It no longer parses
the source of the handler.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant