Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(test): stop the supervised lifecycle test depending on a race

shukieshahc093afba9564
diff --git a/cli/beacon/internal/endpoint/service/service_test.go b/cli/beacon/internal/endpoint/service/service_test.go
index 4f9ad62a..de028942 100644
--- a/cli/beacon/internal/endpoint/service/service_test.go
+++ b/cli/beacon/internal/endpoint/service/service_test.go
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"os"
- "os/exec"
"os/user"
"path/filepath"
"runtime"
@@ -277,12 +276,18 @@ func TestSupervisedLifecycleStartsAndStopsAProcess(t *testing.T) {
t.Fatal("Load with nothing recorded should error")
}
- // `sleep` stands in for the collector: long-lived and harmless.
- sleepBin, err := exec.LookPath("sleep")
- if err != nil {
- t.Skip("no sleep binary available")
+ // A stand-in collector: long-lived, harmless, and tolerant of the arguments the loader
+ // actually passes.
+ //
+ // `sleep` itself cannot be used, though it was. The loader starts the recorded program as
+ // `<program> --config <path>`, which every sleep implementation rejects as an invalid interval,
+ // so the child exited immediately and the assertion below only passed when it won a race
+ // against the process being reaped. That made it pass on macOS and fail on a Linux runner.
+ stub := filepath.Join(home, "fake-collector")
+ if err := os.WriteFile(stub, []byte("#!/bin/sh\nexec sleep 300\n"), 0o755); err != nil {
+ t.Fatalf("write stub collector: %v", err)
}
- if _, err := m.WriteUnit(sleepBin, "300"); err != nil {
+ if _, err := m.WriteUnit(stub, "300"); err != nil {
t.Fatalf("WriteUnit: %v", err)
}
if err := m.Load(); err != nil {
diff --git a/packaging/linux/smoke-package.sh b/packaging/linux/smoke-package.sh
index 4af4c8f3..32f24ea2 100755
--- a/packaging/linux/smoke-package.sh
+++ b/packaging/linux/smoke-package.sh
@@ -147,6 +147,23 @@ owner="$(docker exec "$CONTAINER" stat -c %U "$SETTINGS" 2>/dev/null || true)"
echo "$SETTINGS is owned by $owner, so $SMOKE_USER cannot read it" >&2; exit 1; }
echo "ok: the installing user's Claude Code points at the collector"
+# The hook half of the same step, and the only free coverage of the root-side child-process launch.
+# Installing hooks for another user runs the CLI as them -- via runuser when root on Linux, since a
+# minimal Debian or RPM system may have no sudo at all. If that launch silently did nothing, the
+# native config above would still be written and this would be the only signal.
+docker exec "$CONTAINER" grep -q '"hooks"' "$SETTINGS" || {
+ echo "$SETTINGS has no hooks block, so hook telemetry was not installed for $SMOKE_USER" >&2
+ grep -i "hook" /tmp/beacon-pkg-install.log >&2 || true
+ exit 1
+}
+ADAPTER="/home/$SMOKE_USER/.beacon/endpoint/hooks/beacon-hooks"
+docker exec "$CONTAINER" test -x "$ADAPTER" || {
+ echo "$ADAPTER is missing or not executable, so the configured hooks cannot run" >&2; exit 1; }
+adapter_owner="$(docker exec "$CONTAINER" stat -c %U "$ADAPTER" 2>/dev/null || true)"
+[ "$adapter_owner" = "$SMOKE_USER" ] || {
+ echo "$ADAPTER is owned by $adapter_owner, not $SMOKE_USER" >&2; exit 1; }
+echo "ok: hooks installed for the user and runnable by them"
+
# The two commands the docs tell a new user to run. Both must report healthy with no manual setup.
if ! docker exec "$CONTAINER" /opt/beacon/bin/beacon endpoint status --system --json >/tmp/beacon-status.json 2>&1; then
echo "endpoint status failed:" >&2; cat /tmp/beacon-status.json >&2; exit 1