Skip to content

fix: context engine cleanup — N+1 queries, resolution consolidation#4

Merged
devwhodevs merged 1 commit intomainfrom
fix/context-cleanup
Mar 24, 2026
Merged

fix: context engine cleanup — N+1 queries, resolution consolidation#4
devwhodevs merged 1 commit intomainfrom
fix/context-cleanup

Conversation

@devwhodevs
Copy link
Copy Markdown
Owner

Summary

Retroactive code review fixes for the v0.4.0 context engine. Performance and maintainability improvements, no feature changes.

  • find_file_by_basename — SQL LIKE query replaces get_all_files() + in-memory scan for basename resolution. Used by resolve_file, context_who, context_project, and graph show CLI.
  • edge_counts_for_files — Single UNION ALL query replaces N+1 edge_count_for_file calls in context_list and context_project.
  • Consolidated resolutioncontext_who, context_project, and graph CLI all delegate to resolve_file/find_file_by_basename instead of duplicated logic.
  • total_chars fixProjectContext.total_chars now includes child notes and task text, not just the main note.
  • char_countbyte_count — Renamed for accuracy (content.len() returns bytes).

Test plan

  • 146 tests passing (2 new for store methods)
  • Clippy clean
  • Formatted

🤖 Generated with Claude Code

…tion

- Add find_file_by_basename store method (SQL instead of get_all_files)
- Add edge_counts_for_files batch method (single query instead of N+1)
- Consolidate file resolution: context_who, context_project, graph CLI
  all delegate to resolve_file/find_file_by_basename
- Fix ProjectContext.total_chars to include children and tasks
- Rename char_count to byte_count for accuracy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@devwhodevs devwhodevs merged commit 424469e into main Mar 24, 2026
3 checks passed
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