Skip to content

A curator draft is a private review candidate a person accepts by hash - #2375

Open
zlareb1 wants to merge 4 commits into
mainfrom
feat/curator-draft-candidate
Open

zlareb1 wants to merge 4 commits into
mainfrom
feat/curator-draft-candidate

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Related: #2152
Related: #1232

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

The learnings review queue holds a new private kind of candidate, a curator's drafted answer (source_kind curator_draft): only a namespace's administrators list it, and a person accepts it with learnings.review and approved_sha256, after which it is a fact with that reviewer as its actor. No pass writes a draft.

Why

A curator's drafted answer to a question several people asked is text no person has read. Until someone accepts it, only the namespace's administrators may read it. Loom already holds that kind of record: the private candidates of the learnings review queue, which an administrator lists, everyone else gets neither a row nor a count of, and a review promotes through memory.set. A draft is one more kind of them.

What a draft is. A row of loom.learnings_queue with source_kind curator_draft: the key the fact would be written under (curator/gap/<k>), the drafted answer in proposed_value, the gap it answers in source_resource_id, and in the new column evidence a pointer as JSON to the shared document it cites (kind, key, version, sha256, recheck, run_id, redraft_of). The pointer never holds a quote or a passage.

Why a private candidate and not a proposed memory row. A proposed row lives in loom.memory, so every memory read path would need a term that hides a model's unreviewed text from viewers, and a new actor kind would have to own the row. The queue's private candidates already have the audience rule in each statement, the erasure fence and the redaction scrub, so this change touches no memory read, no status predicate and no view. A draft is also not judged as a proposal is: the proposal policy, the advice and the suite checks apply to proposals, and a draft is judged on the document it cites, so memory.proposals does not list it. The cost is that a draft is not served on trial before review.

The review. learnings.review of a draft:

  • answers 404 RESOURCE_NOT_FOUND unless the caller administers the namespace, then takes the review claim (503 while another reviewer holds it) and the fleet gate below;
  • promote needs a person who administers the namespace and acts under their own name (reviewers.reviewer_subjects; a service account gets 403 AUTH_INSUFFICIENT) and approved_sha256 equal to the content_sha256 learnings.list served. An empty or different hash answers 409 PRECONDITION_FAILED without the stored hash. destination other than memory is a validation error;
  • reject needs the admin role only, a service account included;
  • a decided draft answers its status to a repeat of the same decision and 409 to the other one, so a promotion and a rejection that meet leave one decision.

The fact. A promotion writes through memory.set: identity (org, namespace, loom-curator, -, -) under the draft's key, type semantic, no tags, source_class derived, source_trace curator:<candidate_id>, source_resource_id the cited document's key, if_match_sha256 absent, and grounding verbatim with the pointer in evidence. The last two are set through two private attributes on MemorySetInput, which are not fields, so no memory.set body sets them. A memory.bulk_set entry sets both columns on the row it writes, so neither proves that a review accepted a row. The row's actor is the reviewer, from the review's token.

A refused write. A row now under the key, the blacklist, a pinned conflict or a text that a row of the namespace already states leaves the draft pending. memory.set merges such a text into that row and stores nothing under the draft's key, so the review answers 409 PRECONDITION_FAILED, naming that row's key when the reviewer may read it. The review marks its write uncertain only while the outcome is unknown: a refusal memory.set raises before its insert releases the lease definition.writer/<org>, so the next review, redaction or namespace erasure in the org is not refused until that lease expires. A review that stopped after the write and before its decision row completes on a repeat: a live row of the curator with the draft's trace and content hash is taken as written.

Redaction and erasure. Redacting a version of the fact a draft became blanks the draft's candidate (proposed_value, rationale, decision_reason, evidence). The candidate is the one the row's source_trace names, read by id, whatever key the fact holds by then. Namespace erasure deletes the table's rows of the namespace in the existing learnings_queue.delete step, and the queue's writer fence covers the kind.

Scope and risk

  • Touches the learnings queue's handlers, statements and wire models, MemorySetInput (two private attributes), the row build of memory.set (it copies them to the row when set), the history target a redaction reads (source_trace added), and the redaction of private candidates.
  • learnings.review's body is split into _review and _promote to stay under the function-length ratchet; the routing of the other kinds is unchanged, and their unit and integration tests pass.
  • Leaves alone: every memory read path, status_predicate, memory.proposals, the proposal policy and the dashboard. Nothing writes the kind.
  • Tenant isolation: a candidate is addressed by (org, namespace, candidate_id) from the token's scope. Below the admin role the transport answers 403 for a draft's id and for an unknown id alike, and the handler answers 404 for a caller the namespace does not admit as an administrator.
  • A revoked administrator stops reading drafts when the replica's grant cache refreshes, as for every read that needs the admin role.
  • A writer can store a row under the agent loom-curator with a curator:<id> trace, and a memory.bulk_set entry can also set grounding verbatim and a pointer, so neither the trace nor those columns prove that a review accepted a row. Redacting such a row blanks the draft that id names, as redacting the accepted fact does. The redaction is an administrator's act, and a trace that names no draft blanks nothing.
  • The existing 404 for a private candidate carries no message, while a missing candidate's does. Only a caller that passed the transport's admin gate reaches either, so this change keeps that answer as it is.

Compatibility, rollout and rollback

  • Wire:
    • learnings.review input gains approved_sha256: str = "".
    • learnings.list entries gain content_sha256: str = "" and evidence: object | null = null, both filled for a curator_draft only.
    • learnings.list, learnings.quality and memory.lineage leave a curator_draft out for a caller below the admin role.
    • The Python LearningsClient.review takes approved_sha256. The MCP descriptions of learnings.list and learnings.review say the same; both stay off every listing.
  • Storage: migration 139_curator_draft_evidence.sql adds loom.learnings_queue.evidence String DEFAULT ''. Every queue row carries the column, and a status row copies it.
  • Rolling upgrade (rule 103 of docs/architecture/rolling-upgrades.md): the previous build does not know the kind is private. It lists a draft, with its text, to every viewer, decides it with no person and no hash, and writes a status row without evidence. So review of the kind requires machines.fleet_at(ch, CURATOR_DRAFT_MIGRATION) and answers 503 OVERLOADED below it. tests/unit/test_curator_draft_candidate.py ties the constant to the migration's file name.
  • Numbers: the migration is 139 and the rule is 103. The newest migration on main is 138_knowledge_suite_required.sql, and rule 102 on main is the required regression suite's. If an open pull request that adds a migration or a rule merges first, this one is renumbered to follow it.
  • Operator steps: none to roll forward.
  • Rollback: the fleet gate protects the roll forward only. A rollback below this build is not supported while a curator_draft row of any status exists, and rejecting the drafts does not make it safe, because a rejection keeps the draft's text on its status row. The way back is curator_mode off in every namespace, then ALTER TABLE loom.learnings_queue DELETE WHERE source_kind = 'curator_draft', then the downgrade (docs/architecture/curator.md, "Rolling back"). A fact a draft became is an ordinary memory row and stays. Reverting leaves the column, which the previous build ignores.

Tests

Run on a ClickHouse and a server started for this change, in the main integration posture (auth not required, fake providers, workers off), on the head that holds main at f9cb57fd0.

  • pytest tests/unit/test_curator_draft_candidate.py: 29 passed. It covers the private tuple in every list, quality, redaction and scrub statement and in the writer fence; promotion by a service account, with no hash, with another hash and with the hash served; rejection by a viewer and by an administrator's service account; the written fact and its actor; a refusal memory.set raises before its insert (a row now under the key, a pinned conflict, the blacklist), which leaves no decision and no holder of the writer lease; a failure of unknown outcome, which keeps the lease; a write that memory.set merged into a row stating the text, which leaves the draft pending; a body that sets grounding, evidence or the private names over the transports' validation and the MCP schema; the fleet gate and the constant's file; both orders of a promotion and a rejection; the repeat after an interrupted promotion; and redaction of the accepted fact, moved or not. The four cases of a refused or merged write failed before the fix.
  • pytest tests/integration/test_curator_draft_candidate.py: 6 passed. Only an administrator lists and reviews a draft; a person promotes by hash and a viewer then reads the fact; a key that now holds a row refuses, the draft stays pending and a rejection of it right after answers 200; a text another row states refuses with that row's key, writes no row under the draft's key and leaves the draft pending; namespace erasure leaves no value and no pointer; a promotion and a rejection sent at once leave one decision.
  • pytest tests/integration/test_definition_draft_access.py tests/integration/test_query_history_drafts.py tests/integration/test_memory_history_redact.py: 11 passed, 1 xpassed. tests/integration/test_assistant_turn_learnings.py, run serially: 10 passed.
  • The 15 unit files that drive the learnings handlers or hold a merged conflict, with the scans test_package_contracts, test_op_transport_contract, test_tunable_constants, test_store_names_refused, test_degraded_unnoted, test_public_copy, test_doc_links and test_agent_instructions: 903 passed, 13 skipped, 1 failed. The failure is test_degraded_unnoted.py::test_every_broad_handler_notes_its_fallback_or_says_why_it_need_not, which names server/code/app/index/review_brief_build.py::_history_section::gather::1. This change does not touch that file, and the test fails the same way on a copy of main.
  • pytest tests/analyzer: 12 passed. The corpus was regenerated after the merge: 7 statement shapes differ from main.
  • make migrate from an empty ClickHouse applied 109 files, and make schema-dump on it left schemas/schema.sql as committed: it differs from main by the one column.
  • Every generator ran on this head, then --check: sdk_py_gen, sdk_py_client_gen, sdk_py_admin_gen, sdk_ts_gen, sdk_rb_gen, sdk_rust_gen, sdk_rust_gen --fixtures, sdk_go_gen, docs_reference, op_reach_census, plugin_eval_tools. None changed a file. rustfmt and gofmt came from the rust:1.85.1-slim and golang:1.27.4 images. sdk/rust/src/wire_models.rs is 2,401,769 bytes. The registry holds 426 operations, 312 of them experimental.
  • ruff format and ruff check on the changed files, make typecheck, the function-length gate, and Prettier 3.9.9 on docs/architecture/curator.md and docs/architecture/rolling-upgrades.md: clean.
  • Not run on this head: the other contract tests (test_mcp_listing_budget, test_sdk_surface_contract, test_go_sdk_contract, test_docs_reference, test_op_reach_census, the erasure, schema and migration scans), which passed on the head before main was merged in and run in CI; make test-mixed-version, which builds two images and runs in the mixed-version CI job; and the full unit and integration suites, which run in CI.

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 diff read once against the repository's invariants, the tests above, and the refusal paths over HTTP.

  • 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

zlareb1 and others added 2 commits December 6, 2026 08:54
A drafted answer is text no person has read, so it is stored as a candidate of
the learnings review queue with source_kind curator_draft, which only the
namespace's administrators list, count or decide. No memory read path changes.

learnings.list serves an administrator the draft's content_sha256 and its
evidence pointer. learnings.review promotes it only for a person who
administers the namespace and sends that hash as approved_sha256; a service
account may reject. The promotion writes the curator's namespace-wide row
through memory.set with the reviewer as actor, source_class derived,
source_trace curator:<candidate_id>, the absent precondition, and grounding
and evidence set through two private attributes no request body reaches. A
decided draft takes no other decision, and a promotion that stopped after its
write completes on a repeat.

Migration 139 adds loom.learnings_queue.evidence. Review of the kind waits
for every live replica to have it, because an older build lists the kind to
viewers. Redacting the fact a draft became blanks its candidate, found by the
row's source_trace.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The generated SDK files and the reference pages are regenerated on the merged tree.

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

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit da04b4d. Configure here.

Comment thread server/memory/app/learnings.py Resolved
zlareb1 and others added 2 commits December 6, 2026 09:46
The journal lists `138_knowledge_suite_required.sql` and then
`139_curator_draft_evidence.sql`. Rolling-upgrade rule 102 is the required
regression suite's, so the rule for a curator's draft is 103, and the curator
page cites that number. The analyzer shape list holds the one shape of the
merged schema dump.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… a merged write leaves the draft pending

`learnings.review` marks the write of a draft's fact uncertain only while its
outcome is unknown. A refusal `memory.set` raises before its insert (409
`PRECONDITION_FAILED`, 409 `PINNED_CONFLICT`, 422 `BLACKLISTED`) clears the
mark, so the lease `definition.writer/<org>` is released with the review and
the next review, redaction or namespace erasure in the org is not refused
until the lease expires. A failure of unknown outcome keeps the lease.

`memory.set` merges a draft whose text a row of the namespace already states
and stores no row under the draft's key. The review answers 409
`PRECONDITION_FAILED`, naming that row's key when the reviewer may read it,
and the draft stays pending.

The curator page, the comment on `MemorySetInput` and a test comment say that
no `memory.set` body sets `grounding` or `evidence` and that a
`memory.bulk_set` entry sets both. `learnings.list` takes a draft's value from
the decode its hash is taken over.

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