Skip to content

feat: source enrichment, symbol navigation tools, stale pruning#141

Merged
github-actions[bot] merged 1 commit intomasterfrom
feature/138-139-140-knowledge-enhancements
Mar 6, 2026
Merged

feat: source enrichment, symbol navigation tools, stale pruning#141
github-actions[bot] merged 1 commit intomasterfrom
feature/138-139-140-knowledge-enhancements

Conversation

@jordanpartridge
Copy link
Copy Markdown
Contributor

@jordanpartridge jordanpartridge commented Mar 6, 2026

Summary

Changes

  • SearchCodeTool accepts SymbolIndexService and looks up source per result
  • SymbolIndexService gains getSymbolSourceByNameAndFile() + private findSymbolByNameAndFile()
  • CodeIndexerService gains pruneStaleSymbols(), fixes ScrollPoints parameter order
  • VectorizeCodeCommand and ReindexAllCommand call prune after vectorization
  • 13 new test cases across 5 test files (1194 total, all passing)

Test plan

  • PHPStan level 8 clean on all changed files
  • Laravel Pint formatted
  • 1194 tests passing (5 skipped, pre-existing)
  • SearchCodeTool source enrichment tested with mock
  • FileOutlineTool and SymbolLookupTool unit tested
  • pruneStaleSymbols unit tested (6 scenarios)
  • VectorizeCodeCommand and ReindexAllCommand feature tests updated

Closes #138, closes #139, closes #140

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added file outline feature to view symbol hierarchy within files.
    • Added symbol lookup tool to retrieve detailed symbol metadata.
    • Enhanced search results to include symbol source code and additional metadata.
  • Improvements

    • Automatic cleanup of stale symbols during code indexing and vectorization.
  • Tests

    • Added comprehensive test coverage for new features and enhancements.

…ools, stale symbol pruning (#138, #139, #140)

- SearchCodeTool now returns actual source code via SymbolIndexService lookup
- Add FileOutlineTool and SymbolLookupTool MCP tools for symbol navigation
- Add pruneStaleSymbols() to CodeIndexerService, wired into vectorize-code and reindex:all
- Add getSymbolSourceByNameAndFile() to SymbolIndexService
- Fix ScrollPoints parameter order in pruneStaleSymbols
- 1194 tests passing, PHPStan clean

Closes #138, closes #139, closes #140

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 6, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9d577db-d0de-4616-aeb2-c6c08960b016

📥 Commits

Reviewing files that changed from the base of the PR and between 6863551 and ac9621c.

📒 Files selected for processing (13)
  • app/Commands/ReindexAllCommand.php
  • app/Commands/VectorizeCodeCommand.php
  • app/Mcp/Servers/KnowledgeServer.php
  • app/Mcp/Tools/FileOutlineTool.php
  • app/Mcp/Tools/SearchCodeTool.php
  • app/Mcp/Tools/SymbolLookupTool.php
  • app/Services/CodeIndexerService.php
  • app/Services/SymbolIndexService.php
  • tests/Feature/Commands/VectorizeCodeCommandTest.php
  • tests/Unit/Mcp/Tools/FileOutlineToolTest.php
  • tests/Unit/Mcp/Tools/SearchCodeToolTest.php
  • tests/Unit/Mcp/Tools/SymbolLookupToolTest.php
  • tests/Unit/Services/CodeIndexerServiceTest.php

📝 Walkthrough

Walkthrough

This PR introduces three interconnected features: a symbol pruning mechanism that removes stale Qdrant vectors after re-indexing, two new MCP tools (FileOutlineTool and SymbolLookupTool) for structural code navigation, and source code retrieval in search results. It includes supporting service methods, command integrations, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Symbol Pruning Pipeline
app/Commands/ReindexAllCommand.php, app/Commands/VectorizeCodeCommand.php, app/Services/CodeIndexerService.php
Added pruneStaleSymbols() method to detect and delete stale Qdrant points after vectorization. Commands now call pruning with logging after each successful index update. Handles batch deletion via ScrollPoints and DeletePoints interactions.
New MCP Tools
app/Mcp/Tools/FileOutlineTool.php, app/Mcp/Tools/SymbolLookupTool.php, app/Mcp/Servers/KnowledgeServer.php
Created FileOutlineTool for file-level symbol hierarchy retrieval and SymbolLookupTool for symbol metadata lookup by ID. Both registered in KnowledgeServer with corresponding imports. Tools include schema validation, error handling, and optional source inclusion.
Search Tool Enhancement
app/Mcp/Tools/SearchCodeTool.php, app/Services/SymbolIndexService.php
Extended SearchCodeTool with SymbolIndexService dependency to fetch and include symbol source code in results. Added getSymbolSourceByNameAndFile() public method and findSymbolByNameAndFile() helper for byte-offset reads from content files.
Tool Testing
tests/Unit/Mcp/Tools/FileOutlineToolTest.php, tests/Unit/Mcp/Tools/SymbolLookupToolTest.php, tests/Unit/Mcp/Tools/SearchCodeToolTest.php
Added comprehensive unit tests covering error handling, empty results, nested structures, default repository behavior, and source retrieval. Tests mock SymbolIndexService and verify JSON response structures.
Service & Command Testing
tests/Unit/Services/CodeIndexerServiceTest.php, tests/Feature/Commands/VectorizeCodeCommandTest.php
Added pruneStaleSymbols test suite covering file handling, invalid JSON, batch deletion, scroll failures, and edge cases. Updated vectorize command tests to expect pruning calls in all three scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VectorizeCmd as Vectorize Command
    participant Indexer as CodeIndexerService
    participant Qdrant as Qdrant
    participant FileSystem as File System

    User->>VectorizeCmd: execute vectorize-code
    VectorizeCmd->>Indexer: vectorizeCode()
    Indexer->>FileSystem: scan/index symbols
    Indexer->>Qdrant: upsert vectors
    Indexer-->>VectorizeCmd: vectorization complete
    
    VectorizeCmd->>Indexer: pruneStaleSymbols(indexPath, repo)
    Indexer->>FileSystem: read index file
    Indexer->>Indexer: aggregate valid symbol IDs
    Indexer->>Qdrant: scroll points for repo
    Qdrant-->>Indexer: points with payloads
    Indexer->>Indexer: identify stale points
    Indexer->>Qdrant: delete stale points (batch)
    Qdrant-->>Indexer: deletion confirmed
    Indexer-->>VectorizeCmd: {deleted: count, total_checked: count}
    VectorizeCmd->>User: log pruning result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 Hop along the symbol paths,
No stale vectors left to waste,
Tools now outline files with grace,
Source code shines in search results bright,
Knowledge flows through cleaner gates!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/138-139-140-knowledge-enhancements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

📊 Coverage Report

Metric Coverage Threshold Status
Lines 95.5% 95%

Files Below Threshold

File Coverage Uncovered Lines
app/Enums/ObservationType.php 0% None
app/Exceptions/Qdrant/QdrantException.php 0% None
app/Integrations/Qdrant/Requests/ScrollPoints.php 0% None
app/Mcp/Servers/KnowledgeServer.php 0% None
app/Services/AgentHealthService.php 0% None
app/Commands/DaemonInstallCommand.php 23.1% 57, 58, 61, 66, 67... (+55 more)
app/Mcp/Tools/FileOutlineTool.php 63.2% 47, 48, 49, 50, 51... (+2 more)
app/Commands/ReindexAllCommand.php 63.8% 31, 32, 91, 92, 94... (+16 more)
app/Mcp/Tools/RememberTool.php 66.7% 106, 107, 108, 109, 110... (+19 more)
app/Mcp/Tools/CorrectTool.php 70.4% 53, 54, 55, 56, 57... (+3 more)

🏆 Synapse Sentinel Gate

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

🏆 Sentinel Certified

Tests & Coverage: 0 tests passed
Security Audit: No security vulnerabilities found
Pest Syntax: All test files use describe/it syntax


Add this badge to your README:

[![Sentinel Certified](https://img.shields.io/github/actions/workflow/status/conduit-ui/knowledge/gate.yml?label=Sentinel%20Certified&style=flat-square)](https://github.com/conduit-ui/knowledge/actions/workflows/gate.yml)

@github-actions github-actions bot merged commit e285f48 into master Mar 6, 2026
1 of 2 checks passed
@github-actions github-actions bot deleted the feature/138-139-140-knowledge-enhancements branch March 6, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant