The `maturin develop` path documented in the README and installation guide
failed: python/lawsynth/ has no Cargo.toml and pyproject.toml carried no
manifest-path, so maturin had nothing to build. Point maturin at the
lawsynth-python crate in the Cargo workspace via manifest-path, and document
scripts/build-native.sh as the maturin-free / offline fallback (both produce
an import-compatible lawsynth._native).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Completes the "go all" reach: the standalone `invariants` command and the new
one-shot `analyze` are now first-class in both SDKs.
python/lawsynth analysis.py: invariants() and analyze() methods + frozen
dataclasses (Invariant/InvariantReport, Skipped, AnalyzeReport). _parse_analyze
composes the existing _parse_stability/_parse_lyapunov/_parse_invariants over the
sub-objects (asserted identical to the standalone parsers) and narrows a
{skipped:true} slot to Skipped. analyze/invariants attached to Study/
DiscoveryResult. test_analysis 66 passed; full suite 160 passed / 9 skipped.
packages/world-schema + api-client: InvariantReport + AnalyzeReport interfaces,
parseInvariantReport/parseAnalyzeReport (+ validators, isSkipped guard).
parseAnalyzeReport reuses the standalone validators and re-paths child issues.
api-client 34 pass; world-schema green.
Keys confirmed against crates/lawsynth-cli/src/{invariants,analyze}.rs render_json
AND verbatim CLI capture. Honest note: invariants --box is a single shared LO:HI
interval (vs analyze's per-state box) — the clients encode each correctly.
Batch 14 (partial — TS reach deferred to after a session-limit reset).
python/lawsynth analysis.py: lyapunov/basins/network/mpc client methods over the
CLI --json (single source of truth), with frozen dataclasses mirroring the exact
engine keys and honest per-method docstrings (lyapunov time-averaged; basins
fixed-point attractors only; network correlational; mpc needs a stabilizable
linearization). 9 new dep-free parse tests; full SDK suite 139 passed / 9 skipped.
crates/lawsynth-integration (new, test-only, publish=false): cross-crate
end-to-end tests proving the pipeline composes — discovery→stability finds the
stable spiral, discovery→lyapunov is dissipative (sum≈−0.3 = trace),
stability↔lyapunov agree (stable ⇔ negative largest exponent), a conservative
system is simultaneously a center + energy invariant + zero exponents,
egraph simplification preserves dynamics to 1e-9, and the discover→render chain
is deterministic. 6 tests.
Batch 13 of expansion-v2. Makes the global-dynamics/control engine reachable
from the CLI and the hosted API, and adds a verified end-to-end scenario.
crates/lawsynth-cli: new `lyapunov` (spectrum + KY dimension + chaos flag),
`basins` (attractors + basin fractions + escaped/undetermined), `network`
(directed coupling edge list), and `mpc` (regulate to a setpoint) commands —
all with --json and honest caveats (lyapunov time-averaged; basins fixed-point
attractors only; network correlational-not-causal; mpc successive-linearization
LQR). 135 lib + 9 new integration tests.
python/lawsynth-server: POST /v1/worlds/{id}/analysis/stability mirroring the
simulations resource (auth scope, idempotency key, events). Reaches the engine
the same way the SDK does (native build_world -> save -> CLI-backed stability),
not re-implemented. Honest cases: inconclusive kept, empty box is 200, bad
request 422, engine-absent 503, engine-failure 5xx. 36 passed / 5 skipped
(engine absent), 39 passed with the engine.
examples/20-stability-and-forecast: verified scenario — a conservative oscillator
discovered, then stability finds a center (inconclusive) that invariants explains
via H = 0.25·imbalance² + mid², then forecast. Real captured output; matches the
gallery format; pytest examples 21/21. Honest that bifurcation/sensitivity need
declared parameters.
Batch 10 of expansion-v2. Extends discovery into stochastic dynamics, adds
discrete-time control, and completes the Python/TS reach for the analysis
commands. Deterministic/offline/std-only (Rust) or typed/tested (Python/TS).
crates/lawsynth-sde (new): stochastic law discovery via Kramers-Moyal
conditional moments. Drift a(x)=E[ΔX|x]/Δt and diffusion b²(x)=E[ΔX²|x]/Δt
estimated by binning, occupancy-gated, then sparse-fit to a polynomial library.
Recovers OU (linear drift, constant diffusion), GBM (state-dependent quadratic
diffusion), and double-well (cubic drift) from seeded Euler-Maruyama paths.
Reports raw binned table + fitted laws; honest that it's a statistical
estimator (accuracy scales with path length / bin occupancy). Closes the loop
with the existing SDE simulator. 29 tests.
crates/lawsynth-discrete (new): discrete-time DLQR + Kalman/observer. DARE by
deterministic value iteration (reused on the dual for the filter); discrete
stability = spectral radius < 1, verified via koopman::eigen. DARE residuals
1e-12..5e-14, stabilizes an open-loop-unstable plant, matches the analytic
scalar P=2+√5 case. 34 tests.
python/lawsynth analysis.py: bifurcation/sensitivity/estimate/reduce client
methods over the CLI --json (single source of truth). test_analysis 36 passed;
full SDK suite 130 passed. Honest engine constraints surfaced (pole placement
needs observability; reduce needs a diagonalizable Hurwitz linearization).
packages/world-schema + api-client: typed models + parsers for the four new
analysis-command JSON shapes, verbatim-CLI fixtures, token strings confirmed
against source. api-client 24 tests.
specs/{sde-discovery,discrete-time-control}: boundary specs with honest limits.
Batch 7 of expansion-v2. Extends the product across surfaces and adds an
analysis primitive. Deterministic/offline/std-only (Rust) or graceful-absence
(Python).
python/lawsynth analysis.py (new): Python client for the engine's stability,
control, and domains analyses — shells out to the lawsynth CLI (--json) and
parses to typed dataclasses. No numerics re-implemented in Python; the Rust
engine is the single source of truth. Locates the binary like the benchmarks,
raises MissingBinaryError/CliError honestly, and is fully parse-testable
offline. 20 tests; full SDK suite 114 passed.
crates/lawsynth-features: opt-in std::thread-parallel feature-library
evaluation, bit-identical to serial for ALL thread counts (row-chunked via
thread::scope, ordered assembly, no parallel float reduction). Verified via
f64::to_bits across {1,2,3,4,7,8} threads x 10 library variants x uneven row
counts. Measured 3.6x at 8 threads; honestly sublinear (allocation-bound,
~few-thousand-row crossover). 28 tests + benchmark.
crates/lawsynth-sensitivity (new): forward sensitivity analysis. Integrates the
variational equations Ṡ_j = J_x·S_j + f_θj (J_x from the analytic Jacobian, f_θ
by symbolic differentiation) on the augmented system with fixed-step RK4.
Analytic check to <1e-6; finite-difference cross-check at 1e-6 for every
parameter on logistic + Lotka-Volterra. 22 tests.
docs/guide (new): verified end-to-end guide — getting-started, workflow
(discover→simplify→stability→control→export→validate→uncertainty), and a
determinism demo. All 17 documented commands run exit-0 via run_all.sh; honest
about real behaviors (already-minimal law simplifies to 0 nodes saved, CLI
bootstrap doesn't surface per-coef intervals, center points are inconclusive).
README links the guide.
specs/{parallel-evaluation,sensitivity-analysis}: boundary specs.
Batch 4 of expansion-v2. All deterministic/offline/std-only (Rust) or
graceful-absence (Python), with honest boundary specs.
crates/lawsynth-jacobian (new): symbolic analytic Jacobian J[i][j]=∂f_i/∂x_j
from a discovered vector field's expression trees, for stiff integration and
local stability. Exact sum/product/quotient/chain/power rules over the expr IR;
a non-differentiable node is a typed error, never a silent zero (its power rule
also fixes a NaN the expr crate's naive log-based rule hits on negative bases).
Symbolic result cross-checked against lawsynth-differentiate finite differences
to <=1e-6. 24 tests.
crates/lawsynth-control (new): SINDYc controlled discovery for forced systems
ẋ=f(x,u). Augmented library Θ(x,u) via lawsynth-features (control-only and
state×control cross terms); targets from differentiating a state-only
sub-dataset so controls are never differentiated and never predicted. Recovers
a forced oscillator to ~1e-5; a states-only refit leaves control variance
unmodelled (~8e6x worse RSS), and a constant control is honestly unidentifiable
(persistent-excitation limit). 25 tests.
crates/lawsynth-discovery template priors: declarative grammar constraints
(max degree, allowed variables/kinds, forbid interactions, max active terms,
require a kind) applied as a deterministic hard filter over candidate terms
before the sparse solve, with a full drop report. Default None is byte-identical
to prior behavior; a prior that excludes the truth yields an honest zero law,
never fabricated structure. 29 tests.
python/lawsynth tracking.py (new): MLflow / W&B experiment-tracking interop.
Dep-free deterministic RunRecord anchor (sorted-key JSON, byte-stable) plus
log_to_mlflow/log_to_wandb that lazily import the backend and raise
MissingDependencyError (subclasses ImportError) when absent. Only logs metrics
that genuinely exist on the result — no fabricated mdl/seed/timing; callers pass
measured values via extra_metrics. 21 tests + 2 honest skips; SDK suite 94 pass.
specs/{analytic-jacobian,controlled-discovery,template-priors}: boundary specs.
Batch 3 of the expansion-v2 roadmap, all deterministic/offline/std-only with
honest capability boundaries.
crates/lawsynth-reduce (new): deterministic symmetry & separability detection.
Numerical-derivative probe (finite differences replace AI-Feynman's trained NN
gradients) over a reconstructed Cartesian grid; additive/multiplicative
separability + difference/sum/product/ratio symmetries. Every detection is a
HYPOTHESIS verified by reconstruction residual, never a proof; non-grid data is
honestly rejected (NotReconstructed). 17 tests.
crates/lawsynth-score: two-part MDL objective (L_data + L_model in nats) and
O(n log n) pareto_front_2d (sort-then-sweep), verified equal to the O(n^2)
front across 12 deterministic sets. +5 tests; crate fmt-normalized to config.
python/lawsynth export.py (new): to_sympy/to_torch/to_jax + dep-free
numeric_derivatives anchor. Constants+params hoisted into one trainable vector
so autograd reaches every coefficient (Neural-ODE vector field). Backends
absent here degrade gracefully (MissingDependencyError subclasses ImportError).
Faithful to native simulate at 1.1e-16. 10 tests + 6 honest skips.
benchmarks: SRBench Feynman (15: 12 static algebraic relations as honest
capability-boundaries, 3 dynamics-framed ODEs executed at R2~=1.0) and
black-box (4 systems, predictive R2 + parsimony, no ground truth) families.
Fixes a pre-existing _runner.py failure where Strogatz cases leaked into the
legacy contract suite. 31 benchmark tests.
specs/structural-reductions: boundary spec (detection-is-a-hypothesis contract).
The #1 adoption lever from the competitive analysis: a sklearn-compatible package
(python/lawsynth-sklearn) so the scikit-learn ecosystem adopts LawSynth with
near-zero switching cost (why gplearn/PySINDy win mindshare).
- LawSynthDynamics: fit(X, t=)/predict/simulate/score/equations over the real
Study discovery; full get_params/set_params/__sklearn_tags__/NotFittedError.
- LawSynthRegressor (RegressorMixin), LawSynthTransformer (feature library +
deterministic decorrelation prune), parsimony='auto' (lambda = Cov/Var).
- Inherits sklearn mixins when present; faithful standalone fallback otherwise.
Demo recovers an oscillator R2=0.999996; 50 tests pass (7 sklearn-integration
skip cleanly when sklearn absent). Deterministic, offline.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wave 9 — data quality, trust & monitoring:
CLI — lawsynth prep (smooth/resample/detrend/trim/drop-constant via preprocess)
moves a noisy model WEAK(R2=0.39)->GOOD(R2=0.95); lawsynth monitor (model-based
anomaly detection, robust MAD control limits) flags an injected shock as DRIFT at
the right time; forecast --confidence emits deterministic residual-bootstrap bands.
SDK — Study.prepare (cleaned Study), discover_ensemble -> Ensemble (per-term
selection-frequency + coefficient mean/std = robust vs unstable terms) with
forecast bands, Study.monitor -> MonitorReport. Three runnable examples.
Studio — Data Prep + Monitor screens (now 11 screens): interactive prep with
raw-vs-prepared overlay that promotes to the working dataset, and observed-vs-
predicted residual monitoring with a threshold + in-control/watch/drift verdict.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wave 8 — depth across four fronts:
Studio — @lawsynth/api-client gains the real discovery-run endpoints; the Studio
discovery flow now drives the LIVE client (submit -> bounded-poll -> getWorld ->
feed screens), with an in-memory fake transport for offline end-to-end tests.
Export — lawsynth export --format c|onnx|matlab. The C compiles clean and matches
the engine to ~1e-14; ONNX is an honest computation-graph JSON (each node mapped
to its standard ONNX op, DAG-interned, evaluator-verified); MATLAB .m emitted.
Notebook — WorldExplorerWidget: a self-contained embedded-JS widget that
re-simulates in-browser on slider drag (no kernel round-trip); factors each
discovered coefficient into a tunable parameter. study.discover().explore().
Performance — single-pass streaming CSV parser: 3.19x faster ingest (500k rows
224ms->70ms, 328 MiB/s; 1M rows 7.2M rows/s), byte-for-byte identical output
(equivalence-tested), plus streaming Read-based loaders + progress callbacks + a
scale benchmark.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wave 7 — the backend ties together into one working loop:
API — POST /v1/runs executes a real discovery run state machine (queued ->
running -> succeeded|failed) via the native engine on a worker thread, stores the
discovered world, computes a real result summary (mse/complexity/#laws), and
emits RunQueued/Started/Succeeded/Failed to the event bus (streamed by
/v1/events). GET /v1/runs/{id} (status+summary) and /v1/runs/{id}/world flow
straight into the existing explain/report endpoints. Honest 503 when native
absent; bearer-auth + tenant-scoped + idempotent.
SDK — lawsynth.Client (stdlib urllib) drives the loop: submit_discovery -> wait
-> world -> explain/forecast/report, with a real HTTP transport and an in-process
WSGI transport so it runs fully offline. Demonstrated end to end.
API 98 -> 134 tests (native absent); client 18 tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wave 4 — compare what-ifs to decide:
CLI — lawsynth scenarios: define N named what-if scenarios (scheduled
interventions), compare final-state divergence from baseline in a table + a
self-contained multi-series HTML report (overlaid trajectories + legend).
lawsynth doctor: environment/health check with a real world round-trip self-test.
SDK — Study.add_scenario/compare_scenarios -> ScenarioComparison (table +
overlaid-SVG _repr_html_); a cohesive StudyDashboard in lawsynth-notebook that
composes equations/trajectory/frontier/regimes/uncertainty/scenarios into one
themed Jupyter view; Study._repr_html_ now renders the full dashboard when the
notebook package is present, degrading gracefully otherwise.
Studio — Scenario Board (9th screen): define scenarios, overlay trajectories
(multi-series chart + legend), baseline-divergence table, store-driven selection.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
test_http_csv_is_streamed_coerced_and_numeric_validated asserted three behaviors
the connectors layer deliberately does NOT provide: numeric coercion of CSV
(contradicts the documented no-coercion contract and test_s3's string assertion),
loopback reads without the SSRF opt-in, and an ETag on read batches (only inspect()
surfaces it; the fixture has no HEAD). Rewritten to assert the real contract:
faithful string records + private-network opt-in + numeric=True rejecting textual
CSV. Repo now has zero failing tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds python/lawsynth/scripts/build-native.sh which builds the lawsynth-python
cdylib via cargo and installs it as the package's _native module under the
interpreter's ABI suffix — the same artifact maturin produces, but usable on
toolchains without maturin (air-gapped CI). Unblocks the Python native surface
(python/lawsynth: 22 tests) and the native conformance/e2e legs. The built .so
stays gitignored. Also stages Cargo.lock for the discovery opt/causal deps.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>