lawsynth/benchmarks/causal/lagged/test_benchmark.py
caelum0x 13d696183d feat(product): ship report/explain/compare/forecast, Study SDK, Studio screens
Product depth across all three surfaces (PRODUCT.md captures the vision):

CLI — new lawsynth-report crate (self-contained HTML reports with inline SVG
trajectory + phase-portrait charts) and five product commands: report, explain
(plain-language laws), compare (world diff), forecast (what-if interventions),
library (local world index). Demonstrated end-to-end on a damped oscillator.

SDK — high-level Study workflow (from_csv -> discover -> explain -> simulate/
forecast -> report -> save/load), stdlib HTML report generator, and notebook
rich _repr_html_ display. Quickstart example recovers the oscillator exactly
(R2=1.0) and writes a 30KB report.

Studio — 5 interactive screens (discovery canvas, equation explorer, regime
timeline, uncertainty lens, world lab) composing the shared TS packages through
a reactive state-store; typecheck-clean.

Also: benchmark execution deepened 9 -> 18 real cases (causal + regime families
now scored against ground truth); cross-service integration tests (gateway->
artifact proxy, scheduler<->worker lifecycle over real sockets).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-17 21:05:39 +03:00

43 lines
1.6 KiB
Python

from __future__ import annotations
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from _common import read_config, repository_root
from _engine import EngineUnavailable, ensure_binary
from _families import run_family_case, write_family_dataset
class BenchmarkExecutionTest(unittest.TestCase):
"""The promoted family case now executes and scores through the real CLI."""
directory = Path(__file__).resolve().parent
def test_dataset_generation_is_deterministic(self) -> None:
config = read_config(self.directory)
one = write_family_dataset(config, self.directory / ".benchmark-run").read_bytes()
two = write_family_dataset(config, self.directory / ".benchmark-run").read_bytes()
self.assertEqual(one, two)
def test_executes_and_meets_ground_truth_minimum(self) -> None:
root = repository_root(self.directory)
try:
binary = ensure_binary(root, allow_build=True)
except EngineUnavailable as error:
self.skipTest(str(error))
result = run_family_case(self.directory, self.directory / ".benchmark-run", binary)
self.assertEqual(result["status"], "passed", result)
self.assertIsNotNone(result["signal_value"])
self.assertGreaterEqual(result["signal_value"], result["expected_minimum"])
self.assertEqual(result["discover_returncode"], 0)
self.assertEqual(result["inspect_returncode"], 0)
if __name__ == "__main__":
unittest.main()