Repository navigation
fix(watch): keep a re-extracted file's type stub on the id a full build gives it - #5800
0xkaushik-ai wants to merge 2 commits into
Conversation
…ld gives it A type no file defines (Swift `Int`, Scala `String`) is a sourceless stub. A full build salts one copy per referencing file (`a_swift_int`, `b_swift_int`) when two files reference it, and keeps the bare `int` for a single one. An incremental run re-extracted the edited file alone, so its copy went back to `int` while the other stayed salted; deleting one of two holders left the survivor salted (Graphify-Labs#5797). The stored stub has no source_file and its origin_file hint is not persisted, so the id-collision partner search never saw it. Its owner is now read from its edges. extract() is told which stub ids an unchanged file holds salted and salts a batch stub of the same id too, so no other file is re-extracted for it. Only when a target or deleted file shared a stub with exactly one unchanged file is that file re-extracted, since it may end up the only holder. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Graphify review 
1 bug · High impact
Incremental extraction now tracks salted sourceless stubs held by unchanged files and passes their bare IDs into collision handling.
Hashed stub IDs are missed for paths that normalize alike ·
watch.py:300
Code graph · 6418 functions depend on this change
- 3 functions became more coupled.
dispatch_command()(8 callers),_disambiguate_colliding_node_ids()(6 callers),_id_collision_partners()(3 callers). - 473 of 693 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed e4efcc5 · 1 of 1 earlier findings resolved
The owner's path prefix alone marked a stored stub as salted, so the bare stub of a type named `A_Swift_Int` in A.swift read as a salted `Int`, and another file's lone `Int` was salted against it. The rest of the id now has to be the id of the stub's label. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
| continue | ||
| source, prefix = owner | ||
| if not nid.startswith(prefix) or len(nid) == len(prefix): | ||
| continue |
There was a problem hiding this comment.
Hashed stub IDs are missed for paths that normalize alike
When distinct paths normalize to the same ID prefix, editing or adding a file that references the same type can leave its stub unsalted even though a full build salts it.
Update _salted_stub_holders in graphify/watch.py to recognize hash-suffixed IDs.
Evidence · checked against the code
Expected: The unchanged holder is detected and the re-extracted stub is salted consistently with a full build.
Actually: The holder detector rejects the hash-suffixed ID, so the new stub can remain bare and differ from the full-build ID.
- Independent source review: The helper’s ordinary salted-stub test covers paths without the hash suffix and does not exercise normalized-path collisions. The collision-partner logic also uses
_salted_stub_holders, so it does not recover the omitted hashed holder through that route. No inspected guard compensates for the missed context ID. - This affects paths whose normalized IDs collide and whose stubs are salted with the disambiguator's hash; ordinary path salts are recognized.
Prompt to fix with AI
In graphify/watch.py, _salted_stub_holders (lines 297-300):
Problem: Hashed stub IDs are missed for paths that normalize alike
Expected: The unchanged holder is detected and the re-extracted stub is salted consistently with a full build.
Actually: The holder detector rejects the hash-suffixed ID, so the new stub can remain bare and differ from the full-build ID.
Fix it at the cause, and add a test that fails without the fix.
Graphify · Checked against the code · View in Graphify
Fixes #5797.
A type no file defines (Swift
Int, ScalaString, an unresolvedFooin Rust or Go) is a sourceless stub. A full build salts one copy per referencing file when two files reference it (a_swift_int,b_swift_int) and keeps the bareintwhen only one does. An incremental run re-extracted the edited file alone, so nothing collided in the batch and its copy went back toint, while the other file stayed onb_swift_int. Deleting one of two holders went the other way: the survivor stayed salted where a full build hasint._id_collision_partnersalready pulls id-colliding files into one batch, but it recognises a salted node by itssource_file. A stub is stored withsource_file: ""and itsorigin_filehint is stripped before output, so the search never saw it.Fix
watch.py,_salted_stub_holders: reads a stored stub's owner from its edges. A salted copy is referenced from one file only, its id starts with that file'smake_id(<path>)prefix, and the rest of the id is the id of its label; anything else is left out. The label check keeps out a bare stub whose own name starts like the path (a typeA_Swift_IntinA.swift), which the review bot caught on the first commit.resolution.py,_disambiguate_colliding_node_ids(context_stub_ids=...): a sourceless batch stub whose id an unchanged, still-scanned file holds salted is salted with its own path, as if both files were in the batch. A source-backed node is never touched by this. Both incremental paths (updateinwatch.py,extractincli.py) pass the set through the newextract(resolution_context_stub_ids=...).watch.py,_id_collision_partners: when a target or deleted file shared a stub with exactly one unchanged file, that file is re-extracted, because it may end up the only holder and must return to the bare id.I did not add stub holders to the existing partner closure. In a Swift repo that would re-extract every file that mentions
Stringon each edit. With this change an edit re-extracts no extra file while two other holders exist, and one extra file otherwise.Not covered
int): the unchanged file should becomea_swift_int, but nothing identifies it before extraction. The new file's own copy is unaffected by this PR. A third holder joining two salted ones is covered.graphify extractstill keeps the old, now unreferenced stub node ([Bug]: repeatedgraphify extractkeeps an orphaned base-class stub after its referrer resolves it #5726). Edges match a full build; the end-to-end tests leave such orphans out of the node comparison on theextractpath only and say so.Tests:
tests/test_incremental_type_stub_ids.pyupdateandextract --no-cluster, each compared with a fresh full build: edit one of two holders (Swift, Scala, Rust), delete one of two (Swift, Go), the edited file drops the reference, a third holder is added, a re-extracted partner keeps its other salted stubs, and a type whose name only looks salted. On v8 16 of the 22 fail; the other 6 guard against over-salting (two remaining holders, the look-alike name) and pass on v8. With the fix all pass.🤖 Generated with Claude Code