Skip to content

feat: blast-radius fitness component (#151)#417

Open
yxlyx wants to merge 1 commit intomainfrom
feat/151-blast-radius-fitness
Open

feat: blast-radius fitness component (#151)#417
yxlyx wants to merge 1 commit intomainfrom
feat/151-blast-radius-fitness

Conversation

@yxlyx
Copy link
Copy Markdown
Collaborator

@yxlyx yxlyx commented Apr 10, 2026

Summary

  • parseDiffFiles(): Extracts unique file paths from diff --git lines
  • parseDiffSymbols(): Extracts symbol names from hunk headers (@@) and changed lines (+/-)
  • computeBlastScore(): Pure computation: 1.0 - (unrelated_blast / total_blast_files), clamped [0,1]
  • blastRadiusScore(): Full pipeline: parse diff -> search refs via search.zig -> compute score
  • Also fixes const/var bug in search.zig searchRefs tests (const ArrayList can't call mutable deinit)

Score semantics:

  • 1.0 = no external references, or all blast files are in the touched set
  • 0.0 = all blast files are outside the touched set (maximum sprawl)
  • 0.5 = half of referencing files were not modified by the diff

Test plan

  • zig test src/evolver.zig — 51/51 tests pass (27 evolver + 24 search)
  • parseDiffFiles: extracts unique paths, deduplicates, handles empty
  • parseDiffSymbols: extracts from hunk headers and changed lines, handles empty
  • computeBlastScore: empty blast -> 1.0, all touched -> 1.0, none touched -> 0.0, partial -> 0.5
  • Single file with one unrelated reference -> 0.5

Closes #151

Made with Cursor

…related symbols (#151)

Adds blast-radius scoring to evolver.zig:
- parseDiffFiles: extract unique file paths from unified diff
- parseDiffSymbols: extract symbol names from hunk headers and changed lines
- computeBlastScore: pure score = 1.0 - (unrelated_blast / total_blast)
- blastRadiusScore: orchestrator that ties diff parsing + searchRefs together

Also fixes const/var issue in search.zig searchRefs tests (const ArrayList
can't call deinit which requires mutable self).

9 new tests covering diff parsing, score computation edge cases, and empty inputs.
All 51 tests pass (27 evolver + 24 search).

Made-with: Cursor
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.

evolver.zig: blast-radius fitness component — penalize organisms touching unrelated symbols

1 participant