fed-sx-m1: Step 8b-bridge — http:listen dict ↔ proplist marshalling
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
The native http-listen primitive in bin/sx_server.ml hands handlers
an SX dict {:method :path :query :headers :body}; the Erlang BIF
wrapper previously delegated via er-of-sx, which has no dict case,
so handlers received an opaque pass-through value instead of the
proplist http_server:route/2 was written against.
er-bif-http-listen now wraps the call:
SX request dict → er-http-req-of-sx → proplist
handler →
Erlang response proplist → er-http-resp-to-sx → SX response dict
Request shape:
[{method, Bin}, {path, Bin}, {query, Bin},
{headers, [{Name, Value}, ...]}, {body, Bin}]
Response shape:
[{status, Integer}, {headers, [{Name, Value}, ...]}, {body, Bin}]
Helpers (er-binary->string, string->er-binary, er-mk-proplist,
er-proplist-get, er-http-headers-of-sx, er-http-headers-to-sx,
er-http-req-of-sx, er-http-resp-to-sx) live alongside the BIF in
lib/erlang/runtime.sx — scoped narrowly to the bridge, no edits
elsewhere in the file.
Verified by next/tests/http_listen_bridge.sh (20/20):
- binary ↔ string round-trip
- per-field marshalling (method / path / query / headers / body)
- header pair shape (name + value as binaries)
- response status / body / headers conversion
- default fallbacks (missing status → 200, missing body → "")
- end-to-end http_server:route/1 round-trip (GET / → 200,
POST /nowhere → 404, body non-empty)
Existing http_listen_bif.sh (5/5), http_route.sh (11/11),
http_publish_fold.sh (10/10) unchanged. Erlang-on-SX conformance
761/761. WASM boot green (no lib/sx_primitives.ml changes).
Unblocks Step 8b-start (TCP listener spawn) and the curl-driven
9a-tcp / 9b-tcp smoke tests.
This commit is contained in:
@@ -121,12 +121,20 @@ These three gaps block the remaining unchecked deliverables:
|
||||
API shapes; the bridge would let bundle bodies dispatch through them
|
||||
unchanged.
|
||||
|
||||
3. **Dict ↔ proplist marshalling for `http:listen/2`** — The native
|
||||
`http-listen` primitive calls the handler with an SX dict; the BIF
|
||||
wrapper's bridge would need to marshal that to / from an Erlang proplist.
|
||||
Blocks `Step 8b-start` (actual TCP listening with working route dispatch).
|
||||
The briefing allowed the BIF *wrapper* as a single scope exception; further
|
||||
in-place modifications need agent approval.
|
||||
3. **Dict ↔ proplist marshalling for `http:listen/2`** — **done 2026-06-05.**
|
||||
`er-bif-http-listen` now marshals the native server's request dict
|
||||
(`{:method :path :query :headers :body}`) into the proplist shape
|
||||
`[{method, Bin}, {path, Bin}, {query, Bin}, {headers, [{Name, Value}]},
|
||||
{body, Bin}]` that `http_server:route/2` consumes, and converts the
|
||||
handler's response proplist back to `{:status :headers :body}` for the
|
||||
native server to serialise. Helpers (`er-http-req-of-sx`,
|
||||
`er-http-resp-to-sx`, `er-http-headers-of-sx`, `er-http-headers-to-sx`,
|
||||
`er-mk-proplist`, `er-proplist-get`, `er-binary->string`,
|
||||
`string->er-binary`) live alongside the BIF wrapper in
|
||||
`lib/erlang/runtime.sx`. Verified by `next/tests/http_listen_bridge.sh`
|
||||
(20 cases) including a `http_server:route/1` round-trip. Unblocks
|
||||
`Step 8b-start` (TCP listener spawn) and the curl-driven 9a-tcp / 9b-tcp
|
||||
smoke tests.
|
||||
|
||||
### Bringing up the kernel
|
||||
|
||||
@@ -149,12 +157,11 @@ the chain works.
|
||||
|
||||
In priority order:
|
||||
|
||||
1. **8b-bridge** — extend `er-bif-http-listen` with dict ↔ proplist marshalling
|
||||
so requests reach `route/1` shaped correctly.
|
||||
2. **8b-start** — `http_server:start/1` spawns a process hosting `http:listen/2`.
|
||||
3. **9a-tcp / 9b-tcp** — replace the in-process smoke scripts with curl-driven
|
||||
1. **8b-start** — `http_server:start/1` spawns a process hosting `http:listen/2`.
|
||||
(8b-bridge done — see Substrate gap #3.)
|
||||
2. **9a-tcp / 9b-tcp** — replace the in-process smoke scripts with curl-driven
|
||||
versions hitting the running server.
|
||||
4. **Term codec / on-disk log** — needs either a new BIF or a temp-file
|
||||
3. **Term codec / on-disk log** — needs either a new BIF or a temp-file
|
||||
workaround; current in-memory log keeps everything functional otherwise.
|
||||
5. **SX-source eval bridge** — unlocks real `:schema` / `:fold` body
|
||||
4. **SX-source eval bridge** — unlocks real `:schema` / `:fold` body
|
||||
evaluation from the genesis bundle.
|
||||
|
||||
Reference in New Issue
Block a user