caelum0x 035cebdcf1 feat(product): discovery-as-a-service — run workflow + Python service Client
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>
2026-08-17 22:30:54 +03:00
..
2026-08-16 23:40:41 +03:00
2026-08-16 23:40:41 +03:00
2026-08-16 23:40:41 +03:00
2026-08-16 23:40:41 +03:00
2026-08-16 23:40:41 +03:00

LawSynth API

lawsynth-api is the HTTP process for LawSynth's Python domain core. It is a stdlib WSGI adapter, not a second implementation of projects, datasets, worlds, simulations, artifacts, events, or idempotency. Those operations are dispatched directly to lawsynth_server.Application.

Run the loopback-only development process after installing both local packages:

lawsynth-api --host 127.0.0.1 --port 8080

For a deployment, run a WSGI server behind TLS and import lawsynth_api.main:application:

gunicorn --bind 127.0.0.1:8080 --workers 1 lawsynth_api.main:application

The alpha domain repositories are intentionally process-local, so run one API worker behind a load balancer; the service does not claim distributed metadata or remote worker execution it does not have.

The process accepts JSON objects only. Writes require both a bearer token and an Idempotency-Key; those are passed unchanged to the domain core. Configure local bearer grants through LAWSYNTH_API_TOKENS_JSON, for example:

{"a-long-secret-token":{"organization_id":"acme","scopes":["read","write"]}}

In production, LAWSYNTH_DATABASE_URL must name durable SQLite storage and LAWSYNTH_OBJECT_ROOT must be an absolute path. The API deliberately returns 503 native_unavailable when an executable native LawSynth runtime is absent, and 501 worker_transport_unavailable for /v1/worker/*: this process does not pretend to be a worker gateway.