Files
OBLITERATUS/obliteratus/experiments/search_cli.py
Joseph MaglyandClaude Opus 5.5 b04906e15c feat(experiments): bounded mutation search with Pareto selection
Add F19: a replayable, budgeted search over qualified operations only,
with an all-attempt ledger, Pareto-first selection and independently
confirmed finalists.

- The space is built from persistent-pilot eligible registrations
  (declared coefficient grids and forms), selected candidates and
  recovered candidates, and complete sequences in their evidenced
  order; anything else is refused. Confirmation and test rows are
  refused for search. The space is write-once and digest-identified.
- Proposals reuse the project's Optuna TPE multi-objective approach
  with per-trial seeding, so replay reproduces the ledger; pruning uses
  the anytime-valid screening rule.
- An append-only, hash-chained ledger records every trial; trial ids are
  content digests, and an interrupted trial is marked incomplete and
  re-run or discarded once. Incomplete trials never win.
- Trials with invalid outputs, failing or unmeasured collateral
  endpoints, or target gains flagged by the weak-scorer check are
  infeasible. The Pareto front is reported before any pre-declared
  aggregate score.
- Finalists must pass a fresh locked confirmation registration created
  after the search and disjoint from development rows; search winner
  and confirmed finalist are reported separately.
- `obliteratus experiments search plan|run|resume|front|confirm`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 13:26:24 -05:00

69 lines
4.0 KiB
Python

"""``obliteratus experiments search plan|run|resume|front|confirm``: bounded mutation search."""
import json
from pathlib import Path
def add_search(commands):
parser = commands.add_parser(
"search", help="F19: bounded search over qualified operations with Pareto selection")
sub = parser.add_subparsers(dest="search_command", required=True)
plan = sub.add_parser("plan", help="Qualify a search spec and write its replayable space")
plan.add_argument("spec", help="Search spec JSON (obliteratus.search-spec/1)")
plan.add_argument("--out", required=True, help="Search directory")
for name, text in (("run", "Start the search"), ("resume", "Resume an interrupted search")):
command = sub.add_parser(name, help=text)
command.add_argument("out", help="Search directory")
source = command.add_mutually_exclusive_group(required=True)
source.add_argument("--outcomes", help="Recorded per-point development outcomes JSON "
"(obliteratus.search-outcomes/1)")
source.add_argument("--source", help="Reference model directory (model evaluation)")
command.add_argument("--expect-space", help="Refuse unless the space has this id")
if name == "resume":
command.add_argument("--incomplete", choices=("rerun", "discard"), default="rerun",
help="Re-run an interrupted trial under its id or discard it")
front = sub.add_parser("front", help="Pareto front, optional weighted score and finalists")
front.add_argument("out", help="Search directory")
confirm = sub.add_parser("confirm", help="Check a finalist against a fresh locked "
"confirmation registration")
confirm.add_argument("out", help="Search directory")
confirm.add_argument("--trial", required=True, help="Trial id (sha256:...)")
confirm.add_argument("--registration", required=True, help="Fresh registration id")
confirm.add_argument("--candidate", help="Persistent candidate built for the finalist")
confirm.add_argument("--allow-fixture-results", action="store_true",
help="Test-only: count fixture-model (software-contract) results")
def _evaluator(args):
from obliteratus.experiments.search_eval import ModelEvaluator, ReplayEvaluator
from obliteratus.experiments.search_space import read_space
if args.outcomes:
return ReplayEvaluator(json.loads(Path(args.outcomes).read_text(encoding="utf-8")))
from obliteratus.concepts.pack import ConceptPack
return ModelEvaluator(read_space(args.out), args.source, pack_resolver=ConceptPack.load)
def run_search_command(args):
from obliteratus.experiments import search_run
if args.search_command == "plan":
from obliteratus.concepts.pack import ConceptPack
from obliteratus.experiments.search_space import plan_search, points
space = plan_search(args.spec, args.out, pack_resolver=ConceptPack.load)
return {"space": space["id"], "seed": space["frozen"]["seed"],
"scope": space["frozen"]["scope"], "points": len(points(space)),
"arms": [{"id": a["id"], "kind": a["kind"], "maturity": a.get("maturity")}
for a in space["frozen"]["arms"]],
"development_rows": len(space["frozen"]["development"]["rows"])}
if args.search_command in ("run", "resume"):
return search_run.run_search(
args.out, _evaluator(args), resume=args.search_command == "resume",
incomplete=getattr(args, "incomplete", "rerun"), expect=args.expect_space)
if args.search_command == "front":
return search_run.front(args.out)
from obliteratus.experiments.search_confirm import confirm_finalist
return confirm_finalist(args.out, args.trial, args.registration, candidate=args.candidate,
allow_fixture_results=args.allow_fixture_results)
__all__ = ["add_search", "run_search_command"]