Repository navigation
A curator pass run id is reserved: no caller opens, closes or grades a run under one - #2214
Merged
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #2152
Changelog category (leave one):
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_idof the formcur-and ten digits is reserved for the row of a curator pass, which only the server writes.run.beginwith such an id opens the run under a server-made id, andrun.completeandrun.gradeon 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), sorun.listandrun.getserve 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_idinserver/tasks/domain/session_runs.py, besideis_session_run_id: the shape in Python.NOT_A_PASSinserver/tasks/store/runs.py: the same shape as one SQL predicate,NOT match(run_id, '^cur-[0-9]{10}$').run.beginwith 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.completeon an id of the shape raises the sameNOT_FOUNDas an id no run holds. It makes the same point read first, so the two answers differ in nothing.run.gradedrops 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 answersNOT_FOUND, as for a run or session with no runs.run.list(grade="ungraded"),run_tally(the run count ofnamespace.inventory) andrecent_run_heads(the runs manifest of a context pack) carry the predicate.run.getandrun.listwithout 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_idlabel is not refused: it labels its own row and does not change the run row.Risk:
(org, namespace), so it confirms nothing about a pass. The id is refused whether or not a row holds it.FINAL. The predicate adds one regular-expression match on the key columnrun_idfor each row.is_pass_run_idare 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:
run.listor the run heads, sotests/analyzer/shapes.txtcould not show them. The caseruns.without_passesintests/analyzer/cases/planes.pydrives both. The file gains four shapes and loses the old tally shape.session_idalso 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
run_idof the formcur-and ten digits:run.beginreturns a server-maderun_id, andrun.completeandrun.gradeanswer 404NOT_FOUND. A client that used ids of this form for its own runs gets another id back fromrun.beginand has to use the id in the answer. That is the one break.run.list,run.get,namespace.inventoryand the context pack answer as before.docs/architecture/rolling-upgrades.md; the change that writes the first pass row gates on the fleet.Tests
New tests:
tests/unit/test_pass_run_id.py:test_the_pass_id_shape_is_exactfails whencur-123,cur-12345678901,CUR-1234567890or a session id matches. Four tests run SQL on clickhouse-local against the realloom.agent_runs: the predicate againstis_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 throughch_client:test_a_caller_cannot_open_a_run_under_a_pass_id: fails whenrun.beginreturns 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 whenrun.completeorrun.gradeanswers 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: stillactive, still ungraded.test_a_pass_is_not_ungraded_work: fails when the planted row is undergrade="ungraded", in itstotal, or in the run count ofnamespace.inventory; the plainrun.listandrun.getstill serve it.What ran, once each on the final tree:
ruff formatandruff checkon the changed Python filesnpx prettier@3.9.9 --check docs/features/runs.mdmake typecheckmypy --strict sdk/python/loom: no issues in 71 filesscripts/gates/function_length_gate.pypytest -n 2ontests/unit/test_pass_run_id.pyand 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)pytest -n 2ontest_package_contracts,test_op_transport_contract,test_tunable_constants,test_store_names_refused,test_degraded_unnoted,test_public_copy,test_doc_links,test_agent_instructionsandtests/analyzer, with the ClickHouse of this changepython -m tests.analyzer.corpus --check --case runs.without_passespytest -n 2ontests/integration/test_curator_pass_run_id.py,test_namespace_inventory.py,test_graded_runs_proposals.pyandtest_run_ledger.pyThe machine has no
clickhousebinary, so the unit tests that run SQL skip there. They ran throughclickhouse localof the ClickHouse container started for this change: 5 passed intests/unit/test_pass_run_id.py, and the focused run above includes them.Defect check: with
is_pass_run_idansweringFalseand the predicate replaced by a constant true, all three integration tests fail (the begin keeps the supplied id,run.completeanswers 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.txtis regenerated withpython -m tests.analyzer.corpus --write. No tool was missing.Left to CI: the full unit suite, the full integration suite,
make lintas a whole andmake 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
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/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).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 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.beginwith a reserved pass id (or MCP id) is rewritten to a caller-specific server-minted id; repeat begins idempotently hit the same run.run.completeon a pass id returns NOT_FOUND even if a row exists.run.gradenever includes pass rows, whether targeted byrun_idorsession_id.Read path:
run.listwithgrade="ungraded", namespace run tally (namespace.inventory), and context-pack run heads apply a sharedNOT_A_PASSSQL predicate matchingis_pass_run_id. Unfilteredrun.get/run.liststill 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.