This is the host-side hardening half of ADR-207.
- moves mutable runtime state out of the repo tree with
ALICE_STATE_DIR - keeps the Engine API socket in
/run/alice-runtime/engine.sock - keeps the error log in
/var/log/alice-runtime/alice-errors.log - defaults the skill runner to
sandboxed+runsc - applies
systemd.exechardening around the Node runtime process
- Copy the repo to its final location and adjust the unit paths:
WorkingDirectory=/srv/alice-telegram-bot/runtimeEnvironmentFile=-/srv/alice-telegram-bot/runtime/.env- every
ReadWritePaths=/srv/alice-telegram-bot/...
- Ensure Node.js 22+,
pnpm, Docker, and optionally Go 1.22+ are installed on the host. - Create the service account:
sudo useradd --system --home /var/lib/alice-runtime --shell /usr/sbin/nologin alice-runtime
sudo usermod -aG docker alice-runtimeThat is the compatibility path. If you want the stricter host-side setup, point the unit at a dedicated rootless Docker socket instead of granting the service user docker group access.
- Install JavaScript dependencies from the repo root with
pnpm:
cd /srv/alice-telegram-bot
pnpm install --frozen-lockfile- Build the required runtime binaries inside
runtime/:
cd /srv/alice-telegram-bot/runtime
# Required system-bin commands for runtime command space
pnpm run build:bin
# Build alice CLI and Go skills
mkdir -p dist/bin
CGO_ENABLED=0 go build -ldflags="-s -w" -o dist/bin/alice ./cmd/alice
for skill in cmd/skills/*/; do
name=$(basename "$skill")
CGO_ENABLED=0 go build -ldflags="-s -w" -o "dist/bin/$name" "./$skill"
done- Build the sandbox runner image:
cd /srv/alice-telegram-bot/runtime
pnpm docker:build-runnerDo not enable the unit until these checks pass:
cd /srv/alice-telegram-bot/runtime
test -x dist/bin/alice
test -x dist/bin/irc
test -x dist/bin/self
test -x dist/bin/alice-pkg
ALICE_RUNTIME_DIR=/srv/alice-telegram-bot/runtime ./dist/bin/alice doctorIf alice doctor reports missing System bin, you skipped pnpm run build:bin or built in the wrong directory.
sudo cp runtime/deploy/systemd/alice-runtime.service /etc/systemd/system/alice-runtime.service
sudo systemctl daemon-reload
sudo systemctl enable --now alice-runtimesystemctl status alice-runtime
journalctl -u alice-runtime -n 100 --no-pager
ls -la /run/alice-runtime/engine.sock
ls -la /var/lib/alice-runtime
ls -la /var/log/alice-runtime/alice-errors.logThe unit deliberately keeps only these locations writable:
/var/lib/alice-runtime- SQLite state, caches,ALICE_HOME/run/alice-runtime- Engine API Unix socket/var/log/alice-runtime- error logruntime/skills/store- installed skill payloadsruntime/skills/system-bin- exported skill command symlinksruntime/skills/man- exported manpage symlinksruntime/skills/registry.json- installed skill registry
If you later move skill exports out of the repo tree, tighten ReadWritePaths again.