Repository navigation
namespace.validate lists the token edits a followed rename allows in each memory, or why none is offered - #1674
Merged
Merged
Conversation
…each memory, or why none is offered A link that follows its definition to another name or file reads `moved`, and the memory's text still names the old one. Nothing computed the replacement, and a blind replace is wrong often: the old bare name can be borne by another definition, the new one can be ambiguous, and a sentence about the name or a past state is right as it is. - `anchor.code_spans` reads the names a text writes as code (a whole backticked identifier, `A::b`, a call `a.b(` or `f()`) with their positions, and the spans that quote code: fenced blocks, URLs, quoted strings and longer backticked spans. A name joined to a path, a flag or a file suffix is neither. - `server.memory.domain.code_rename.plan` takes a memory's text and head, its links and the index's definitions at the head. It returns the edits (old and new token with character positions) and the hash memory.get serves for the text, or one reason from a closed list. Each name keeps its spelling: as many segments, the same separators, a full dotted name under the whole new module. One reason withholds the whole memory. - The `code_rename_edits` finding of namespace.validate lists, for the repositories the caller may read, each served memory with a `moved` link and its edits or reason. The finding's `totals` field counts the memories by `edits` and by reason. No high-sensitivity memory is read. - `stale_links` takes the link states to list. Loom writes nothing. The caller applies an edit with memory.update and `if_match_sha256`, a revision with its conflict check that is refused when the memory changed after the report read it. memory.update keeps `files`, so a memory whose `files` name a renamed path gets the reason `named_in_files`. Signed-off-by: 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.
|
…s the index for every old path - `code.live_paths` reads its paths in slices of 500, the most the file table's reads answer for in one call. A report with more old paths than that read the rest as gone and offered a whole-path edit for a file the head still has. The link pass resolves a batch's `files` through the same call. - A sentence that says `name`, `names`, `naming`, `called` or a word that starts with `alias` is about the name and gets `about_naming`. `call` and `calls` are left out: they say the code is called. - The dotted module a definition left, written over two segments or more outside the edits (an import, a sentence about the place), withholds the memory as `old_name_remains`, or `quoted_or_literal` inside quoted code. - A memory whose text names no old name or path is left out of the finding: its count, samples and `totals` are the memories whose text says an old name. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d one, and reads a wrapped sentence whole A name written as code that ends in the old name and is not edited was taken to name another definition without asking the index. With `Reader::read_rows` renamed, "`Reader.read_rows` retries; wrap `conn.read_rows()` in a try." got one edit and kept `conn.read_rows()`, a call the head no longer has. Such a name is now left alone only when it names a definition at the head, or the old definition of another followed link, which that link edits; otherwise the memory gets `old_name_remains`. The same holds for `~Reader` beside an edited `Reader`. The naming and date cues were searched in the line. A sentence now ends after `.`, `!` or `?` and a space (not after a one-letter abbreviation such as `e.g.`), at a blank line and before a list item, so "formerly named" on the line above the name withholds the edit. `May` capitalised after another word of the sentence counts as a month: "In May `read_rows` retried twice." is a dated claim, and "`read_rows` may retry" is still edited. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…and that the slice must read `old` The planner positions an edit by Python string index, which counts Unicode code points. The guide, the concept page and the finding's `detail` said only "characters", and no step checked the slice. A caller that indexes UTF-16 units or bytes read another slice once the text held a character outside the Basic Multilingual Plane before the edit: for the text "<rocket emoji> `read_rows` retries" the edit is at 3..12, and a UTF-16 slice of 3..12 is "`read_row". `if_match_sha256` matches the unrevised memory, so memory.update accepted the corrupted text. The guide's step, the concept page, the finding's `detail` and the `Edit` docstring now name the unit, and the step applies nothing unless the text from `start` to `end` reads `old`. The planner's output is unchanged. A unit case plans a text with such a character before the edit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
sdk/rust/src/wire_models.rs is regenerated with scripts/codegen/sdk_rust_gen.py from the merged operation registry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
There are 4 total unresolved issues (including 2 from previous reviews).
❌ 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 679dc5b. Configure here.
A reason the links, the key, a tag or `files` give (`link_not_settled`, `incomplete`, `named_in_key_or_tags`, `named_in_files`, and `overloaded` for a numbered definition) was returned before the text was found to write an old name, so `code_rename_edits` listed and counted memories whose text holds as it is. Such a plan is `no_code_token`, which the listing skips. Two cases withheld an edit the text allows: - the module a definition left, written as the start of a name that names another definition at the head (`io.util.helper` after `backoff` moved to `net.util`), read as `old_name_remains`; - a blank line written `\r\n\r\n`, which did not end a sentence, so a naming or dating cue in the paragraph before withheld the edit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…y as a path of its own A C or C++ name carries no module part, so the whole old name was respelled with as many segments as it wrote: `ns::Reader::get` became `io::Reader::get` when the definition moved to `ns::io::Reader::get`. The whole old name is the whole new one in every language. `new_name_present` was a substring test on the new path, so `test/src/util.py` or `src/util.pyc` withheld the edit to `src/util.py`. The new path counts where it is written as a path of its own, a line number after it included. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
This was referenced Nov 28, 2026
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):
After a rename or a move that a memory's code link follows,
namespace.validatelists, for each memory whose text still says the old name, module or path, the exact token edits that bring it up to date, or the one reason it offers none, under thecode_rename_editsfinding. Loom writes nothing: the caller applies an edit withmemory.updateandif_match_sha256.Why
A link that follows its definition to another name or file reads
moved, and the memory's text still names the old one. Nothing computed the replacement:anchor.mentionsfinds where the names are and keeps only the names.A blind whole-word replace is wrong too often to offer. Whether a name can be swapped depends on how the text spells it and on the sentence around it, not on the link:
This change computes the edit only where the spelling is explicit and the index agrees, says why otherwise, and leaves the write to a principal. The finding's
totalsare the per-namespace measure of how often a mechanical revision is offered and what stops the rest.Design:
anchor.code_spans(text)returns the names a text writes as code with their positions (a whole backticked identifier,A::b, a call writtena.b(orf(); aself.,cls.orthis.receiver kept apart), and the spans that quote code without naming any (fenced blocks, URLs, quoted strings, a backticked span that is more than one name). A name that touches/ - # = @ " 'or a file suffix is neither. It is separate frommentions, which stays as the link pass reads it.server.memory.domain.code_rename.planis pure. It takes the memory's text and head, the links made from it as it is now, the index's definitions at the head and the old paths the head no longer has. Only a link in statemovedwhose last check matched its baseline is revised, and only when every link of the memory isfreshormovedon its baseline under the fingerprint rules in force. A name is replaced in its own spelling: as many segments and the same separators inside its module, and under the whole new module where the whole old one was written. A whole repository path is replaced once the head no longer has the old file.not_text,link_not_settled,incomplete,overloaded,quoted_or_literal,prose_occurrence,old_name_remains,names_several,receiver_form,old_name_still_defined,new_name_present,dated_claim,about_naming,named_in_key_or_tags,named_in_files,would_unlink.would_unlinkresolves the revised text with the rule the link pass uses (anchor.resolve), because applying an edit makes the pass link the memory again from its new text.no_code_token: a bare name still holds after a move) is not listed. The finding's count, samples andtotalsare the memories whose text says something old.about_namingis a word list, named in the docs table:name,names,named,naming, a word that starts withrenamoralias,called,formerly,used to,replaced,moved from,deprecated,legacy,before,previously.callandcallsare not on it. In a memory about code they nearly always say the code is called, and withholding on them would drop the edit of "the worker callsread_rowstwice". So "never call a helperread_rows" is offered an edit; the finding's stated uncertainty covers it (whoever applies an edit reads the sentence)..,!or?and a space (not after a one-letter abbreviation such ase.g.), at a blank line and before a list item. A line break alone does not end one, so "formerly named" on the line above a wrapped name withholds the edit.Maycounts as a month only capitalised after another word of the sentence; elsewhere it is the verb.conn.read_rows(),~Reader) is left alone only when it names a definition at the head, or the old definition of another followed link, which that link edits. Otherwise the memory getsold_name_remains: the revised text would still tell its reader to call something the head no longer has.from src.io.util import backoff, "it lives in the io.util module"), withholds the memory:quoted_or_literalinside quoted code, elseold_name_remains. Every trailing part of the old module that the new module does not also end in is searched, joined by.or::. One segment is not searched:readerorutilsis as often a word of the prose.startandendcount Unicode code points of the text, as a Python string index does. The guide, the concept page and the finding'sdetailname the unit, and the guide's step applies nothing unless the text fromstarttoendreadsold. A caller that indexes UTF-16 units or bytes reads another slice once a character outside the Basic Multilingual Plane (for bytes, outside ASCII) comes before the edit, andif_match_sha256does not catch that: it matches the unrevised memory.server.memory.app.code_renames.plannedreads the memories with amovedlink throughstale_links(which now takes the states to list), so it starts from the links into repositories the caller may read, and plans each.Alternatives considered:
totalsfrom a real namespace and at least 100 listed edits checked by hand with none wrong.mentionsfor the positions. Its prose patterns match inside a URL, a flag and a file name, and a backticked span that is not an identifier shields nothing.code_unlinked_*findings do. Seventeen findings on every report (the edits and the 16 reasons); atotalsmap on the one finding carries the same counts.Scope and risk
namespace.validateruns one more check; with nothingmovedit is one read of the link table.memory.updatekeeps a row'sfiles, so the planner never editsfiles: a memory whosefilesname a renamed path getsnamed_in_files. Not edited either:memory_key, tags, entities, concepts, and a line number written in the text.code.live_pathsnow asks the file table in slices of 500 paths, the most its two reads answer for in one call. Before, every path past the 500th in sort order came back absent, so a report with more than 500 old paths in one repository offered a whole-path edit for a file the head still has. The link pass resolves a batch'sfilesthrough the same call (500 memories a batch by default), so a batch whosefilesname more than 500 distinct paths now resolves all of them; before, the ones past the 500th were read as not indexed.loom.memory(valid_to,invalid_at,temporal_anchor); the statement corpus (tests/analyzer/shapes.txt) carries the new shape.written_as(the identity a link's memory was written against) lives in the new module. The open pull request that names moved code on reads defines the same rule; whichever lands second should keep one copy.Compatibility, rollout and rollback
namespace.validatereturns one more finding,code_rename_edits(severityinfo, so it never changeshealthyand never blocks the coding plugins' stop gate). Each finding carries a new optional fieldtotals: dict[str, int], empty for every other check. No input changes.code_rename_editsfinding and nototals.Tests
Unit tests were not run locally as a suite. The new and changed test functions were called directly in a Python process (no pytest run): the 74 cases of
tests/unit/test_memory_code_rename_plan.pyand the tests oftests/unit/test_code_anchor.pyat the third commit, and the 26 tests oftests/unit/test_namespace_validate.pyat the second commit (the third changes neither that file nor the module it tests); all passed. The fourth commit changes wording and adds one unit case. At it, 70 of the 75 cases oftests/unit/test_memory_code_rename_plan.pywere called again (all but the five listing tests, whose module it does not change), with the threecode_rename_editstests oftests/unit/test_namespace_validate.py, which read the finding'sdetail; all passed. CI runs the suites. The integration testtest_validate_lists_the_edit_a_followed_rename_allows_and_an_update_applies_it(rename, read the listed edit, apply it withmemory.update, check the link at the new name, a second apply with the same hash is refused, an unreadable repository lists nothing) needs ClickHouse and was not run locally.New tests:
tests/unit/test_memory_code_rename_plan.py: each explicit spelling is edited at its own depth and separator; a word of the prose, a part of a longer name, a URL, a flag, a file name, a quoted key, a fenced snippet and a longer backticked expression are not, each with its reason; "rename X to Y", a sentence with a commit hash, "formerly X", "X is a bad name", "never name a helper X", "is called X" and "X is an alias" withhold, as do a cue on the line above a wrapped name, a cue beforee.g.and "In May"; a cue in another sentence, behind a blank line or in another list item, a longer word that holds one (filename,namespace), "calls X" and "may retry" do not; a call through something the index does not define (cfg.read_rows(),conn.read_rows()) and~Readerbeside an editedReaderwithhold asold_name_remains, while a name another definition at the head answers to is left alone and two renamed methods of one name are each edited by their own link; the module a definition left withholds in an import, in the prose and in::form, while the part both modules end in and one segment do not, and two definitions that left one module are both edited; a homonym of the old name withholds, a homonym of the new one withholds aswould_unlink; an ordinal name, cut links and a pending, changed, lost or carried link withhold; the old name in the key or a tag, and the old path infiles, withhold; a renamed file edits its whole path once the old one is gone; text outside the edits is byte-identical; an edit after a character outside the Basic Multilingual Plane is positioned in code points, where a UTF-16 slice of the same positions reads another token; planning the output again offers nothing. The listing returns edits or a reason per memory, lists no memory whose text names nothing old, reads no high-sensitivity, unserved or stale-linked memory, and nothing of an unreadable repository. With 501 old paths in one repository, the last still on the head, the file table is asked twice (500 and 1) and that memory getsold_name_remains; with one read it fails.tests/unit/test_code_anchor.py: which names are code spans, what is quoted, what is joined, and that the read is linear in the text.tests/unit/test_namespace_validate.py: the finding's count, samples andtotals, a failed read skips this check alone, and an unreadable repository reads nothing.tests/integration/test_memory_code_links.py: the test named above.Gates run locally at the head commit:
ruff format --check,ruff checkon the lint targets, the function-length gate, the secret scan, every generator--check(SDK tables, settings, docs reference, reach census), Prettier on the two changed docs pages, and the package-contract, public-copy, doc-link and tunable-constant checks. The MCP listing budget check ran at the second commit; the later commits change no op text. The statement corpus was regenerated at the first commit (tests.analyzer.corpus --write, one shape replaced); the later commits change no statement. The mypy gate reports onlyserver/llm/vertex_auth.py(nogoogle-authstubs in the local environment).Measurement, offline (git reads only, no ClickHouse, no model call). A frozen sample of 882 rename, move, split and deletion events mined from the history of eight open-source Python repositories is replayed through the real recheck; for each of the 199 events it leaves
movedon the true new definition, one sentence naming the old definition is synthesised per spelling and planned against an index read from the repository at the commit. An edit counts as wrong unless it swaps exactly one token for a name of the true new definition (the whole dotted name where the whole old one was written). The revised sentence is planned again.The simple name changed (40 events), memory with no
files:would_unlink9,old_name_still_defined3f()would_unlink8,old_name_still_defined3,old_name_remains1Class.method, backtickedold_name_still_defined1Class::methodin proseold_name_still_defined1Class.method()in proseold_name_still_defined1quoted_or_literal1 (a hyphen in a directory name)With
filesnaming the old path, the bare spellings are offered an edit in 34 of 40 (85%): the new name resolves inside the file.Only the scope or the file changed (159 events), memory with no
files: a bare name names nothing old in all 159 (it still holds), so the finding does not list it;Class.methodis edited in 83 (52%) and the full dotted name in 146 (92%), with 0 wrong edits. Withfilesnaming the old path, 67 of the 159 getnamed_in_files(the file was renamed); for the full dotted name that is 64, and 3 getquoted_or_literal.filesnamed_in_files67Class.method, backtickedwould_unlink1Class.method, backtickednamed_in_files67, names nothing old 39quoted_or_literal3,would_unlink2,new_name_present1named_in_files64, names nothing old 7,quoted_or_literal3,new_name_present1The module check moved 3 events of this table, and no other number of the measurement: a full dotted name under a directory with a hyphen is a backticked span that is not one name, so it is quoted code. Before, such a memory counted as naming nothing old; now the old module found in it gives
quoted_or_literal, and the finding lists it.Spellings that must not be edited (40 events each): a word of the prose, a CLI flag and a file name get
prose_occurrence(29) orold_name_remains(11); a URL, a quoted key, a fenced snippet and a longer backticked expression getquoted_or_literal(40). No edit is offered for any. The 50 events where the old name stays defined as an alias get no edit (link_not_settled: the alias's text changed). Two links the recheck leftmovedon another definition than the true one get no edit either.The prediction made before the run was 70% for the bare spelling with
old_name_still_definedas the main reason, 97% forClass.methodand 100% for the full dotted name. The shares hold within the stated 10 points. The reason for the bare spelling does not: three quarters of the withheld arewould_unlink(the new bare name is not one definition), because a commit that renames a method usually renames it in every class that has it.The first run of the measurement found a defect that is fixed in this diff: a full dotted name whose module gained a segment was respelled without its first segment (33 wrong edits). A module-qualified spelling now takes the whole new module.
The recheck itself is unchanged: over the 882 events, 0 change outcome against the same run on
main, at the first commit and again at the head.The third commit (the sentence boundaries,
May, and a second code name that keeps the old one) moved no number of the measurement: every table above, and the reason of every withheld sentence, is the same at the head. The fourth commit (the unit ofstartandend) changes no planner output: the replay and the tables were run again at it and are identical.Not in the measurement, because its one sentence holds none of them: the
about_namingwords, a sentence wrapped over two lines,May, a second code name that keeps the old one, the old module beside an edit, a character outside the Basic Multilingual Plane, and the 500-path slices. Each was reproduced on hand-made sentences before the change and is covered by the unit cases above.Only ClickHouse can confirm: the SQL of
stale_of_servedwithstate = 'moved', the three added columns of the heads read, that the listed hash equals the onememory.updatecompares, and the relink after the update. The integration test covers each. Not measured: real memory text (every sentence above is synthesised), languages other than Python, and the cost of the check on a namespace with thousands ofmovedlinks (it reads at most 2,000 memories).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 the agent: the planner on hand-made cases and on the measurement above, the test functions called directly, and the gates listed under Tests.
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) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.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.Note
Medium Risk
Read-only reporting, but new text-editing heuristics affect what callers may apply to memory content, and the live-path batching change alters link resolution for large file lists.
Overview
Adds a new
code_rename_editsinfo finding tonamespace.validatefor memories whose code link ismovedbut text still names the old symbol or path. Each sample includes Unicode code-pointedits(start/end,old/new) pluscontent_sha256, or a singlereasonwhen no safe mechanical swap is offered;totalson findings aggregate counts by outcome.Loom does not auto-rewrite memories: callers apply changes with
memory.updateandif_match_sha256. Planning is driven by newanchor.code_spans,server.memory.domain.code_rename.plan, andcode_renames.planned(integrated as validate’s 19th check).stale_linkscan targetmovedlinks only;code.live_pathsnow batches path lookups in slices of 500 so large path sets resolve correctly.Wire/SDK types gain optional
totalson validate findings; docs describe the workflow and withholding rules.Reviewed by Cursor Bugbot for commit 64d0e4c. Bugbot is set up for automated code reviews on this repo. Configure here.