caelum0x 7087e7925e feat(product): symbolic simplify (egraph), model compose/edit, hosted-deploy
Wave 11 — the three candidates:
CLI — lawsynth simplify (egraph equality saturation extracts the lowest-cost
EQUIVALENT law; proves equivalence by simulating both worlds, deviation ~0;
honest 'already minimal' on sparse discovered worlds); lawsynth compose (union
two worlds into a coupled system, namespacing collisions) and lawsynth edit
(immutable rename/set-param/drop-law/scale-law, re-validated).

SDK — lawsynth.simplify / World.simplify (stdlib expand/fold/combine +
equivalence verify), lawsynth.compose, World.rename/set_parameter/drop_law/
scale_law. Two runnable examples.

Deploy — a verifiable hosted-deploy story: deploy/quickstart (config-validated
minimal api+gateway) + docs/self-hosting/quickstart.md (real curl/Client run
loop), after fixing genuine drift in the compose files (SQLite URL the API
actually accepts, correct token env, object root, health endpoints, native
build step) — verified end-to-end from source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-18 01:08:14 +03:00

89 lines
4.0 KiB
YAML

# API + admission gateway for the local LawSynth stack.
#
# api — Python WSGI facade over the domain core (gunicorn, :8080).
# gateway — in-process admission layer (body/header limits, rate window, CORS)
# wrapping the API, exposed to the host on :8081. Studio and the CLI
# talk to the gateway, not the API, in a realistic setup.
#
# IMPORTANT — the API's real backing services:
# The LawSynth API is SQLite + filesystem, not Postgres + S3. The domain core
# (`lawsynth_server.database.Database`) accepts ONLY SQLite URLs and raises on
# anything else; storage is a content-addressed filesystem tree at
# LAWSYNTH_OBJECT_ROOT. It reads NONE of the LAWSYNTH_S3_*, LAWSYNTH_EVENT_BUS_URL,
# or LAWSYNTH_ARTIFACT_ENDPOINT variables. Discovery runs on the compiled
# `lawsynth` engine IN-PROCESS. The Postgres/MinIO/NATS services in this stack
# back the separate Rust scheduler/worker/artifact plane (worker.yaml), which
# is not yet wired to the API's discovery path — see the README "boundaries".
#
# The API also needs the compiled `lawsynth` engine baked into its image. The
# stock deploy/docker/images/api.Dockerfile builds it; if you see
# `503 native_unavailable` on POST /v1/runs, rebuild with `--build`.
#
# Both build from the repository root using the Dockerfiles under
# deploy/docker/images/. Included by compose.yaml.
services:
api:
image: ${LAWSYNTH_REGISTRY:-ghcr.io/lawsynth}/api:${LAWSYNTH_VERSION:-0.1.0}
build:
context: ../../..
dockerfile: deploy/docker/images/api.Dockerfile
restart: unless-stopped
environment:
LAWSYNTH_API_ENV: development
GUNICORN_WORKERS: ${LAWSYNTH_API_WORKERS:-1}
# Metadata: durable SQLite on the API data volume.
LAWSYNTH_DATABASE_URL: sqlite:////var/lib/lawsynth/metadata.sqlite3
# Object store: content-addressed files under an absolute root.
LAWSYNTH_OBJECT_ROOT: /var/lib/lawsynth/objects
# Bearer grant: token -> {organization_id, scopes}. Token must be >= 16
# chars; scopes subset of read/write/admin. Local-only default value.
LAWSYNTH_API_TOKENS_JSON: >-
{"${LAWSYNTH_API_TOKEN:-local-dev-token-change-me-please}":{"organization_id":"local","scopes":["read","write"]}}
expose:
- "8080"
ports:
- "${LAWSYNTH_API_HOST_PORT:-8080}:8080"
volumes:
- lawsynth_api_data:/var/lib/lawsynth
networks:
- lawsynth
gateway:
image: ${LAWSYNTH_REGISTRY:-ghcr.io/lawsynth}/gateway:${LAWSYNTH_VERSION:-0.1.0}
build:
context: ../../..
dockerfile: deploy/docker/images/gateway.Dockerfile
restart: unless-stopped
depends_on:
api:
condition: service_healthy
environment:
GUNICORN_WORKERS: ${LAWSYNTH_GATEWAY_WORKERS:-1}
LAWSYNTH_GATEWAY_BACKEND: lawsynth_api.main:application
LAWSYNTH_GATEWAY_MAX_BODY_BYTES: ${LAWSYNTH_GATEWAY_MAX_BODY_BYTES:-67108864}
LAWSYNTH_GATEWAY_REQUESTS_PER_WINDOW: ${LAWSYNTH_GATEWAY_REQUESTS_PER_WINDOW:-120}
LAWSYNTH_GATEWAY_RATE_WINDOW_SECONDS: ${LAWSYNTH_GATEWAY_RATE_WINDOW_SECONDS:-60}
LAWSYNTH_GATEWAY_ALLOWED_ORIGINS: ${LAWSYNTH_GATEWAY_ALLOWED_ORIGINS:-http://localhost:8083}
# The gateway image bundles the API package and runs it in-process, so it
# resolves the same SQLite + object store as the api service. Both share
# the data volume so the wrapped backend sees identical metadata/objects.
LAWSYNTH_API_ENV: development
LAWSYNTH_DATABASE_URL: sqlite:////var/lib/lawsynth/metadata.sqlite3
LAWSYNTH_OBJECT_ROOT: /var/lib/lawsynth/objects
LAWSYNTH_API_TOKENS_JSON: >-
{"${LAWSYNTH_API_TOKEN:-local-dev-token-change-me-please}":{"organization_id":"local","scopes":["read","write"]}}
ports:
- "${LAWSYNTH_GATEWAY_HOST_PORT:-8081}:8081"
volumes:
- lawsynth_api_data:/var/lib/lawsynth
networks:
- lawsynth
networks:
lawsynth:
volumes:
# SQLite metadata database + content-addressed object store for the API.
lawsynth_api_data: