mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-06 19:13:55 +01:00
Add optimization O07: turn dossiers, causal maps and labeled features into a versioned queue of specific requests for new examples, plus a study comparing queue-driven acquisition with random acquisition. - Gap detectors: unstable boundaries across group-disjoint folds, prediction/behaviour disagreement, sparse neighbourhoods, missing strata, confounded controls and unsupported causal-map cells. - Each item carries the gap, digest-checked evidence references, rationale, an operator-provided source requirement (the queue never fetches), required partition and group lineage, a declared-heuristic expected value and priority. - Test rows, protected roles, registered confirmation rows and their independence units are removed before scoring; anchors there are refused. Diversity caps per unit and neighbourhood plus a seeded exploration quota prevent repeated outlier targeting. - Ingest writes a new write-once revision bound to the queue and its parent digests; the parent file is never modified. - The study reports random acquisition at equal budget, a stratified arm and the queue on a hidden held-out set; verdict is "no improvement" unless the queue's seed interval clears random's. `obliteratus experiments acquisition queue|ingest|study`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
4.2 KiB
Python
72 lines
4.2 KiB
Python
"""``experiments acquisition queue|ingest|study``: O07 acquisition requests, ingest and study.
|
|
|
|
Nothing here fetches data: ``queue`` writes requests, ``ingest`` adds rows from an
|
|
operator-provided fixture as a new dataset revision, ``study`` compares
|
|
queue-driven with random acquisition on a local or synthetic pool.
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def add_acquisition(commands):
|
|
parser = commands.add_parser(
|
|
"acquisition", help="O07: acquisition queue from coverage and uncertainty gaps")
|
|
sub = parser.add_subparsers(dest="acquisition_command", required=True)
|
|
queue = sub.add_parser("queue", help="Write a versioned queue of requests for new examples")
|
|
queue.add_argument("--revision", required=True, help="Dataset revision (or seed) JSON")
|
|
queue.add_argument("--features", help="Per-record features JSON "
|
|
"(obliteratus.acquisition-features)")
|
|
queue.add_argument("--dossier", action="append", default=[], help="Target dossier (repeatable)")
|
|
queue.add_argument("--map", action="append", default=[], help="Causal map JSON (repeatable)")
|
|
queue.add_argument("--registry", action="append", default=[],
|
|
help="Run or registry directory whose confirmation rows are protected")
|
|
queue.add_argument("--config", help="Queue config JSON (budget, seed, quotas, roles, ...)")
|
|
queue.add_argument("--out", required=True, help="Output directory for queue-<digest>.json")
|
|
ingest = sub.add_parser("ingest", help="Add operator-provided rows as a new dataset revision")
|
|
ingest.add_argument("--revision", required=True, help="Revision the queue was built on")
|
|
ingest.add_argument("--queue", required=True, help="Queue JSON the fixture answers")
|
|
ingest.add_argument("--fixture", required=True, help="Operator fixture JSON")
|
|
ingest.add_argument("--store", required=True, help="Revision store directory")
|
|
ingest.add_argument("--registry", action="append", default=[],
|
|
help="Additional run or registry directory to protect")
|
|
study = sub.add_parser("study", help="Queue-driven versus random acquisition at equal budget")
|
|
study.add_argument("--pool", help="Pool JSON (labeled, reservoir, heldout); default synthetic")
|
|
study.add_argument("--fixture-seed", type=int, default=0, help="Synthetic pool seed")
|
|
study.add_argument("--config", help="Study config JSON (budget, rounds, seeds, ...)")
|
|
study.add_argument("--out", required=True, help="Output directory for acquisition-study.json")
|
|
|
|
|
|
def _json(path):
|
|
return None if path is None else json.loads(Path(path).read_text(encoding="utf-8"))
|
|
|
|
|
|
def run_acquisition_command(args):
|
|
if args.acquisition_command == "queue":
|
|
from obliteratus.analysis.acquisition_queue import build_queue, write_queue
|
|
queue = build_queue(args.revision, base=args.out, features=args.features,
|
|
dossiers=args.dossier, maps=args.map, registry_dirs=args.registry,
|
|
config=_json(args.config))
|
|
path = write_queue(queue, args.out)
|
|
return {"queue": str(path), "queue_sha256": queue["queue_sha256"],
|
|
"items": len(queue["items"]), "unfilled": queue["unfilled"],
|
|
"candidates": queue["candidates"], "refused": len(queue["refused"])}
|
|
if args.acquisition_command == "ingest":
|
|
from obliteratus.analysis.acquisition_queue import load_queue
|
|
from obliteratus.analysis.acquisition_revisions import ingest
|
|
queue, digest = load_queue(args.queue)
|
|
return ingest(args.store, args.revision, queue, digest, args.fixture,
|
|
registry_dirs=args.registry)
|
|
from obliteratus.analysis.acquisition_study import run_study, synthetic_pool
|
|
pool = _json(args.pool) if args.pool else synthetic_pool(args.fixture_seed)
|
|
report = run_study(pool, _json(args.config))
|
|
out = Path(args.out)
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
path = out / "acquisition-study.json"
|
|
path.write_text(json.dumps(report, indent=1, sort_keys=True, allow_nan=False) + "\n")
|
|
return {"report": str(path), "report_sha256": report["report_sha256"],
|
|
"verdict": report["verdict"]["verdict"]}
|
|
|
|
|
|
__all__ = ["add_acquisition", "run_acquisition_command"]
|