Skip to content

fix: use CORE_SYMBOL_KINDS in flow matching#382

Merged
carlos-alm merged 7 commits intomainfrom
fix/flow-kind-regression
Mar 9, 2026
Merged

fix: use CORE_SYMBOL_KINDS in flow matching#382
carlos-alm merged 7 commits intomainfrom
fix/flow-kind-regression

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Flow's findMatchingNodes was limited to FUNCTION_KINDS, so codegraph flow couldn't trace from interfaces, types, or struct declarations
  • Pass CORE_SYMBOL_KINDS via opts.kinds override so all 10 core symbol kinds are searchable
  • Support opts.kinds array in findMatchingNodes as a general-purpose override alongside the existing opts.kind scalar

Split from #376.

Test plan

  • codegraph flow <interface-name> now finds and traces from interface declarations
  • codegraph flow <function-name> still works as before (FUNCTION_KINDS default unchanged)
  • Existing query/sequence commands unaffected (they don't pass opts.kinds)

flow's findMatchingNodes was limited to FUNCTION_KINDS, so `codegraph flow`
couldn't trace from interfaces, types, or struct declarations. Pass
CORE_SYMBOL_KINDS via opts.kinds override so all 10 core symbol kinds
are searchable. Also support opts.kinds array in findMatchingNodes as
a general-purpose override alongside the existing opts.kind scalar.

Impact: 2 functions changed, 21 affected
@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review Complete

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:101-102GOOD

const flowOpts = { ...opts, kinds: CORE_SYMBOL_KINDS };
let matchNode = findMatchingNodes(db, name, flowOpts)[0] ?? null;
  • Clean override pattern using spread operator
  • Clear variable naming (flowOpts)
  • Good comment explaining the rationale

src/flow.js:107GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds || FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.


@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 9, 2026

Greptile Summary

This PR fixes codegraph flow so it can trace from any core symbol kind (interfaces, types, structs, enums, etc.) rather than only from FUNCTION_KINDS (function, method, class). The change is minimal and well-scoped: flowData now builds a flowOpts object that overrides kinds with CORE_SYMBOL_KINDS before calling findMatchingNodes, and findMatchingNodes gains a new opts.kinds array parameter that slots into the existing priority chain (opts.kind scalar → opts.kinds array → FUNCTION_KINDS default).

  • src/flow.js: Imports CORE_SYMBOL_KINDS and constructs flowOpts = { ...opts, kinds: CORE_SYMBOL_KINDS }, applying it to both Phase 1 and Phase 2 (prefix-stripped) matching. Other opts fields (depth, noTests, file, kind) are correctly propagated via the spread.
  • src/queries.js: Extends the kinds resolution in findMatchingNodes to check opts.kinds?.length before falling back to FUNCTION_KINDS. The ?.length guard (addressing the previously raised empty-array edge case) is in place.
  • No other callers of findMatchingNodes pass opts.kinds, so the query and sequence commands are unaffected.

Confidence Score: 5/5

  • Safe to merge — changes are minimal, focused, and do not regress existing callers.
  • The diff is two lines of logic change plus a new import/spread. The priority chain in findMatchingNodes is correct, the empty-array guard is present, all existing callers that omit opts.kinds are unaffected, and both match phases in flowData consistently use the widened kind set.
  • No files require special attention.

Important Files Changed

Filename Overview
src/queries.js Adds opts.kinds array support to findMatchingNodes with correct priority ordering (opts.kindopts.kindsFUNCTION_KINDS) and includes the empty-array guard (opts.kinds?.length) to prevent invalid SQL.
src/flow.js Imports CORE_SYMBOL_KINDS and builds flowOpts by spreading opts with kinds: CORE_SYMBOL_KINDS, consistently passing it to both matching phases so flow can trace from all 10 core symbol kinds.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["flowData(name, opts)"] --> B["flowOpts = { ...opts, kinds: CORE_SYMBOL_KINDS }"]
    B --> C["Phase 1: findMatchingNodes(db, name, flowOpts)"]
    C --> D{matchNode found?}
    D -- No --> E["Phase 2: for each prefix in FRAMEWORK_ENTRY_PREFIXES\nfindMatchingNodes(db, prefix+name, flowOpts)"]
    E --> F{matchNode found?}
    F -- No --> G["Return empty result"]
    D -- Yes --> H["BFS forward through callees"]
    F -- Yes --> H

    subgraph findMatchingNodes["findMatchingNodes(db, name, opts)"]
        I{opts.kind set?} -- Yes --> J["kinds = [opts.kind]"]
        I -- No --> K{opts.kinds?.length?}
        K -- Yes --> L["kinds = opts.kinds\n(e.g. CORE_SYMBOL_KINDS)"]
        K -- No --> M["kinds = FUNCTION_KINDS\n(function, method, class)"]
    end

    C --> I
    E --> I
Loading

Last reviewed commit: 5e12131

src/queries.js Outdated
Comment on lines 167 to 168
const kinds = opts.kind ? [opts.kind] : opts.kinds || FUNCTION_KINDS;
const placeholders = kinds.map(() => '?').join(', ');
Copy link
Contributor

Choose a reason for hiding this comment

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

Empty opts.kinds array would produce invalid SQL

If a caller passes opts.kinds = [] (an empty array), [] is truthy in JavaScript, so the fallback to FUNCTION_KINDS is skipped. The resulting placeholders string will be empty, producing invalid SQL:

WHERE n.name LIKE ? AND n.kind IN ()

This will throw a SQLite syntax error at runtime. Consider adding a guard:

Suggested change
const kinds = opts.kind ? [opts.kind] : opts.kinds || FUNCTION_KINDS;
const placeholders = kinds.map(() => '?').join(', ');
const kinds = opts.kind ? [opts.kind] : (opts.kinds?.length ? opts.kinds : FUNCTION_KINDS);

This is safe for all current callers (which always pass CORE_SYMBOL_KINDS, a 10-element array), but protects the API surface if findMatchingNodes is called with an empty kinds override in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 06fb91b. Changed to opts.kinds?.length ? opts.kinds : FUNCTION_KINDS so an empty array now correctly falls back to FUNCTION_KINDS instead of producing an invalid WHERE n.kind IN () clause.

@carlos-alm
Copy link
Contributor Author

@greptileai

# Conflicts:
#	src/queries.js

Impact: 73 functions changed, 74 affected
@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review Complete

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:101-102GOOD

const flowOpts = { ...opts, kinds: CORE_SYMBOL_KINDS };
let matchNode = findMatchingNodes(db, name, flowOpts)[0] ?? null;
  • Clean override pattern using spread operator
  • Clear variable naming (flowOpts)
  • Good comment explaining the rationale

src/flow.js:107GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds?.length ? opts.kinds : FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.


@carlos-alm
Copy link
Contributor Author

@greptileai

@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review in Progress

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:105GOOD

const flowOpts = { ...opts, kinds: opts.kind ? [opts.kind] : CORE_SYMBOL_KINDS };
  • Clean override pattern using spread operator
  • Preserves existing opts.kind scalar behavior for backward compatibility
  • Clear comment explaining the rationale

src/flow.js:111GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds?.length ? opts.kinds : FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Includes the ?.length guard to handle empty arrays (addresses review feedback)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.


Resolve conflict in src/flow.js: combine CORE_SYMBOL_KINDS default
(from this PR) with opts.kind passthrough (from main/PR #378).

Impact: 42 functions changed, 65 affected
@carlos-alm carlos-alm force-pushed the fix/flow-kind-regression branch from d249d40 to 0ff85a3 Compare March 9, 2026 04:22
@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review Complete

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:105GOOD

const flowOpts = { ...opts, kinds: opts.kind ? [opts.kind] : CORE_SYMBOL_KINDS };
  • Clean override pattern using spread operator
  • Preserves existing opts.kind scalar behavior for backward compatibility
  • Clear comment explaining the rationale

src/flow.js:111GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds?.length ? opts.kinds : FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Includes the ?.length guard to handle empty arrays (addresses review feedback)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.


@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review in Progress

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:105GOOD

const flowOpts = { ...opts, kinds: opts.kind ? [opts.kind] : CORE_SYMBOL_KINDS };
  • Clean override pattern using spread operator
  • Preserves existing opts.kind scalar behavior for backward compatibility
  • Clear comment explaining the rationale

src/flow.js:111GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds?.length ? opts.kinds : FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Includes the ?.length guard to handle empty arrays (addresses review feedback)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.

@claude
Copy link

claude bot commented Mar 9, 2026

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


PR Review in Progress

Review Tasks:

  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity assessment
  • Phase 4: Code quality review
  • Read modified files for context
  • Analyze CORE_SYMBOL_KINDS vs FUNCTION_KINDS usage
  • Assess potential side effects
  • Provide final recommendation

Root Cause Analysis

Problem Being Solved: The codegraph flow command was limited to tracing from functions, methods, and classes only (FUNCTION_KINDS = ['function', 'method', 'class']). This prevented users from starting flow traces from interfaces, types, structs, enums, traits, records, or modules - which are valid entry points in many languages.

Why This Approach: The fix expands the search scope in flowData() from FUNCTION_KINDS (3 types) to CORE_SYMBOL_KINDS (10 types) by passing opts.kinds override to findMatchingNodes(). This is a targeted fix that:

  1. Preserves backward compatibility: Other query commands still use their existing defaults
  2. Uses existing infrastructure: Leverages the already-implemented opts.kinds parameter in findMatchingNodes()
  3. Addresses the root cause: Expands the symbol search scope rather than working around limitations

Risk Assessment: LOW RISK - This is a focused change that only affects the flow command's node matching behavior.

Configuration/Test Integrity Assessment

No configuration changes - No linting rules, build configs, or test thresholds modified
No test modifications - No test files changed or expectations lowered
Minimal scope - Only 2 files changed with +7/-5 lines total

Code Quality Review

Changes Analysis:

src/flow.js:105GOOD

const flowOpts = { ...opts, kinds: opts.kind ? [opts.kind] : CORE_SYMBOL_KINDS };
  • Clean override pattern using spread operator
  • Preserves existing opts.kind scalar behavior for backward compatibility
  • Clear comment explaining the rationale

src/flow.js:111GOOD

matchNode = findMatchingNodes(db, `${prefix}${name}`, flowOpts)[0] ?? null;
  • Consistent use of flowOpts in both matching phases

src/queries.js:167EXCELLENT

const kinds = opts.kind ? [opts.kind] : opts.kinds?.length ? opts.kinds : FUNCTION_KINDS;
  • Elegant precedence hierarchy: opts.kind (scalar) > opts.kinds (array) > FUNCTION_KINDS (default)
  • Includes the ?.length guard to handle empty arrays (addresses review feedback)
  • Maintains backward compatibility for all existing callers
  • No breaking changes to the API

Technical Correctness

Import properly added: CORE_SYMBOL_KINDS imported from ./queries.js
Constants are correct: CORE_SYMBOL_KINDS includes all 10 core symbol types
Logic flow preserved: Both direct and prefix-stripped matching phases updated consistently
No side effects: Other commands using findMatchingNodes() are unaffected

Potential Edge Cases Considered

CLI parameter conflicts: The --kind flag (scalar) still takes precedence over the internal opts.kinds (array) override
Performance impact: Minimal - same SQL query structure, just broader WHERE clause
Language compatibility: All 10 symbol types are extracted by existing parsers

Test Coverage Assessment

⚠️ Manual testing required: The PR includes a test plan but no automated tests added. However:

  • This is a bug fix restoring expected functionality
  • The existing findMatchingNodes() function is already well-tested
  • The change leverages existing, tested code paths

Recommendation: The manual test plan should be sufficient, but consider adding a regression test in the future.

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Flow tracing was artificially limited to 3 symbol kinds when 10 are supported
**Why This Approach**: Uses existing `opts.kinds` override infrastructure for clean, backward-compatible expansion  
**Risk Assessment**: LOW - Focused change with clear scope and no breaking changes

## Critical Concerns
None identified. This is a well-implemented bug fix.

## Final Recommendation
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: APPROVE
- Reasoning: Clean implementation that fixes a legitimate functional limitation. Code is well-structured, maintains backward compatibility, and follows existing patterns. Only missing automated regression tests to achieve 5 stars.

Excellent work on this fix! The implementation is clean, the approach is sound, and the change directly addresses the stated problem without introducing risk.


@carlos-alm carlos-alm merged commit a1be19d into main Mar 9, 2026
16 checks passed
@carlos-alm carlos-alm deleted the fix/flow-kind-regression branch March 9, 2026 04:36
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 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