Files
momentum devandClaude Fable 5 c835861c81 experiment-os: registry + CLI (register/list/get, immutable)
Plan 006 step 1-2. registry.apply_schema honors PG_SKIP_SCHEMA; register()
validates required keys incl. fidelity floors and refuses to overwrite an
existing id (pre-registration is immutable). CLI: python -m research.experiments
{register|run|adjudicate} with deferred imports. 6 registry tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 23:37:27 -04:00

45 lines
1.2 KiB
Python

"""Shared fixtures for the experiment-OS tests.
Every test runs against an ISOLATED throwaway Postgres schema (EventStore
":memory:") with the experiment tables applied on top — never the production
DB (mirrors tests/conftest.py isolation; the mem_* schema is swept at session
end).
"""
from __future__ import annotations
import json
import pytest
from research.experiments import registry
from storage.event_store import EventStore
@pytest.fixture
def store():
s = EventStore(":memory:")
registry.apply_schema(s.con)
yield s
s.close()
def write_spec(tmp_path, spec: dict) -> str:
p = tmp_path / f"{spec['id']}.json"
p.write_text(json.dumps(spec))
return str(p)
def base_spec(**over) -> dict:
spec = {
"id": "demo_v1",
"hypothesis": "demo hypothesis",
"population": {"min_entry_gap_pct": 0.10},
"intervention": {"kind": "time_stop", "minutes": 10, "confirm": "new_high_or_0.5R"},
"bars": {"expR_delta_min": 0.05, "min_n": 300},
"futility": {"min_n": 500, "expR_delta_max": -0.02},
"fidelity": {"atr_frac": 0.25, "spread_mult": 3, "adverse_ticks": 1},
}
spec.update(over)
return spec