Repository navigation
A write with proposed=true waits for review whatever its type or sensitivity - #2191
Merged
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Part of: #1144
Related: #2161
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):
memory.set(proposed=true)of anepisodicorprofilerow, or of a value the sensitivity gate reads ashigh, is storedproposedand waits for review. It was storedactiveand served with no review. The profile leg ofloom_searchreturns served sections only.Why
memory.settakes its plain insert (_set_plain_insert) for a type that is not embedded (episodic,profile) and for ahighvalue._memory_set_oncereturned through that insert before_stamp_lifecycle, the one place that setsstatus = 'proposed'andrequires_review = 1. A proposal of such a row was storedactivewithrequires_review = 0:profile.renderand a context pack served it,memory.proposalsdid not list it, and a webhook receivedmemory.writtenfor it. An agent told to propose was a way around review, and every reader of "pending" missed these rows._stamp_lifecycleruns 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_setannounces no proposal, andholds_graph_factskeeps a proposal's statedrelationsout of the fact graph, as the docs say of every proposal.Two changes the stamp needs:
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 onmain.loom_search(PROFILE_FETCH_SQL) had no status predicate. With the stamp alone it would serve a pendingprofileproposal, and a rejected one after its rejection. It takesserved_status_sql(), the predicateprofile.renderuses. 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_plain_insert: a second copy of the rule, which the next insert path would have to copy again._set_build_memory_row, before the paths part: on the embedded path aduplicateverdict wins overproposed, so the stamp would have to be undone after the verdict.activewheremainanswers""): it changes the answer of everyepisodic,profileandhighwrite that is not a proposal.Scope and risk
server/memory/app/write.py(the call;_stamp_lifecycletakes no verdict from the plain path),server/memory/app/set_commit.py(the answer'sstatus),server/memory/app/profile_search.py(the predicate). No op, field, setting, table or migration.memory.proposalslists them. Ahighone is listed with no value preview and no content hash, as anyhighproposal is onmain: its reviewer reads the value and the hash withmemory.get_by_id, andmemory.proposal_decideaccepts it on that hash.profile.renderand the profile block of the memory stack filter on the served statuses.activeandconflictedrows.memory.searchcan return them, and the embedding worker's reconcile skipshighrows and types that are not embedded.memory.get) returns the row withstatus: "proposed", as it does for an embedded proposal.loom_searchwas the one read that needed a change.profilesection whose status isrejected,supersededorduplicate.profile.rendernever rendered those.KEY_HOLDS_FACTrefusal; on the embedded path aduplicateverdict wins overproposed; a dry run of the plain path; a write that sends noproposedstores, answers and announces what it does onmain(tested);memory.proposalsandmemory.proposal_decide.activerow that was written withproposed=truecannot be told from a direct write: thememory.setaudit 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.Compatibility, rollout and rollback
memory.setanswersstatus: "proposed"for a proposal that takes the plain insert (""onmain), and the profile section ofloom_searchandsearch.queryomits a section that is not served.activefor the writes it serves, and its profile leg returns a pendingprofileproposal that the new build stored.proposed. They stay listed bymemory.proposalsand can be decided; the previous build's profile leg returns a pendingprofileone.Tests
The tests came first. Against the three server files as they are on
main,tests/unit/test_memory_set_proposed.pygives 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 realmemory.sethandler over an in-process store:test_a_proposed_write_of_a_non_embedded_type_lands_proposed(episodic,profile) andtest_a_proposed_write_of_a_high_value_lands_proposed(declaredhigh, and detected by the gate): the stored head isproposedwithrequires_review = 1, the answer saysproposed, 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'sstatusis""andmemory.writtenis announced.test_such_a_proposal_is_listed_and_not_servedruns the real statements inclickhouse-localover the rows those writes stored:memory.proposalslists the three proposals (thehighone 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 theclickhousebinary 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 aprofilesection and readsstatus: "proposed"; an administrator'smemory.proposalslists it with the write's memory id and content hash;profile.renderhas no section;memory.proposal_decideaccepts it on the listed hash; the key readsactivewith the reviewer asverified_by, the listing is empty andprofile.renderhas the section.Run on the branch after it merged
main(the merge has no conflict), withpytest -n 2:tests/unit/test_proposals.py,test_proposal_triage.py,test_proposal_commit_review.py,test_plain_memory_audit.py,test_profile_leg.pyandtest_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.pyandtest_degraded_unnoted.py: 726 passed.tests/integration/test_proposals.py,test_proposal_triage.py,test_proposal_independent_review.pyandtest_graded_runs_proposals.py: 5 passed.tests/integration/test_profile.py,test_sensitivity_high_canary.pyandtest_structured_profile.py: 41 passed.tests/analyzeragainst that ClickHouse: 12 passed.PROFILE_FETCH_SQLis not a shape in the analyzer corpus.ruff check server extractor sdk/python tests scripts .claudeandruff format --check .pass.make typecheck: the mypy gate reports 0 errors against a baseline of 0, andmypy --strict sdk/python/loompasses. Prettier passes on the three docs. The function-length gate stays at its baseline (52), the secret gate finds none, and every generator's--checkreports its file current except the three named below.high, anepisodicand aprofileproposal each answerstatus: "proposed"and are listed;search.queryandprofile.renderreturn only aprofilesection that is served; thehighproposal is accepted on the hashmemory.get_by_idreturns and theepisodicone on its listed hash, and both readactiveafterwards.Run before the merge of
main, on the same diff: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.pyandtest_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-unitand its coverage floors, the mixed-version gate, the Postgres authority suite,sdk_rust_gen.py --check,sdk_rust_gen.py --fixtures --checkandsdk_go_gen.py --check(rustfmtandgofmtare 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,supersededorduplicateprofilesection on the profile leg. The predicate is the oneprofile.renderuses, and the listing test covers itsproposedcase. 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
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.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.setlifecycle 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, orhighsensitivity) was storedactivewithrequires_review = 0because that path returned before_stamp_lifecycle.The write path now calls
_stamp_lifecyclebefore the plain insert (with no conflict verdict), matching the embedded path’s single lifecycle rule.memory.setanswersstatus: "proposed"for those proposals instead of an empty status.PROFILE_FETCH_SQLin theloom_searchprofile leg now filters withserved_status_sql()(same asprofile.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.