Repository navigation
A link follows a definition renamed as it moves to another file or scope - #1672
Merged
Merged
Conversation
When a linked definition's name is gone from its file, the recheck searched only that file and scope for a renamed successor, and other files only for the same name. A definition renamed as it moved read `missing`, and under the default policy its memory left search although the code lives on. The recheck now also weighs the definitions the changed files did not define at the range's base. The only one with the old exact shape is followed as a rename alone; failing that, the only one of its own name with a close text is followed as changed, unless a definition of that name that stayed in the changed files is close as well. A member reads changed unless its class came with it unchanged. A definition under 30 tokens is told by neither its text nor a name any class may define, so it goes only under a related name and with its scope. Two candidates, or one another removed definition may have become, leave the link unresolved. A range that changed more than 32 files under the entry's prefixes is not searched and is counted in the pass outcome (`wide_ranges`). A link already missing is never handed to a new definition. 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.
|
The search of the other changed files admitted a definition under 30 tokens under any related name, and one shared word past the common lead is a related name. At that size the name-blanked shape of two stubs is the same, so a removed `class ReadError(Exception): pass` was followed as `moved`, its baseline replaced, to a new `class RetryError(Exception): pass` in any of up to 32 changed files. Its memory stayed in search as a lesson on the other class; without the search the link read `missing`. A small definition is now followed there only under a name of the same words: a leading underscore, the case or a `v` version may differ (`_read_rows`, `read_rows_v2`). The search of its own file and scope is unchanged. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rning A recheck that `code.refresh` runs keeps only the errors of its result, and it sets the checked head, so the link worker never follows that range: the `wide_ranges` number of the worker's pass outcome does not count it. The one trace both rechecks share is the log line in `RepoReads.turnover`, which is now a warning. The concept page says what the pass outcome counts: the ranges the worker's own pass followed. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A link the search across files leaves `unresolved` keeps the commit its code was last read at, and every later pass looks for it from that commit. The range only grows. Once it changed more than 32 files under the entry's prefixes, `RepoReads.turnover` returned None, `_renamed_elsewhere` answered that nothing became the definition, and the link read `missing` with both candidates still in place. Under `retire_removed` its memory left search, and a `missing` link is never handed to a new definition, so removing one candidate later could not resolve it. `_renamed_elsewhere` answers unsure for a link already `unresolved` when the range is too wide or cannot be read, the rule the namesake search has past `_MAX_ELSEWHERE`. A live link over such a range reads as it did. Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Both sides changed the lost-link search in the recheck. A definition the same-file search leaves unsure with no close text among the new definitions there is still looked for under its own name in another module; the search for one renamed as it moved runs only where the same-file search found no new definition, as before this merge. 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 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ 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 5592838. Configure here.
…a renamed definition is searched for `_file_turnover` read a file still present at the head whose names the ingest does not index (over `code_ingest_max_file_bytes`, binary, or not parsing) as defining nothing there, so every definition it had at the base joined `Turnover.gone`. `elsewhere` then weighed them as rivals of the lost link's definition, and one of its shape left the link `unresolved` where the renamed definition is in another file; `_vacated` read the file's classes as emptied. Only a deleted file is evidence that its names left: a file still there that is not indexed adds nothing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d in it The autouse stub of `RepoReads.turnover` answered None, which `_renamed_elsewhere` reads as a range that was not searched, so an `unresolved` link stays `unresolved`. `test_a_namesake_renamed_since_the_check_is_not_new[unresolved]` expects `missing` once both candidates are gone and failed in CI. The stub answers an empty `Turnover`: the range was searched and brought no definition in, which is what those fake histories hold. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…hen most of that class is its own `_may_be` took the destination class's members from the `new` side of its file, which holds only the names the range brought in. The members the class already had are on the `kept` side, so they were left out of the share: an existing class of five methods that took the removed class's members in passed with a share of 1.0, and the link of a method under 30 tokens went to it, while the same class new in the range was refused. The members the file kept under that class now count in the share. 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.

Related: #1669
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):
A memory's code link follows a definition that is renamed as it moves to another file, class or namespace:
movedwhen only its name changed,changedwhen it was edited or left its class. Such a link readmissingbefore, and under the defaultretire_removedpolicy its memory left search although the code lives on.Why
When a linked definition's name is gone from its file, the recheck looked for a renamed successor only in that file and scope (
_renamed,successor.successor), and in other files only for the same qualified or module-local name (_elsewhere,_in_mirror,anchor.locate). A definition renamed in the commit that moved it was never a candidate, so the link readmissing.Measured on 882 labelled events (renames, moves, edits, merges, deletions) mined from the history of eight open-source Python repositories, one link followed over one commit by the real
_recheckagainst bare clones, with no ClickHouse:missing;missing;missing(32%).The recheck now also weighs the definitions the changed files did not define at the range's base, in any file or scope, where every earlier search found nothing:
moved, orchangedwhen a member did not arrive with its class unchanged. A definition under 30 tokens is a candidate only under a name of the same words and with its scope (the first two guards below).changed.unresolved. Such a link is looked for from the commit its code was last read at. It is followed once a searched range leaves one candidate, and staysunresolvedover a range that is not searched.Two guards came from reading the first runs by hand, and review narrowed the first. The labels scored four wrong follows as correct, because the miner had paired the same definitions by chance:
class ReadError(Exception): passwas followed asmovedto a newclass RetryError(Exception): passin another file, and its memory stayed in search as a lesson on the other class. A definition under 30 tokens is now followed only under a name of the same words: a leading underscore, the case or avversion may differ (_read_rows,read_rows_v2). The search of its own file and scope keeps the wider rule.getanddeletewere followed to a new async namesake, while the sync text lived on under a name the destination file already had. Rule 2 counted close candidates among new names only. It now refuses when a definition of that name that stayed in the changed files is close as well. A kept namesake still never inherits a link.After the guards, measured again at the head commit (neither the narrower name rule nor the rule for a link already
unresolvedchanged any of the 882 outcomes):missingbeforemissingnowmissing)Read as removed although the code lives on: 230 of 722 (32%) before, 116 of 722 (16%) now. The 15 deletions read
unresolvedbefore are stillunresolved. Every followed link carries the line range of the definition it went to (493 of 493).Of the 110 links newly followed, one is scored as a wrong target and three as a part of a merge. Read by hand, all four are right: a function that became a nested definition of its own name inside a new wrapper (the miner counts no closures), and a method in a renamed test class. I read all 17 follows of a definition under 30 tokens and 17 of the larger ones (the lowest similarities and the generic names) and found no wrong one after the two guards. Those of them that went to another name differ from the old one by a leading underscore only. The other 76 have the exact shape or a similarity of 0.85 or more under a name specific to them and were not read one by one.
Scope and risk
server/code/domain/successor.py:elsewhere, a pure function besidesuccessor, with the rules above. It reuses_similar,_renamed_alone, the name words and the member-share bounds of the same-file search.server/memory/app/code_link_pass.py:RepoReads.turnover(base, head)reads, once per range and pass, what each changed file gained, lost and kept by the name inside its module, a renamed file as one file. It reads the files the ingest would index, by the checks the mirror search uses. It logs a warning for a range it did not read, andPassResult.wide_rangescounts those ranges for the pass that met them.server/memory/app/code_link_recheck.py:_renamed_elsewhereruns after the same-file search, the search for the name in other files and the moved-with-an-edit search, only when all of them found nothing and none is unsure. A link alreadymissingis never handed to a new definition, as before.unresolvedlink keeps the commit its code was last read at, so the range it is looked for over grows with every commit. Review found that once that range changed more than 32 files the link readmissingwith both candidates in place, and underretire_removedits memory left search._renamed_elsewherenow answers unsure for a link alreadyunresolvedwhen the range is too wide or its diff cannot be read, the rule the search for namesakes has past the same bound.unresolveduntil the search of its own file or for its own name finds it. The link row does not record which search left itunresolved, so this also holds for a link the same-file search leftunresolvedwhose file later holds no candidate: over a range that is not searched it staysunresolved, where it readmissingbefore this change. The warning is logged in every pass that rechecks such a link: every pass for 30 days after it becameunresolved, and later ones that change its file or recheck every link.missingcan readmoved,changedorunresolved. A memory the default policy left out of search is then served again; achangedone ranks below the next three results as any changed link does, andrevisejudges it._MAX_ELSEWHERE, an existing constant); a wider one is not searched, a live link reads as it did before, and a warning in the server log names the range. Thememory_code_linkspass outcome counts the ranges that worker's own pass followed. A recheck thatcode.refreshruns keeps no outcome and sets the checked head, so a range it followed is in the log only. In the sample 45 of the 882 events are in a commit wider than that, and the warning was logged for 18 of them, in 8 commits (a pass logs it once for a range); an earlier search settled the link in the others. The read happens only when a link is lost and nothing else found it.missing, as before this change), a definition that takes a new own name as it moves and does not keep its exact shape (40 of the 52 stillmissingin the two move-and-rename rows changed their own name), merges and splits, kept aliases, the policies, the link rows and every reader.unresolvedlink: unit tests alone cover that rule.Compatibility, rollout and rollback
memory_code_linkspass outcome gains the numberwide_ranges, whichworkers.statusserves as stored.missingduring the rollout staysmissingunder this one until its own name returns (docs/architecture/rolling-upgrades.md, rule 66).missingbefore this change are not revisited._recheckand the same paragraph of the concept page. Whichever lands second resolves a small conflict: the gate for both searches becomes "nothing found, and not unsure unless unmatched". I ran that composition on the sample, hand-resolved and unpushed: 14 links are followed that neither change follows alone (12 scored correct; the other two are the nested-definition case described above), and no follow of either change is lost. That run predates the narrower name rule; none of its follows is a definition under 30 tokens under a name of other words.Tests
ruff format --check .,ruff check, the function-length gate, the secrets gate, every generator with--check, and the mypy gate (its only errors are inserver/llm/vertex_auth.py, from a library missing in the local environment).RepoReads.turnoverover a fake history:tests/unit/test_code_successor.py(a function and a class with its members renamed across files; a method that left its class or became a function readschanged; a small function under a name of the same words and of other words; a removed stub and a new stub that share a word; a small method with and without its class, with its class kept, and with an alias left behind; a close namesake that stayed; two candidates; a removed rival; twins),tests/unit/test_memory_code_links.py(through_recheck: file kept, deleted and renamed; a name the other file already had; amissinglink not revived; the cap, its count and its warning; prefixes; a file that does not parse or the ingest refuses; the name searched before another name; the count reaching the pass outcome; anunresolvedlink rechecked over a second range that is too wide, that cannot be read, and that leaves one candidate),tests/unit/test_code_anchor.py(recheckwith a successor in another file).RepoReads.turnoverfor the older tests of that module, as one already stubs the mirror search: their fake histories answer no git diff.tests/integration/test_memory_code_links.py, not run: a definition renamed into a new file ismoved, served bymemory.searchandcode.symbolunder its new name, andmissingonce removed; a method of 30 tokens or more moved to another class readschanged.missingfor a small definition whose namesake appears in another class or namespace. I replayed their sources through the pure function and they still readmissing._write_moveswrites for a rename across files (the former identity,policy_due),_current_moves, the lost-link reread (store.losthanding anunresolvedlink back with the commit_write_moveskept), therevisepolicy on a followed link, and the index's candidates in place of the fake index the measurement used._recheckover the commit with a realRepoReadson a bare clone; the index is replaced by a read of the clone at the head.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked by hand: the diagnosis against the code paths named above, the measurement before and after, every outcome that is not a plain follow, and the 34 follows listed above.
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.🤖 Generated with Claude Code
Note
Medium Risk
Changes core memory-to-code link resolution and search/lesson surfacing, with nuanced edge cases (small defs, wide diffs, unresolved state) but no schema or wire API break beyond a new pass metric.
Overview
Memory code links can now track a definition that moves to another file, class, or namespace under a new name, instead of stopping at
missing. After the same-file successor search, mirror/name search, and “moved with edit” logic all come up empty, recheck calls newsuccessor.elsewhereon definitions newly introduced in the changed files (viaRepoReads.turnover).Matching prefers an exact shape →
moved, else a unique same-name body →changed, with extra guards for small definitions (scope + word-related names). Ambiguity yieldsunresolved;missinglinks are still not revived. Ranges touching more than 32 indexed paths are skipped (logged, counted aswide_rangeson the worker pass); already-unresolvedlinks stay uncertain over those ranges.Docs describe the behavior and rolling-upgrade rule 66; unit and integration tests cover the new paths.
Reviewed by Cursor Bugbot for commit 369475e. Bugbot is set up for automated code reviews on this repo. Configure here.