Skip to content

A write with proposed=true waits for review whatever its type or sensitivity - #2191

Merged
zlareb1 merged 2 commits into
mainfrom
fix/proposed-write-lands-pending
Dec 5, 2026
Merged

zlareb1 merged 2 commits into
mainfrom
fix/proposed-write-lands-pending

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Part of: #1144
Related: #2161

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

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

memory.set(proposed=true) of an episodic or profile row, or of a value the sensitivity gate reads as high, is stored proposed and waits for review. It was stored active and served with no review. The profile leg of loom_search returns served sections only.

Why

memory.set takes its plain insert (_set_plain_insert) for a type that is not embedded (episodic, profile) and for a high value. _memory_set_once returned through that insert before _stamp_lifecycle, the one place that sets status = 'proposed' and requires_review = 1. A proposal of such a row was stored active with requires_review = 0: profile.render and a context pack served it, memory.proposals did not list it, and a webhook received memory.written for it. An agent told to propose was a way around review, and every reader of "pending" missed these rows.

_stamp_lifecycle runs before the plain insert too. It is the function the embedded path calls before its dual write; the plain path passes no verdict, because it checks no peer. There is one rule with two call sites and no copy of it.

Two things follow from the stamped row with no code of their own: _announce_set announces no proposal, and holds_graph_facts keeps a proposal's stated relations out of the fact graph, as the docs say of every proposal.

Two changes the stamp needs:

  • The plain insert's answer carries status: "proposed" for a proposal, as the embedded path's answer does, so the writer reads that its row waits. A plain write that is not a proposal answers "", as on main.
  • The profile leg of loom_search (PROFILE_FETCH_SQL) had no status predicate. With the stamp alone it would serve a pending profile proposal, and a rejected one after its rejection. It takes served_status_sql(), the predicate profile.render uses. The same statement feeds the re-embed stub of a section just written, so a pending section gets no vector.

Alternatives and their cost:

  • Set the status inside _set_plain_insert: a second copy of the rule, which the next insert path would have to copy again.
  • Stamp in _set_build_memory_row, before the paths part: on the embedded path a duplicate verdict wins over proposed, so the stamp would have to be undone after the verdict.
  • Answer the stored row's status for every plain write (active where main answers ""): it changes the answer of every episodic, profile and high write that is not a proposal.

Scope and risk

  • Three server files: server/memory/app/write.py (the call; _stamp_lifecycle takes no verdict from the plain path), server/memory/app/set_commit.py (the answer's status), server/memory/app/profile_search.py (the predicate). No op, field, setting, table or migration.
  • The reads that serve a row of these kinds, checked one by one:
    • memory.proposals lists them. A high one is listed with no value preview and no content hash, as any high proposal is on main: its reviewer reads the value and the hash with memory.get_by_id, and memory.proposal_decide accepts it on that hash.
    • profile.render and the profile block of the memory stack filter on the served statuses.
    • The startup recall of a context pack keeps active and conflicted rows.
    • The plain insert writes no vector row, so no leg of memory.search can return them, and the embedding worker's reconcile skips high rows and types that are not embedded.
    • A key read (memory.get) returns the row with status: "proposed", as it does for an embedded proposal.
    • The profile leg of loom_search was the one read that needed a change.
  • The profile leg also stops returning a profile section whose status is rejected, superseded or duplicate. profile.render never rendered those.
  • Unchanged: the 409 KEY_HOLDS_FACT refusal; on the embedded path a duplicate verdict wins over proposed; a dry run of the plain path; a write that sends no proposed stores, answers and announces what it does on main (tested); memory.proposals and memory.proposal_decide.
  • Stored data: rows written before this change stay as they are. An active row that was written with proposed=true cannot be told from a direct write: the memory.set audit row records the key, the memory id, the content hash, the source class, the verdict and the pin, not the flag. No statement finds those rows.
  • Tenant isolation and auth: no new read and no change to a grant. Concurrency: the stamp sets two fields of the request's own row before its insert.
  • Not run against the Postgres memory authority. Its plain commit takes the same stamped row object as the ClickHouse insert.

Compatibility, rollout and rollback

  • Wire: no op or field added or removed. Two answers change: memory.set answers status: "proposed" for a proposal that takes the plain insert ("" on main), and the profile section of loom_search and search.query omits a section that is not served.
  • Operator steps: none.
  • Rolling upgrade: no stored shape changes. Until the roll ends, a replica on the previous build stores such a proposal active for the writes it serves, and its profile leg returns a pending profile proposal that the new build stored.
  • Rollback: reverting leaves the proposals this build stored proposed. They stay listed by memory.proposals and can be decided; the previous build's profile leg returns a pending profile one.

Tests

The tests came first. Against the three server files as they are on main, tests/unit/test_memory_set_proposed.py gives 5 failed, 3 passed: the four proposal cases read ('active', 0) where they expect ('proposed', 1), the listing is [], and the three cases of a write that is not a proposal pass. With the stamp and no predicate on the profile leg, the listing case fails on ['drinks', 'food'] == ['food']: the leg returns the pending section.

New tests:

  • tests/unit/test_memory_set_proposed.py, through the real memory.set handler over an in-process store:
    • test_a_proposed_write_of_a_non_embedded_type_lands_proposed (episodic, profile) and test_a_proposed_write_of_a_high_value_lands_proposed (declared high, and detected by the gate): the stored head is proposed with requires_review = 1, the answer says proposed, no live vector row exists and no webhook event is announced.
    • test_a_plain_write_that_is_not_a_proposal_lands_active (three cases): active, requires_review = 0, the answer's status is "" and memory.written is announced.
    • test_such_a_proposal_is_listed_and_not_served runs the real statements in clickhouse-local over the rows those writes stored: memory.proposals lists the three proposals (the high one with no preview), the profile leg returns the served section only, and a startup context pack holds the served profile section and the served episode and none of the three proposed values. It is skipped where the clickhouse binary is absent; it ran here.
  • tests/integration/test_proposals.py::test_a_profile_proposal_is_accepted_from_its_review, over HTTP: a service token proposes a profile section and reads status: "proposed"; an administrator's memory.proposals lists it with the write's memory id and content hash; profile.render has no section; memory.proposal_decide accepts it on the listed hash; the key reads active with the reviewer as verified_by, the listing is empty and profile.render has the section.

Run on the branch after it merged main (the merge has no conflict), with pytest -n 2:

  • The new unit file with tests/unit/test_proposals.py, test_proposal_triage.py, test_proposal_commit_review.py, test_plain_memory_audit.py, test_profile_leg.py and test_ch_params.py: 109 passed.
  • tests/unit/test_public_copy.py, test_doc_links.py, test_package_contracts.py, test_op_transport_contract.py, test_integration_suite_targets.py and test_degraded_unnoted.py: 726 passed.
  • Against a server from this source on a ClickHouse started for it: tests/integration/test_proposals.py, test_proposal_triage.py, test_proposal_independent_review.py and test_graded_runs_proposals.py: 5 passed. tests/integration/test_profile.py, test_sensitivity_high_canary.py and test_structured_profile.py: 41 passed.
  • tests/analyzer against that ClickHouse: 12 passed. PROFILE_FETCH_SQL is not a shape in the analyzer corpus.
  • ruff check server extractor sdk/python tests scripts .claude and ruff format --check . pass. make typecheck: the mypy gate reports 0 errors against a baseline of 0, and mypy --strict sdk/python/loom passes. Prettier passes on the three docs. The function-length gate stays at its baseline (52), the secret gate finds none, and every generator's --check reports its file current except the three named below.
  • A probe over HTTP against that server: a high, an episodic and a profile proposal each answer status: "proposed" and are listed; search.query and profile.render return only a profile section that is served; the high proposal is accepted on the hash memory.get_by_id returns and the episodic one on its listed hash, and both read active afterwards.

Run before the merge of main, on the same diff:

  • The unit files nearest the write path, the lifecycle and the read scope (among them test_memory_lifecycle_state_machine.py, test_read_scope_admission.py, test_memory_absence_precondition.py, test_profile_redaction.py, test_coded_width_memory_writes.py): 734 passed. test_delete_version_sql.py, test_embedding_reemit.py, test_profile_ops.py, test_context_pack_startup.py, test_memory_sensitivity.py, test_high_rows_sql.py, test_write_outcome_counting.py, test_memory_set_verdict.py, test_pg_authority.py and test_background_drain.py: 918 passed.
  • tests/integration/test_vector_retire_race.py -k profile: 1 passed.

Not run here, left to CI: the full make test-unit and its coverage floors, the mixed-version gate, the Postgres authority suite, sdk_rust_gen.py --check, sdk_rust_gen.py --fixtures --check and sdk_go_gen.py --check (rustfmt and gofmt are not installed on this machine; the diff changes no op, field or model), and the Biome lint (no frontend file changes).

No test of its own: a rejected, superseded or duplicate profile section on the profile leg. The predicate is the one profile.render uses, and the listing test covers its proposed case. The rolling-upgrade statement above comes from reading the two builds, not from a mixed-version run.

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 wrote the diff from an agreed design and ran the checks listed under Tests. It read its own diff once against the review checklist. No person and no reviewing agent has read it yet.

  • 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.

Unticked boxes: this change has no generated file, migration, plugin file or frontend file, and the CLA assistant has not asked.

🤖 Generated with Claude Code


Note

Medium Risk
Changes core memory.set lifecycle stamping and profile search SQL so mis-proposed rows stop being served immediately; behavior is scoped but affects writes and reads for episodic, profile, and high-sensitivity proposals.

Overview
Fixes a bug where memory.set(proposed=true) on the plain insert path (episodic, profile, or high sensitivity) was stored active with requires_review = 0 because that path returned before _stamp_lifecycle.

The write path now calls _stamp_lifecycle before the plain insert (with no conflict verdict), matching the embedded path’s single lifecycle rule. memory.set answers status: "proposed" for those proposals instead of an empty status.

PROFILE_FETCH_SQL in the loom_search profile leg now filters with served_status_sql() (same as profile.render), so proposed, rejected, superseded, or duplicate profile sections are not ranked or re-embedded.

Docs describe proposal review for non-embedded types and profile search exclusions. Unit and integration tests cover storage, listing, render/search/context pack omission, and accept-from-review for profile proposals.

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

zlareb1 and others added 2 commits December 5, 2026 00:27
…itivity

memory.set takes its plain insert for a type that is not embedded (episodic,
profile) and for a value the sensitivity gate reads as high. That path
returned before the lifecycle stamp, so such a proposal was stored active with
requires_review = 0 and served with no review.

_stamp_lifecycle runs before the plain insert as it does before the dual
write, and the write answers status "proposed". The profile leg of
loom_search reads served sections only, as profile.render does: a section
that is proposed, rejected or retired is no hit and gets no re-embed stub.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The merge is clean. The listing of a `high` proposal carries no content hash on
main; the tests of this branch read no hash from a `high` row.

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

Request Review

@zlareb1
zlareb1 merged commit ac4a8d3 into main Dec 5, 2026
85 checks passed
@zlareb1
zlareb1 deleted the fix/proposed-write-lands-pending branch December 5, 2026 02:10
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