Skip to content

feat(review): deeper cross-file context via caller resolution + signature slicing#345

Merged
ajianaz merged 1 commit into
developfrom
feat/caller-context-resolution
Jul 16, 2026
Merged

feat(review): deeper cross-file context via caller resolution + signature slicing#345
ajianaz merged 1 commit into
developfrom
feat/caller-context-resolution

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Deepens PR review beyond the git diff — the context chain now resolves who calls the changed code (inbound / blast radius), not just what the changed code calls. This is the highest-value axis for flagging breaking signature/type changes, and it stays token-economical via bounded scanning + thin slices + a signature-only budget fallback.

Also fixes a real token-economy bug.

Bug fix (G2) — wrong ignore list

review.rs passed config.ignore.rules (finding-type strings like "security") to the context resolver instead of config.ignore.files (globs like target/**, node_modules/**). The resolver could inject code from build artifacts — wasting tokens and adding noise. Now uses ignore.files.

New: inbound caller (blast-radius) resolution

Piece What it does
extract_definitions_from_diff (extraction.rs) Detects functions/types declared in added lines (Rust/Python/JS-TS/Go/Java-Kotlin) via per-language regexes
resolve_callers (resolver.rs) For each changed definition, walks source files to find call/reference sites. Gitignore-aware (ignore crate) so build artifacts are never scanned. Bounded: ≤400 files scanned, ≤3 call-sites/symbol. Injects only the call line + 1 line of context
ContextPriority::CallerSite Lowest-priority tier so callers fill remaining budget after the more critical defs
ContextConfig.include_callers New flag, default true

New: signature-only budget fallback (Tier 3)

When the token budget can't fit a full function/type body, signature_only() injects just the signature (up to { or 4 lines) instead of skipping the entry entirely → ~3–5× more symbols under the same budget.

Tuning

  • max_context_tokens default 3000 → 5000 (more coverage; bounded by the above slicing).

Design note: follow_depth

follow_depth (recursive outbound resolution) remains at default 1. It was previously a no-op placeholder for depth > 1, and properly implementing it (cycle-safe + budget-bounded) is a separate, larger task. The new include_callers axis is what delivers the real "deeper review" value here.

Testing

  • 7 new tests: definition extraction (Rust/Python/Go + dedup), caller resolution (finds call-site / skips defining file / respects include_callers=false), signature_only (header-only, no body).
  • All 659 tests pass (637 unit + 16 CLI + 6 config).
  • Clippy clean, fmt clean, cargo audit clean.

…ture slicing

Review previously only resolved OUTBOUND dependencies (what changed code
calls/imports). This adds the INBOUND axis — who calls the changed code
(blast radius) — which is the highest-value context for flagging breaking
signature/type changes, while staying token-economical.

Bug fix (G2): review.rs passed `ignore.rules` (finding-type strings) to the
context resolver instead of `ignore.files` (globs like target/**,
node_modules/**). The resolver could inject build-artifact code, wasting
tokens and adding noise. Now uses ignore.files.

Changes
- G2: review.rs build_context_chain now receives &config.ignore.files.
- Config: new ContextConfig.include_callers (default true);
  max_context_tokens default 3000 -> 5000.
- extraction.rs: extract_definitions_from_diff() — detects functions/types
  DECLARED in added lines for Rust/Python/JS-TS/Go/Java-Kotlin (per-language
  regexes).
- resolver.rs: resolve_callers() walks source files (gitignore-aware via the
  `ignore` crate, so build artifacts are never scanned), bounded by
  MAX_CALLER_FILES_SCAN (400) and MAX_CALLERS_PER_SYMBOL (3). Caller slices
  are tiny (call line + 1 line of context, MAX_CALLER_LINES=4).
- resolver.rs: signature_only() budget fallback — when the full body won't
  fit the remaining budget, inject the signature (up to `{` / 4 lines)
  instead of skipping the entry entirely. New ContextPriority::CallerSite.

Design notes
- follow_depth (outbound recursion) remains at its default of 1; recursive
  outbound resolution was previously a no-op placeholder and properly
  implementing it (cycle-safe, budget-bounded) is a separate larger task.
  The new include_callers axis delivers the real "deeper review" value,
  token-economically.
- Caller resolution never self-reports (defining file excluded), respects
  include_tests, and skips ignored paths.

Tests: 7 new (definition extraction across languages + dedup, caller
resolution finds/skips, signature_only header-only). All 659 tests pass;
clippy + fmt + audit clean.
@ajianaz
ajianaz merged commit 840efd6 into develop Jul 16, 2026
10 checks passed
@ajianaz
ajianaz deleted the feat/caller-context-resolution branch July 16, 2026 04:32
@ajianaz ajianaz mentioned this pull request Jul 16, 2026
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