Skip to content

A curator pass run id is reserved: no caller opens, closes or grades a run under one - #2214

Merged
zlareb1 merged 2 commits into
mainfrom
feat/curator-pass-run-id
Dec 5, 2026
Merged

zlareb1 merged 2 commits into
mainfrom
feat/curator-pass-run-id

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Related: #2152

Changelog category (leave one):

  • Improvement

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):

A run_id of the form cur- and ten digits is reserved for the row of a curator pass, which only the server writes. run.begin with such an id opens the run under a server-made id, and run.complete and run.grade on one answer 404, as for a run that does not exist.

Why

A curator pass is recorded as one row of the run ledger (loom.agent_runs), so run.list and run.get serve the history of passes with no new table. That row has to be the server's alone: a caller must not be able to forge a pass, close one or grade one, and a pass must not be counted as an agent's work that waits for a grade.

This change reserves the id before any build writes such a row. The id is cur- and the ten digits of the pass's start in epoch seconds, so a namespace has at most one pass id a second and the ids sort by time. The namespace is the row's own column and is not part of the id.

Scope and risk

What changes:

  • is_pass_run_id in server/tasks/domain/session_runs.py, beside is_session_run_id: the shape in Python.
  • NOT_A_PASS in server/tasks/store/runs.py: the same shape as one SQL predicate, NOT match(run_id, '^cur-[0-9]{10}$').
  • run.begin with a supplied id of the shape goes to the caller's own server-made id, the path an MCP session's id already takes. The same begin sent again lands on the same run.
  • run.complete on an id of the shape raises the same NOT_FOUND as an id no run holds. It makes the same point read first, so the two answers differ in nothing.
  • run.grade drops a pass's row from the runs it grades, whether the call names the run or its session. A call that is left with no run answers NOT_FOUND, as for a run or session with no runs.
  • run.list(grade="ungraded"), run_tally (the run count of namespace.inventory) and recent_run_heads (the runs manifest of a context pack) carry the predicate.
  • run.get and run.list without the ungraded filter are unchanged: they serve a pass's row to whoever may read the namespace's runs.

What it leaves alone: the writers of a pass row, the worker that runs a pass, what the row holds and how the Runs page shows it. A write or a read that names a pass id as its run_id label is not refused: it labels its own row and does not change the run row.

Risk:

  • Tenant isolation: each refusal is the missing-run answer, in the caller's own (org, namespace), so it confirms nothing about a pass. The id is refused whether or not a row holds it.
  • Cost: the three reads already scan the namespace's runs under FINAL. The predicate adds one regular-expression match on the key column run_id for each row.
  • The predicate and is_pass_run_id are one rule in two engines. A unit test runs the predicate on clickhouse-local over ids one edit away from the shape (a trailing newline, a leading space, upper case, nine and eleven digits, digits of another script, an MCP session's id) and holds it to the Python function.

Two things differ from the first plan of this change:

  • The analyzer corpus did not render the ungraded page of run.list or the run heads, so tests/analyzer/shapes.txt could not show them. The case runs.without_passes in tests/analyzer/cases/planes.py drives both. The file gains four shapes and loses the old tally shape.
  • A grade addressed by session_id also leaves a pass's row out. Without it a caller could grade a pass by naming the session its row carries.

Compatibility, rollout and rollback

  • Wire: no op, field, table or setting is added or removed. Three answers change for a run_id of the form cur- and ten digits: run.begin returns a server-made run_id, and run.complete and run.grade answer 404 NOT_FOUND. A client that used ids of this form for its own runs gets another id back from run.begin and has to use the id in the answer. That is the one break.
  • Empty case: no row on any deployment has an id of the shape, so run.list, run.get, namespace.inventory and the context pack answer as before.
  • Rolling upgrade: a build without this change does not reserve the shape. No build writes a pass row, so during a roll there is no pass for the older build to open over, close or grade. This change writes no new value, so it adds no rule to docs/architecture/rolling-upgrades.md; the change that writes the first pass row gates on the fleet.
  • Operator steps: none.
  • Rollback: reverting leaves nothing behind. There is no migration and no stored row.

Tests

New tests:

  • tests/unit/test_pass_run_id.py: test_the_pass_id_shape_is_exact fails when cur-123, cur-12345678901, CUR-1234567890 or a session id matches. Four tests run SQL on clickhouse-local against the real loom.agent_runs: the predicate against is_pass_run_id, the tally, the run heads, and the ungraded page with its count beside the plain page that still serves the pass.
  • tests/integration/test_curator_pass_run_id.py, over HTTP on a ClickHouse and a server started for this change, with pass rows planted through ch_client:
    • test_a_caller_cannot_open_a_run_under_a_pass_id: fails when run.begin returns the supplied id, for an id a row holds and for one no row holds; the planted row keeps its goal and status.
    • test_a_pass_is_not_completed_or_graded_by_a_caller: fails when run.complete or run.grade answers a pass id differently from a random id (status, code and message with the id masked), by run and by session. It first closes and grades an agent's own run in the same namespace, then reads the planted rows back: still active, still ungraded.
    • test_a_pass_is_not_ungraded_work: fails when the planted row is under grade="ungraded", in its total, or in the run count of namespace.inventory; the plain run.list and run.get still serve it.

What ran, once each on the final tree:

Command Result
ruff format and ruff check on the changed Python files no change, all checks passed
npx prettier@3.9.9 --check docs/features/runs.md passed
make typecheck 0 errors; mypy --strict sdk/python/loom: no issues in 71 files
scripts/gates/function_length_gate.py at the baseline
pytest -n 2 on tests/unit/test_pass_run_id.py and the 14 unit files closest to the changed functions (test_graded_runs, test_identity_sentinel_reads, test_namespace_inventory, test_run_begin_claim_order, test_run_complete_sequential, test_run_ledger, test_run_list_paging, test_run_reads_statement_sql, test_mcp_session_runs, test_session_run_begin, test_run_retention, test_run_reliance, test_reflection_type, test_role_and_witness_rank) 242 passed
pytest -n 2 on test_package_contracts, test_op_transport_contract, test_tunable_constants, test_store_names_refused, test_degraded_unnoted, test_public_copy, test_doc_links, test_agent_instructions and tests/analyzer, with the ClickHouse of this change 601 passed, 12 skipped
python -m tests.analyzer.corpus --check --case runs.without_passes checked 3, rejected 0
pytest -n 2 on tests/integration/test_curator_pass_run_id.py, test_namespace_inventory.py, test_graded_runs_proposals.py and test_run_ledger.py 25 passed

The machine has no clickhouse binary, so the unit tests that run SQL skip there. They ran through clickhouse local of the ClickHouse container started for this change: 5 passed in tests/unit/test_pass_run_id.py, and the focused run above includes them.

Defect check: with is_pass_run_id answering False and the predicate replaced by a constant true, all three integration tests fail (the begin keeps the supplied id, run.complete answers 200, the ungraded page lists the pass). Both lines were restored before the runs in the table.

Generators: none applies, since no op, field, setting or table changes. tests/analyzer/shapes.txt is regenerated with python -m tests.analyzer.corpus --write. No tool was missing.

Left to CI: the full unit suite, the full integration suite, make lint as a whole and make test-mixed-version.

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 running: each new test against the change, the three integration tests failing with the shape check and the predicate disabled, the regenerated shapes through EXPLAIN QUERY TREE, and the diff read once against the review checklist.

  • 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.
  • 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.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ 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


Note

Medium Risk
Changes run API semantics for cur-* ids (begin remints, complete/grade 404) and adds regex filters on several run ledger scans; tenant isolation relies on treating passes like missing runs for mutating ops.

Overview
Reserves cur- and ten epoch-second digits as server-only curator pass run ids, documented alongside existing MCP session ids (mcp- + 40 hex). Clients cannot own rows under that shape.

Write path: run.begin with a reserved pass id (or MCP id) is rewritten to a caller-specific server-minted id; repeat begins idempotently hit the same run. run.complete on a pass id returns NOT_FOUND even if a row exists. run.grade never includes pass rows, whether targeted by run_id or session_id.

Read path: run.list with grade="ungraded", namespace run tally (namespace.inventory), and context-pack run heads apply a shared NOT_A_PASS SQL predicate matching is_pass_run_id. Unfiltered run.get / run.list still return pass history.

Includes docs, analyzer corpus case, unit tests (Python/SQL parity on clickhouse-local), and HTTP integration tests with planted pass rows.

Reviewed by Cursor Bugbot for commit 464ad09. Bugbot is set up for automated code reviews on this repo. Configure here.

…a run under one

A curator pass is recorded as a row of the run ledger, under `cur-` and the ten
digits of the pass's start in epoch seconds, so `run.list` and `run.get` serve its
history with no new table. That row is the server's alone.

`run.begin` with a supplied id of the shape opens the run under a server-made id, as
it does for an MCP session's id. `run.complete` and `run.grade` on one answer as for
a run that does not exist, whether or not a row holds it, and a grade addressed by
session leaves a pass's row out. `run.get` and `run.list` serve the row to whoever
may read the namespace's runs.

A pass is no agent's work. `run.list(grade="ungraded")`, the run count of
`namespace.inventory` and the newest run heads of a context pack leave it out by one
SQL predicate on the id shape (`NOT_A_PASS`). A unit test runs the predicate on
clickhouse-local and holds it to `is_pass_run_id`.

No row has an id of the shape on any deployment, so no answer changes.

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 6:28am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 6:28am UTC

Request Review

The comment on `RunBeginInput.run_id` covers both id shapes a begin does
not keep, an MCP session's and a curator pass's, by naming the module that
defines them.

The docstring of `test_the_pass_id_shape_is_exact` names what a shape that
took a session's id would break: a caller's `run.complete` and `run.grade`
on its MCP session's run. The transport closes a session's run without the
pass check, so that close would still work.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zlareb1
zlareb1 merged commit 187ed6f into main Dec 5, 2026
70 of 82 checks passed
@zlareb1
zlareb1 deleted the feat/curator-pass-run-id branch December 5, 2026 06:31
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