host RA: the Erlang durable runner adapter — built + tested (module + integration)

lib/host/ra.sx — a PURE-SX seam runner (advertises {effect,branch,each,suspend}) with an INJECTED
erl-eval (real = er-to-sx-deep ∘ erlang-eval-ast; mock in unit tests), so it loads in the plain host
(Erlang refs resolve lazily inside lambdas) and is unit-testable without the Erlang runtime.
host/ra--{atom,bin,erl-src,start-expr,resume-expr,parse,make-runner,resume,real-eval}: marshals our
canonical activity → Erlang source (CID as <<"…">> binary, atoms single-quoted), starts a named
next/ flow via flow_store, parses (ok Id (flow_done V))→{:status done :effects V :flow-id} /
(ok Id (flow_suspended T))→{:status suspended :resume {:id :tag}}.

DUAL-RUNNER ROUTING (flows.sx): host/flow--required-caps now handles a {:erl-flow :needs} DAG
(declared caps, since a foreign flow can't be introspected); host/flow--select-runner picks the
cheapest runner whose capabilities cover the DAG's needs. The capability model is now REAL with two
runners — an {effect,branch} composition lands on exec-runner; a {suspend} DAG routes to RA.

Verified: ra 9/9 (mock erl-eval) + plans/ra-integration.sh 4/4 (the REAL module driving live
flow_store: urgent→done, newsletter→suspended with a resume handle, digest_sent effect-as-data).
Full host conformance 607/607; next/tests/triggers_e2e.sh 10/10 baseline intact.

FINDING → RA-LIVE deferred: gen_servers don't persist across separate erlang-eval-ast calls (flow
README), so true cross-call suspend/resume needs a PERSISTENT next/ kernel process. The runner +
marshalling + suspend/resume mechanics are proven; RA-live is process lifecycle + wiring, documented.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 16:20:36 +00:00
parent 17602e597f
commit c21be815f3
7 changed files with 245 additions and 14 deletions

View File

@@ -225,14 +225,29 @@ driven from SX. KEY FINDINGS for the build: erlang-eval-ast returns Erlang TERMS
raw, atoms as {:tag atom :name …}) — the runner must parse results, not assume :name; flow_store
start→{done,V}|{suspended,Tag}, resume(Id,Res) maps 1:1 onto {:status done|suspended :effects :resume};
the flow instance Id is the resume handle.
- [ ] Build the RA runner (a seam {:capabilities #{effect,branch,each,suspend} :run}): marshal via
host/blog--activity->erl → Erlang source; flow_store:start (or apply_triggers) via erlang-eval-ast;
parse {done,V}→{:status done :effects V} / {suspended,Tag}→{:status suspended :resume {id,tag}}.
- [ ] REMAINING (beyond the spike): (a) load the Erlang runtime + next/flow into the serving process
(big serve.sh dependency) OR run RA out-of-process; (b) DEBT #3 — async boundary: dispatch off the
request path, a background loop drives resume + behavior/pump; (c) real CID→binary marshalling
(spike used atom ids); (d) structured result parsing (Erlang term → SX effects). Baseline still
green: next/tests/triggers_e2e.sh 10/10.
- [x] **RA RUNNER BUILT + TESTED (module + integration) 2026-07-02.** lib/host/ra.sx — a PURE-SX
seam runner (advertises {effect,branch,each,suspend}) with an INJECTED erl-eval (real =
er-to-sx-deep ∘ erlang-eval-ast; mock in unit tests), so it loads in the plain host and is testable
without the Erlang runtime. host/ra--{atom,bin,erl-src,start-expr,resume-expr,parse,make-runner,
resume,real-eval}: marshals our canonical activity → Erlang source (CID as <<"…">> binary, atoms
single-quoted), starts flow_store, parses (ok Id (flow_done V))→{:status done :effects V :flow-id} /
(ok Id (flow_suspended T))→{:status suspended :resume {:id :tag}}. DUAL-RUNNER ROUTING in flows.sx:
host/flow--required-caps handles a {:erl-flow :needs} DAG (declared caps); host/flow--select-runner
picks the cheapest runner covering the DAG's needs — the capability model is now REAL (2 runners:
an {effect,branch} composition → exec-runner; a {suspend} DAG → RA). ra 9/9 (mock) + plans/
ra-integration.sh 4/4 (the REAL module driving live flow_store: urgent→done, newsletter→suspended
with resume handle, effect-as-data carried). Full host conformance green. next/tests/triggers_e2e.sh
10/10 baseline intact.
- [ ] **RA-LIVE (deferred — the deployment step, prerequisite now PRECISE).** KEY FINDING: gen_servers
do NOT persist across separate erlang-eval-ast calls (flow README: "the scheduler doesn't preserve
spawned processes across separate erlang-eval-ast invocations"). So a boot-per-call proves the
module (done), but TRUE async (suspend → return the request → resume LATER in another call) needs a
PERSISTENT next/ kernel PROCESS holding flow_store — the async boundary (DEBT #3) is deeper than
"off the request path". REMAINING: (a) stand up a long-lived next/ kernel (nx_kernel/http_server
already run persistently for TCP) that RA talks to; (b) wire a DURABLE behavior binding ({:erl-flow
"blog_digest" :needs (effect branch suspend)}) into the live publish engine, routed to RA via
select-runner; (c) the resumed completion re-enters via the transport inbound + behavior/pump.
The runner + marshalling + suspend/resume mechanics are all proven; this is process lifecycle + wiring.
## TA — the FED-SX TRANSPORT adapter ← federation proper
- [ ] A seam transport over next/ delivery: :emit → outbox → peers; :deliver → inbox. A remote
@@ -267,6 +282,16 @@ covers everything until a DAG's cost/latency/placement forces the substrate.
activities), so business logic can change state, which federates, which triggers more flows.
## Progress log (newest first)
- 2026-07-02 — RA RUNNER BUILT + tested (module + integration). lib/host/ra.sx = a pure-SX seam
runner with injected erl-eval (loads in the plain host, mock-testable); marshals our activity →
Erlang, drives flow_store, parses done/suspended → the runner contract. Dual-runner ROUTING in
flows.sx (host/flow--select-runner + required-caps for {:erl-flow :needs} DAGs) makes the capability
model REAL (2 runners). ra 9/9 (mock) + plans/ra-integration.sh 4/4 (REAL module → live flow_store).
Full host conformance 607/607. FINDING: gen_servers don't persist across erlang-eval-ast calls, so
RA-LIVE (true cross-call suspend/resume) needs a persistent next/ kernel process — the async
boundary is deeper than "off the request path". Runner mechanics fully proven; RA-live = lifecycle
+ wiring. NEXT: RA-live (persistent kernel + a durable binding wired to RA), or P1 (capability model
is now real, so it's no longer vacuous).
- 2026-07-02 — RA SPIKE DONE → RA is VIABLE (plans/ra-spike.sh, 4/4). From SX: our canonical activity
serializes to valid Erlang, drives blog_publish_digest through flow_store (done + suspend + resume),
no er-scheduler deadlock. De-risks the whole durable/federated half. Findings: erlang-eval-ast