Hypothesis evolution loop
Scientific agent skills for Claude Code and Codex that turn research goals into auditable hypothesis generation, review, ranking, evolution, and synthesis.
npx -y skills add panjose/Co-Scientist --skill hypothesis-evolution-loopAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Run the iterative evolution loop from the current persisted run state until convergence.
SKILL.md
19.1 KB, as published. Nobody here has run it
hypothesis-evolution-loop
Goal:
- Run the iterative evolution loop from the current persisted run state until convergence.
Inputs:
- current persisted run artifacts
- active
state/STRATEGY_PLAN.json - optional
resumeflag
Outputs:
- updated hypotheses
- updated island statistics
- updated proximity receipt/status artifacts, plus
state/PROXIMITY_GRAPH.jsonwhen the embedding bridge succeeds - updated tournament artifacts
- updated convergence counters
- updated
state/EVOLUTION_STATE.json - appended
state/EVOLUTION_ROUNDS.jsonl - updated
state/PIPELINE_STATE.json - updated
state/CURRENT_STAGE.json
Context Loading:
- Open
skills/shared-references/schema-index.md. - Read
packages/agent_contracts/pipeline_control.pybefore updatingstate/EVOLUTION_STATE.jsonorstate/COMPLETION_DECISION.json. - Read
packages/agent_contracts/pipeline_runtime.pybefore updatingstate/PIPELINE_STATE.jsonorstate/CURRENT_STAGE.json. - Read
packages/agent_contracts/hypothesis.pybefore writing any evolvedhypotheses/<id>/HYPOTHESIS.jsonartifact. - Read
packages/agent_contracts/state.pybefore any island state validation, and readpackages/run_artifacts/island_state.pybefore invoking the run-level island persistence helper. - Read
packages/agent_contracts/ranking.pywhen the round will write tournament artifacts through downstream ranking work. - Read
packages/agent_contracts/evolution_round.pybefore appendingstate/EVOLUTION_ROUNDS.jsonl. - Read the active
state/STRATEGY_PLAN.json,state/PIPELINE_STATE.json,state/CURRENT_STAGE.json,state/EVOLUTION_STATE.json, the selected parent hypotheses, and the latest parent review bundles before starting or resuming a round.
Execution Contract:
- Resume decisions must come from artifact state, not hidden process memory.
- The active evolution route must be consistent with
state/STRATEGY_PLAN.json. - Refresh
state/STRATEGY_PLAN.jsonthroughpython -m tools.policy.plan_strategy <run_dir>before every evolution round that is resuming from persisted state. - Use an explicit phase override only when the caller is intentionally forcing a new stage transition instead of restoring the current persisted round or substage.
- Use
from tools import sync_pipeline_stage_artifactsas the canonical paired write surface when enteringEvolution,Reflection,Insights from Reviews,Proximity, orRanking. - The stage-sync helper is implemented in
packages/run_artifacts/stage_sync.py. - Before resuming or starting an evolution round, call
tools.sync_pipeline_stage_artifacts(...)forEvolution. - Before dispatching review, insights, proximity, or ranking work for the active child, call
tools.sync_pipeline_stage_artifacts(...)for the exact substage being entered so dashboard state reflects the live round status. - Read
state/RESOLVED_RUN_CONFIG.jsonbefore deciding whether the loop is capped or completion-driven:convergence.max_iterations > 0means a user-visible capped run.convergence.max_iterations == 0means completion-driven mode; do not invent a small hard iteration cap.convergence.safety_max_iterationsis still a hard safety ceiling and must be recorded if reached.- Persist
EVOLUTION_STATE.safetyMaxIterationsexactly fromRESOLVED_RUN_CONFIG.convergence.safety_max_iterations; never rewrite it from the current iteration count.
- Treat
iteration_policy = completion_driventogether withhuman_checkpoint = autoas an autonomous loop contract: after one round closes, refresh routing and continue automatically instead of returning to the user for per-round confirmation. human_checkpointcan still intentionally pause the loop, but only at the configured checkpoint boundary (before_overview,before_completion, orevery_major_stage).- If the host-agent turn stops before a terminal route is reached, the handoff must state that convergence has not been reached, state is persisted, and the recommended next action is continue evolution through resume or an explicit continue request.
- One evolution round may create only one new child hypothesis. Do not batch-refine every seed candidate once and then stop.
- Do not synthesize placeholder hypotheses, reviews, tournaments, proximity receipts, embeddings, or evolution-round receipts to make progress.
- If an evolve, review, proximity, ranking, convergence, or round-receipt substage cannot run through its canonical skill or tool, stop and report a resumable blocked state instead of writing low-information artifacts.
- When
state/STRATEGY_PLAN.jsonreportsnext_action: continue_evolution, usesignals.selected_parent_idsas the parent set for the next child hypothesis and persist the resulting parent linkage inHYPOTHESIS.jsonandORIGIN.json. - Before generating that child, run
evolution-strategy-supervisorand choose exactly one concrete evolution strategy allowed by:signals.selection_strategyselected_evolution_strategies- the parent hypotheses and their latest review bundles
- For single-island rounds, use
from tools import update_run_single_island_rewardas the canonical run-level island reward / decay update and persistence surface after the child has finished review and ranking update receipt coverage. - For seed island initialization and multi-island child island creation, use
from tools import ensure_run_islands_for_hypothesesas the canonical run-level island initialization surface. - The run-level helper is implemented in
packages/run_artifacts/island_state.pyand delegates the deterministic reward mechanics topackages/agent_mechanics/island_reward_update.py. - Do not hand-edit
islands/ISLANDS.json, and never writestate/ISLANDS.json. The run-level helper must load hypotheses, apply decay/reward, and persist the canonicalislands/ISLANDS.jsonartifact. - After the run-level helper returns, reload canonical
islands/ISLANDS.jsonand confirm the selected island now has nonzerovisit_countand nonzerodecayed_visits; the selected islandvisit_countmust also cover the completed single-island round receipts that selected it. - If the selected island metrics do not validate after a single-island closeout, stop before the next routing refresh, run
python -m tools.validation.contract_validation <run_dir> --skill hypothesis-evolution-loop, and report a resumable blocked state instead of continuing on stale UCB state. - Newly created islands must remain unvisited until they are later selected by a completed single-island round: verify
decayed_reward = 0.0,decayed_visits = 0.0, andvisit_count = 0after calling the initialization helper. - Persist only canonical island fields. Do not add dashboard-derived or router-derived fields such as
hypothesis_ids,ucb_score, orstrategy_labeltoislands/ISLANDS.json. - The lower-level
tools.update_single_island_reward(...),tools.compute_single_island_reward(...), andtools.apply_decayed_island_update(...)surfaces are internal/testing fallbacks only for in-memory mechanics; do not use them as the host-agent evolution-loop persistence path. - Use
from tools import evaluate_convergenceas the canonical convergence-counter update surface after the child's final top-k membership is known. - The convergence helper is implemented in
packages/agent_mechanics/convergence_check.py. - Use
from tools import append_evolution_round_recordas the canonical append-only write surface forstate/EVOLUTION_ROUNDS.jsonlafter the child has completed review, proximity, ranking, and convergence updates. state/EVOLUTION_ROUNDS.jsonlis the completed round receipt. It does not replacestate/STRATEGY_DECISIONS.jsonl, and it must not be used to rewrite prior routing decisions.- The round receipt's
placement_match_idsandranked_match_idsmust be child-owned closeout refs for that round only:- placement refs require
match_strategy = placement_tournamentandhypothesis_1_id = child_hypothesis_id - ranked refs require
match_strategy = ranked_tournamentandhypothesis_1_id = child_hypothesis_id - duplicate match IDs are invalid
- later matches where the child appears as
hypothesis_2_idmay remain in the child's lifetimeHYPOTHESIS.jsonrefs, but they must not be copied into this earlier round receipt
- placement refs require
- After appending a completed round receipt, update
state/EVOLUTION_STATE.jsonfrom the same convergence helper output and refreshstate/STRATEGY_PLAN.json; do not leave pre-round router signals as the current plan. - The referenced
continue_evolutiondecision must be a canonical router record frompython -m tools.policy.plan_strategy <run_dir>with router-level signals. Do not add child IDs, chosen concrete strategies, proximity statuses, tournament IDs, top-k entry results, or convergence transitions tostate/STRATEGY_DECISIONS.jsonl. - Treat the referenced router signals as a replayable pre-round state contract:
signals.hypothesis_countandsignals.viable_hypothesis_countare the counts before the child is created.signals.convergence_countis the value before the child is created and must become the round receipt'sconvergence_count_before.signals.entered_top_k_last_roundmust reflect the prior completed round when one exists.signals.top_hypothesis_idsmust become the round receipt'sprevious_top_k_ids.signals.selected_parent_idsmust reference viable hypotheses already persisted before the child is created.signals.selected_island_idsmust match the selected parents' persistedisland_idvalues.
- A completed evolution round must be replayable from exactly one router decision, one evolved child, one review bundle, one proximity receipt, completed ranking artifacts with ranking update receipt coverage, one convergence update, and one appended round receipt.
- After emitting the child hypothesis, you must:
- run
hypothesis-review-pipeline - run
insights-from-reviewswhen the child is viable - run
hypothesis-proximity-updatefor each viable child hypothesis - run
hypothesis-ranking-pipeline - for
signals.selection_strategy == single_island, calltools.update_run_single_island_reward(run_dir, selected_island_id, candidate_hypothesis.id, decay_factor)exactly once after the child's final Elo and viability state are known, and use the helper-persisted canonicalislands/ISLANDS.jsonartifact as the source of truth - after that single-island reward update, verify the helper-persisted selected island has nonzero
visit_countanddecayed_visits; do not append a completed round receipt or refresh routing if the selected island metrics are stale - for
signals.selection_strategy == multi_island, assign the child a new non-emptyisland_id, calltools.ensure_run_islands_for_hypotheses(run_dir, [candidate_hypothesis.id]), verify the created island remains unvisited, and do not apply the single-island reward helper to that cross-island child - call
tools.evaluate_convergence(candidate_hypothesis.id, previous_top_k_ids, current_top_k_ids, current_convergence_count)exactly once after the final ranked frontier is known, then persist bothenteredTopKLastRoundandconvergenceCountexactly as returned - call
tools.append_evolution_round_record(run_dir, record)exactly once with anEvolutionRoundRecordContractthat records the decision index, selected parent IDs, selected island IDs, chosen concrete evolution strategy, child hypothesis ID, child island ID, proximity receipt status, child-owned placement/ranked tournament match IDs, previous/current top-k IDs,entered_top_k, and convergence counts before and after the round - update
state/EVOLUTION_STATE.json
- run
- When
next_action: return_to_generation, leave the evolution loop, run the requested generation pass, then refresh the evolution plan again. - Do not skip proximity because no embedding vector is already present. The bridge owns provider invocation and records a receipt/status when the provider is disabled, unavailable, invalid, or failed.
- Do not generate, infer, or fabricate embeddings in prompt output. Let ranking use its documented receipt-gated missing-graph fallback only after
hypothesis-proximity-updatehas recorded a skipped or failed receipt/status. - The evolution-round
proximity_receipt_statusmust be copied from the persisted per-childstate/proximity_receipts/<child_hypothesis_id>.jsonreceipt. Do not infer this field from environment variables, provider availability, or dashboard state. - The loop is complete only when
state/EVOLUTION_STATE.jsonrecords a terminal stop reason and the routing audit log contains one decision record per evolved hypothesis. - When writing
state/EVOLUTION_STATE.json, persist the activestopPolicy,iterationPolicy,iterationBand, andsafetyMaxIterationsmetadata from the effective run configuration and policy artifacts. - Only record
stopReason: safety_iteration_limit_reachedwheniterationCount >= RESOLVED_RUN_CONFIG.convergence.safety_max_iterationsandsafetyLimitHitistrue. - When consumed by a host agent, run
python -m tools.validation.contract_validation <run_dir> --skill hypothesis-evolution-loopafter each evolved hypothesis is persisted. - When the loop reports
status: completed, runpython -m tools.validation.verify_pipeline_completion <run_dir> --skill hypothesis-evolution-loop. - The final research overview remains a separate step in
research-overview-pipeline. - Treat
completeas a completion-verifier outcome after overview, not as astate/STRATEGY_PLAN.jsonroute.
Execution Steps:
- Open
skills/shared-references/schema-index.md, then read the exact Python contracts for the evolution, pipeline-state, hypothesis, island, and ranking artifacts that this round may write. - Load the persisted routing, pipeline-state, evolution-state, island, and parent-hypothesis artifacts for the active round or substage.
- Refresh
state/STRATEGY_PLAN.jsonthroughpython -m tools.policy.plan_strategy <run_dir>before every evolution round that is resuming from persisted state, or use an explicit phase override only when intentionally forcing a new stage transition. - If
next_actionisinspect_state, pause automatic execution and inspect or repair the persisted routing artifacts before continuing. - If
next_actionisrun_review,run_insights,run_proximity, orrun_ranking, first updatestate/PIPELINE_STATE.jsonandstate/CURRENT_STAGE.jsonto that exact substage, then resume it for the active round before attempting another child. - If
next_actionisreturn_to_generation, leave the evolution loop, run the requested generation pass, then refresh the evolution plan again. - If
next_actioniscontinue_evolution, first calltools.sync_pipeline_stage_artifacts(run_dir, current_phase="Evolution", current_skill="hypothesis-evolution-loop"), then runevolution-strategy-supervisor, create exactly one new child hypothesis fromsignals.selected_parent_ids, and persist its canonical hypothesis and origin linkage artifacts.- Confirm the active strategy decision includes router signals for hypothesis counts, viable counts, convergence state, top-k IDs, research-plan status, island selection, and selected parents.
- Keep child/result metadata out of
state/STRATEGY_DECISIONS.jsonl; it is recorded later throughtools.append_evolution_round_record(...).
- After the child is emitted, update the run-level stage artifacts before each downstream child substage:
Reflection/hypothesis-review-pipelineInsights from Reviews/insights-from-reviewswhen viableProximity/hypothesis-proximity-updatefor each viable childRanking/hypothesis-ranking-pipeline
- In the proximity substage, call
tools.update_hypothesis_proximity(run_dir, hypothesis_id)exactly once throughhypothesis-proximity-update. If the bridge records a skipped, disabled, failed, or provider-unavailable receipt/status, preserve the per-child receipt and continue to ranking without fabricating placeholder embeddings. - For
signals.selection_strategy == single_island, calltools.update_run_single_island_reward(run_dir, selected_island_id, candidate_hypothesis.id, decay_factor)exactly once after the child's final Elo and viability state are known, then reloadislands/ISLANDS.jsonand verify the selected island metrics before writing the completed round receipt or refreshing routing; forsignals.selection_strategy == multi_island, assign the child a new non-emptyisland_id, calltools.ensure_run_islands_for_hypotheses(run_dir, [candidate_hypothesis.id]), verify the created island remains unvisited, and do not apply the single-island helper. - After the final ranked frontier is known, call
tools.evaluate_convergence(candidate_hypothesis.id, previous_top_k_ids, current_top_k_ids, current_convergence_count)exactly once and persist the returnedentered_top_k/convergence_countvalues intostate/EVOLUTION_STATE.jsonwithout manual reinterpretation. - Append the completed round receipt through
tools.append_evolution_round_record(run_dir, record). The record must serializepackages.agent_contracts.EvolutionRoundRecordContract; copyproximity_receipt_statusfrom the persisted per-child receipt when one is recorded, include only duplicate-free child-owned placement/ranked match IDs for this round, and do not infer or omit the child ID, chosen concrete strategy, or top-k entry result. - Update
state/EVOLUTION_STATE.json,state/PIPELINE_STATE.json, andstate/CURRENT_STAGE.jsonfor the finished round or resumed substage. KeepcurrentPhase,currentSkill, andstageTrailaligned with the active substage being closed. Treatmax_iterations = 0as completion-driven mode, reservemax_iterations_reachedfor user-visible capped runs only, and reservesafety_iteration_limit_reachedfor cases where the resolved safety ceiling has actually been reached. - After each finished round, refresh
state/STRATEGY_PLAN.jsonagain. Incompletion_driven + human_checkpoint = automode, keep looping until the refreshed plan reaches a terminal route (generate_overvieworinspect_state) or a validator/safety block occurs. - If
human_checkpointrequests a pause, stop only at that configured checkpoint boundary. Do not ask for user confirmation after every evolution child inautomode. - If execution stops before a terminal route for any reason other than a configured checkpoint, produce a paused handoff that says convergence has not been reached and the next action is continue evolution via resume or an explicit continue request.
- Run
python -m tools.validation.contract_validation <run_dir> --skill hypothesis-evolution-loopafter each evolved hypothesis is persisted. When the loop reportsstatus: completed, runpython -m tools.validation.verify_pipeline_completion <run_dir> --skill hypothesis-evolution-loop.
Completion Rule:
- This skill is complete only when the active round or restored substage has been executed according to the persisted routing plan, the completed child has a matching
state/EVOLUTION_ROUNDS.jsonlreceipt, required evolution-state updates validate, and any terminal completion signal has been checked through the completion verifier.