feat(evolve): add code search workbench spine - #8
Merged
Conversation
…cking Implements the foundation for wishful.evolve, an AlphaEvolve-style evolutionary code improvement feature. Key components: - EvolutionError: Rich exception with best_variant recovery - EvolutionHistory: Core tracking with get_context_for_llm() - VariantRecord/GenerationRecord: Data classes for evolution state The critical innovation is history-as-context: the LLM receives previous attempts sorted by fitness, enabling informed mutations. This is the AlphaEvolve paradigm from Google DeepMind. Tests: 17 unit tests covering all foundation classes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements the core mutation infrastructure for evolutionary code improvement: - mutate_with_llm(): Core function that calls LLM with evolution context - _build_evolution_context(): THE KEY ALPHAEVOLVE MECHANISM - formats history into rich LLM prompt with current best, sorted history, and user guidance - get_function_source(): Extracts source from functions (__wishful_source__ first) - _truncate_source(): Prevents context overflow for large functions The context builder gives the LLM: - Current best implementation - Evolution history sorted by fitness (best first) - Failed attempts with error messages - User guidance/mutation prompts 16 new tests (33 total), all passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Complete specification for @wishful.context decorator system: Problem: _build_evolution_context() shows fitness scores (90, 55, 25) but not the actual fitness function. The LLM has no idea what's being measured! Solution: @wishful.context(for_=target) lets developers declaratively attach context (fitness functions, constraints, examples) to wishful functions. Spec includes: - PRD: Problem statement, 5 features, acceptance criteria - SDD: Architecture decisions, data models, API surface, integration plan - Implementation Plan: 5-phase TDD approach Key design decisions (all confirmed): - Parameter name: for_= (most natural English) - Multiple targets: for_=[a, b, c] - Priority: order in list - Scope: global only (scoped for later) - Pattern: mirror @wishful.type exactly Ready to implement via /start:implement 002 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
CI note: removed the Claude GitHub Action workflows from this PR branch ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wishful now has the first runnable code-search spine: a function can be improved through repeated LLM mutations, deterministic correctness gates, fitness scoring, and preserved attempt history. This moves the project from one-shot helper generation toward bounded search over reusable Python artifacts.
The branch also captures the product direction around "function with lineage" so future work on context, evidence casefiles, CLI surfaces, and accept/rollback has a concrete center of gravity instead of scattered brainstorm docs.
Design Notes
wishful.evolve()is exported from bothwishfulandwishful.evolve, returning the best passing callable with__wishful_source__and__wishful_evolution__metadata.Verification
uv run pytest --cov=wishful tests/154 passed, total coverage78%uv run pytest tests/test_evolve.py -q42 passeduv run ruff format src/wishful/evolve tests/test_evolve.py src/wishful/__init__.py examples/14_evolve.py8 files left unchangeduv run ruff check src/wishful/evolve tests/test_evolve.py src/wishful/__init__.py examples/14_evolve.pyAll checks passed!uv run mypy src/wishful/evolve/Success: no issues found in 5 source filesWISHFUL_FAKE_LLM=1 uv run python examples/14_evolve.pyImprovement: +11.0%,Result: [0.0, 0.5, 1.0]git diff --checkCoverage still emits the known warnings for generated temporary
.wishfulcache files during tests.