Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(computer): refuse an overlapping View before setting anything aside

claude-opus-5-5-mediumae74c4105c1d
diff --git a/apps/computer/local-daemon/internal/linger/context/orphaned_projection.go b/apps/computer/local-daemon/internal/linger/context/orphaned_projection.go
index fdfbcb87..a1158d4c 100644
--- a/apps/computer/local-daemon/internal/linger/context/orphaned_projection.go
+++ b/apps/computer/local-daemon/internal/linger/context/orphaned_projection.go
@@ -49,14 +49,17 @@ func setAsideOrphanedProjection(workspace string, mappings []Mapping) (string, e
roots := append([]string(nil), next.ReadOnlyRoots...)
// An outer root carries the roots inside it.
sort.Slice(roots, func(left, right int) bool { return len(roots[left]) < len(roots[right]) })
- destination := ""
+ // A writable tree is agent work; it is never moved. Every root is checked
+ // before the first move, so a View that cannot publish moves nothing.
for _, root := range roots {
for _, writable := range next.WritableRoots {
if pathWithin(root, writable) || pathWithin(writable, root) {
- // A writable tree is agent work; it is never moved.
return "", contextConflict("read-only mapping %s overlaps writable mapping %s", root, writable)
}
}
+ }
+ destination := ""
+ for _, root := range roots {
source := filepath.Join(workspace, root)
info, err := os.Lstat(source)
if errors.Is(err, os.ErrNotExist) {
diff --git a/apps/computer/local-daemon/internal/linger/context/orphaned_projection_test.go b/apps/computer/local-daemon/internal/linger/context/orphaned_projection_test.go
index da19924c..b20f67ef 100644
--- a/apps/computer/local-daemon/internal/linger/context/orphaned_projection_test.go
+++ b/apps/computer/local-daemon/internal/linger/context/orphaned_projection_test.go
@@ -154,3 +154,22 @@ func TestSameWorkspacePath(t *testing.T) {
}
}
}
+
+func TestSetAsideMovesNothingWhenRootsOverlap(t *testing.T) {
+ workspace := t.TempDir()
+ if err := os.MkdirAll(filepath.Join(workspace, "inbox"), 0o700); err != nil {
+ t.Fatal(err)
+ }
+ mappings := []Mapping{
+ {Kind: "inbox", TargetPath: "inbox", Access: "read_only"},
+ {Kind: "playground", TargetPath: "playground", Access: "read_write"},
+ {Kind: "skills", TargetPath: "playground/x", Access: "read_only"},
+ }
+ destination, err := setAsideOrphanedProjection(workspace, mappings)
+ if !errors.Is(err, ErrContextConflict) || destination != "" {
+ t.Fatalf("setAsideOrphanedProjection = %q, %v; want a conflict", destination, err)
+ }
+ if _, err := os.Stat(filepath.Join(workspace, "inbox")); err != nil {
+ t.Fatalf("inbox moved before the overlap was refused: %v", err)
+ }
+}