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.
Completes batch 14's deferred TypeScript reach (the agent had been killed by the
session limit before starting it).
packages/world-schema/src/analysis.ts: typed interfaces + runtime parsers for
the four global-dynamics command outputs — LyapunovReport, BasinReport (+
Attractor, a BasinLabel `a${number}`|"escaped"|"undetermined" type), NetworkModel
(+ NetworkEdge, boolean adjacency matrix), MpcResult (nullable final_error_norm).
Keys confirmed against the Rust `crates/lawsynth-cli/src/{lyapunov,basins,network,
mpc}.rs` render_json. validateX/parseX mirror the existing idiom, reuse the
shared helpers, throw SchemaValidationError.
packages/api-client: re-exports the new parsers/validators + types.
Tests: world-schema analysis suite extended (parse + malformed-rejection for all
four, verbatim-shaped fixtures); api-client 26 pass (+2 narrowing/rejection).
Both typecheck clean.
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 8 of expansion-v2. Adds the state-estimation and model-reduction control
layers, surfaces coefficient uncertainty in the CLI, and reaches the TS SDK.
Deterministic/offline/std-only (Rust) or typed/tested (TS).
crates/lawsynth-estimate (new): Luenberger observer + steady-state continuous
Kalman filter for discovered linear models, derived as the exact dual of
lawsynth-feedback (place_poles/lqr on (Aᵀ,Cᵀ)). Coupled plant+observer RK4
proves ‖x−x̂‖→0 from a wrong initial estimate reconstructing unmeasured states
from partial measurements; Kalman CARE residual ~4e-16. Observability enforced;
error spectrum verified via koopman::eigen. 33 tests.
crates/lawsynth-modelreduce (new): balanced truncation. Gramians via Kronecker
Lyapunov solve, square-root (Laub) balancing, Hankel-SV truncation with the
2·Σσ a priori bound. HSV analytic match to 1e-12, Lyapunov residual <1e-12,
monotone full-vs-reduced response error, stability preserved. 23 tests.
crates/lawsynth-discovery + lawsynth-cli: `discover --bootstrap N [--confidence
C]` now computes and reports per-coefficient bootstrap CIs + inclusion
probability (text + --json), reusing lawsynth-uncertainty. Hooked in the shared
driver so single-node and partitioned paths agree; content-derived deterministic
seed; default path byte-identical. Closes the gap the docs surfaced. Discovery
41 lib + CLI 101 lib tests.
packages/world-schema + api-client: typed models + runtime parsers mirroring the
engine's stability/control/domains --json exactly (classification strings
confirmed against source + live output). Parsers, not a fabricated HTTP route
(no such endpoint exists). 20 api-client tests + world-schema suite green.
specs/{state-estimation,model-reduction}: boundary specs; discovery-run
candidate contract notes coefficient uncertainty.
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>