Skip to content

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

Fix windows-test: compare /Volumes with POSIX separators and assert the no-mode-bits contract

Claude9a3c98de181e
diff --git a/cli/beacon/internal/endpoint/service/launchd_volume.go b/cli/beacon/internal/endpoint/service/launchd_volume.go
index 043061eb..496c4286 100644
--- a/cli/beacon/internal/endpoint/service/launchd_volume.go
+++ b/cli/beacon/internal/endpoint/service/launchd_volume.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
+ "path"
"path/filepath"
"strings"
)
@@ -86,11 +87,13 @@ func InspectLaunchAgentVolume(plistPath string) LaunchAgentVolume {
return vol
}
-func underVolumes(path string) bool {
- if resolved, err := filepath.EvalSymlinks(path); err == nil {
- path = resolved
+// underVolumes reports whether p is under the macOS /Volumes mount point. launchd paths are POSIX
+// paths, so the comparison is done with forward slashes whatever the host's separator is.
+func underVolumes(p string) bool {
+ if resolved, err := filepath.EvalSymlinks(p); err == nil {
+ p = resolved
}
- return strings.HasPrefix(filepath.Clean(path)+"/", "/Volumes/")
+ return strings.HasPrefix(path.Clean(filepath.ToSlash(p))+"/", "/Volumes/")
}
// launchdStagingDirName carries the uid so the /private/tmp fallback cannot collide between users.
diff --git a/cli/beacon/internal/endpoint/service/launchd_volume_test.go b/cli/beacon/internal/endpoint/service/launchd_volume_test.go
index b675e5de..d2d7c523 100644
--- a/cli/beacon/internal/endpoint/service/launchd_volume_test.go
+++ b/cli/beacon/internal/endpoint/service/launchd_volume_test.go
@@ -229,14 +229,22 @@ func TestLoadLaunchdJobExplainsAnExternalHomeWhenBootstrapStillFails(t *testing.
if err == nil {
t.Fatal("loadLaunchdJob succeeded, want the bootstrap failure")
}
- for _, want := range []string{
+ wants := []string{
"Bootstrap failed: 5",
f.external,
"not on the startup volume",
- filepath.Join(f.staging, UserLabel+".plist"),
"--no-start",
"launchctl bootstrap gui/502",
- } {
+ }
+ if testenv.HasPOSIXFileModes() {
+ // Staging succeeded, so the note names the copy launchd refused too.
+ wants = append(wants, filepath.Join(f.staging, UserLabel+".plist"))
+ } else {
+ // No mode bits means the 0700 check cannot pass, so staging is refused and the note says
+ // so; launchd never runs on such a host, but the explanation must still be coherent.
+ wants = append(wants, "could not be staged")
+ }
+ for _, want := range wants {
if !strings.Contains(err.Error(), want) {
t.Fatalf("error missing %q:\n%v", want, err)
}