Findings from a pass over the daemon, the sandbox and the surfaces. HTTP: a loopback dashboard without a token was reachable from any web page. The wildcard CORS grant and an OPTIONS branch before the token check let a cross-origin page POST into the one session, and a DNS-rebinding page could read it under its own name. Requests now need a loopback Host while no token is configured, an Origin must match the Host, and there is no CORS grant. MCP connections get a receive/send timeout instead of pinning a thread forever. CLI: --check silently ignored an unreadable or invalid config and printed a green self-test, because the load error was discarded. It now fails with the parser message, prints the sandbox plan, and only then runs the scripted turn. --self-test still works without a config. Budgets: max_turn_seconds (default 1800) cancels a turn that outlives it and records turn_timeout; the answer produced after the cancel is discarded. External chat now counts against max_impulses_per_hour instead of bypassing it. Stuck detection: kstuck_turn() reset the whole ladder whenever a turn called a mutating tool, so a loop of failing 'run' calls never escalated. The ladder now resets only after a turn whose tool signals are clean. The dashboard's stuck level is a locked snapshot instead of a read of daemon-private state. Ledger: impulse records stored the running session total as if it were that impulse's usage; they now store per-turn deltas, and turn_end logs them. Config: refuse / and .. in rootfs/state/workspace, refuse nested trees (a state inside the disposable rootfs would be deleted with it), and reject negative sizes. Event log: O_NOFOLLOW|O_CLOEXEC. Makefile: check-asan reused the same object paths, so a plain make afterwards linked uninstrumented code against sanitizer objects and failed. It now cleans before and after. Tests: test_server covers Host/Origin refusal and the OPTIONS/token check; test_krang covers the path guards and the stuck reset; test_timeout proves the wall-clock cancellation with a sleeping tool. make check is now seven suites, ASAN also green, and the root integration still passes on a fresh debootstrap.
krang
An autonomous agent daemon built on the splinter engine. The design notes and the prior art are in docs/DESIGN.md.
krang exists to test one hypothesis: what an assistant lacks is not intelligence but a regular impulse to continue. It is born once, keeps one session forever, wakes on its own cadence, works on a goal, notices when it is stuck, changes approach, and records what happened. There is no user to ask.
It lives in a chroot. The process starts as root only to build that world, then drops to an unprivileged uid and applies two one-way restrictions: Landlock for paths and seccomp-bpf for syscalls on Linux (the design is pledge/unveil; the OpenBSD backend is not implemented yet).
Build
make -C ../splinter # libsplinter.so and the headers
make
make check # no network, no key, no model
libsplinter.so has no SONAME; the binary carries an rpath to ../splinter.
Rebuild krang whenever splinter changes.
Configure
sudo install -d /etc/krang
sudo install -m 0600 krang.conf.example /etc/krang/krang.conf
$EDITOR /etc/krang/krang.conf
The goal is used only when the session is empty: that is the newborn. After
that the goal in the session's .meta is the life's goal.
Prepare and start
sudo krang --prepare-rootfs --config /etc/krang/krang.conf
krang --plan --config /etc/krang/krang.conf # read the plan, do not start
sudo krang --config /etc/krang/krang.conf # start
Do not start it casually: once it has a provider it will act on its own. The
service unit in share/krang.service restarts it after an unexpected exit; a
deliberate stop is systemctl stop krang (or SIGTERM).
What it offers
- Dashboard
http://127.0.0.1:8096/— state, goal, impulses, turns, tool calls, failures, tokens, cost, context, session, compactions, stuck level, last outcome and error, working notes, and a chat box. - HTTP API —
/healthz,/api/state,/api/impulses,/api/log,/api/history,/api/threads,/api/tools,/api/sandbox,/api/config,/api/events,POST /api/say,GET /api/say/<id>,POST /mcp. - MCP — newline-delimited JSON-RPC on
127.0.0.1:8098. Tools:krang_state,krang_impulses,krang_events,krang_session,krang_history,krang_tools,krang_sandbox,krang_config,krang_say,krang_say_status,krang_steer,krang_cancel. Nokrang_approve: krang never asks. - Chat from either surface goes into the same session as the daemon's own impulses. One turn at a time; a message that arrives mid-turn is queued.
The model also gets journal_search (read-only): it searches the full session
log, including the history compaction dropped.
Splinter plugins are opt-in: plugin = /absolute/plugin.so (max 8). The root
phase bind-mounts each plugin and libsplinter.so read-only into /opt/krang
and sets LD_LIBRARY_PATH; only the path is wired, not the plugin's own
plugin NAME { } config block yet. The root integration loads the clock plugin
inside the chroot as a proof.
If a token is set in the config, loopback is not required and every request
needs it (Authorization: Bearer, ?token=, or the MCP AUTH <token> line).
Without a token krang refuses to bind to a non-loopback address.
A loopback dashboard without a token is still a local service, so the HTTP
surface checks the names a browser sends: a request whose Host is not a
loopback name is refused (DNS rebinding), and an Origin that does not match
the Host is refused (cross-site requests). There is no CORS grant; the
dashboard is same-origin.
The experiment log
state/sessions/krang.jsonlis the conversation and the model's memory.state/events.jsonlis the append-only experiment log. It is opened by the root phase, owned by root, mode 0600, and written through the inherited descriptor; the sandbox user can neither open nor truncate it. The fd isFD_CLOEXEC, so theruntool's children do not inherit it.- The dashboard, HTTP API and MCP all read the same snapshot and the same ring of recent events. There is no second counter.
Tests
make check
make check-asan
./krang --check --config krang.conf.example # config + plan + scripted turn
./krang --self-test # one scripted turn, no network
sudo tests/root-integration.sh # debootstrap + chroot + drop
make check covers config parsing and path guards, the birth prompt, stuck
detection, the snapshot/HTTP/MCP surfaces (including the Host/Origin refusal
and token check), a real scripted engine turn, the engine under Landlock +
seccomp, kdaemon_run itself (one birth impulse on the script transport, then
a clean stop), and a turn cancelled by max_turn_seconds. The sandbox tests
prove Landlock denies a write outside the allowed set and seccomp denies
mount(2) while fork/execve/network still work.
tests/root-integration.sh is the root-only proof: it prepares a real rootfs
with debootstrap, enters it with --sandbox-test, loads the clock plugin from
the splinter tree, and checks uid 65534, mount denial, plugin execution,
event-log ownership/mode, session ownership, and that the sandbox uid cannot
read the event log. It never starts the autonomous daemon or calls a provider.
Safety notes
- chroot is isolation, not a jail against root. krang runs as an unprivileged uid after setup and has no path back.
- The provider key is readable by the daemon; assume the model can eventually
see anything in its environment. Use a throwaway, budget-capped key. The
runtool's environment is filtered withsp_secret_env_add(), and the event log redacts the configured key. - The network namespace is shared.
runcan reach the network; the chroot does not change that. - The session log is the model's memory. It is writable by the sandbox uid; the experiment log is not.
- User namespaces and kernel bugs remain outside the model. The layers raise the cost of an escape; they are not a proof.