updated 2026-11-26·5 min read
Evaluation Metrics Specification
Definitions for Function Acc@K, File Acc@K, Context Coverage@4k, HSI@10, Bamber discrimination bounds, and GoldPatchParser interval resolution.
Every score reported in Perron comes out of perron.metrics and gets pinned down by tests/test_evaluation_invariants.py. Keeping the metric code strict sounds pedantic until a subtle tie-break shifts your numbers behind your back: during the SWE-bench Verified audit, standalone BM25 printed 175 / 344 (50.87%) in one table and 176 / 344 (51.16%) in another on the exact same split.
The culprit turned out to be astropy__astropy-14182, where overloaded methods tied right at rank 10. Canonical AST sorting (file_path::qualified_name) pushed the gold target to rank 11, whereas raw token ordering kept it at rank 10. Ever since catching that, every runner uses deterministic kind="stable" sorting preserving symbol declaration order so paired McNemar tests don’t drift.
What the Four Metrics Track
- Function Acc@K ():
1.0if at least one gold modified function appears inside the top- retrieved symbols,0.0otherwise. - File Acc@K (): Same check at the file level after normalizing Windows/POSIX separators (
\vs/) and comparing exact paths or relative suffixes. - Coverage@4k: Packs ranked AST breadcrumbs one by one until adding the next symbol would cross tokens, then reports the fraction of gold functions that actually fit inside that budget.
- HSI@10 (Hub Suppression Index): Measures how much of the top-10 list is not clogged by the repository’s top-25 highest in-degree hubs ( means zero hub congestion; means all 10 slots went to utility hubs).
Formal Set Definitions
Given ranked symbols , gold modified functions , ranked files , gold files , and the top-25 global in-degree hubs :
Why Larger Candidate Pools Hurt Small Rerankers
Expanding the graph from 10 seeds to 50 candidates adds recall, yet downstream Top-5 accuracy barely budges. Bamber’s theorem explains why in one line: keeping an expected rank out of candidates forces the scorer’s ROC-AUC to stay above:
At mean pool size and target , the break-even bar is . On non-seed graph neighbors (where surface keyword overlap is low), Gemma 4 E2B’s discrimination drops from 0.7966 to 0.6596, pushing the expected rank out to ~9.00 (17.68 at ) instead of inside the top 5.


Extracting Gold Targets from Unified Diffs
Ground-truth modified symbols come from human patches parsed by benchmarks.gold_patch_parser.GoldPatchParser:
- Unified Diff Hunk Parsing
Extract (file_path, old_start_line, old_line_count) tuples and form pre-image line intervals [old_start_line, old_start_line + max(0, old_line_count - 1)].
- AST Interval Intersection
Intersect each hunk interval against every symbol span [L_start(s), L_end(s)] registered under file_path in the repository AST symbol table.
- Innermost Symbol Resolution
Prefer function and method nodes over class or module containers by picking the narrowest span (L_end - L_start); pure additions resolve to the enclosing scope.
Edge-Case Handling
| Edge Case | Metric Behavior | Rationale |
|---|---|---|
| Empty Gold () | , , | No defect exists to localize. |
| Duplicate IDs in Retrieved | Evaluated on slice; deduplicated for set hits | Preserves exact rank position without double-counting hits. |
| Evaluates all available candidates | Handles compact modules without index errors. | |
| Gold Absent from Catalog | , | Treated safely as an unretrieved miss rather than raising. |
| Zero Token Budget () | Zero context can be delivered within budget. |
For how these metrics partition hub and non-hub defects, see Hub-Gold & SWE-bench Benchmarks.