Skip to content

fix(affected): unify affected-tests and dead-code queries between CLI and MCP - #575

Merged
ajianaz merged 1 commit into
developfrom
fix/affected-unify-cli-mcp
Oct 7, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/affected-unify-cli-mcp

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

New src/index/queries.rs is the single implementation of "affected tests for changed files" and "dead code with config-derived options". CLI (cora affected, cora dead-code) and MCP (cora.find_affected_tests, cora.dead_code) now only parse input and format output.

Why

Closes #568. The CLI derived the stem via rsplit('.') (returns the extension), so naming-convention matching never worked; it also lacked LIKE escaping, ran N queries, and used a different pattern list than MCP. MCP dead-code ignored entry_point_patterns.

How

  • file_stem via Path::file_stem, escape_like + ESCAPE '\', batched/chunked queries (500 binds), deduplicated sorted union.
  • Naming conventions: {stem}_test, test_{stem}, {stem}.test, {stem}.spec, tests/{stem}, __tests__/{stem} over rs go py ts tsx js jsx.
  • Caller strategy is now one batched call_graph query (no per-symbol 100-row cap).
  • MAX_AFFECTED_FILES (200) enforced via validate_changed_files at the MCP boundary only; the CLI (git diff input) is chunked instead.
  • MCP dead-code loads entry_point_patterns from project .cora.yaml only (existing load_project_config: no env/global/keys).

Testing

  • cargo test --features tree-sitter passes
  • cargo fmt --all -- --check passes
  • cargo clippy --all-targets --features tree-sitter -- -D warnings passes
  • cargo build --release --features tree-sitter passes
  • Manual smoke-test (covered by in-memory SQLite tests)

New in-memory SQLite tests: stem extraction, _/% literal matching, cap, both strategies, --filter markers, project scoping, chunking (1200 files), entry_point_patterns honored.

Related Issues

Closes #568

Checklist

  • Branch name follows convention
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR

🤖 Generated with Claude Code

… and MCP

Add src/index/queries.rs as the single implementation. Fixes the CLI stem
bug (extension used as stem), adds LIKE ESCAPE, batches queries, and makes
MCP dead-code honor analysis.entry_point_patterns from project config.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz merged commit 40cbb8f into develop Oct 7, 2026
14 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.

fix(affected): unify 'affected tests' and dead-code queries between CLI and MCP (CLI stem bug)

1 participant