Skip to content

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

fix(windows): state the supervised fallback's limits wherever it is described

shukieshah4a77ad026424
diff --git a/cli/beacon/internal/endpoint/service/supervised.go b/cli/beacon/internal/endpoint/service/supervised.go
index 7c21efda..806c8006 100644
--- a/cli/beacon/internal/endpoint/service/supervised.go
+++ b/cli/beacon/internal/endpoint/service/supervised.go
@@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strconv"
"strings"
"time"
@@ -197,15 +198,34 @@ func (b supervisedBackend) status(userMode bool) Status {
status.Running = st.PID > 0 && processAlive(st.PID)
switch {
case status.Running:
- status.Message = fmt.Sprintf("supervised pid %d (no automatic restart: no service manager)", st.PID)
+ status.Message = fmt.Sprintf("supervised pid %d (%s)", st.PID, supervisedCaveats(userMode))
case status.Loaded:
- status.Message = "recorded but not running"
+ status.Message = "recorded but not running (" + supervisedCaveats(userMode) + ")"
default:
status.Message = "no supervised collector recorded"
}
return status
}
+// supervisedCaveats names what this backend cannot promise, for status to report in-band.
+//
+// Stated wherever an installed collector is described, not only while one happens to be running:
+// an operator reading `endpoint status` on a configured-but-stopped endpoint is exactly the person
+// who needs to know nothing will start it again.
+//
+// Logout is a Windows-only caveat and is named only there, because it is only true there. A
+// detached process on POSIX has its own session -- that is what setsid buys -- and outlives the
+// login that started it. Windows terminates the session's processes at logoff, so a user-mode
+// collector there stops when the person walks away, which is a materially worse guarantee and one
+// they should not have to discover from an empty log.
+func supervisedCaveats(userMode bool) string {
+ const noRestart = "no automatic restart: no service manager"
+ if userMode && runtime.GOOS == "windows" {
+ return noRestart + "; does not survive logout"
+ }
+ return noRestart
+}
+
// processAlive reports whether a pid is live.
func processAlive(pid int) bool {
if pid <= 0 {
diff --git a/cli/beacon/internal/endpoint/service/windows_test.go b/cli/beacon/internal/endpoint/service/windows_test.go
index 65550b69..a14cf42b 100644
--- a/cli/beacon/internal/endpoint/service/windows_test.go
+++ b/cli/beacon/internal/endpoint/service/windows_test.go
@@ -41,11 +41,36 @@ func TestWindowsUserModeFallsBackToSupervised(t *testing.T) {
t.Errorf("user mode backend = %q, want %q -- Windows has no per-user service manager",
got, KindSupervised)
}
- if runtime.GOOS == "windows" {
- st := user.Status()
- if !strings.Contains(strings.ToLower(st.Message), "restart") {
- t.Errorf("user-mode status must disclose that nothing restarts it, got %q", st.Message)
- }
+}
+
+// The fallback's limitations have to reach the operator, and reach them wherever an installed
+// endpoint is described -- not only while one happens to be running. Someone reading status on a
+// configured-but-stopped Windows user-mode endpoint is exactly the person who needs to know that
+// nothing will start it again and that it stops when they log off.
+//
+// Asserted against the message builder rather than through Status, because Status on a fresh
+// machine reports "nothing recorded" and would let the claim go untested -- which is how the first
+// version of this test passed locally and failed on a clean runner.
+func TestSupervisedStatusNamesWhatItCannotPromise(t *testing.T) {
+ caveats := supervisedCaveats(true)
+ if !strings.Contains(caveats, "no automatic restart") {
+ t.Errorf("caveats = %q, want the absence of restart-on-failure named", caveats)
+ }
+
+ // Logout is Windows-only and must be claimed only there: a detached POSIX process has its own
+ // session and outlives the login that started it, so saying otherwise would be false.
+ mentionsLogout := strings.Contains(caveats, "logout")
+ if runtime.GOOS == "windows" && !mentionsLogout {
+ t.Errorf("windows user mode must disclose that it stops at logout, got %q", caveats)
+ }
+ if runtime.GOOS != "windows" && mentionsLogout {
+ t.Errorf("a detached POSIX collector does survive logout; %q claims otherwise", caveats)
+ }
+
+ // System mode never carries the logout caveat: it is not tied to a login session on any
+ // platform, and on Windows it is not even this backend.
+ if strings.Contains(supervisedCaveats(false), "logout") {
+ t.Error("system mode must not claim a logout limitation")
}
}