Repository navigation
Erasure runs on replicated tables, search serves each session's row of a key, and the write gates read values, JSON credentials and long names right - #146
Merged
Conversation
zlareb1
force-pushed
the
fix/same-key-search-and-replicated-erasure
branch
9 times, most recently
from
November 2, 2026 05:52
e512b47 to
afeb5de
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ored name Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…with labels taken from what the key holds The in-batch replay is one list of steps in entry order: a step per entry that builds a row, or per exact repeat of its key's latest built row. One decision function settles each step over what its key holds at that point (stored row or the last landed batch row), the rows that land or that a verdict keeps out go through apply_bulk_verdicts once, and every other result is written once after it. Rows are dropped by filtering the steps; the parallel row_results, restatements, inherited_level_rows, batch_rows, batch_entries and rewritten_ids structures and the drop/renumber, landing and copy passes are gone. A repeat's sensitivity level and expiry are now settled at replay against the key's landed state, not inherited at build time from a batch row that may not land. A stored 'high' row repeated after a merged value of its key stays unchanged (or, with a pin, lands still 'high' with its expiry and no vector), and a repeat after a merged or refused ttl/level row takes neither. A row the replay makes 'high' drops its embedding row and its conflict verdict. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ccept them ReplicatedMergeTree and SharedMergeTree refuse an ALTER UPDATE/DELETE or a lightweight DELETE whose statement holds a subquery or a non-deterministic function (code 36). The user-scope erasure steps matched rows through subqueries (the user's memory keys, record ids, shared keys, the graph keys and entities only the user's memories link, the user's documents and blobs, supported learnings), and memory.clear compared locks with now(). Each step now reads its predicate's subquery first, the same one the residue census counts with, and mutates by what it found, bound as an array a slice at a time (ch_params.chunks, which measures a tuple as the driver renders it). The blob delete and the pending-learnings delete re-read their slice right before each delete. memory.clear binds its timestamp and names the embedding identities it clears when a lock keeps some rows. The blacklist hit count, the projection-failure resolve, the saved-message mark and the blob sweep's age cutoff bind their times too. An erasure mutation's tag now hashes its bound values, but not the stamp it writes, so the slices of one step wait for their own mutations and a step re-run after a crash finds its own pending ones. Signed-off-by: zlareb1 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…caped values Placeholders such as YOUR_API_KEY and <redacted> stay unlabelled, a value starting with $ or holding a colon is read, and the raw pair and the sweep's prefilter read JSON escapes inside the value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ps room for other keys Two users who write one key with no session are two rows: the duplicate and superseded lookups, the unit bodies, the chunk fold and the key-match and digest arms now tell them apart. Chunk and record hits carry the row's identity. Key-match returns at most the per-key cap of one key's rows, so a key written in many sessions no longer fills the arm. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ide in one mutation - memory.clear with locked rows reads the locked identities and runs one embeddings mutation with `NOT IN` over them, one bound array per 64 KiB slice, instead of one mutation per slice of every unlocked identity. - The user-scope graph, community and document steps bind `cityHash64(namespace, ...)` of each key, computed by ClickHouse on both sides: a stored entity name or URI can be longer than the 128 KiB form field a bound value travels in. - One slicer: `ch_params.chunks`; `repo_base.param_slices` delegates to it, `scope_reads.slices` is gone and `slices_or_none` is `slices_or_one_empty`. - `blobs.delete` raises when the clock read returns no row. - Integration tests: a user graph with a 160 KB entity name is erased with no residue; the user steps and a lock-bearing clear run on ReplicatedMergeTree copies of their tables, which refuse the subquery and `now()` forms. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…p, and bodies, raw pairs and slicing read one way - memory.clear names the hashes of locked identities, at most 10,000 per mutation; past that the scope is split into hash buckets. - Key-match binds the window's own rows-per-key rule: 0 or an aggregational query keeps up to the statement's limit instead of no rows. - A unit body is served only for the hit's own writer and session. - A raw JSON pair's value is decoded before the credential check. - A bulk row the replay lands without a vector retires the key's old one. - One slicer (ch_params.chunks); the learnings step slices every bound list; the analyzer renders the hash-bound erasure mutations. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…writer's row, and clear buckets fit a form field - status_by_rows and superseded_successors bind the pool's row keys instead of returning every writer's row of each served key. - A unit body is read under the row the hit names, so two writers of one key in one session each get their own. - memory.clear names at most 2,500 locked hashes per mutation, about 54 KB. - The clear is straight-line: memory, announce, then embeddings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
… filter falls back to the parsed entities The architecture page states the 2,500-lock bucket bound and the supporter window of the learnings delete. A replicated test binds the empty key slice of a user with chunks and no memory keys. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…r entry embedded The retire check matched the batch's embedding rows by key, so an earlier entry's vector of the same key kept the old text answering; it now matches the winning row's version. The sweep's credential prefilter reads a \b escape, as the detector does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…a secret `_SECRET_REFERENCE` is matched at the start of the value, so `../secrets/db1` missed the `./` arm and `$DB_PASS1` matched nothing: both read as a password and labelled the row `high`. An all-caps `$NAME` and a `../` path now read as references; a lowercase `$value` still reads as a secret. Also rewraps the `detector_text` docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s test hashes unevenly `_unlocked_parts` splits by `hash % buckets`, so a bucket can name more than `_LOCKED_PER_MUTATION` identities; the comment called it the most one mutation names. The test's evenly stepped hashes hid that; it now spreads hashes unevenly and checks the bound that matters, one 128 KiB form field per list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ead scope The read names another writer's identity when the hit carries one, so a test now pins that it still passes the caller's `request_scope()`: an `own_user` token never reads another user's body through a hit. The comment on the read says which reads pick one row per key. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
`_vectors_to_retire` matches an embedding row to the winner by version, as the row builder writes it; the fixture's rows had none and the test raised KeyError. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
`_BulkWriteState` already defaults `now_utc` to the current UTC time, and `loom.memory.duplicate_of` is a non-nullable String, so `ifNull(toString(...))` returned the column unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s which row it means Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e prefilter's credential keys come from the detector's word tuples Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…hich fields it does not Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ack, as memory.set does Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ches the replay and asserts the outcome Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…mory.set does Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…changed, so a replayed extraction cannot revive it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…; a label-changing repeat of a retired row is documented and tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…abel; the retention test reaches the skip gate too Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… a reference unless it carries a password Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… under a credential key reads high Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…led top_k; security.md reflowed Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… caller's row; merged decisions are credited in the home search's window Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s not filter by writer Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/same-key-search-and-replicated-erasure
branch
from
November 2, 2026 08:29
75e6319 to
5417875
Compare
… per_key_fetch rows Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ph wraps evenly Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…public; the learnings re-read uses query_all_sliced Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ps the first hit of each key Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…; a value drops any whitespace before its unit Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…whitespace Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
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):
User erasure and
memory.clearrun on replicated and shared ClickHouse tables. Search serves each session's row of a shared key with its own text. A value update is no longer filed as a duplicate, a credential inside a JSON value is labelledhigh, and entity names over 256 characters are dropped, so a long name no longer fails a search.memory.apply'smin_scorecompares a hit's similarity, where any value above 0 matched nothing. Amemory.bulk_setentry that repeats a stored value with a newttl_secondssets the expiry.Why
Six defects, each also on
main, found while reviewing the conflict-resolver work:WHEREholds a subquery (Code: 36 … statement with subquery may be nondeterministic) or callsnow(). 17 erasure andmemory.clearcall sites (22 statements) did one or both, so a user erasure failed at its first such step. On a replicatedloomdatabase seeded for two users, the base commit endsfailedwith 16 residue rows.(org, namespace, agent, user_id, session_id, memory_key), so extraction writes the same key once per session and two users may write one key, but several search stages keyed hits on(namespace, memory_key):bodies="unit"gave both hits the same session's text;same_content_wordsread the low overlap as a paraphrase, so the update was storedduplicateand the old value kept answering.detector_textputs each key and scalar on its own line, so{"password": "hunter2xyz123"}never met thepassword: <token>pattern. The raw-text path (reads_high) and the sweep's prefilter missed the quoted form too.memory.bulk_setwas handled by two entry streams merged by a sort and four later patch-up passes over six parallel structures. A repeat also inherited its level and expiry at build time from a batch row that might not land.They ship as one change because they were found together and are checked by one replicated-table run and one same-key search suite; the search fixes share the row key (
hit_row_key) and the erasure and clear fixes share the bound-slice helpers (ch_params.chunks). Reverting one of them means reverting this PR.What changed
server/erasure/store/,server/memory/store/lifecycle.py):ch_params.chunks, which sizes tuples as the driver renders them). The reads are inscope_reads.py.now()in a mutation is bound from Python, or read from the ClickHouse clock first for the blob sweep cutoff.source_uri, are bound ascityHash64of their key columns, computed by ClickHouse on the read and in the mutation. So a stored name over 128 KiB, which older builds could write, never travels as a parameter. A 64-bit collision inside one org could delete an unrelated graph row, or supersede another writer's unrelated document version during a purge.memory.clearwith locked rows reads only the hashes of the locked identities and runs one embeddings mutation that excludes them. Past 2,500 locked identities the scope is split into hash buckets, one mutation each, so a mutation's command (kept in Keeper on a replicated table) stays small.now(): the blacklist hit counter (server/memory/app/blacklist_guard.py),mark_projection_failures_resolvedandmark_message_savedbind the time from Python, so they also run on replicated tables.hit_row_key(server/memory/domain/search_types.py) names a hit's row as(namespace, agent, user_id, session_id, memory_key), and every stage above keys on it. A hit whose leg read no identity has only its session.session_id. A record hit carries itssession_idbut names no memory row, and gives way to a stronger fact of its key from any writer, as before. Amemory.setchunk is written undermemory.set:<key>, and its hit carries its owncontent_sha256. When a private-scope pool holds such a chunk,_set_chunk_rowsreads the writer's served rows of the key with the newest vectors, with their versions and tags, fromloom.memory_embeddings(memory_search_set_chunk_rowsof them, default 64), then those rows' values fromloom.memory, a form field at a time; rows holding the same value text and type are chunked once. The chunk belongs to the first of those rows whose current value cuts it, by the write path's own rule (set_chunk_identities); a status change re-writes a vector, so it counts as newer. The chunk folds onto that row when the row is pooled, and otherwise becomes that row's hit, with itsversionand tags. A chunk that no served row's value cuts is dropped: a later write replaced it, or the row is lapsed, superseded or outside the hard tags. A pending or older-model vector still counts as served. A row filedduplicatewrites no chunks, and a re-set too short to chunk leaves the earlier chunks in storage; the read drops a chunk no served row's value cuts. When the read fails the chunks are dropped rather than shown on another value's row. Under shared scope, where the writer's private row is never served, a chunk folds onto a pooled fact of its key, as onmain, or becomes the hit of the key's promoted row(_shared, -, -), so a later leg that reads that row (key-match, digest descent) finds it pooled and does not serve it twice. Every fact leg reads its row's identity.main: the shared fact is the promoted row, whose writer no chunk carries.exclude_pooled, bound to one form field; a row past it comes back and is collapsed), not their keys; a record leaves out nothing. Once every leg has added its hits, legs that pooled one row twice (a chunk's passage and the value's head) leave one hit of it (collapse_rows, counted inretrieval_work.rows_collapsed), with the tags a leg read of that row. A hit made from a set chunk carries its row's tags, which_set_chunk_rowsreads with the row, so the hard tag belt judges it by its own row. Under shared scope the promoted row's tags are not read, so a lone such hit fails a hard tag filter, as onmain.hit_sort_key, the one order every ranked list uses, breaks a tie after the key by the row's namespace, writer and session, so which row of a key the window keeps depends on the hits, not on read order.rows_per_key:memory_search_per_key_cap, or every row up to the statement's limit when the cap is 0 or the query is aggregational ortemporal_diff), so a key written in many sessions leaves room for other keys. Rows that tie are taken in row order, so which rows come back does not depend on read order: by agent, user, session and key in key-match and the anchor pool, and after their own order by key, agent, user and session in the lexical fallback, the recency backfill and the unmatched leg; by agent, user and key in digest descent, whose session is fixed; after the newest version by agent, user and session in the set-chunk read, and by agent, user, session and key in the entity follow. The arm's gate counts the pool's rows by the same rule (onmainit always applied the cap), so for an aggregational ortemporal_diffquery every row of a key counts and the gate reportsthin_poolless often.status_by_rowsandsuperseded_successorsread each pooled row by its full identity.context.packlabels a fact hit that names its row with that row's writer (by=), where two writers of one key in one session used to readunknown.one_per_key) and ask the search fortop_ktimes the per-key cap (per_key_fetch), so they still filltop_k:decision.precedents,procedure.match,memory.demonstrate(one vote per example),loom_search's repository-decision pass,loom decisions extract's restatement check (each key's most similar row) andcode.ask's memory lines. The decisions section ofcontext.packlists a decision once but shares the pack's one search, so it does not over-fetch.memory.applyover-fetches the same way, with no session filter so a long value's set chunks are found, reads one of the caller's rows pastlimitto reporttruncated(also set when the window comes back as full as the search served it: the search does not filter by writer, so more of the caller's rows may rank below it), comparesmin_scorewith each hit'ssimilarity(it read ascorefield search hits do not carry, so anymin_scoreabove 0 matched nothing), and judges a hit's owner by the row it names (hit_row_key), marking its key seen only once it meets the caller's own row; a record names no row and resolves by key.memory.askmerges a compound part's, an entity follow's and a decomposed part's hits throughPooledRows: a hit that names its row joins when that row is not pooled, and a record, which names none, only when no hit of its key is. The entity follow's key read (bridge_rows_by_key) reads each row's identity and tags, so it names its row and the hard tag belt judges that row, and keeps at mostmemory_search_per_key_caprows of one key (up to the follow'stop_kwhen the cap is 0), so one attribute written in many sessions leaves room for the bridge's others.body_truncatedwith itsmemory.getcall. A hit that names no row, and a shared (promoted) row, keep the caller-identity read; a record's body is read under the caller's session, as its own session is not its parent fact's.same_content_wordsreturns False when each side states a value the other lacks (values_differ, built on the value tokensvalue_updatesalready used, now inserver/memory/domain/conflicts.py). Such a pair goes on to the conflict check. A thousands separator is not part of a value (1,000is1000), for this gate and for the value-update linker that shares the tokens; a currency sign is, so$40and40 dollarsstill read as two values and the pair costs one conflict check.password,db_password,dbPassword,client_secret,api.key; a barepwdkey, an environment's working directory, is not one) states its string value aspassword: <value>for the detector. To qualify, the value must be one token of 8 or more characters holding a letter and a digit, and not be a reference (env:NAME,vault:PATH,secret:NAME,ref:NAME, an all-caps$NAME,${NAME}, a value that opens with/, a segment, then/, or one opening~/,./or../; a relative path without that prefix, such assrc/app1, still reads as a secret; a lowercase$value, and a token with a single leading/as base64 may open, still read as a secret). Quotes, commas and semicolons in the value do not cut it short. So placeholders such asYOUR_API_KEYand<redacted>stay unlabelled, and a password made only of letters is missed, as is a base64 secret that opens with/, a segment, then/(it reads as a path; roughly half of those that open with/). A URL is never a reference, since a webhook or a presigned URL is the secret itself, so a URL that only names where a secret lives readshigh, as does an ARN that names one (itssecret:part reads as an assignment).reads_highreads the quoted pair in raw JSON text, escapes included, and the sweep's prefilter selects it.canonical_entitydrops text over 256 characters (MAX_ENTITY_CHARS, the bound a triple's subject and object already had), on write, for a file, concept or topic facet, and in anentity_filter._Stepper entry that reaches the replay, in entry order, and per-key state in_Held._settle_stepsettles each step over what its key holds and gives its row the labels and pin it lands with. Results are written afterapply_bulk_verdicts(write_step_results), except a repeat that lands an earlier row, whose result_settle_repeatwrites._labels). A row the replay makeshighdrops its embedding row and its verdict.Scope and risk
_set_chunk_rowsreads the writer's rows of the key fromloom.memory_embeddings(bound by the pooled chunks' (agent, user_id, key), pruned by(org, namespace, agent, user_id)), then those rows' values fromloom.memoryby its full sort-key prefix, a form field at a time. It runs in eachvector_searchcall (each namespace, sub-query and set-expansion pool) whose private-scope pool holds amemory.setchunk.candidates_totalcounts rows, not keys.high. Stored JSON values holding a credential are labelledhighby the sensitivity sweep on its next passes. Their vectors are removed, so they leave semantic search and stay readable by key.duplicate. A value update now gets theconflictverdict for the resolver, or links as a value update.read_onlyrow's expiry is refused as locked, asmemory.setrefuses it.ttl_secondswrites a new version, so the expiry is set, asmemory.setsets it; it was dropped as unchanged, so the expiry was never set (test_a_ttl_only_repeat_of_the_stored_value_sets_its_expiry,test_a_ttl_only_repeat_of_a_batch_value_sets_its_expiry).highthat the replay decides is not. This happens only when a pin landed earlier in the batch refuses an earlierhighrow of the same key. The key's older vector retires with it, so the old text never answers for the new value.memory.clearstays one mutation up to 2,500 locked identities; past that it runs one per bucket and waits for each (mutations_sync = 2), so 25,000 locked identities wait on 10.memory.clearkeeps the vectors of the locked identities it reads before the embeddings mutation: a row locked after that read, while the clear runs, keeps its memory row but loses its vector.mainchecked the lock inside the mutation, a narrower window._set_chunk_rowsread drops that pool's set-chunk passages (logged as a warning) rather than show one on another value's row. The match recomputes a row's chunks with the running build's chunker, so a later change to the chunk geometry leaves stored chunks unmatched until their keys are set again (and lowering the chunk cap leaves the chunks past the new cap unmatched).valid_at,valid_to,filesor declaredsource_classis counted unchanged and writes nothing, wherememory.setwrites a new version; as onmain. A re-extraction differs in most of these (a new confidence, the session'svalid_at, raw tags without the storedsensitivity:/attribute:labels), so matchingmemory.setwould write a version on nearly every one, a change of its own.activeis counted unchanged, as onmainand asmemory.importleaves such a key: a replayed extraction batch must not write a superseded or rejected row back as active, which undernewest_winswould retire the value that replaced it, nor promote aproposedrow without an outcome (test_a_repeat_of_a_retired_stored_value_leaves_it).memory.setwrites such a restatement back. An entry that names a new level, adds a pin or setsttl_secondsis a new assertion and writes the row as active, asmemory.setdoes (test_a_repeat_of_a_retired_stored_value_that_changes_a_label_writes_it_active); the retention window alone does not count (test_the_retention_window_alone_leaves_a_repeat_unchanged).newest_winsit reads as older than the rows written between the two entries, though serially it is the later write; as onmain.loom.memory_chunkswith no agent filter, and the table has no scope column, so a shared-scope search can pool a private row's chunks (memory.setand conversation chunks alike).maindoes the same; closing it belongs in the chunk leg, in its own change.memory.set:<key>, by chunk index and hash) and replaced per user: a later long write by the same user, in any session or under any agent, replaces that user's older long-value chunks, so only a user's latest long value of a key is findable by a passage past its excerpt. Writers whose values cut the same chunk share itsmemory_chunksrow, stamped with the last of them, and the chunk names that writer's memory row; once that writer's value no longer cuts it, the others lose the passage, though their facts still serve (as onmain, where the chunk folded by key). Recording the cutting row on the chunk needs amemory_chunkskey change.purge=truethe memory rows are deleted before the key-based steps read their keys, so graph triples, cached answers and belief sources of a purged user can remain while the census reports 0.maindoes the same; it needs its own change.bridge_rows_by_key) carries the hard tags but not the other fact-leg predicates (expires_at,valid_to,as_of, the hard memory type and the types left out of an unfiltered search, a hard category), as onmain; it needs_build_where's helpers overloom.memory, in its own change.(namespace, memory_key), with no writer filter, as onmain. Every search fact leg and the ask pool's entity-follow key read stamp their row's tags (that read also carries the hard tags in SQL), and a hit made from a set chunk carries its row's. The point read still servesmemory.ask's identifier injection and chase, its bridge completion and content fallback, and its facet completion; reading it by row is its own change.make migratedoes not run on a self-managed Replicated database (a refreshable view needs a replicated target), so the replicated check below converted the tables by script.Compatibility, rollout and rollback
entitiesandentity_filteritems over 256 characters are dropped rather than refused. Anentity_filterwhose items are all that long is treated as absent, so the search uses the entities the query parser found.session_id, which was empty.version, which was 0.include_tags, a private-scope hit made from a set chunk returns its row'stags, which were left off.memory.demonstratereturns each example's stored excerpt (thefulltier) at anyk; akof 8 or more used to return the 200-characterexcerpttier.LOOM_MEMORY_SEARCH_SET_CHUNK_ROWS(default 64, at least 1) bounds how many of a writer's served rows of a key, those with the newest vectors, a pooled set chunk is matched against.highstayhigh.Tests
tests/integration/same_key/test_search_ch.py: two sessions, one key, both served with their own text, forexcerptandunitbodies.test_split_tail_keeps_the_rows_one_key_holds_in_other_sessions.test_a_duplicate_is_hidden_though_another_writer_holds_its_key_active.test_duplicate_step_requires_the_same_content_words.test_a_credential_under_a_credential_key_reads_high, plus the credential rows in the ClickHouse prefilter test (clickhouse-local).test_text_longer_than_a_name_is_no_entityandtest_a_name_too_long_to_bind_is_dropped_on_write_and_search.test_bulk_rows_carry_labels.py.test_side_legs_exclude_pooled_rows.py(the unmatched and recency legs).test_fold_set_chunks.py(a set chunk under itsmemory.set:<key>session folds onto the row it was cut from, and leaves an older session's row alone).test_a_shared_row_is_read_under_the_callers_identityandtest_an_own_user_read_never_serves_another_users_body.test_a_record_gives_way_to_a_stronger_fact_of_its_key_whoever_wrote_it,test_under_private_scope_a_chunk_is_dropped_only_for_a_fact_of_its_own_writerandtest_under_shared_scope_a_chunk_that_opens_like_a_fact_drops.test_a_duplicate_leaves_the_keys_chunks_to_the_served_value.test_two_rows_of_one_key_with_equal_scores_sort_by_their_writerandtest_one_row_identity_in_two_namespaces_sorts_by_its_namespace.test_a_failed_row_read_names_no_row_and_its_chunks_dropandtest_the_set_chunk_row_bound_is_at_least_one.test_set_chunk_rows_sql.pyruns_set_chunk_rowson clickhouse-local: a hard category filter decides whether the row is served; the row whose value cuts the chunk; none when no row's value cuts it any more (a short re-set); the newest of two rows holding one value; the bound to the writer's newestmemory_search_set_chunk_rowsrows; none when the fact leg does not serve the row (lapsed, outside the hard tags); a row embedded under another model still names its chunks.test_collapse_rows.py(one hit per row at assembly, before the duplicates are read).test_key_match_sql.py(one key's sessions, and two keys at the limit),test_anchor_and_descent_sql.py,test_side_leg_ties_sql.py(the lexical fallback, the unmatched leg and the recency backfill), and the one-version cases intest_set_chunk_rows_sql.pyandtest_bridge_rows_sql.py.test_a_full_search_window_may_hold_more_of_the_callers_rowsandtest_min_score_is_a_hits_least_similarity(test_memory_apply.py).test_search_scoring_one_per_key.py,test_a_procedure_served_in_two_sessions_is_one_match,test_a_decision_served_in_two_sessions_is_one_precedent,test_two_rows_of_one_decision_key_count_as_one_decision,test_a_confirmed_restatement_below_keys_of_many_rows_still_blocks,test_a_key_served_in_many_sessions_is_one_memory_line,test_a_part_adds_another_sessions_row_of_a_pooled_key, and the two-row cases intest_demonstrate.py,test_context_pack_decisions.pyandtest_memory_apply.py.test_duplicate_status_sql.pyrunsstatus_by_rowson clickhouse-local against the realloom.memory.test_new_mutations_bind_parameters_only.pyruns whole user, namespace and namespace-list sagas, andmemory.clearwith and without locks, through a fake client. It fails on any mutation holdingSELECTor a non-deterministic function on a non-KeeperMap table.tests/integration/test_erasure_replicated_ch.py(CI's ClickHouse runs an embedded Keeper) builds a throwawayReplicateddatabase ofReplicatedMergeTreecopies of 13 tables. It runs the real chunk, source-link, entity-graph, community, graph-link and document-purge steps and a lockedmemory.clearthere. It also asserts that the old subquery andnow()forms are refused with code 36.test_erasure.pyerases a user whose graph holds a 160 KB entity name (written past the write cap); before the hash binding it failed withField value too long.test_a_clear_names_a_bounded_number_of_locked_identities_per_mutation: 1 lock runs 1 embeddings mutation, 25,000 locks run 10 bucket mutations.test_a_clear_that_tombstones_nothing_announces_nothing,test_an_entity_filter_of_only_long_names_falls_back_to_the_parsed_entitiesandtest_a_user_with_chunks_and_no_memory_keys_binds_an_empty_slice(replicated tables).schema.sqltable converted to a Replicated engine:now()forms are refused.failed(code 36, 16 residue); this branch endscompleted, residue 0, all 26 mutations done, and the second user's rows remain._hitfixtures carrysession_id;tests/analyzer/shapes.txtis regenerated.make format-check lint typecheck test-unit; the integration files for bulk, same-key search, entity filter, erasure, export, learnings, blobs andmemory.clearagainst a local server.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. Each defect was reproduced by a test that failed before its fix, and the erasure change was checked against replicated tables.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass, except three unit failures this branch inherits frommain(itsdecision_extractcode):test_no_call_site_caps_its_output_with_a_literal,test_tests_patch_only_real_settingsandtest_no_new_tunable_constant(_MIN_WINDOW_CHARS,_RESTATEMENT_TOP_K,MAX_KNOWN_DECISIONS). The restatement fix here wraps_RESTATEMENT_TOP_Kinper_key_fetchand passes it toone_per_key, so a change that turns it into a setting touches those two lines; the integration suite passes if server behaviour changed.main; no merged migration is edited. (none)frontend/changed. (unchanged)docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s).🤖 Generated with Claude Code