feat(cli): add stats command for indexed codebase - #53
Merged
Conversation
Reports the four things the issue asks for -- node counts by kind, edge counts by type, language distribution and file count -- plus --json for scripting. Edges are grouped by the `kind` property rather than by relationship type, because batch_upsert_edges writes everything as a generic :EDGE and carries the semantic type as a property. Grouping by type(r) would report a single 'EDGE' bucket. A test pins that so the query can't regress to type(r). The CurrentVersion bookkeeping node is excluded from node counts; it is the graph's version pointer, not code. Verified against a 103-file Spring Boot index: Files indexed: 103 Nodes (921 total): Field 414, Method 368, Class 100, Constructor 27, ... Edges (951 total): CONTAINS_FIELD 409, CONTAINS_METHOD 392, CALLS 150 Languages: java 921 (100%) Suite: 3 failed, 179 passed (baseline on main: 3 failed, 174 passed) -- same three pre-existing failures, fixed separately in #51.
Collaborator
Author
|
CI on this PR is red at the Ruff is unpinned and Because lint runs before #51 fixes that and is passing. Once it lands, this PR should go green on a re-run; I've verified all three CI steps locally in the meantime. |
Owner
|
Good pr |
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.
Closes #13
Adds
ast-rag stats, reporting the four things the issue asks for — node counts by kind, edge counts by type, language distribution, file count — plus--jsonfor scripting.That output is from a real 103-file Spring Boot codebase, not a fixture.
Two details worth flagging
Edges are grouped by the
kindproperty, not by relationship type.batch_upsert_edgeswrites every edge as a generic:EDGEand carries the semantic type as a property, sotype(r)would collapse everything into a singleEDGEbucket and the command would look broken. The query usescoalesce(r.kind, type(r))so it still degrades sensibly if typed relationships are ever introduced. There's a test pinning this specifically, so it can't quietly regress.CurrentVersionis excluded from node counts. It's the graph's bookkeeping pointer rather than a code node — including it made the total read 922 for a codebase with 921 nodes.Tests
5 new tests in
tests/test_stats_command.py, all against a mock driver so they need no live Neo4j: totals and shaping, the two query-shape guards above, the empty-index hint, and--jsonemitting parseable JSON.Verification
Baseline on
mainis3 failed, 174 passed— same three pre-existing failures (fixed separately in #51), plus the 5 new tests.Independent of #50, #51 and #52; branches from
main.