Connectors: 22 real pytest modules (186 pass / 7 optional-dep skips) exercising
every connector's dependency-free surface + missing-driver degradation; SSRF
guard verified; errors_connector.py as a thin re-export (no forked taxonomy).
Services: config/{dev,staging,prod,test,limits,logging}.yaml + docs/*.md for
api/gateway/scheduler/worker, mapped to the real config structs; gateway/scheduler
Dockerfiles + scheduler .env/README. All YAML validated.
Closes 66 manifest files (gap 175->109). No source behavior changed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.4 KiB
Architecture
lawsynth-gateway is a transport-independent WSGI admission layer that wraps the
local lawsynth-api application in the same process. It has no business logic and
no persistence; it decides what may reach the backend and how the response is
returned to the caller.
Composition
The gateway is composed around the API application, not deployed as a separate network hop:
from lawsynth_api import create_wsgi_app
from lawsynth_gateway import create_gateway
application = create_gateway(create_wsgi_app())
GatewayApplication wraps the backend in an InProcessWsgiBackend. Remote
upstream proxying, TLS termination, and retries are deliberately absent:
InProcessWsgiBackend.remote(...) raises RemoteUpstreamUnavailable rather than
pretending an unimplemented remote path succeeded. Those capabilities belong to a
separately audited edge proxy.
Admission pipeline
Each request passes through, in order (app.py):
- Request id — validate an inbound
X-Request-Idor mint a UUID. _admit— method allowlist, absolute/normalized path check,api_prefixrouting, draining check, query validation, client-address extraction.- Header canonicalization — capitalize names, reject invalid names/values and duplicates, strip hop-by-hop and client forwarding headers, enforce the header count and byte ceilings.
- Body admission — reject
Transfer-Encoding/chunked, validateContent-Lengthagainstmax_body_bytes, requireContent-Typewhen a body is present. - Origin check and, for
OPTIONS, preflight. - Rate limit —
BoundedRateLimiter, a lock-protected sliding window with an LRU-bounded per-client key-space. - Relay — build a clean backend
environ, invoke the backend, validate and clean the backend's WSGI response, relay it with safe headers.
Determinism and safety
The rate limiter takes an injectable monotonic clock, so window behavior is
testable without sleeping. Every response gets fixed safe headers
(Cache-Control: no-store, X-Content-Type-Options: nosniff, an authoritative
X-Request-Id, a computed Content-Length). A backend that misbehaves
(double start_response, non-bytes body, invalid status/headers) is turned into
a 502 backend_failure rather than propagated.
Trust boundary
The gateway is the public front door; the API behind it is not internet-exposed.
See docs/security.md.