aether

A polyglot distributed actor/OTP runtime over NATS. A lord (supervisor) spawns
thralls (genservers) as OS processes and lets them communicate in the ether (NATS).
If you know OTP, that is all you need: the lord is a supervisor, a thrall is a
GenServer (or a gen_statem / gen_event behaviour), and the ether is the message
transport. The names are flavor; the model is plain supervision-and-genservers - here over NATS
and across languages.
The goal: an SDK that makes it very easy to write thralls and run a lord. Not BEAM-scale
(millions of processes), but tens of processes that communicate reliably - in any language
and with real OS-process isolation.
Full design: DESIGN.md. License: MIT. Contributing:
CONTRIBUTING.md. Roadmap and deliberately deferred work: ROADMAP.md.
Glossary
| term |
meaning |
OTP counterpart |
| ether |
the bus - embedded NATS or an external cluster |
message transport |
| lord |
the supervisor - spawns and watches thralls, restarts them per strategy |
Supervisor |
| thrall |
the genserver - state + serialized message processing |
GenServer |
Features
Everything below is implemented and exercised for real (see the manifests in examples/counter/).
| Area |
Status |
Detail |
| Spawn |
✅ |
The lord starts thralls as OS processes, injects the AETHER_* env, watches their exit code |
| Polyglot SDK |
✅ |
TS/Bun, Python, Go - the same wire contract, indistinguishable to the lord |
| Messaging |
✅ |
call (sync request/reply), cast (fire-and-forget), a serialized mailbox |
| Behaviours |
✅ |
GenServer thrall (Def / defThrall), a state-machine thrall (FSM / defFSM, a gen_statem analogue - see State machine) and an event manager (EventManager / defEvent, a gen_event analogue - see Event manager) |
| Supervision |
✅ |
one_for_one, one_for_all, rest_for_one + a restart-intensity window + backoff |
| Graceful drain |
✅ |
ctl:drain -> the thrall finishes its mailbox -> terminate -> escalation to SIGTERM/SIGKILL |
| Lord-liveness fencing |
✅ |
no thrall survives its lord: every thrall verifies a KV lease and self-terminates when its lord dies, even on an external SIGKILL where the process-group kill never runs |
| Observability |
✅ |
Structured logs (lord + all SDKs), a Prometheus /metrics endpoint, heartbeat miss detection, cross-process tracing - see Observability |
| Durable mailbox |
✅ |
durable=true -> casts survive a thrall crash (JetStream). TS + Python + Go. What survives a restart: see Durability |
| Event-sourced rebuild |
✅ |
event_log=true -> Append events to a retention log, Rebuild state from it in init - state survives a restart by replaying the log, not a snapshot. See Event-sourced rebuild |
| External NATS |
✅ |
mode="external" is purely a config switch - the same stack against a real cluster |
| Singleton |
✅ |
scope="singleton" -> a distributed KV-CAS lock + failover: at most one live instance (overlap bounded by the lock TTL), not a strict single-writer - see Singleton fencing |
| Dynamic supervisor |
✅ |
ctx.StartChild(spec) / ctx.StopChild(name) -> spawn/stop thralls at runtime, supervised one_for_one, outside manifest groups; idempotent on name |
| HTTP edge (ingress) |
✅ |
[[edge.http]] -> a built-in HTTP server maps routes to a thrall op (call/cast) with no code, supervised as a singleton thrall - see HTTP edge |
Restart policy per thrall: permanent / transient / temporary.
Dynamic children live only in the running lord and do not survive a lord restart by
design - re-establishing them is the owner's job, not the lord's. Because StartChild is
idempotent on name, a supervising thrall can re-spawn its children blindly from its own
init (and re-apply on demand) with no duplicates. Runnable demo:
examples/dynamic-topology/ (Go/TS/Python); rationale in DESIGN.md section 12.
Layout
cmd/aether/ CLI: up | ps | events | cast | call
internal/
ether/ embedded NATS / external connection (mode switch)
lord/ supervisor: manifest, supervisor loop, restart strategies,
graceful drain, durable stream provisioning, singleton lock
registry/ JetStream KV registry (name -> pid/status)
singleton/ distributed lock over KV (Create/CAS + TTL failover)
obs/ structured logging + the metric registry (Prometheus exposition)
soak/ bounded latency/leak metric primitives for the soak suite
wire/ envelope + subject/stream conventions (Go side, shared with the SDKs)
sdk/ts/ @hamicek/aether (Bun/TS): defThrall/start + defFSM/startFSM + defEvent/startEvent, call, cast
sdk/python/ aether.py: def_thrall/start/run + FSM/start_fsm/run_fsm + def_event/start_event/run_event
sdk/go/thrall/ thrall.Def[S]/Start (GenServer) + thrall.FSM[D]/StartFSM (state machine) + thrall.EventManager/StartEvent (event manager)
examples/counter/ counter (TS/Py/Go) + gateway + a manifest per scenario
examples/fsm/ state-machine (FSM) behaviour demo - a turnstile
examples/eventbus/ event-manager (gen_event) behaviour demo - one event, many handlers
examples/eventsourced/ event-sourced rebuild demo - state that survives a restart
examples/dynamic-topology/ dynamic children re-established by their owner after a lord restart
scripts/soak.sh run the soak/chaos suite (out of CI)
Subject convention
aether.<app>.<name>.call # request/reply (call)
aether.<app>.<name>.cast # fire-and-forget (cast); for durable thralls a JetStream stream captures it
aether.<app>.<name>.info # out-of-band (timers, notifications)
aether._lord.<name>.ctl # lord -> thrall (drain / shutdown / ping)
aether._lord.<name>.hb # thrall -> lord (heartbeat)
aether._lord.events # lifecycle stream (spawned/ready/down/restarting/...)
aether_<app>_<name> # JetStream stream for the durable mailbox (dots -> underscores)
CLI
aether up -f <manifest> # bring up the ether + the lord per the manifest
aether ps [--url <nats>] # a table of thrall status from the KV registry
aether events [--url <nats>] # the live lifecycle stream
aether cast <name> <op> [json] # send a cast to a thrall
aether call <name> <op> [json] # send a call and print the reply
In embedded mode ps/events/cast/call connect via .aether-endpoint
(written by aether up); against an external cluster via --url. For a secured
external bus (server TLS + nkeys) pass --ca <file> / --nkey <seed> (or the
AETHER_NATS_CA / AETHER_NATS_NKEY_SEED env); each layers flag > .aether-endpoint
env. Against a secured cluster aether up writes the credential paths into
.aether-endpoint, so the other tools pick them up automatically.
A thrall in TS (example)
import { defThrall, start } from "@hamicek/aether";
const counter = defThrall<number>({
name: process.env.AETHER_NAME ?? "counter",
init: () => 0,
handleCall: { get: (_p, s) => [s, s] }, // [reply, newState]
handleCast: { inc: (_p, s) => s + 1, dec: (_p, s) => s - 1 },
terminate: (reason, s) => console.log(`counter exiting (${reason}), last value = ${s}`),
});
await start(counter);
The same thrall also exists in counter_py.py (Python) and counter_go.go (Go) - functionally
identical. Durability is purely a manifest concern (durable = true), not thrall code.
State machine (FSM) behaviour
Alongside the GenServer thrall, a thrall can be a finite state machine - aether's analogue
of OTP's gen_statem. Instead of a state field and a switch in a cast handler, you declare
named states and per-op reactions; the SDK dispatches an event to the current state's reaction,
applies the transition, and serializes everything through the same mailbox (so the machine's
data needs no locks). Reactions may carry a guard, and a state may arm a state timeout.
Events are ordinary call/cast, so an FSM thrall interoperates with any caller; a reserved
_state call op reports the current state.
fsm := thrall.FSM[int]{
Name: "turnstile", Initial: "locked",
Init: func(*thrall.Ctx) (int, error) { return 0, nil },
States: map[string]thrall.State[int]{
"locked": {On: map[string]thrall.Reaction[int]{
"coin": {Fn: func(_ thrall.Event, pushes int, ctx *thrall.Ctx) (thrall.Outcome[int], error) {
return thrall.Outcome[int]{Next: "unlocked", Data: pushes}, nil
}},
}},
"unlocked": {
On: map[string]thrall.Reaction[int]{
"push": {Fn: func(_ thrall.Event, pushes int, ctx *thrall.Ctx) (thrall.Outcome[int], error) {
return thrall.Outcome[int]{Next: "locked", Data: pushes + 1, Reply: pushes + 1}, nil
}},
"autolock": {Fn: func(_ thrall.Event, pushes int, ctx *thrall.Ctx) (thrall.Outcome[int], error) {
return thrall.Outcome[int]{Next: "locked", Data: pushes}, nil
}},
},
Timeout: &thrall.StateTimeout[int]{After: 5 * time.Second, Op: "autolock"}, // idle -> autolock
},
},
}
thrall.StartFSM(fsm)
An event with no reaction in the current state is rejected (no_transition), not silently lost.
The FSM is deliberately domain-neutral - a lifecycle/alarm automaton is built on top of it, not
inside it. Mirrored in all three SDKs (startFSM/defFSM in TS, start_fsm/FSM in Python).
Runnable demo: examples/fsm/.
Event manager (gen_event) behaviour
The third behaviour is an event manager - aether's analogue of OTP's gen_event. Instead of
one state and one handler, you register several named handlers; one incoming event (an async
cast to the manager's name) is dispatched to every handler, in registration order, on the
same serialized mailbox - so handlers see events in a stable order and each keeps its own state.
That is what raw NATS fan-out (N independent subscribers) does not give: co-located, ordered
handlers. A handler that throws is logged and skipped, so the others still run.
import { defEvent, startEvent } from "@hamicek/aether";
const alarms = defEvent({
name: "alarms",
handlers: {
audit: { // counts every alarm in its own state
init: () => ({ count: 0 }),
handleEvent: (ev, s: { count: number }, ctx) => {
const count = s.count + 1;
ctx.log.info("alarm audited", { op: ev.op, total: count });
return { count };
},
},
pager: { // reacts only to a hot temperature
init: () => ({}),
handleEvent: (ev, s, ctx) => {
const p = (ev.payload ?? {}) as { celsius?: number };
if (ev.op === "temp_high" && (p.celsius ?? 0) >= 80) ctx.log.warn("would page on-call");
return s;
},
},
},
});
await startEvent(alarms);
Events are async: a call to an event manager is answered with an error rather than a silent
timeout (synchronous events and runtime add/remove of handlers are deliberate follow-ups). Mirrored
in all three SDKs (startEvent/defEvent in TS, start_event/def_event in Python,
StartEvent/EventManager in Go). Runnable demo: examples/eventbus/.
Manifest (example)
app = "demo"
strategy = "one_for_one" # | one_for_all | rest_for_one
restart_intensity = { max = 3, within_ms = 5000 }
[nats]
mode = "embedded" # | external (+ url = "nats://...")
# store_dir = "./.aether-store" # embedded only: persist the durable mailbox across restarts
[[thrall]]
name = "counter"
cmd = "bun run ./counter.ts"
restart = "permanent" # | transient | temporary
scope = "local" # | singleton
durable = false # true -> cast over JetStream
# fencing = false # opt out of lord-liveness fencing (see below)
By default every thrall self-terminates when it can no longer verify its lord's lease, so no
thrall outlives its lord. On a shared external bus a KV hiccup then reaps the whole tree. Set
fencing = false on a thrall whose orphan is harmless (a stateless / read-only poller) so a bus
blip does not take it down - it then may outlive its lord, so use it only for thralls that own
nothing. Singleton fencing (one instance per cluster) is separate and stays on.
HTTP edge (ingress)
An edge is a process whose input arrives from outside the ether (a push - HTTP) rather than
from a mailbox (a pull). A [[edge.http]] section maps HTTP routes to a thrall operation with no
code - the lord runs a built-in aether _edge server for it, supervised as a singleton thrall
(heartbeat, restart, drain, fencing):
[[edge.http]]
name = "api"
addr = ":8080"
route."GET /value" = { thrall = "counter", op = "get", kind = "call" } # waits for the reply -> body
route."POST /increment" = { thrall = "counter", op = "inc", kind = "cast" } # fire-and-forget -> 202
[[edge.http]] # multiple servers, each on its own port, in one manifest
name = "admin"
addr = ":8081"
route."POST /decrement" = { thrall = "counter", op = "dec", kind = "cast" }
A call route returns the thrall's reply as the body (200); a cast route returns 202. Errors map
deterministically: application error -> 502, no responders -> 503, reply timeout -> 504, unknown
route -> 404. A real port is held by one active instance (singleton); aether does no load balancing -
put a reverse proxy in front to scale a single port. Runnable demo: examples/webserver/.
Custom edge (you write the code). When a route cannot be expressed as configuration - custom auth,
transformation, a non-HTTP protocol (a SCADA driver, cron, tail) - write the edge yourself via
StartEdge / startEdge / start_edge (Go, TS and Python SDK): you supply a run-loop that owns the
socket and a graceful-stop hook, and get heartbeat/restart/drain/fencing for free. A custom edge is an
ordinary [[thrall]] with a cmd, so it coexists with the built-in ingress in one manifest - and a TS or
Python edge is indistinguishable from a Go edge under the same lord. Demos: examples/webserver-custom/
(main.go, edge.ts, edge.py). SSEStream (live push) has the same full Go+TS+Python parity - edge is
polyglot across all three SDKs. Design: DESIGN.md §12b.
thrall.StartEdge(thrall.EdgeDef{
Init: func(ctx *thrall.Ctx) error { /* build the http.Server */ return nil },
Run: func(ctx *thrall.Ctx, stop <-chan struct{}) error {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
return err // a real error -> abnormal exit -> the lord restarts; ErrServerClosed is a clean drain
}
return nil
},
Stop: func() { srv.Shutdown(context.Background()) }, // graceful hook on drain
})
Live push to the browser (SSE). The reverse flow - ether -> browser. thrall.SSEStream lets an edge
push events out over Server-Sent Events, scoped per client: your handler authorizes the request and
passes the authorized subject scope to ServeClient, which gives that connection its own NATS
subscription - so NATS never delivers a client an out-of-scope event. Backpressure drops for a slow
client; Close drains live connections. Read-only (control goes through ingress); reconnect is the
browser's EventSource retry with no server-side replay. Demo: examples/live-dashboard/ (two clients,
each streaming only its own site).
stream := thrall.NewSSEStream(ctx)
mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) {
scope := authorize(r) // your code: verify a token -> subject scope
if scope == nil { http.Error(w, "unauthorized", 401); return }
stream.ServeClient(w, r, scope...) // holds the SSE connection, forwards only that scope
})
// on drain: stream.Close(); srv.Shutdown(ctx)
Durability
durable = true means a cast is not lost if the thrall crashes before handling it - it does
not mean the thrall's state is remembered (a restart runs a clean init, like OTP). How long the
durable mailbox survives depends on where JetStream stores it:
| Mode |
Config |
Survives a thrall crash |
Survives a lord/process restart |
| embedded, ephemeral (default) |
mode="embedded" |
✅ |
❌ (temp dir wiped on Stop) |
| embedded, persistent |
mode="embedded" + store_dir |
✅ |
✅ (same host, same dir) |
| external, persistent |
mode="external" |
✅ |
✅ (independent of the app host) |
Use store_dir for a single-host deployment that must keep the mailbox across restarts (see
examples/counter/aether-durable-persistent.toml); use external NATS when durability must be
independent of the application host. Full model: DESIGN.md §13.
Event-sourced rebuild
The durable mailbox keeps messages, not state - a restarted thrall runs a clean init. To
make state survive a restart, opt a thrall into an event log and rebuild from it: "the
log is truth, state is a projection". The event log is a separate retention stream (kept, so
it can be replayed), independent of the WorkQueue mailbox; the lord provisions it when the
manifest sets event_log = true.
[[thrall]]
name = "account"
cmd = "../../bin/account"
event_log = true
# event_log_max_msgs = 100000 # optional retention bounds - see the caveat below
# event_log_max_age_ms = 604800000
Retention vs rebuild. Rebuild folds the whole log, and there is no snapshot or
compaction (yet). So a retention bound silently truncates the rebuilt state once it purges old
events - safe for an audit-only log, wrong as a rebuild source. The lord logs a warning at
startup when event_log is combined with a bound; leave the log unbounded if you rebuild from
it.
A thrall Appends domain events as it handles messages, and Rebuilds its state from the log
in init (works for both the GenServer and the FSM behaviour, since both have an init):
Init: func(ctx *thrall.Ctx) (account, error) {
// replay the log into the balance; empty log -> the initial value
return thrall.Rebuild(ctx, account{}, apply)
},
HandleCast: map[string]thrall.CastFn[account]{
"deposit": func(payload json.RawMessage, acc account, ctx *thrall.Ctx) (account, error) {
ctx.Append(delta{Delta: amount}) // persist first (the log is the truth)
acc.Balance += amount
return acc, nil
},
},
Replay is ordered, and complete as long as retention keeps the whole log (single-writer = append
order). Because the mailbox is at-least-once, the fold must be idempotent (an event may be
replayed). A non-idempotent event (a signed delta, not "set to X") needs more: pass a dedup key
to Append - typically ctx.MsgID, the id of the message being handled - so a redelivered
command does not write the event twice (within the stream's duplicate window). See the
command-key pattern in DESIGN §13c. With a persistent JetStream (store_dir or
external), the rebuilt state survives stopping and starting aether up. Mirrored in all three
SDKs (ctx.append + rebuild in TS/Python). Snapshots and compaction are future work. Runnable
demo: examples/eventsourced/ (a bank account whose balance survives a restart).
Singleton fencing (liveness, not write-exclusivity)
A scope="singleton" thrall holds a KV-CAS lock, and if it loses that lock (a new holder took it,
or it cannot reach the KV past the lease) it self-terminates. That bounds the window in which
two instances are alive to the lock TTL - which is what the soak suite measures, and what
lord/orphan failover needs.
It is not a strict single-writer guarantee. A lease plus self-termination can never be, per
Kleppmann's fencing argument:
between a lease expiring (a new holder starting) and the old, e.g. GC-paused, instance noticing
and exiting, the old instance can still issue a write. The guarantee is "at most one live
instance, overlap ≤ lock TTL", not "exactly one writer".
If you need strict single-writer against a resource (a PLC, a driver, a DB), enforce a fencing
token at that resource: the lord stamps a monotonic epoch into the lock, and a handler reads it
as ctx.SingletonEpoch (ctx.singletonEpoch / ctx.singleton_epoch, 0 for a non-singleton).
Send it with every write and have the resource reject a lower epoch, so a stale writer is fenced
out even if it has not yet self-terminated. Runnable demo in all three languages:
examples/fencing-token/.
Observability
The runtime reports on itself so a remote deployment can answer "why isn't it working" without
guessing. Three layers, all configured through the manifest and environment:
Structured logs. The lord and all three SDKs log as machine-parseable records with levels,
tagged with component / app / name so lord and thrall lines are tellable apart on a shared
stream. Configured by environment, and the lord injects the same config into every thrall so the
whole tree logs consistently:
AETHER_LOG_LEVEL=debug # debug | info | warn | error (default info)
AETHER_LOG_FORMAT=json # json | text (default text, for dev)
Metrics. Enable the Prometheus endpoint in the manifest (off by default):
[observability]
metrics_addr = "127.0.0.1:7391" # empty / omitted = disabled
dashboard = true # also serve the read-only observer dashboard at / (off by default)
Then scrape http://127.0.0.1:7391/metrics. The endpoint is the lord's own HTTP server, so it
works the same embedded or external. Exposed series:
| Metric |
Type |
Meaning |
aether_up |
gauge |
1 while the lord is running |
aether_thralls{status} |
gauge |
thralls by current status (starting/ready/down/stale) |
aether_restarts_total{name} |
counter |
restarts per thrall |
aether_gave_up_total{name} |
counter |
thralls the lord stopped restarting (intensity exceeded) |
aether_heartbeat_misses_total{name} |
counter |
detected heartbeat outages |
aether_mailbox_depth{name} |
gauge |
messages a thrall currently holds (self-reported) |
aether_mailbox_latency_ms{name} |
gauge |
most recent handler duration (self-reported) |
aether_processed_total{name} |
counter |
messages a thrall has processed (self-reported) |
aether_durable_backlog{name} |
gauge |
pending casts in a durable thrall's stream (JetStream num_pending) |
aether_thrall_rss_bytes{name} |
gauge |
thrall resident memory, summed over its process group |
aether_thrall_cpu_percent{name} |
gauge |
thrall CPU usage %, a delta over the sample interval, summed over its process group |
Thralls report their own mailbox metrics on the heartbeat they already send every 2s; the lord
aggregates them plus its own supervision counters. A thrall that stops heart-beating is marked
stale and counted (aether_heartbeat_misses_total) even though its process is still alive.
Tuning liveness detection. The heartbeat interval and how many misses count as stale are
configurable, so a latency-sensitive deployment can detect a hung thrall faster than the default
~6s. The lord injects the interval into the thralls and derives its own reaper threshold from the
same value, so the two never drift:
[liveness]
heartbeat_interval_ms = 500 # default 2000
stale_after_misses = 2 # default 3 -> stale after 1s instead of 6s
(Process death is already detected instantly by the OS watcher; this tunes detection of the
hung-but-alive case. Faster connection-loss detection via NATS $SYS events is future work,
relevant to a networked topology where thralls connect over a network rather than to a local
embedded NATS.)
Tracing. The envelope carries a trace correlation id propagated across call/cast hops:
an edge (the CLI, or the first message) mints it, ctx.Call / ctx.Cast pass it downstream, and
it appears in the logs - so one logical operation can be followed across processes. See
examples/tracing/ for a runnable two-thrall demo.
Observer dashboard. A read-only web view of the supervision tree, aether's analogue of
Erlang's observer / Phoenix LiveDashboard. Enable dashboard = true (it shares the /metrics
server, so it needs metrics_addr) and open http://127.0.0.1:7391/. It shows the live tree -
each thrall's status (starting/ready/down/stale), scope, restart policy, durable/
event_log flags and self-metrics (memory/CPU, mailbox depth/latency, processed, durable backlog, restarts) -
and a live event feed pushed over SSE from the lifecycle stream, so the tree updates within ~1s of
a spawn/crash/restart without a page refresh. It is a consumer of signals the lord already holds
(no SDK change) and works the same embedded or external. It deliberately does not chart metrics
over time - that stays the domain of Prometheus/Grafana, which /metrics feeds - and it is
read-only (no control actions). The page is self-contained (no external assets), so it works
offline. Like /metrics, it binds wherever metrics_addr says (default a loopback address);
exposing it on a network needs authentication (a follow-up).
Quickstart
The default demo (aether.toml) is polyglot, so it needs Go, Bun and Python. Build the runtime
and the Go thrall, then set up the Bun and Python sides:
# 1) build the runtime and the Go counter thrall
go build -o bin/aether ./cmd/aether
go build -o bin/counter-go ./examples/counter
# 2) TypeScript workspace
bun install
# 3) Python thrall dependency
cd examples/counter
python -m venv .venv
.venv/bin/pip install -r requirements.txt
cd ../..
# 4) run it
cd examples/counter
../../bin/aether up -f aether.toml
# the gateway prints, once per second: counter=N counter-py=N counter-go=N
If go tries to download a different toolchain, prefix the build with GOTOOLCHAIN=local.
Sample manifests in examples/counter/ (each runs with any of the three languages - the
thrall name comes from the manifest):
aether.toml - the default polyglot demo (TS + Python + Go + gateway)
aether-durable.toml - durable mailbox (embedded), survives a thrall restart
aether-durable-persistent.toml - durable mailbox with a persistent embedded JetStream (store_dir)
aether-durable-poly.toml - durable mailbox in both Python and Go
aether-external.toml - against a standalone NATS cluster (7390)
aether-external-durable.toml - durable mailbox on the external cluster (stream + KV off-runtime)
aether-observability.toml - polyglot demo with the /metrics endpoint enabled
aether-singleton.toml - singleton scope with distributed-lock failover (external cluster)
aether-one-for-all.toml - the one_for_all supervision strategy
aether-rest-for-one.toml - the rest_for_one supervision strategy
aether-secure-external.toml - external cluster over TLS with nkey auth
Security
By default the embedded server binds 127.0.0.1 and is meant for a trusted single host. To run
against a networked / shared NATS, connect over TLS with nkey authentication: add a [nats.tls]
CA and a [nats.auth] nkey seed to the manifest. The lord authenticates with them and injects the
paths (not the secrets) into every thrall, so all three SDKs connect the same secured way.
[nats]
mode = "external"
url = "tls://nats.internal:4222"
[nats.tls]
ca = "/etc/aether/ca.pem" # verify the server (server TLS)
[nats.auth]
nkey_seed = "/etc/aether/user.nk" # authenticate (nkey)
Secrets are passed by file path, never as an env value - the nkey seed never appears in ps or
the process environment. A full example is examples/counter/aether-secure-external.toml.
Python thralls using nkey auth need the optional nkeys package (plain nats-py omits it):
pip install 'nats-py[nkeys]'.
Scope: this secures the client side against an already-secured external NATS (server TLS + nkeys),
including the operator CLI (--ca/--nkey). Securing the embedded server itself (for a networked
0.0.0.0 bind), mutual TLS, JWT/account isolation and token auth are follow-ups tracked in
ROADMAP.md.
Reliability testing (soak)
For high-reliability use (e.g. SCADA) the functional integration tests are not enough - they run for
seconds and cannot surface leaks, message loss under pressure or latency drift. The soak suite drives
the runtime under an hours-long load and checks it against concrete bars. It lives behind the soak
build tag, so normal CI (go test ./...) never runs it; you invoke it explicitly:
scripts/soak.sh smoke # ~2 min - all scenarios, a quick end-to-end check
scripts/soak.sh default chaos # ~45 min - one scenario (all|load|chaos|drain|singleton)
scripts/soak.sh overnight singleton # ~8 h
scripts/soak.sh smoke 12345 # a fixed seed for a reproducible run
# ad-hoc: override the length, write the report to a file
AETHER_SOAK_DURATION=30s AETHER_SOAK_REPORT=soak.txt scripts/soak.sh smoke
Each timed scenario runs for the profile duration (so all at a long profile is long - pick a single
scenario for default/overnight). The suite measures:
- Sustained load - a concurrent
call stream; bar: p99 < 50ms and no upward latency trend.
- Durable no-loss - a durable cast stream over JetStream; bar: every stored cast delivered
(zero loss); duplicates are counted and tolerated.
- Leak detection - the lord's goroutines and heap plus a sample of thrall RSS; bar: < 10% growth
after warm-up. (On a run too short to warm up, the deltas are reported but not enforced.)
- Chaos - random thralls are
SIGKILLed under load; bar: recovery per strategy < 3s, with durable
delivery lossless through the kills (checked server-side by the stream draining to zero).
- Singleton failover - two lord nodes (OS processes) race for a singleton; the holder's node is
killed repeatedly; bar: failover < 5s and never more than one live instance (fencing - a
liveness bound, not write-exclusivity; see Singleton fencing).
- Graceful drain - a durable thrall is drained mid-stream and restarted; bar: no work lost.
It ends with a structured report and a non-zero exit on any bar breach.
Deliberately deferred
The runtime has conscious gaps, tracked in ROADMAP.md: liveness beyond heartbeats
($SYS events), temporary semantics inside group strategies, thrall state persistence
(today durability covers the mailbox, not the state - see Durability; event-sourced
rebuild covers the rest), and chaos/failover coverage on top of the soak suite for high-reliability
use. Thrall-level fencing for orphaned singletons - once listed here - is done (both singleton
and lord-liveness fencing; see Singleton fencing).