Skip to content

test(dead-code): cover find_dead_code end to end through the real parser→writer→query chain - #1598

Merged
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
rrodriguesNutrium:fix/dead-code-is-dependency
Aug 13, 2026
Merged

test(dead-code): cover find_dead_code end to end through the real parser→writer→query chain#1598
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
rrodriguesNutrium:fix/dead-code-is-dependency

Conversation

@rrodriguesNutrium

@rrodriguesNutrium rrodriguesNutrium commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Superseded in part by #1609 — rescoped to the test only.

You landed the same one-line fix in #1609 (identical row.setdefault("is_dependency", is_dependency)), so I have dropped the source change from this branch. It is now purely the complementary test.

#1609 added test_writer_is_dependency_propagation.py, which covers the writer. This covers the other end: the full chain, exercising the tool that was broken.

It parses real source with KotlinTreeSitterParser, writes via GraphWriter.add_file_to_graph, then calls CodeFinder.find_dead_code() and asserts a genuinely uncalled function is reported. Nothing in main currently exercises find_dead_code against a real graph.

It builds no file_data by hand, and that is the entire point. Hand-built fixtures naturally include is_dependency: False on each function dict, so every existing dead-code test passed while the shipped path returned [] for every project, in every language, on every backend. The bug was invisible precisely because no test drove the real path.

One detail worth flagging for whoever reviews it: the language choice is load-bearing. python.py's _find_functions hardcodes is_dependency per function, so a Python fixture would pass with or without the fix. Kotlin does not. If someone later 'simplifies' this to Python, the test silently stops guarding anything — hence the comment in the file.

Verified passing against main with #1609 applied. One file, +90, tests only.

Happy to close this instead if you would rather not carry a second test for the same bug — no argument from me either way.

@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.

@rrodriguesNutrium

Copy link
Copy Markdown
Contributor Author

CI is red on this PR, and I want to save a reviewer the investigation: the failures are pre-existing on main and not caused by this change.

The Build Test workflow is failing on main itself — run at 2026-08-13T17:58, before this branch existed. Same failures, same jobs.

Two distinct clusters, neither related to this diff:

1. tests/integration/cli/test_cli_commands.py — a CLI inventory mismatch over bundle inspect / bundle diff / bundle verify. The test's expected command set is out of step with the registered commands. Nothing to do with the writer.

2. tests/integration/test_parser_goldens.py (all languages) — these fail at

assert run_res.returncode == 0, f"Index/export failed for {project_name}..."

i.e. the index/export subprocess errors. That is an infrastructure failure, not a graph-content regression — the golden comparison never runs.

Worth being precise about, because this change does add a property (is_dependency) to contained nodes, so "all goldens failed" is exactly what a content regression would look like. It is not one. Locally, with this change applied, the goldens pass:

pytest "...test_language_golden[sample_project_go]" \
       "...test_language_golden[sample_project_java]" \
       "...test_language_golden[sample_project_c]" -q
3 passed in 75.73s

I ran the full 21-project golden suite green on a related branch too, so the baselines tolerate the added property.

One observation, offered as a suggestion rather than part of this PR: the golden test asserts returncode == 0 and bundle_path.exists(), but never that the exported bundle contains anything. When the index subprocess fails in a way that still exits 0 — FalkorDB Lite runs storage in a worker whose startup is timing-sensitive under CPU contention — the export writes an empty bundle and the diff then reports every node as missing. That failure mode cost me several hours: I concluded the golden suite was broadly broken, when in fact my machine was saturated by an unrelated index. On an idle machine all of them pass.

A guard between extraction and comparison — "indexing produced an empty graph, this is an indexing/database failure, not a parser regression" plus the subprocess stderr — would make that class of failure self-diagnosing. Happy to open it as a separate PR if useful.

The diff here remains 1 line of source plus a test; pytest tests/unit -q gives 12 failed, 1155 passed, all 12 verified pre-existing.

@Shashankss1205

Copy link
Copy Markdown
Collaborator

I know the CI is red, I have been merging some PRs and one of them broke this... Will have to check what's the issue before merging others.

CodeGraphContext#1609 fixed the is_dependency propagation and added a writer-level test.
This adds the complementary end-to-end case: parse real source with a
real parser, write via GraphWriter.add_file_to_graph, then call
CodeFinder.find_dead_code and assert a genuinely uncalled function is
reported.

It builds no file_data by hand, which is the point. Hand-built fixtures
naturally include is_dependency, so every existing test passed while the
shipped path returned nothing for every project.

The language choice is load-bearing: python.py's _find_functions
hardcodes is_dependency per function, so a Python fixture would pass with
or without the fix. Kotlin does not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rrodriguesNutrium
rrodriguesNutrium force-pushed the fix/dead-code-is-dependency branch from f4a39c6 to 0ef7112 Compare August 13, 2026 19:45
@rrodriguesNutrium rrodriguesNutrium changed the title fix(dead-code): propagate is_dependency to contained nodes so find_dead_code returns results test(dead-code): cover find_dead_code end to end through the real parser→writer→query chain Aug 13, 2026

@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. I verified this test actually has teeth rather than just passing: I swapped in the pre-#1609 writer.py (from 16828c78) and it fails; on current main it passes. So it genuinely closes the gap that let the is_dependency bug ship.

The reasoning in the docstring for using Kotlin rather than Python is the important part and worth preserving — python.py hardcodes "is_dependency": False on every function dict it builds, so a Python-based version of this test would pass even with the bug present and give false confidence. That's exactly the trap the rest of the suite fell into.

Also glad you drove the real tree-sitter parser rather than hand-building file_data. Every hand-built fixture in the suite mirrors what a correct parser would emit, which is precisely why none of them caught it.

@Shashankss1205
Shashankss1205 merged commit 38e0494 into CodeGraphContext:main Aug 13, 2026
17 of 18 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:intermediate GSSoC difficulty: 35 pts contributor / 20 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:testing GSSoC type bonus: testing labels Aug 15, 2026
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:intermediate GSSoC difficulty: 35 pts contributor / 20 mentor mentor:Shashankss1205 GSSoC mentor attribution: credits reviewing mentor quality:clean GSSoC quality: x1.2 contributor / +5 mentor type:testing GSSoC type bonus: testing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants