Repository navigation
fix(watch): watch-mode rebuild now populates full node schema - #2380
Merged
Merged
Conversation
…orted codegraph watch's single-file rebuild path (prepareWatcherStatements in watcher.ts, insertFileNodes in incremental.ts) only ever inserted (name, kind, file, line, end_line, accessor_kind) and never set exported=1 on an exported symbol — unlike the full-build path (insertDefinitionsAndExports/collectChildRowsAndFileEdges in stages/insert-nodes.ts), which populates qualified_name, scope, visibility, parent_id, content_hash, and exported. A symbol touched only by a watch-mode rebuild would silently diverge from one touched by a full or regular incremental build, affecting any downstream query that filters/joins on those columns. insertNode's column set now mirrors the full-build path's getNodeStmt exactly, and a child's parent_id is resolved via a real post-insert lookup (getNodeId), not lastInsertRowid — which INSERT OR IGNORE makes unreliable when a def already exists from a prior rebuild. Extracted the ~18 near-identical local makeStmts(db) helpers duplicated across watch-mode integration tests into a single shared tests/helpers/incremental-stmts.ts, since fixing the schema meant every one of them needed the same update anyway — each was one paste away from drifting out of sync with production the next time this schema changes. docs check acknowledged: bug fix only, no language/architecture/CLI change Impact: 4 functions changed, 6 affected
Contributor
Greptile SummaryThe PR aligns watch-mode node insertion with the full graph-build schema and consolidates duplicated incremental-test statement bundles.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Change["Source file change"] --> Watcher["Watcher"]
Watcher --> Parse["Incremental parse"]
Parse --> Insert["Insert file, definitions, and children"]
Insert --> Lookup["Resolve parent IDs"]
Lookup --> Export["Mark exported symbols"]
Export --> Edges["Rebuild containment and reference edges"]
Edges --> DB["Persist full node schema"]
Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
Contributor
Codegraph Impact Analysis3 functions changed → 6 callers affected across 3 files
|
…insertnode-missing-columns
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #2220
Root cause
codegraph watch's single-file rebuild path (prepareWatcherStatementsinsrc/domain/graph/watcher.ts,insertFileNodesinsrc/domain/graph/builder/incremental.ts) only ever inserted(name, kind, file, line, end_line, accessor_kind)intonodes, and never setexported = 1on an exported symbol. The full-build path (insertDefinitionsAndExports/collectChildRowsAndFileEdgesinstages/insert-nodes.ts) additionally populatesqualified_name,scope,visibility,parent_id,content_hash, andexported.A symbol touched only by a watch-mode rebuild would silently diverge from one touched by a full or regular incremental
codegraph build— any downstream query that filters/joins on those columns (cross-file reference lookups, "go to definition", exported-symbol queries) could behave differently depending purely on which rebuild path last touched it.Fix
insertNode's column set now mirrors the full-build path'sgetNodeStmtexactly:(name,kind,file,line,end_line,parent_id,qualified_name,scope,visibility,content_hash,accessor_kind).insertFileNodescomputesqualified_name/scopethe same wayinsertDefinitionsAndExportsdoes (a dotted definition name yields a scope from everything before the last dot), and resolves a child'sparent_idvia a real post-insertgetNodeIdlookup — notlastInsertRowid, whichINSERT OR IGNOREmakes unreliable when a definition already exists from a prior rebuild.markExportedstatement (mirroring the full-build path'sgetExportStmt) so an exported symbol getsexported = 1regardless of which rebuild path touched it.Test infrastructure cleanup
Fixing the schema meant every one of the ~18 watch-mode integration test files needed the same update to their local, hand-rolled
makeStmts(db)helper (each duplicated the same prepared-statement set, one paste away from drifting out of sync with production the next time this schema changes — which is exactly what happened here). Extracted them into a single sharedtests/helpers/incremental-stmts.ts.Test plan
tests/integration/issue-2220-watch-insertnode-columns.test.ts: verifies a watch-mode rebuild gives a top-level exported functionqualified_name/exported = 1, a dotted method definition the correctscope, and a parameter child the correctparent_id/qualified_name.npm test(292 files / 4749 tests passed),tsc --noEmit,biome checkall clean.watcher.ts/incremental.ts).