Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
State shape becomes [{actors, [{Id, Bucket}, ...]}, {next_actor_seq, N}]
with ActorBucket = [{key_spec, KS}, {actor_state, AS}, {log, L},
{projections, [Name]}, {next_published, N}]. Pure-functional multi-
actor APIs (new/0, add_actor/4, has_actor/2, actors/1, actor_count/1,
publish/3, per-actor accessors, with_actor_projections/3) join the
legacy single-actor accessors, which now read from the first bucket.
Every M1 test continues to pass via bootstrap:start/3 -> new/3 ->
first-bucket lookup.
Local has_keyed/find_keyed/set_keyed/set_bucket helpers cover the
keyed-list ops since lists:keymember/keyfind aren't registered in
this substrate.
next/tests/nx_kernel_multi.sh 17/17. M1 nx_kernel-adjacent suites
green (bootstrap_start 10/10, nx_kernel_server 11/11, http_publish
10/10, smoke_app_pure 12/12, http_post_format 13/13, http_publish_fold
10/10, http_marshal 10/10). Erlang conformance 761/761 preserved.
Blockers entry added for pre-existing http_server_tcp.sh 0/5
regression (78eae9ef left dead helper references in runtime.sx:1593) —
substrate-side, out of m2 scope, confirmed pre-existing by reverting
1a's changes and re-running.
160 lines
7.8 KiB
Bash
Executable File
160 lines
7.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# next/tests/nx_kernel_multi.sh — m2 Step 1a tests.
|
|
#
|
|
# Pure-functional multi-actor bucket APIs. No gen_server.
|
|
|
|
set -uo pipefail
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}"
|
|
if [ ! -x "$SX_SERVER" ]; then
|
|
SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe"
|
|
fi
|
|
if [ ! -x "$SX_SERVER" ]; then
|
|
echo "ERROR: sx_server.exe not found." >&2
|
|
exit 1
|
|
fi
|
|
|
|
VERBOSE="${1:-}"
|
|
PASS=0; FAIL=0; ERRORS=""
|
|
TMPFILE=$(mktemp); trap "rm -f $TMPFILE" EXIT
|
|
|
|
# Two actors share the same signing-key bytes but have different ids;
|
|
# signatures verify because each carries the matching public_keys
|
|
# entry. AliceK / BobK distinguish them visually only.
|
|
PRELUDE='AliceK = <<1,2,3,4>>, AliceKS = [{key_id,k1},{algorithm,ed25519},{value,AliceK}], AliceAS = [{public_keys,[[{id,k1},{created,0},{value,AliceK}]]}], BobK = <<5,6,7,8>>, BobKS = [{key_id,k1},{algorithm,ed25519},{value,BobK}], BobAS = [{public_keys,[[{id,k1},{created,0},{value,BobK}]]}], Req = [{type,create},{object,nil}],'
|
|
|
|
cat > "$TMPFILE" <<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 "(get (erlang-load-module (file-read \"next/kernel/envelope.erl\")) :name)")
|
|
(epoch 3)
|
|
(eval "(get (erlang-load-module (file-read \"next/kernel/log.erl\")) :name)")
|
|
(epoch 4)
|
|
(eval "(get (erlang-load-module (file-read \"next/kernel/pipeline.erl\")) :name)")
|
|
(epoch 5)
|
|
(eval "(get (erlang-load-module (file-read \"next/kernel/outbox.erl\")) :name)")
|
|
(epoch 6)
|
|
(eval "(get (erlang-load-module (file-read \"next/kernel/nx_kernel.erl\")) :name)")
|
|
|
|
;; new/0 returns kernel with 0 actors
|
|
(epoch 10)
|
|
(eval "(erlang-eval-ast \"S = nx_kernel:new(), nx_kernel:actor_count(S)\")")
|
|
|
|
;; new/0 has next_actor_seq = 1
|
|
(epoch 11)
|
|
(eval "(erlang-eval-ast \"S = nx_kernel:new(), nx_kernel:next_actor_seq(S)\")")
|
|
|
|
;; new/0 has actor_id/1 = nil (legacy accessor returns nil with no actors)
|
|
(epoch 12)
|
|
(eval "(get (erlang-eval-ast \"S = nx_kernel:new(), nx_kernel:actor_id(S) =:= nil\") :name)")
|
|
|
|
;; add_actor returns {ok, NewState}
|
|
(epoch 13)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, _} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), ok\") :name)")
|
|
|
|
;; has_actor returns true after add
|
|
(epoch 14)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), nx_kernel:has_actor(alice, S)\") :name)")
|
|
|
|
;; actors/1 lists the new actor
|
|
(epoch 15)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), nx_kernel:actors(S) =:= [alice]\") :name)")
|
|
|
|
;; add_actor twice same id -> {error, already_present}
|
|
(epoch 16)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), case nx_kernel:add_actor(alice, AliceKS, AliceAS, S) of {error, already_present} -> ok; _ -> bad end\") :name)")
|
|
|
|
;; add two distinct actors -> both present
|
|
(epoch 17)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), nx_kernel:actors(S2) =:= [alice, bob]\") :name)")
|
|
|
|
;; next_actor_seq increments per add
|
|
(epoch 18)
|
|
(eval "(erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), nx_kernel:next_actor_seq(S2)\")")
|
|
|
|
;; publish/3 to known actor returns {ok, _, NewState}
|
|
(epoch 19)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), case nx_kernel:publish(alice, Req, S1) of {ok, _, _} -> ok; _ -> bad end\") :name)")
|
|
|
|
;; publish/3 advances only the named actor's log
|
|
(epoch 20)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), {ok, _, S3} = nx_kernel:publish(alice, Req, S2), AliceTip = nx_kernel:actor_log_tip(alice, S3), BobTip = nx_kernel:actor_log_tip(bob, S3), {AliceTip, BobTip} =:= {1, 0}\") :name)")
|
|
|
|
;; publish/3 to unknown actor -> {error, no_actor, State}
|
|
(epoch 21)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} S = nx_kernel:new(), case nx_kernel:publish(ghost, Req, S) of {error, no_actor, _} -> ok; _ -> bad end\") :name)")
|
|
|
|
;; Two actors maintain independent next_published counters
|
|
(epoch 22)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), {ok, _, S3} = nx_kernel:publish(alice, Req, S2), {ok, _, S4} = nx_kernel:publish(alice, Req, S3), {ok, _, S5} = nx_kernel:publish(bob, Req, S4), {ok, AliceN} = nx_kernel:actor_next_published(alice, S5), {ok, BobN} = nx_kernel:actor_next_published(bob, S5), {AliceN, BobN} =:= {3, 2}\") :name)")
|
|
|
|
;; actor_state/2 returns per-actor AS
|
|
(epoch 23)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), {ok, ASa} = nx_kernel:actor_state(alice, S2), {ok, ASb} = nx_kernel:actor_state(bob, S2), {ASa, ASb} =:= {AliceAS, BobAS}\") :name)")
|
|
|
|
;; with_actor_projections sets per-actor projection list
|
|
(epoch 24)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} {ok, S1} = nx_kernel:add_actor(alice, AliceKS, AliceAS, nx_kernel:new()), {ok, S2} = nx_kernel:add_actor(bob, BobKS, BobAS, S1), {ok, S3} = nx_kernel:with_actor_projections(alice, [px], S2), {ok, AliceP} = nx_kernel:actor_projections(alice, S3), {ok, BobP} = nx_kernel:actor_projections(bob, S3), {AliceP, BobP} =:= {[px], []}\") :name)")
|
|
|
|
;; Legacy new/3 + publish/2 still route to the single actor
|
|
(epoch 25)
|
|
(eval "(get (erlang-eval-ast \"${PRELUDE} S = nx_kernel:new(alice, AliceKS, AliceAS), {ok, _, S1} = nx_kernel:publish(Req, S), nx_kernel:log_tip(S1) =:= 1 andalso nx_kernel:actor_id(S1) =:= alice\") :name)")
|
|
EPOCHS
|
|
|
|
OUTPUT=$(timeout 240 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
|
|
|
check() {
|
|
local epoch="$1" desc="$2" expected="$3"
|
|
local actual
|
|
actual=$(echo "$OUTPUT" | awk -v e="$epoch" '
|
|
$0 ~ "^\\(ok-len " e " " { getline; print; exit }
|
|
$0 ~ "^\\(ok " e " " { print; exit }
|
|
$0 ~ "^\\(error " e " " { print; exit }
|
|
')
|
|
[ -z "$actual" ] && actual="<no output for epoch $epoch>"
|
|
if echo "$actual" | grep -qF -- "$expected"; then
|
|
PASS=$((PASS+1))
|
|
[ "$VERBOSE" = "-v" ] && echo " ok $desc"
|
|
else
|
|
FAIL=$((FAIL+1))
|
|
ERRORS+=" FAIL [$desc] (epoch $epoch) expected: $expected | actual: $actual
|
|
"
|
|
fi
|
|
}
|
|
|
|
check 6 "nx_kernel module loaded" "nx_kernel"
|
|
check 10 "new/0 -> 0 actors" "0"
|
|
check 11 "new/0 -> next_actor_seq = 1" "1"
|
|
check 12 "new/0 actor_id = nil" "true"
|
|
check 13 "add_actor returns {ok, NewState}" "ok"
|
|
check 14 "has_actor true after add" "true"
|
|
check 15 "actors/1 lists added actor" "true"
|
|
check 16 "duplicate add -> already_present" "ok"
|
|
check 17 "two distinct actors both present" "true"
|
|
check 18 "next_actor_seq increments" "3"
|
|
check 19 "publish/3 returns {ok, _, S}" "ok"
|
|
check 20 "publish/3 isolates per actor" "true"
|
|
check 21 "publish/3 unknown -> no_actor" "ok"
|
|
check 22 "independent next_published seqs" "true"
|
|
check 23 "actor_state/2 per-actor" "true"
|
|
check 24 "with_actor_projections per-actor" "true"
|
|
check 25 "legacy new/3 + publish/2 routes" "true"
|
|
|
|
TOTAL=$((PASS+FAIL))
|
|
if [ $FAIL -eq 0 ]; then
|
|
echo "ok $PASS/$TOTAL next/tests/nx_kernel_multi.sh passed"
|
|
else
|
|
echo "FAIL $PASS/$TOTAL passed, $FAIL failed:"
|
|
echo "$ERRORS"
|
|
fi
|
|
[ $FAIL -eq 0 ]
|