9 Commits

Author SHA1 Message Date
a3b1ef8de1 feat(sdk): Python + TS clients for invariants and analyze
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.
2026-08-18 22:59:17 +03:00
1442b15920 feat(sdk): Python + TS clients for the koopman / sde / pde discovery engines
Surface parity for the discovery engines exposed on the CLI in e147df5.

python/lawsynth analysis.py: koopman()/sde()/pde() client methods over the CLI
--json, with frozen dataclasses mirroring the exact engine keys (discrete +
continuous eigenvalues, drift/diffusion laws + binned table, PDE term list) and
honest per-method docstrings (operator-not-a-world; statistical estimator;
finite-difference grid). Dep-free parse tests + skip-guarded live tests;
test_analysis 54 passed, full SDK suite 148 passed / 9 skipped.

packages/world-schema + api-client: typed KoopmanReport/SdeReport/PdeReport
interfaces + runtime parsers (parseKoopmanReport/parseSdeReport/parsePdeReport,
KoopmanEigenvalue adds `modulus`), method-token constants, malformed-rejection
tests. world-schema green; api-client 30 pass.

All keys confirmed against crates/lawsynth-cli/src/{koopman,sde,pde}.rs
render_json AND verbatim runtime capture. No shape differed from source.
2026-08-18 21:18:09 +03:00
04010a7d10 feat: TS SDK reach for lyapunov / basins / network / mpc
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.
2026-08-18 20:25:08 +03:00
220552d530 feat: SDE discovery + discrete-time control + Python/TS reach
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.
2026-08-18 17:21:57 +03:00
cf7fab2642 feat: estimation + reduction + uncertainty surfacing + TS types
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.
2026-08-18 16:36:00 +03:00
ebd7076388 feat(P6): collaboration clients — SDK Client, api-client, Studio review screen
Completes P6 end-to-end (backend endpoints + now clients):
SDK — Client gains 9 collaboration methods (members/revisions/annotations/review/
merge); example drives the full loop offline in-process (roles -> submit ->
revisions -> annotate -> review/approve -> merge) with viewer-403 + owner-only-
approve enforced.
Studio — 12th screen (Collaboration & Review): members+roles, revision lineage,
annotations, role-gated review actions; @lawsynth/api-client CollaborationApi +
InMemoryCollaborationTransport. Typecheck clean; api-client 15 + studio 15 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-18 02:30:18 +03:00
68f07af53b feat(product): Studio↔live services, C/ONNX/MATLAB export, notebook widget, 3x faster ingest
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>
2026-08-17 23:09:54 +03:00
5828d99939 dragon warrior 2026-08-16 22:04:11 +03:00
6a9ce627e0 asdoruyu 2026-08-16 20:29:23 +03:00