Skip to content

feat: contract-driven runtime HTTP server with a pluggable MEOS engine#7

Open
estebanzimanyi wants to merge 1 commit into
masterfrom
feat/runtime-server
Open

feat: contract-driven runtime HTTP server with a pluggable MEOS engine#7
estebanzimanyi wants to merge 1 commit into
masterfrom
feat/runtime-server

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

What

Adds server/ + serve.py: the projection that executes. It builds
routing, request validation and dispatch from the enriched catalog
(network / wire) — the same single source the OpenAPI (#5) and MCP (#6)
generators consume; the server is just the consumer that runs the algebra.

python run.py                                 # enriched catalog
python serve.py                               # 127.0.0.1:8080 (StubEngine)
MEOS_LIBRARY_PATH=/path/libmeos.so python serve.py 0.0.0.0 9000

How

POST /{function} per stateless-exposable function: validate the JSON body
decode each serialized string to an opaque handle → invokeencode
the result → {"result": …} (204 void, 400 {"error","code"} on a
MEOS/validation error, 404 unknown). All MEOS work is behind an Engine:

  • CtypesEnginedlopen a built libmeos, call by symbol. Every
    opaque value is an anonymous void *; no struct layout is ever needed,
    because the catalog already reduced every exposable function to scalars +
    decode/encode of opaque pointers
    . Selected via MEOS_LIBRARY_PATH.
  • StubEngine — no MEOS build: routing/validation/error-mapping run;
    calls return deterministic placeholders. Default; makes the server
    runnable and testable without a compiled MEOS.

Stdlib http.server only — no new dependencies.

Validation (and its honest boundary)

  • Generation / routing / validation / dispatch / error mapping: fully
    validated
    — built from the live MobilityDB master catalog (1790
    operations, 0 malformed
    ), exercised end-to-end over real HTTP sockets.
  • CtypesEngine arg/return ctype mapping and decode→invoke→encode flow:
    unit-tested against a fake shared library.
  • Not validated here: linkage against a real libmeos.so — no compiled
    MEOS exists in this environment (only headers + the catalog). That is the
    integration step; CtypesEngine is the seam for it. Stated plainly in
    docs/server.md.

tests/test_server.py: 17 stdlib unittest cases, all green.

Scope / dependency

Logically stacks on the catalog-enrichment work (consumes network /
wire). Delivers a correct-by-construction reference server, not a tuned
production stack (concurrency/auth/ASGI are intentionally out of scope).
Next units: a built-MEOS integration run, result memory ownership
(pfree), and an MCP stdio server reusing the same engine.

@estebanzimanyi estebanzimanyi force-pushed the feat/runtime-server branch 6 times, most recently from dd98a46 to 1ea37a8 Compare May 18, 2026 10:30
Adds server/ + serve.py: the projection that executes. Routing, request validation and dispatch are built from the enriched catalog (network/wire) — the same single source the OpenAPI/MCP generators consume.

- POST /{function} per stateless-exposable function: validate body,
  decode each serialized string -> opaque handle, invoke, encode the
  result -> {"result": ...} (204 void, 400 {error,code} on failure)
- Engine seam: CtypesEngine (dlopen a built libmeos; opaque values are
  anonymous void*) and StubEngine (runs without a MEOS build)
- CtypesEngine installs a non-fatal MEOS error handler, so a bad request
  becomes a 400 instead of MEOS's default exit() killing the process
- stdlib http.server only; no new dependencies

Validated against the live MobilityDB master catalog (1522 routes, 0
malformed) over real HTTP sockets, and end-to-end against an installed
/usr/local/lib/libmeos.so: POST /temporal_num_instants -> 200
{result:3}, malformed body -> 400 with the real MEOS message, server
survives. Integration test skipped unless MEOS_LIBRARY_PATH is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant