Skip to content

fix: FTS5 injection, N+1 queries, and code quality audit#3

Merged
sdsrss merged 1 commit intomainfrom
fix/code-review-audit-fixes
Mar 17, 2026
Merged

fix: FTS5 injection, N+1 queries, and code quality audit#3
sdsrss merged 1 commit intomainfrom
fix/code-review-audit-fixes

Conversation

@sdsrss
Copy link
Owner

@sdsrss sdsrss commented Mar 17, 2026

Summary

  • [C1] Fix FTS5 query injection: Strip metacharacters (* ^ : + - ~ " ( ) { }) from search terms, keeping only alphanumeric and underscore characters to prevent FTS5 operator injection
  • [I5] Eliminate N+1 queries: Add get_nodes_with_files_by_name() batch query with JOIN, replacing per-node get_file_path() calls in disambiguate_symbol and tool_get_ast_node
  • [I4] Optimize incremental index: Replace O(N) filesystem exists() stat calls with DirectoryCache::file_exists() which uses already-collected mtime data
  • [I1] BufReader for read_source_context: Read files line-by-line instead of loading entire file into memory
  • [I2/I3] Document lock ordering and write-access model: Add safety documentation for Mutex ordering and SQLite WAL concurrent access
  • [S4] Extract compute_risk_level: Deduplicate risk assessment logic from 3 locations into domain::compute_risk_level()
  • [S5] Enhance is_test_symbol: Cover Go, Rust, TS, JS, JSX, TSX test file conventions
  • [S1] Replace glob import: Use explicit imports in pipeline.rs

Test plan

  • cargo check --no-default-features — clean
  • cargo test --no-default-features — 220 tests pass
  • cargo build --release — clean
  • CI pipeline passes

🤖 Generated with Claude Code

…lity improvements

Fix critical FTS5 query injection by stripping metacharacters from search
terms. Eliminate N+1 queries in disambiguate_symbol and get_ast_node with
new get_nodes_with_files_by_name batch query. Optimize incremental index
by replacing O(N) filesystem stat calls with DirectoryCache.file_exists().
Extract duplicated risk-level logic into domain::compute_risk_level,
improve read_source_context with BufReader, enhance is_test_symbol
heuristics, add lock ordering docs, and replace glob import in pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdsrss sdsrss merged commit 08efd11 into main Mar 17, 2026
1 check passed
@sdsrss sdsrss deleted the fix/code-review-audit-fixes branch March 17, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant