Skip to content

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

test(macos): assert uninstall removes the launchd job

shukieshahaf3038dcc8eb
diff --git a/packaging/macos/smoke-endpoint.sh b/packaging/macos/smoke-endpoint.sh
index 8711b9f2..d1067e07 100755
--- a/packaging/macos/smoke-endpoint.sh
+++ b/packaging/macos/smoke-endpoint.sh
@@ -166,6 +166,18 @@ run_beacon endpoint hooks uninstall --harness opencode --user --log-path "$LOG_P
test ! -f "$OPENCODE_PLUGIN"
echo "Uninstalling endpoint config..."
+PLIST="$HOME_DIR/Library/LaunchAgents/com.beacon.endpoint.collector.user.plist"
+LABEL="com.beacon.endpoint.collector.user"
+
+# Recorded before the uninstall, so the check after it means something. launchd may never have been
+# told about this job at all -- the plist lives in a temporary HOME rather than the real
+# ~/Library/LaunchAgents, and a CI runner has no GUI session to bootstrap into -- and a job launchd
+# never knew cannot demonstrate that uninstall deregisters anything.
+KNOWN_BEFORE=no
+if launchctl print "gui/$(id -u)/$LABEL" >/dev/null 2>&1; then
+ KNOWN_BEFORE=yes
+fi
+
run_beacon endpoint uninstall --user --log-path "$LOG_PATH" --keep-logs >/dev/null
if [ -f "$HOME_DIR/.beacon/endpoint/config.json" ]; then
@@ -173,6 +185,28 @@ if [ -f "$HOME_DIR/.beacon/endpoint/config.json" ]; then
exit 1
fi
+# The macOS counterpart of the Linux test's "unit file survived uninstall". A service definition left
+# behind is how a collector comes back at the next login after the operator was told it was removed --
+# the failure this whole assertion exists for, and the one that shipped once on Windows.
+if [ -f "$PLIST" ]; then
+ echo "launchd plist survived uninstall: $PLIST" >&2
+ exit 1
+fi
+echo "ok: the launchd plist was removed"
+
+# Asked of launchd itself, not just the filesystem. Skipped loudly rather than silently when launchd
+# never knew the job: an unrun check must not read as a passing one.
+if [ "$KNOWN_BEFORE" = yes ]; then
+ if launchctl print "gui/$(id -u)/$LABEL" >/dev/null 2>&1; then
+ echo "launchd still knows $LABEL after uninstall" >&2
+ exit 1
+ fi
+ echo "ok: launchd no longer knows $LABEL"
+else
+ echo "note: launchd never had $LABEL bootstrapped (temporary HOME, headless runner), so"
+ echo " deregistration is unverified here; the plist removal above is what was checked"
+fi
+
test -f "$LOG_PATH"
echo "Beacon endpoint smoke test passed."