EvoX
Co-evolves the search strategy with the solutions: the parent/context selection policy is itself LLM-written code, scored by windowed improvement and hot-swapped on stagnation.
"""EvoX Proposer component — SEARCH/REPLACE diff (full-rewrite fallback) + lineage stamping.
One file per component (see scaffold.py). The solution operator is the shared
:class:`~galapagos.components.proposer.DiffProposer` (upstream ``diff_based_generation: true``
with ``parse_full_rewrite`` fallback). The one EvoX-specific addition mirrors the upstream
``_run_iteration`` bookkeeping: every child is stamped with ``metadata["parent_info"] =
(label, parent_id)`` and ``metadata["context_ids"]`` from ``state.signals["evox"]`` (published by
the policy's ``select``) plus ``metadata["iteration"]`` — generated strategies READ these fields
(faithful-port checklist item 13), and the population's execution trace is built from them.
``Genome.child`` copies metadata wholesale, so the stamps are refreshed every generation.
"""
from __future__ import annotations
from ...components.proposer import DiffProposer, Env
from ...records import Genome
class EvoXProposer(DiffProposer):
"""Diff proposer that stamps the EvoX lineage fields the evolved strategies consume.
The EvoX SOLUTION loop runs the DEFAULT ``DiscoveryController._run_iteration`` (CoEvolutionController
overrides neither it nor ``_parse_llm_response``) in diff mode (``diff_based_generation: true`` —
the ``false`` in the meta search config governs only the strategy/meta loop). That diff path applies
diffs by WHOLE-LINE matching (``apply_diff``) and is STRICT: no block, or a non-matching block, is a
parse error → retried/discarded, never a full rewrite or an evaluated parent-duplicate. So whole-line
is on but the full-rewrite fallback is OFF — identical to topk/best_of_n."""
diff_wholeline = True
def propose(self, prompt, env: Env) -> Genome:
child = super().propose(prompt, env)
sig = (env.state.signals.get("evox", {}) if env.state is not None else {}) or {}
parent_id = sig.get("parent_id")
if parent_id is not None:
child.metadata["parent_info"] = (str(sig.get("label") or ""), parent_id)
child.metadata["context_ids"] = list(sig.get("context_ids") or [])
if env.state is not None:
child.metadata["iteration"] = env.state.iteration
return child