Skip to content

feat: CrossoverMutator — multi-parent synthesis via LLM (#154)#419

Open
yxlyx wants to merge 1 commit intomainfrom
feat/154-crossover-mutator
Open

feat: CrossoverMutator — multi-parent synthesis via LLM (#154)#419
yxlyx wants to merge 1 commit intomainfrom
feat/154-crossover-mutator

Conversation

@yxlyx
Copy link
Copy Markdown
Collaborator

@yxlyx yxlyx commented Apr 10, 2026

Summary

  • Organism struct with parent_ids: ?[]const u64 for multi-parent lineage tracking
  • FailureCase struct: test_name + snippet
  • buildCrossoverPrompt(): Constructs bounded prompt showing top-K parents with fitness scores, explanations (400 chars), diffs (2000 chars), and optional learning history
  • parseMutationResponse(): Extracts EXPLANATION + DIFF sections, strips ```diff fences
  • CrossoverMutator.crossover(): Caps at k parents, builds multi-parent child with lineage tracking; placeholder for LLM call

Test plan

  • zig test src/evolver.zig — 24/24 tests pass
  • buildCrossoverPrompt includes all 3 parents' names and explanations
  • buildCrossoverPrompt includes learning history when provided
  • parseMutationResponse: valid response with code fence
  • parseMutationResponse: returns null on garbage
  • CrossoverMutator.crossover: child has correct parent_ids, generation incremented
  • CrossoverMutator.crossover: caps at k=2 even when 3 parents provided

Closes #154

Made with Cursor

Adds CrossoverMutator and supporting types to evolver.zig:
- Organism struct: code-patch candidate with id, parent lineage
  (single parent_id + multi-parent parent_ids), generation, diff, fitness
- FailureCase struct: test_name + snippet
- buildCrossoverPrompt(): constructs bounded prompt showing top-K parents
  with their fitness, explanations, diffs, and optional history
- parseMutationResponse(): extracts EXPLANATION + DIFF from LLM output,
  strips code fences, returns null on malformed
- CrossoverMutator.crossover(): caps at k parents, tracks multi-parent
  lineage; placeholder for LLM call pending API integration

6 new tests covering prompt construction (all parents present, history
inclusion), response parsing (valid + garbage), crossover child creation
(parent IDs, generation), and k-capping behavior.
All 24 evolver tests pass.

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: CrossoverMutator — multi-parent synthesis via LLM

1 participant