Skip to content

feat: expand node types with parameter, property, constant kinds#270

Merged
carlos-alm merged 5 commits intomainfrom
feat/expanded-node-types-impl
Mar 3, 2026
Merged

feat: expand node types with parameter, property, constant kinds#270
carlos-alm merged 5 commits intomainfrom
feat/expanded-node-types-impl

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Adds 3 new sub-declaration node kinds (parameter, property, constant) to all 9 WASM language extractors, linked to parent symbols via a new parent_id column
  • Enables structural queries like "which functions take a Request param?" or "which classes have a userId field?" without reading source code
  • New CLI children command and MCP symbol_children tool for querying sub-declaration nodes

Changes

Schema & Builder

  • Migration v11: nullable parent_id INTEGER REFERENCES nodes(id) + indexes
  • insertNode links children to parent after inserting the parent definition

Extractors (all 9 languages)

  • JS/TS/TSX: function/method parameters, class field properties, const constants, TS enum members
  • Python: function parameters (incl. defaults, *args, **kwargs), class/__init__ properties, UPPER_CASE constants
  • Go: function/method parameters, struct fields, const declarations
  • Rust: function parameters, struct fields, const items, enum variants
  • Java: method/constructor parameters, class fields, enum constants
  • C#: method/constructor parameters, class/struct fields (+ property_declaration kind fix), enum members
  • Ruby: method parameters, instance variable properties, class/module constants
  • PHP: function/method parameters, class properties, class const declarations, enum cases
  • HCL: variable/output block attributes as property children

Constants & API

  • CORE_SYMBOL_KINDS (10 original), EXTENDED_SYMBOL_KINDS (3 new), EVERY_SYMBOL_KIND (13 total)
  • ALL_SYMBOL_KINDS preserved as alias for backward compat
  • kindIcon() gains cases: parameterp, property., constantC

Queries

  • New childrenData() / children() functions
  • contextData() includes children in output when present
  • CLI --kind validation uses EVERY_SYMBOL_KIND across all 11 commands

MCP

  • New symbol_children tool
  • All 6 kind enums updated to EVERY_SYMBOL_KIND

Native Engine (deferred)

  • Rust Definition struct gains children: Option<Vec<Definition>> field
  • Actual extraction logic deferred to Phase 2 — WASM fallback handles new kinds

Test plan

  • New tests/parsers/extended-kinds.test.js — 27 tests across 8 languages verifying parameter, property, constant extraction
  • Updated tests/unit/mcp.test.jssymbol_children in tool list, childrenData mock in all dispatch tests
  • Updated tests/parsers/csharp.test.js — property_declaration kind methodproperty
  • Updated tests/integration/build-parity.test.js — filters extended kinds from native/WASM comparison
  • npm test — 1178 tests pass, 0 failures
  • npm run lint — 0 errors (1 pre-existing warning)
  • codegraph build . --engine wasm → 2547 nodes (up from 1006), 1107 parameters, 93 properties, 11 constants
  • codegraph children buildGraph → shows rootDir and opts parameters
  • codegraph context initSchema → shows "Children (1)" section with db parameter

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR adds 3 new sub-declaration node kinds (parameter, property, constant) to enable structural queries without reading source code. Schema migration v11 adds a parent_id column to the nodes table with proper indexes. All 9 WASM language extractors (JS/TS/TSX, Python, Go, Rust, Java, C#, Ruby, PHP, HCL) now extract function/method parameters, class/struct field properties, and constant declarations as child nodes linked to their parent symbols.

Key changes:

  • New children CLI command and symbol_children MCP tool for querying sub-declarations
  • CORE_SYMBOL_KINDS (10 original) + EXTENDED_SYMBOL_KINDS (3 new) = EVERY_SYMBOL_KIND (13 total)
  • ALL_SYMBOL_KINDS preserved as alias for backward compatibility
  • normalizeSymbol() helper standardizes 7-field symbol shape across all query functions
  • contextData() includes children when present
  • Bug fix: C# property_declaration kind changed from method to property
  • Native engine defers child extraction to Phase 2; build-parity test filters extended kinds
  • 27 new tests in extended-kinds.test.js + 7 stable schema conformance tests

Impact:
Enables queries like "which functions take a Request param?" or "which classes have a userId field?" without source code access. The implementation is systematic, well-tested, and maintains backward compatibility. All 1178 tests pass.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All 1178 tests pass including 27 new extended-kinds tests. Schema migration properly handles parent_id with indexes and foreign key constraints. Implementation is systematic across all 9 extractors with consistent patterns. Backward compatibility maintained via ALL_SYMBOL_KINDS alias. Native/WASM parity properly handled by filtering extended kinds in tests.
  • No files require special attention

Important Files Changed

Filename Overview
src/db.js Migration v11 adds parent_id column with proper foreign key constraint and indexes for efficient child queries
src/builder.js Inserts child nodes (parameters, properties, constants) after parent insertion, properly linking via parent_id
src/queries.js Adds EXTENDED_SYMBOL_KINDS, childrenData(), normalizeSymbol() helper; backward compatible with ALL_SYMBOL_KINDS alias
src/extractors/javascript.js Extracts function/method parameters, class properties, const constants, and TS enum members as children
src/extractors/python.js Extracts function parameters (incl. *args, **kwargs), init self.x properties, and UPPER_CASE module constants
src/extractors/go.js Extracts function/method parameters, struct fields as properties, and const declarations
src/extractors/rust.js Extracts function parameters (incl. self), struct fields, const items, and enum variants as constant children
src/cli.js Adds new children command; updates all --kind validation to use EVERY_SYMBOL_KIND (13 kinds vs 10)
src/mcp.js Adds symbol_children tool; updates all kind enums to EVERY_SYMBOL_KIND for extended kinds support
tests/parsers/extended-kinds.test.js Comprehensive test suite with 27 tests covering parameter, property, constant extraction across 8 languages

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Source Code] --> B[Tree-sitter Parse]
    B --> C[Extractor Functions]
    C --> D{Extract Definitions}
    D --> E[Parent Nodes<br/>function, class, etc.]
    D --> F[Child Nodes<br/>parameter, property, constant]
    E --> G[insertNode with parent_id=null]
    F --> H[insertNode with parent_id=parent.id]
    G --> I[(SQLite nodes table)]
    H --> I
    I --> J[Query Layer]
    J --> K[childrenData/children]
    J --> L[contextData includes children]
    K --> M[CLI: codegraph children]
    L --> N[CLI: codegraph context]
    K --> O[MCP: symbol_children tool]
Loading

Last reviewed commit: 6d07a0e

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

34 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@claude
Copy link

claude bot commented Mar 3, 2026

Claude finished @carlos-alm's task —— View job


PR Review Complete

Reviewing PR #270: "feat: expand node types with parameter, property, constant kinds"

Todo List

  • Phase 1: Root Cause Analysis - understand problem and approach
  • Phase 2: Configuration Change Detection - check for risky config changes
  • Phase 3: Test Integrity - verify test quality and coverage
  • Phase 4: Code Quality Review - examine implementation details
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: Enables structural queries like "which functions take a Request param?" or "which classes have a userId field?" without reading source code. This adds significant value for AI-assisted code navigation and understanding by providing fine-grained sub-declaration metadata.

Why This Approach: Uses a logical parent-child relationship via new parent_id column in SQLite with proper foreign key constraints and indexing. Extracts parameters, properties, and constants as child nodes linked to their parent symbols systematically across all 9 language extractors.

Risk Assessment: Low risk. The schema migration (v11) is properly designed, and the implementation maintains backward compatibility while adding substantial new functionality.

Configuration Change Detection ✅

No High-Risk Changes Found: No modifications to biome.json, vitest.config.js, or other configuration files that could hide underlying issues or relax quality gates.

Test Integrity ✅

Comprehensive Test Coverage:

  • 27 new tests in extended-kinds.test.js covering parameter, property, constant extraction across 8 languages
  • Build parity test appropriately filters extended kinds since native engine defers child extraction to Phase 2
  • All test changes are additions or corrections, not relaxations

Bug Fix Identified: C# property_declaration kind corrected from method to property (line 81 of csharp.test.js)

Code Quality Assessment ✅

Schema Design:

  • Migration v11 properly adds parent_id INTEGER REFERENCES nodes(id) with appropriate indexes
  • Foreign key constraint ensures referential integrity
  • Query performance optimized with idx_nodes_parent and idx_nodes_kind_parent indexes

Security:

  • All SQL queries use parameterized statements (no injection risk)
  • New queries in src/queries.js:2408 and builder.js:546 follow established patterns

Backward Compatibility:

  • ALL_SYMBOL_KINDS preserved as alias for original 10 core kinds
  • EVERY_SYMBOL_KIND new constant for all 13 kinds (core + extended)
  • MCP tools properly updated to use expanded kind enums

Implementation Quality:

  • normalizeSymbol() helper provides consistent 7-field symbol shape
  • childrenData() includes proper error handling (try/catch around parent_id queries)
  • Child extraction logic is systematic across all extractors with consistent patterns
  • Native engine correctly defers child extraction to Phase 2

Performance Considerations:

  • Incremental builds preserved - only WASM extractors populate children
  • New queries are indexed and use simple parent_id lookups
  • Pagination support maintained for large result sets

Minor Observations

  • Code follows established patterns and conventions throughout
  • Error handling is appropriate with graceful degradation
  • No obvious edge cases or resource leaks identified

Final Assessment

Root Cause Analysis

Problem Being Solved: Enables fine-grained structural queries without source code access - a valuable capability for AI coding assistants and code analysis tools.
Why This Approach: Systematic parent-child relationship design with proper database constraints and backward compatibility.
Risk Assessment: Very low risk - well-designed schema migration with comprehensive test coverage.

Critical Concerns

None identified. This is a well-implemented feature addition with appropriate safeguards.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Excellent implementation quality, comprehensive test coverage, proper schema design, and backward compatibility. The feature adds significant value with minimal risk. Only missing the 5th star due to the scope being Phase 1 of a larger feature (native engine support deferred).

@claude
Copy link

claude bot commented Mar 3, 2026

Claude finished @carlos-alm's task —— View job


Claude finished @carlos-alm's task —— View job


PR Review Complete

Reviewing PR #270: "feat: expand node types with parameter, property, constant kinds"

Todo List

  • Phase 1: Root Cause Analysis - understand problem and approach
  • Phase 2: Configuration Change Detection - check for risky config changes
  • Phase 3: Test Integrity - verify test quality and coverage
  • Phase 4: Code Quality Review - examine implementation details
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: Enables structural queries like "which functions take a Request param?" or "which classes have a userId field?" without reading source code. This adds significant value for AI-assisted code navigation and understanding by providing fine-grained sub-declaration metadata.

Why This Approach: Uses a logical parent-child relationship via new parent_id column in SQLite with proper foreign key constraints and indexing. Extracts parameters, properties, and constants as child nodes linked to their parent symbols systematically across all 9 language extractors.

Risk Assessment: Low risk. The schema migration (v11) is properly designed, and the implementation maintains backward compatibility while adding substantial new functionality.

Configuration Change Detection ✅

No High-Risk Changes Found: No modifications to biome.json, vitest.config.js, or other configuration files that could hide underlying issues or relax quality gates.

Test Integrity ✅

Comprehensive Test Coverage:

  • 27 new tests in extended-kinds.test.js covering parameter, property, constant extraction across 8 languages
  • Build parity test appropriately filters extended kinds since native engine defers child extraction to Phase 2
  • All test changes are additions or corrections, not relaxations

Bug Fix Identified: C# property_declaration kind corrected from method to property (line 81 of csharp.test.js)

Code Quality Assessment ✅

Schema Design:

  • Migration v11 properly adds parent_id INTEGER REFERENCES nodes(id) with appropriate indexes
  • Foreign key constraint ensures referential integrity
  • Query performance optimized with idx_nodes_parent and idx_nodes_kind_parent indexes

Security:

  • All SQL queries use parameterized statements (no injection risk)
  • New queries in src/queries.js:2408 and builder.js:546 follow established patterns

Backward Compatibility:

  • ALL_SYMBOL_KINDS preserved as alias for original 10 core kinds
  • EVERY_SYMBOL_KIND new constant for all 13 kinds (core + extended)
  • MCP tools properly updated to use expanded kind enums

Implementation Quality:

  • normalizeSymbol() helper provides consistent 7-field symbol shape
  • childrenData() includes proper error handling (try/catch around parent_id queries)
  • Child extraction logic is systematic across all extractors with consistent patterns
  • Native engine correctly defers child extraction to Phase 2

Performance Considerations:

  • Incremental builds preserved - only WASM extractors populate children
  • New queries are indexed and use simple parent_id lookups
  • Pagination support maintained for large result sets

Minor Observations

  • Code follows established patterns and conventions throughout
  • Error handling is appropriate with graceful degradation
  • No obvious edge cases or resource leaks identified

Final Assessment

Root Cause Analysis

Problem Being Solved: Enables fine-grained structural queries without source code access - a valuable capability for AI coding assistants and code analysis tools.
Why This Approach: Systematic parent-child relationship design with proper database constraints and backward compatibility.
Risk Assessment: Very low risk - well-designed schema migration with comprehensive test coverage.

Critical Concerns

None identified. This is a well-implemented feature addition with appropriate safeguards.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Excellent implementation quality, comprehensive test coverage, proper schema design, and backward compatibility. The feature adds significant value with minimal risk. Only missing the 5th star due to the scope being Phase 1 of a larger feature (native engine support deferred).

…se 1)

Add sub-declaration node extraction to all 9 WASM language extractors,
enabling structural queries like "which functions take a Request param?"
or "which classes have a userId field?" without reading source code.

Schema: migration v11 adds nullable parent_id column with indexes.
Builder: insertNode links children to parent via parent_id FK.
Extractors: JS/TS, Python, Go, Rust, Java, C#, Ruby, PHP, HCL now
emit children arrays for parameters, properties, and constants.
Queries: new childrenData() function, children in contextData output.
CLI: new `children` command, EVERY_SYMBOL_KIND validation on --kind.
MCP: new `symbol_children` tool, extended kind enum on all kind fields.
Constants: CORE_SYMBOL_KINDS (10), EXTENDED_SYMBOL_KINDS (3),
EVERY_SYMBOL_KIND (13). ALL_SYMBOL_KINDS preserved for backward compat.

Native Rust engine: Definition struct gains children field but actual
extraction is deferred to Phase 2 — WASM fallback handles new kinds.

Impact: 63 functions changed, 62 affected
…se 2)

Build file→definition and parent→child contains edges, parameter_of
inverse edges, and receiver edges for method-call dispatch. Add
CORE_EDGE_KINDS, STRUCTURAL_EDGE_KINDS, EVERY_EDGE_KIND constants.
Exclude structural edges from moduleMapData coupling counts. Scope
directory contains-edge cleanup to preserve symbol-level edges.

Impact: 3 functions changed, 22 affected
The Definition struct gained a children field but no extractor was
updated to include it, causing 50 compilation errors. Add children: None
to every Definition initializer across all 9 language extractors.
Also fix unused variable warnings in parser_registry.rs and parallel.rs.

Impact: 13 functions changed, 10 affected
@carlos-alm carlos-alm force-pushed the feat/expanded-node-types-impl branch from 218a0d6 to 4b0fd8a Compare March 3, 2026 03:24
@carlos-alm carlos-alm closed this Mar 3, 2026
@carlos-alm carlos-alm reopened this Mar 3, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2026
…portsData imports

Impact: 24 functions changed, 40 affected
@optave optave unlocked this conversation Mar 3, 2026
@claude
Copy link

claude bot commented Mar 3, 2026

Claude finished @carlos-alm's task —— View job


Claude finished @carlos-alm's task —— View job


PR Review Complete

Reviewing PR #270: "feat: expand node types with parameter, property, constant kinds"

Todo List

  • Phase 1: Root Cause Analysis - understand problem and approach
  • Phase 2: Configuration Change Detection - check for risky config changes
  • Phase 3: Test Integrity - verify test quality and coverage
  • Phase 4: Code Quality Review - examine implementation details
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: Enables structural queries like "which functions take a Request param?" or "which classes have a userId field?" without reading source code. This adds significant value for AI-assisted code navigation and understanding by providing fine-grained sub-declaration metadata.

Why This Approach: Uses a logical parent-child relationship via new parent_id column in SQLite with proper foreign key constraints and indexing. Extracts parameters, properties, and constants as child nodes linked to their parent symbols systematically across all 9 language extractors.

Risk Assessment: Low risk. The schema migration (v11) is properly designed, and the implementation maintains backward compatibility while adding substantial new functionality.

Configuration Change Detection ✅

No High-Risk Changes Found: No modifications to biome.json, vitest.config.js, or other configuration files that could hide underlying issues or relax quality gates.

Test Integrity ✅

Comprehensive Test Coverage:

  • 27 new tests in extended-kinds.test.js covering parameter, property, constant extraction across 8 languages
  • Build parity test appropriately filters extended kinds since native engine defers child extraction to Phase 2
  • All test changes are additions or corrections, not relaxations

Bug Fix Identified: C# property_declaration kind corrected from method to property (line 81 of csharp.test.js)

Code Quality Assessment ✅

Schema Design:

  • Migration v11 properly adds parent_id INTEGER REFERENCES nodes(id) with appropriate indexes
  • Foreign key constraint ensures referential integrity
  • Query performance optimized with idx_nodes_parent and idx_nodes_kind_parent indexes

Security:

  • All SQL queries use parameterized statements (no injection risk)
  • New queries in src/queries.js:2408 and builder.js:546 follow established patterns

Backward Compatibility:

  • ALL_SYMBOL_KINDS preserved as alias for original 10 core kinds
  • EVERY_SYMBOL_KIND new constant for all 13 kinds (core + extended)
  • MCP tools properly updated to use expanded kind enums

Implementation Quality:

  • normalizeSymbol() helper provides consistent 7-field symbol shape
  • childrenData() includes proper error handling (try/catch around parent_id queries)
  • Child extraction logic is systematic across all extractors with consistent patterns
  • Native engine correctly defers child extraction to Phase 2

Performance Considerations:

  • Incremental builds preserved - only WASM extractors populate children
  • New queries are indexed and use simple parent_id lookups
  • Pagination support maintained for large result sets

Minor Observations

  • Code follows established patterns and conventions throughout
  • Error handling is appropriate with graceful degradation
  • No obvious edge cases or resource leaks identified

Final Assessment

Root Cause Analysis

Problem Being Solved: Enables fine-grained structural queries without source code access - a valuable capability for AI coding assistants and code analysis tools.
Why This Approach: Systematic parent-child relationship design with proper database constraints and backward compatibility.
Risk Assessment: Very low risk - well-designed schema migration with comprehensive test coverage.

Critical Concerns

None identified. This is a well-implemented feature addition with appropriate safeguards.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Excellent implementation quality, comprehensive test coverage, proper schema design, and backward compatibility. The feature adds significant value with minimal risk. Only missing the 5th star due to the scope being Phase 1 of a larger feature (native engine support deferred).

@carlos-alm carlos-alm merged commit 2bc986f into main Mar 3, 2026
22 of 23 checks passed
@carlos-alm carlos-alm deleted the feat/expanded-node-types-impl branch March 3, 2026 04:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant