Skip to content

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

fix(sandbox): assert guarded paths by identity, not by separator

shukieshahe977804dd5f0
diff --git a/beacon-sandbox/hostguard/hostguard_test.go b/beacon-sandbox/hostguard/hostguard_test.go
index 6ef814d4..79f5f829 100644
--- a/beacon-sandbox/hostguard/hostguard_test.go
+++ b/beacon-sandbox/hostguard/hostguard_test.go
@@ -3,6 +3,7 @@ package hostguard
import (
"os"
"path/filepath"
+ "runtime"
"strings"
"testing"
)
@@ -99,6 +100,12 @@ func TestLogDirCreationIsDetected(t *testing.T) {
}
func TestExistenceModeChangeIsDetected(t *testing.T) {
+ // os.Chmod on Windows only toggles the read-only attribute; there are no permission bits to
+ // change, so the signal this asserts cannot be produced there. The existence half of
+ // watchExistence is covered by the other tests on every platform.
+ if runtime.GOOS == "windows" {
+ t.Skip("file mode bits are a POSIX concept")
+ }
dir := t.TempDir()
sub := filepath.Join(dir, "opt-beacon")
if err := os.MkdirAll(sub, 0o755); err != nil {
@@ -185,7 +192,15 @@ func TestUnchangedStateIsClean(t *testing.T) {
// The guarded set must actually cover what a Beacon install touches, or the guard looks in the
// wrong place and passes vacuously.
func TestGuardedPathsCoverBeaconInstallSurface(t *testing.T) {
- joined := strings.Join(GuardedPaths(), "\n")
+ // Compared with forward slashes, because the guarded set is built with filepath.Join and
+ // therefore renders with the host separator. The assertion is about which paths are guarded,
+ // not how they are spelled -- on Windows the backslash form made every one of these look
+ // uncovered while the guard was in fact watching exactly the right places.
+ slashed := make([]string, 0, len(GuardedPaths()))
+ for _, p := range GuardedPaths() {
+ slashed = append(slashed, filepath.ToSlash(p))
+ }
+ joined := strings.Join(slashed, "\n")
for _, want := range []string{
".beacon/endpoint/config.json",
".beacon/endpoint/otelcol.yaml",
diff --git a/beacon-sandbox/image/image_test.go b/beacon-sandbox/image/image_test.go
index e67061f1..fad11bcf 100644
--- a/beacon-sandbox/image/image_test.go
+++ b/beacon-sandbox/image/image_test.go
@@ -116,7 +116,10 @@ func TestArtifactsErrorNamesTheBuildCommand(t *testing.T) {
if !strings.Contains(err.Error(), BuildBeaconHint) {
t.Errorf("error should tell the user how to build it, got: %v", err)
}
- if !strings.Contains(err.Error(), beaconRelPath) {
+ // Slash-normalized for the same reason as the guarded-path assertion: the error embeds a
+ // filepath.Join'd path, so it renders with the host separator while beaconRelPath is written
+ // with forward slashes.
+ if !strings.Contains(filepath.ToSlash(err.Error()), beaconRelPath) {
t.Errorf("error should name the missing path, got: %v", err)
}
}