Skip to content

feat(evolve): add code search workbench spine - #8

Merged
pyros-projects merged 7 commits into
mainfrom
feat/001-wishful-evolve
Jun 3, 2026
Merged

feat(evolve): add code search workbench spine#8
pyros-projects merged 7 commits into
mainfrom
feat/001-wishful-evolve

Conversation

@pyros-projects

Copy link
Copy Markdown
Owner

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 both wishful and wishful.evolve, returning the best passing callable with __wishful_source__ and __wishful_evolution__ metadata.
  • Evolution history is fed back into mutation prompts so later variants can learn from prior scores, failures, and source snippets.
  • Correctness checks run before fitness scoring for both the baseline and generated variants, which keeps "start broken, search toward passing" from crashing on the original implementation.
  • Generated candidates go through the existing static safety validator before execution.
  • Context and evidence casefiles remain explicitly documented as follow-up work rather than silently implied as complete.

Verification

Check Result
uv run pytest --cov=wishful tests/ 154 passed, total coverage 78%
uv run pytest tests/test_evolve.py -q 42 passed
uv run ruff format src/wishful/evolve tests/test_evolve.py src/wishful/__init__.py examples/14_evolve.py 8 files left unchanged
uv run ruff check src/wishful/evolve tests/test_evolve.py src/wishful/__init__.py examples/14_evolve.py All checks passed!
uv run mypy src/wishful/evolve/ Success: no issues found in 5 source files
WISHFUL_FAKE_LLM=1 uv run python examples/14_evolve.py Improvement: +11.0%, Result: [0.0, 0.5, 1.0]
git diff --check no whitespace errors

Coverage still emits the known warnings for generated temporary .wishful cache files during tests.


Compound Engineering
GPT-5

pyros-projects and others added 5 commits November 25, 2025 15:45
…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>
@pyros-projects

pyros-projects commented Jun 3, 2026

Copy link
Copy Markdown
Owner Author

CI note: removed the Claude GitHub Action workflows from this PR branch (.github/workflows/claude-code-review.yml and .github/workflows/claude.yml). The remaining normal tests workflow passes. The previous claude-review failure was from the deleted workflow trying to use an uninstalled Claude Code GitHub App.

@pyros-projects
pyros-projects merged commit 1a17bcc into main Jun 3, 2026
1 check passed
@pyros-projects
pyros-projects deleted the feat/001-wishful-evolve branch June 3, 2026 05:11
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.

1 participant