Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Serving a FormaSL application

This page documents the Block D application host: loading a resolved project as a long-lived application and invoking typed operations over loopback HTTP. The host is a new access shape over the same engines the CLI uses — it is not a second runtime, and transport outcomes never rewrite semantic outcomes.

What serve does

formasl serve <project-dir> loads exactly ONE resolved application world per process:

discover project → resolve dependencies (frozen) → exact closure →
checked program → bind loopback HTTP → READY

Resolution is always frozen (--locked + --offline semantics): the host validates forma.lock and never mutates it. A missing or stale lock is a typed startup failure — the host never refreshes resolution. An invalid project, an unresolvable dependency, or a rejected source set each fail startup with exit 3; a partially loaded server is never started.

The world is frozen for the process lifetime: no hot reload, no multi-application hosting. Application identity reported by the host derives from the project contract (package reference, version label, resolution digest) — never from the port, PID, or filesystem path.

$ formasl serve
usage: serve requires a project directory

Operations

The public operation set is closed: check, inspect, run, health. POST /op/<name> carries the operation; unknown names are typed protocol rejections, never fallbacks.

OperationBodyNotes
check(empty)Machine envelope of the loaded world’s check.
inspect{"view": "summary"}View is required; same five views as the CLI.
run{"gas": 1000, "application": "Name"}Gas is mandatory; application is optional exactly as --app.
health— (GET /health)Readiness only; claims nothing about providers or future success.

Semantic outcomes ride HTTP 200 in the machine envelope (formasl.machine, schema revision 1). A transport success never launders a semantic rejection, and a semantic rejection never becomes a transport error:

HTTP 200 + outcome.aggregate_status = "REJECTED"     ← possible and normal
HTTP 413 TRANSPORT_BODY_TOO_LARGE                    ← infrastructure, not semantics
HTTP 400 GAS_REQUIRED                                ← protocol rejection, not engine output

Gas is a semantic budget inside the run; request timeouts and client disconnects are infrastructure events and never become OUT_OF_GAS, nor does gas exhaustion ever look like a network failure.

CLI and host agree byte-for-byte

Under the same project, lock, and operational source coordinates, the host’s check and run envelopes are byte-identical to the CLI’s --format json --schema-revision 1 output. There is one engine; the host is another door into it. The analyze verb follows the same rule: it is a thin facade over run --app, and every contract/operator coordinate stays authored in the source, never in CLI flags.

$ formasl analyze examples/hello.fsl
usage: analyze requires --app NAME (the declared analyze application)

Limits of this version

  • One application per process; one project per process.
  • Loopback only (127.0.0.1); a non-loopback bind is not offered in this version — put a reverse proxy in front if you need external access, and treat its authentication as an access boundary, not as FormaSL governance authorization.
  • Bounded by operational limits: 4 MiB request bodies, 8 concurrently executing requests, 64 concurrently served connections. These are infrastructure policy; they do not redefine gas or the language.
  • A duplicate Content-Length header (conflicting or identical values) is a typed 400 TRANSPORT_MALFORMED transport rejection: it is a request-smuggling shape, never a lenient last-value-wins parse.
  • A Transfer-Encoding header (including chunked) is a typed transport rejection naming the cause. The host never silently ignores it and never reports the resulting short body as a protocol or semantic outcome.
  • Expect: 100-continue is tolerated: the host sends no interim 100 and produces the final response once the client sends its body. Clients that wait for an interim response before sending will see the delay, not a rejection.
  • Every connection read is bounded by a 30-second read timeout. A client that stalls mid-request gets 408 TRANSPORT_READ_TIMEOUT — an infrastructure event, never a semantic outcome and never gas exhaustion. A stalled client therefore cannot pin the host.
  • Request bodies must be valid UTF-8 with string literals that are valid UTF-8; violations are typed transport/protocol rejections. Multibyte selectors arrive at the engine byte-exact.
  • Fields that do not apply to an operation (view on run, gas on inspect, anything on check) are rejected with the typed UNSUPPORTED_FIELD protocol rejection.
  • Restart reconstructs the world from disk (lock + sources + checked program) with identical identity and byte-identical envelopes. In-process execution-plane session state is session-bounded by law (the execution plane’s in-memory profile); durable operation state is owned by the execution plane, not by the host process.