lawsynth/python/lawsynth-server
caelum0x e841852b59 feat: product reach — CLI global-dynamics commands, server analysis endpoint, e2e example
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.
2026-08-18 18:11:36 +03:00
..
2026-08-16 22:04:11 +03:00
2026-08-16 22:04:11 +03:00
2026-08-16 22:04:11 +03:00
2026-08-16 22:04:11 +03:00
2026-08-16 22:04:11 +03:00

LawSynth Server

lawsynth-server is the dependency-light domain core for local LawSynth server mode. It provides organization-scoped repositories, bearer-token authorization, idempotent writes, append-only events, SQLite transaction support, and atomic filesystem content-addressed storage. Application.dispatch() is an in-process transport boundary; deployments may adapt it to ASGI/WSGI after their edge authentication and network policy are selected.

The package intentionally does not pretend to implement OAuth, S3 signing, worker scheduling, or a distributed event bus. Those require deployment-owned adapters and credentials. The implemented local contracts remain fully usable for deterministic development and integration testing.

from lawsynth_server import Settings, create_app

app = create_app(Settings(tokens={"dev-token": ("acme", frozenset({"read", "write"}))}))
response = app.dispatch({
    "method": "POST", "path": "/projects",
    "headers": {"Authorization": "Bearer dev-token", "Idempotency-Key": "create-climate"},
    "body": {"name": "climate"},
})
assert response["status"] == 201

Run the service core tests with:

PYTHONPATH=src python -m pytest -q tests