An open-source, faster Devin alternative
TypeScript
fix workspace build issue
Brian Reardonde084ddd3070
diff --git a/deploy/ec2/build-rootfs-docker.sh b/deploy/ec2/build-rootfs-docker.shindex bbe943fb..63b635c3 100755--- a/deploy/ec2/build-rootfs-docker.sh+++ b/deploy/ec2/build-rootfs-docker.sh@@ -94,12 +94,14 @@ elsedonefi-# ── Mount workspace: data disk at /workspace (persistent user data) ──-mkdir -p /workspace-if mount /dev/vdb /workspace 2>/dev/null || mount /dev/vdb1 /workspace 2>/dev/null; then- echo "init: workspace mounted (/dev/vdb -> /workspace)"+# ── Mount workspace: data disk at /home/sandbox (persistent user data) ──+# /workspace is a symlink to /home/sandbox, so mount the real path.+mkdir -p /home/sandbox+if mount /dev/vdb /home/sandbox 2>/dev/null || mount /dev/vdb1 /home/sandbox 2>/dev/null; then+ chown sandbox:sandbox /home/sandbox 2>/dev/null+ echo "init: workspace mounted (/dev/vdb -> /home/sandbox)"else- echo "init: warning: no data disk found, /workspace is ephemeral"+ echo "init: warning: no data disk found, /home/sandbox is ephemeral"fi# ── Mount virtual filesystems (in the final root) ──@@ -236,8 +238,8 @@ mount -o loop "$EXT4_PATH" "$MNT_DIR"tar xf "$TMPDIR/rootfs.tar" -C "$MNT_DIR"-# Ensure key directories exist-for dir in proc sys dev dev/pts dev/shm tmp workspace run; do+# Ensure key directories exist (workspace is created by Dockerfile)+for dir in proc sys dev dev/pts dev/shm tmp run; domkdir -p "$MNT_DIR/$dir"donediff --git a/internal/qemu/manager.go b/internal/qemu/manager.goindex be923418..47b5a71c 100644--- a/internal/qemu/manager.go+++ b/internal/qemu/manager.go@@ -266,6 +266,15 @@ func (m *Manager) PrepareGoldenSnapshot() error {return fmt.Errorf("create golden workspace: %w", err)}+ // Save the workspace ext4 UUID so createFromGolden can stamp new workspaces+ // with the same UUID. The golden kernel caches ext4 metadata (superblock,+ // journal) by UUID — a new workspace with a different UUID triggers checksum+ // errors ("Bad message" / EBADMSG) because the cached metadata doesn't match.+ if wsUUID, uuidErr := getWorkspaceUUID(workspaceFile); uuidErr == nil {+ os.WriteFile(filepath.Join(goldenDir, "workspace_uuid"), []byte(wsUUID), 0644)+ log.Printf("qemu: golden: workspace UUID=%s", wsUUID)+ }+// Allocate a temporary network for golden bootnetCfg, err := m.subnets.Allocate()if err != nil {@@ -476,10 +485,16 @@ func (m *Manager) createFromGolden(ctx context.Context, cfg types.SandboxConfig,return nil, fmt.Errorf("copy golden rootfs: %w", err)}- // Create fresh workspace as qcow2 (matching golden snapshot format)+ // Create fresh workspace as qcow2 with the golden's ext4 UUID.+ // The golden kernel caches ext4 metadata by UUID — mismatched UUIDs cause+ // "Bad message" (EBADMSG) checksum errors on the restored workspace.workspacePath := filepath.Join(sandboxDir, "workspace.qcow2")diskMB := m.cfg.DefaultDiskMB- if err := CreateWorkspace(workspacePath, diskMB); err != nil {+ var goldenWSUUID string+ if data, readErr := os.ReadFile(filepath.Join(m.goldenDir, "workspace_uuid")); readErr == nil {+ goldenWSUUID = strings.TrimSpace(string(data))+ }+ if err := CreateWorkspace(workspacePath, diskMB, goldenWSUUID); err != nil {os.RemoveAll(sandboxDir)return nil, fmt.Errorf("create workspace: %w", err)}diff --git a/internal/qemu/rootfs.go b/internal/qemu/rootfs.goindex ccbfa1ee..809c946d 100644--- a/internal/qemu/rootfs.go+++ b/internal/qemu/rootfs.go@@ -121,6 +121,27 @@ func CreateWorkspace(path string, sizeMB int, uuid ...string) error {return nil}+// getWorkspaceUUID extracts the ext4 filesystem UUID from a qcow2 workspace image.+// Converts to raw, runs tune2fs, and parses the UUID line.+func getWorkspaceUUID(qcow2Path string) (string, error) {+ rawPath := qcow2Path + ".uuid-check.raw"+ defer os.Remove(rawPath)+ cmd := exec.Command("qemu-img", "convert", "-f", "qcow2", "-O", "raw", qcow2Path, rawPath)+ if out, err := cmd.CombinedOutput(); err != nil {+ return "", fmt.Errorf("convert to raw: %w (%s)", err, strings.TrimSpace(string(out)))+ }+ out, err := exec.Command("tune2fs", "-l", rawPath).Output()+ if err != nil {+ return "", fmt.Errorf("tune2fs: %w", err)+ }+ for _, line := range strings.Split(string(out), "\n") {+ if strings.HasPrefix(line, "Filesystem UUID:") {+ return strings.TrimSpace(strings.TrimPrefix(line, "Filesystem UUID:")), nil+ }+ }+ return "", fmt.Errorf("UUID not found in tune2fs output")+}+// detectDrivePath returns the actual path for a drive file (rootfs or workspace),// preferring qcow2 if it exists, falling back to ext4.func detectDrivePath(sandboxDir, prefix string) string {diff --git a/web/tsconfig.tsbuildinfo b/web/tsconfig.tsbuildinfoindex 8708ac61..eae896d6 100644--- a/web/tsconfig.tsbuildinfo+++ b/web/tsconfig.tsbuildinfo@@ -1 +1 @@-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/components/terminal.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/checkpoints.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessiondetail.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}\ No newline at end of file+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/components/terminal.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/billing.tsx","./src/pages/checkpoints.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessiondetail.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}\ No newline at end of file