Backend basics
What the rendered backend gives you
corvid build --target=server produces a Cargo project that compiles
to a production-shape axum 0.7 binary with:
- Routes — declared in Corvid source as
serverblocks. - Middleware pipeline — auth, rate-limit, tracing-headers, CORS, compression, request logging — wired in declared order.
- Graceful shutdown via tokio oneshot.
- Handler isolation: each request runs in a subprocess with a per-handler timeout (504 on exceed).
- Body-limit enforcement (413 on exceed).
/healthz,/readyz,/metricsendpoints generated from runtime state.
Declaring a server
server refund_api: route "/refund" -> handle_refund route "/refund/status" -> handle_status route "/healthz" -> healthz # auto-generated, override-ableWriting a handler
struct RefundRequest: customer_id: String amount: Float
struct RefundResponse: ok: Bool receipt_id: String
@budget($0.50)@max_wall_time(10s)agent handle_refund(req: RefundRequest) -> RefundResponse uses http_effect, refund_effect: approve Refund(req.amount, req.customer_id) let receipt = refund(req.amount, req.customer_id) return RefundResponse { ok: true, receipt_id: receipt.id }The handler agent’s effect row drives middleware behavior:
refund_effectcarriestrust: supervisor_required, so the middleware enforces the host-side approval check.@max_wall_timesets the per-request handler-isolation timeout.
Building and running
corvid build src/main.cor --target=servercd target/servercargo run --releaseThe server listens on 0.0.0.0:8080 by default; override with
PORT=9090 cargo run.
Configuration
[server]port = 8080body_limit_bytes = 1048576 # 1 MiBhandler_timeout_seconds = 30graceful_shutdown_seconds = 10
[server.cors]allowed_origins = ["https://app.example.com"]
[server.rate_limit]requests_per_minute = 1000burst = 100
[server.auth]jwt_jwks_url = "https://auth.example.com/.well-known/jwks.json"required_claims = ["sub", "tenant"]Observability
Every request emits structured logs and OTel spans. The /metrics
endpoint exposes Prometheus-format counters: requests by route, by
status, by effect-row, plus handler-isolation timeouts and body-limit
hits.
See Observability.
Scope boundaries
Out of scope for v1.0:
- Multi-process worker pool (current shape: one server process, subprocess-spawned handlers per request).
- Custom middleware injection from Corvid source (current set is fixed by the renderer).