Skip to content

chore(graph-builder): remove five shadowed/orphaned methods (-552 lines, no behaviour change) - #1619

Merged
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
rrodriguesNutrium:upstream/remove-shadowed-writer
Aug 13, 2026
Merged

Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
rrodriguesNutrium:upstream/remove-shadowed-writer

Conversation

@rrodriguesNutrium

Copy link
Copy Markdown
Contributor

graph_builder.py defines add_file_to_graph twice — at line 203 and again at line 768. Python keeps the second, so the first ~550 lines are unreachable.

It is worse than redundant. The dead copy's item_mappings has drifted from the live one in indexing/persistence/writer.py: the live list handles objects, mixins, extensions, modules and enum_members, the dead one handles none of them. Anyone reading the file top-to-bottom to learn which node types reach the graph gets a wrong answer, and nothing in the file signals which copy wins. It cost me a wrong conclusion before I noticed.

What this removes

The unreachable region turned out to contain five class-scope methods, not one. Each was traced across the repo before removal:

method why it is dead
add_file_to_graph shadowed by the later definition
_resolve_function_call duplicate; the surviving copy has a behaviourally identical body
_create_all_function_calls separately shadowed — a later definition already won
_resolve_inheritance_link zero call sites; live equivalent is the free function in indexing/resolution/inheritance.py
_create_csharp_inheritance_and_interfaces zero call sites here; the live one is on GraphWriter (writer.py, called from writer.py)

Verified before deleting that inspect.getsourcelines(GraphBuilder.add_file_to_graph) reported the second definition, and after deleting that it resolves to the single remaining one.

Verification

Pure deletion, so the bar is that nothing changes. Test results are byte-identical before and after — same failures, same pass count. On a change like this a newly passing test would be as suspicious as a new failure, since it would mean the code was not actually dead.

Note there is at least one further shadowed pair still in the file (add_repository_to_graph, defined twice), left alone here to keep this reviewable. Reported with the rest on #1595.

One file, −552 lines, no behaviour change.

Removed 552 lines of unreachable dead code from graph_builder.py
(lines 202–753), containing five class-scope methods:

1. add_file_to_graph (lines 203–499)
   — shadowed by live definition at line 768; stale item_mappings had
     drifted from the active one in writer.py:290-313

2. _resolve_function_call (lines 501–510)
   — shadowed by identical survival copy at line 154

3. _create_all_function_calls (lines 512–652)
   — shadowed by later definition at line 828

4. _resolve_inheritance_link (lines 654–694)
   — no call sites in src/; live equivalent is in
     indexing/resolution/inheritance.py:9

5. _create_csharp_inheritance_and_interfaces (lines 696–752)
   — no call sites in graph_builder.py; live version is on GraphWriter
     in indexing/persistence/writer.py:891 (called from writer.py:1021)

All verified dead with live equivalents elsewhere. Zero behavioral impact.
Tests pass identically before and after (12 pre-existing failures only).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@rrodriguesNutrium is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. For a 552-line deletion I wanted to trace every removed name myself rather than take the claim on trust:

Three shadowed names — one definition each remains after removal, and it's the live one:

add_file_to_graph           1 remaining
_resolve_function_call      1 remaining
_create_all_function_calls  1 remaining

Two orphans — live equivalents confirmed elsewhere:

  • _resolve_inheritance_link → zero references anywhere in src/ after removal; the live one is the free function resolve_inheritance_link at indexing/resolution/inheritance.py:9.
  • _create_csharp_inheritance_and_interfaces → live on GraphWriter at writer.py:930, called from writer.py:1081. No remaining reference from graph_builder.

Suites green: 1204 unit, 44 integration.

The item_mappings drift you pointed out is the real justification here — the dead copy silently taught readers the wrong set of node types, which is worse than the dead code itself.

One thing left over: add_repository_to_graph is still defined twice (graph_builder.py:187 and :202), which you'd flagged in the original report as the third shadowed name. Not a blocker for this PR, but worth a follow-up — and #1604 stays open until it's done. Happy to take it if you'd rather move on to the Android stack.

@Shashankss1205
Shashankss1205 merged commit 96ca9d7 into CodeGraphContext:main Aug 13, 2026
18 of 19 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Aug 13, 2026
@Shashankss1205 Shashankss1205 added gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:refactor GSSoC type bonus: refactor labels Aug 15, 2026
Shashankss1205 added a commit that referenced this pull request Aug 18, 2026
…P graph_name, JS/TS imports, .NET ignore defaults and dev-env pins (#1646)

* fix(jobs): stop cleanup_old_jobs deleting jobs that are still active (#1537)

Active jobs with recent progress survive the sweep; a RUNNING/PENDING job
with no update for the whole window is flipped to FAILED (still visible to
check_job_status) instead of vanishing, and ages out via the terminal path.

* fix(watcher): clear watched_paths and watches in stop() (#1519)

A stopped Observer cannot be restarted; stale entries made watch_directory
answer 'Already watching' for a dead observer.

* fix(validator): stop rejecting read queries that mention write keywords as identifiers (#1511)

Keywords in provably-safe positions (property access, label/rel-type,
parameter, AS-alias) no longer trip the read-only gate; clause-position
writes are still rejected, including a real SET/DELETE following an alias.

* fix(simulator): make simulate_metrics work on embedded backends (#1512)

labels(<var>)[0] is now rewritten for any variable name (the literal
labels(n)[0] replace missed n1/n2), and the relationship query's bare
pattern predicate is restructured as a CONTAINS*0.. match.

* feat(mcp): honour add_code_to_graph graph_name on multi-graph backends (#1558); drop last shadowed method (#1604)

GraphBuilder accepts a graph_name and binds its writer to
get_driver(graph_name); the handler builds a scoped builder on FalkorDB and
refuses explicitly on single-graph backends instead of silently indexing
into the default graph. Also removes the remaining shadowed
add_repository_to_graph definition #1619 missed.

* fix(ignore): exclude .NET obj/ from the default ignore patterns (#1585)

obj/ contains generated source (AssemblyInfo.cs, GlobalUsings.g.cs) that
added phantom File/Module/IMPORTS rows to the graph. The golden test already
masks obj/ via GENERATED_BUILD_DIRS, so the drift never failed the test —
it only rotted the recorded golden. With the indexer itself excluding obj/,
raw output matches the comparison scope and the C# golden regenerates with
zero logical drift (the CALLS 12→7 loss reported in #1585 no longer
reproduces on current main; it was fixed by intervening parser merges).

* fix(js/ts): extract named, default and namespace ES import bindings (#1526)

import_clause is an unnamed child of import_statement, so
child_by_field_name('import') always returned None and every ES import
collapsed into the bare-module fallback — the entire binding-extraction
block was dead code, and would have tested the wrong node types anyway.
The clause's children are now walked (a single clause can carry a default
and named bindings together), the namespace alias is read from the
identifier child, and both grammars are covered by binding-level tests.

Downstream effects, captured in the regenerated goldens: IMPORTS edges
carry the real binding in imported_name (was the module path), and 4
TypeScript call edges upgraded from HEURISTIC_CALLS to resolved CALLS
because named-import bindings now reach the imports map.

* test(env): fail loudly when tree-sitter-language-pack violates the pyproject pin (#1625)

A stale venv holding an out-of-pin grammar pack makes the parser suite pass
while disagreeing with CI (the #1600 misparse exists on 1.14.x but not
0.13.x, which nearly got a correct fix closed as a no-op). The divergence is
now a named test failure pointing at the venv, not the parser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC validation: counts toward scoring level:advanced GSSoC difficulty: 55 pts contributor / 30 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:exceptional GSSoC quality: x1.5 contributor / +10 mentor type:refactor GSSoC type bonus: refactor

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants