Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(nix): probe /healthz inside the NixOS smoke container

Test08db806b3ac4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3db7df65..79b48135 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,9 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`packages.x86_64-linux.nixos-ai-memory-docker` builds one NixOS
`system.build.toplevel` (via the docker-image rootfs tarball) and
`scripts/test-nixos-systemd-container.sh` runs a privileged systemd
- container smoke (`systemctl` + `/healthz` + dataDir restart/volume
- persistence) on the Linux `nix.yml` leg. The existing `flake.nix`
- package/devShell/CLI build is unchanged. (#NNN)
+ container smoke (`systemctl` + in-container `/healthz` + dataDir
+ restart/volume persistence) on the Linux `nix.yml` leg. The existing
+ `flake.nix` package/devShell/CLI build is unchanged. (#NNN)
### Changed
- `.github/workflows/nix.yml` now builds the flake on `x86_64-linux` and
@@ -39,10 +39,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
provider. (#997)
### Fixed
-- NixOS systemd container smoke (`scripts/test-nixos-systemd-container.sh`)
- now invokes `systemctl`/`journalctl` via absolute NixOS profile paths.
- `docker import` leaves no image `PATH`, so bare names failed with
- `executable file not found in $PATH` on the Linux `nix.yml` leg. (#989)
+- NixOS systemd container smoke probes `/healthz` via in-container `curl`
+ (and ships `curl` in the smoke image). The module's default
+ `127.0.0.1` bind is unreachable through Docker published ports, so the
+ previous host-side probe timed out after the unit was already active.
+ Also invokes `systemctl`/`journalctl` via absolute NixOS profile paths
+ because `docker import` leaves no image `PATH`. (#989)
- Kimi Code no longer receives a bare `{}` when a `UserPromptSubmit` is
dropped by capture policy: the hook now writes an empty success response
Kimi accepts instead of a JSON object it rejects. (#996)
diff --git a/docs/install.md b/docs/install.md
index 83f99ab6..e0818f71 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -749,7 +749,9 @@ scripts/test-nixos-systemd-container.sh
```
That script imports the rootfs, runs a privileged systemd container,
- checks `systemctl is-active ai-memory` and `curl /healthz`, writes a
+ checks `systemctl is-active ai-memory` and in-container `curl /healthz`
+ (the module's default loopback bind is unreachable via Docker `-p`),
+ writes a
marker under `/var/lib/ai-memory`, restarts the unit, and (by default)
remounts a named volume once. Wired into the Linux leg of `nix.yml`
only (same path filters as the rest of the Nix job).
diff --git a/flake.nix b/flake.nix
index ad8f47da..ce69db44 100644
--- a/flake.nix
+++ b/flake.nix
@@ -195,7 +195,7 @@
modules = [
self.nixosModules.default
(
- { modulesPath, ... }:
+ { modulesPath, pkgs, ... }:
{
imports = [ "${modulesPath}/virtualisation/docker-image.nix" ];
system.stateVersion = "25.05";
@@ -206,6 +206,9 @@
documentation.info.enable = false;
documentation.man.enable = false;
documentation.nixos.enable = false;
+ # In-container /healthz probe (docker published ports cannot
+ # reach the module's default 127.0.0.1 bind).
+ environment.systemPackages = [ pkgs.curl ];
services.ai-memory.enable = true;
}
)
diff --git a/scripts/test-nixos-systemd-container.sh b/scripts/test-nixos-systemd-container.sh
index 7fb1c008..989a12d5 100755
--- a/scripts/test-nixos-systemd-container.sh
+++ b/scripts/test-nixos-systemd-container.sh
@@ -5,7 +5,8 @@
# tarball derived from one NixOS system.build.toplevel — imports it into
# Docker/Podman, starts systemd as PID 1, and checks:
# - systemctl is-active ai-memory
-# - curl /healthz from the host
+# - curl /healthz inside the container (module default bind is loopback;
+# Docker published ports hit eth0 and cannot reach 127.0.0.1)
# - a marker under /var/lib/ai-memory survives systemctl restart
# - optional: the same marker survives a recreate with a named volume
#
@@ -24,8 +25,8 @@ VOLUME_NAME="${AI_MEMORY_NIXOS_TEST_VOLUME_NAME:-ai-memory-nixos-test-data}"
KEEP="${AI_MEMORY_NIXOS_TEST_KEEP:-0}"
# Default on: one volume remount persistence pass. Set 0 to skip.
TEST_VOLUME="${AI_MEMORY_NIXOS_TEST_VOLUME:-1}"
-PORT="${AI_MEMORY_NIXOS_TEST_PORT:-49374}"
-HEALTH_URL="http://127.0.0.1:${PORT}/healthz"
+# Probed via docker exec against the unit's loopback bind (not host-mapped).
+HEALTH_URL="http://127.0.0.1:49374/healthz"
DATA_DIR="/var/lib/ai-memory"
MARKER_PATH="${DATA_DIR}/.ai-memory-nixos-ci-marker"
MARKER_VALUE="nixos-container-smoke"
@@ -60,6 +61,10 @@ ctr_journalctl() {
ctr_exec "${NIXOS_SW_BIN}/journalctl" "$@"
}
+ctr_curl() {
+ ctr_exec "${NIXOS_SW_BIN}/curl" "$@"
+}
+
repo_root() {
local script_dir
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -102,13 +107,13 @@ wait_for_http() {
local url="$1"
local i
for i in $(seq 1 120); do
- if curl -fsS "${url}" >/dev/null 2>&1; then
+ if ctr_curl -fsS "${url}" >/dev/null 2>&1; then
return 0
fi
sleep 0.5
done
ctr_journalctl -u ai-memory --no-pager -n 120 >&2 || true
- fail "timed out waiting for ${url}"
+ fail "timed out waiting for in-container ${url}"
}
wait_for_active() {
@@ -128,11 +133,11 @@ run_container() {
local extra_args=("$@")
# Privileged + host cgroup namespace: systemd as PID 1 on cgroup v2 hosts
# (including GitHub Actions ubuntu-latest) needs this to activate units.
+ # No -p: default --bind is 127.0.0.1; published ports never reach it.
"${ENGINE}" run -d --name "${CONTAINER_NAME}" \
--privileged \
--cgroupns=host \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
- -p "127.0.0.1:${PORT}:49374" \
"${extra_args[@]}" \
"${IMAGE_NAME}" /init
}
@@ -157,9 +162,9 @@ smoke_once() {
wait_for_active
ctr_systemctl is-active ai-memory
- log "Waiting for ${HEALTH_URL}"
+ log "Waiting for in-container ${HEALTH_URL}"
wait_for_http "${HEALTH_URL}"
- curl -fsS "${HEALTH_URL}" >/dev/null
+ ctr_curl -fsS "${HEALTH_URL}" >/dev/null
log "Writing marker and restarting ai-memory"
write_marker