next: the real durable-execution KERNEL SERVICE (host_kernel) — RA-live substrate
Promotes the persistent-kernel spike into a real service. next/kernel/host_kernel.erl: boots flow_store, registers named behavior flows (blog_digest), then blocks in http:listen so the er-scheduler + gen_server stay alive across requests. Parameterised flow routes (paths matched by byte prefix — binary =:= is buggy): GET /flow/start/<category> starts the flow with that category and returns '<InstanceId>:<status>' (suspended|done); GET /flow/resume/<id> resumes that instance. Path plumbing (starts_with / last_seg / field) is byte-level for portability. next/kernel/serve.sh: the persistent service launcher (container entrypoint / local) — loads the runtime + next/flow + the kernel, then host_kernel:start(); sleep infinity holds stdin so the listener serves forever. next/tests/host_kernel.sh: drives it over HTTP — 4/4: newsletter → instance 1 SUSPENDED, urgent → 2 DONE, draft → 3 DONE (skipped), resume 1 in a SEPARATE request → DONE (durable state persists across requests). serve.sh launcher verified live (bind + start + resume). This is the RA-live substrate: a working durable-execution service the host drives over HTTP. Remaining for RA-live: deploy it (a container/placement), point host/ra.sx's real-eval at it (POST /flow instead of in-process erlang-eval-ast), route a durable binding to RA. TA-live adds inbox/ outbox routes on the same kernel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
40
next/kernel/serve.sh
Executable file
40
next/kernel/serve.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# next/kernel/serve.sh — run host_kernel as a PERSISTENT durable-execution service (RA-live substrate).
|
||||
# Loads the Erlang-on-SX runtime + next/flow + the kernel, then host_kernel:start($KERNEL_PORT) blocks
|
||||
# in http:listen forever — keeping the er-scheduler + flow_store's gen_server alive so durable flow
|
||||
# instances survive across requests. Doubles as a container entrypoint and a local launcher. The host's
|
||||
# RA runner drives it over HTTP (GET /flow/start/<category>, GET /flow/resume/<id>).
|
||||
set -uo pipefail
|
||||
cd "${SX_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || echo .)}"
|
||||
|
||||
SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}"
|
||||
[ -x "$SX_SERVER" ] || SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe"
|
||||
if [ ! -x "$SX_SERVER" ]; then echo "ERROR: sx_server.exe not found." >&2; exit 1; fi
|
||||
PORT="${KERNEL_PORT:-8930}"
|
||||
|
||||
# The epoch stream loads everything then calls start (which blocks in http:listen). `sleep infinity`
|
||||
# holds stdin open so EOF doesn't exit(0) before/while the listener serves.
|
||||
{
|
||||
cat <<EPOCHS
|
||||
(epoch 1)
|
||||
(load "lib/erlang/tokenizer.sx")
|
||||
(load "lib/erlang/parser.sx")
|
||||
(load "lib/erlang/parser-core.sx")
|
||||
(load "lib/erlang/parser-expr.sx")
|
||||
(load "lib/erlang/parser-module.sx")
|
||||
(load "lib/erlang/transpile.sx")
|
||||
(load "lib/erlang/runtime.sx")
|
||||
(load "lib/erlang/vm/dispatcher.sx")
|
||||
(epoch 2)
|
||||
(eval "(er-load-gen-server!)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/kernel/envelope.erl\")) :name)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/flow/flow.erl\")) :name)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/flow/flow_spec.erl\")) :name)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/flow/flow_store.erl\")) :name)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/flow/flows/blog_publish_digest.erl\")) :name)")
|
||||
(eval "(get (erlang-load-module (file-read \"next/kernel/host_kernel.erl\")) :name)")
|
||||
(epoch 3)
|
||||
(eval "(erlang-eval-ast \"host_kernel:start($PORT)\")")
|
||||
EPOCHS
|
||||
sleep infinity
|
||||
} | exec "$SX_SERVER"
|
||||
Reference in New Issue
Block a user