Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: expose Deep handoff refusal on Windows

Adam Eivy3dae85f58959
diff --git a/server/services/deepAudit.workspace.test.js b/server/services/deepAudit.workspace.test.js
index 6bc4094e34..cdb22203d9 100644
--- a/server/services/deepAudit.workspace.test.js
+++ b/server/services/deepAudit.workspace.test.js
@@ -82,8 +82,9 @@ it('expands a fresh submodule at its gitlink and refuses to reset retained submo
expect(ledger.scope.capabilities.submodules).toEqual([]);
expect(ledger.scope.files.some(f => f.path === 'lib/child/nested.js' && f.kind === 'blob')).toBe(true);
fault.rejectAdd = true;
- await expect(adoptWorktree('agent-failed', repo, workspacePath, worktree.branchName, { deepResume: true }))
- .rejects.toMatchObject({ code: 'DEEP_RESUME_PRESERVED', message: expect.stringContaining('Synthetic add failure') });
+ const failedHandoff = await adoptWorktree('agent-failed', repo, workspacePath, worktree.branchName, { deepResume: true }).catch(error => error);
+ expect(failedHandoff.code).toBe('DEEP_RESUME_PRESERVED');
+ expect(failedHandoff.message).toContain('Synthetic add failure');
expect(await readFile(join(workspacePath, 'lib/child/nested.js'), 'utf8')).toContain('nested = true');
fault.rejectAdd = false;
// The preserved detached tree can reattach its still-unoccupied branch for a
diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.js
index 5101879181..d0f72afcf8 100644
--- a/server/services/worktreeManager.js
+++ b/server/services/worktreeManager.js
@@ -953,9 +953,10 @@ async function adoptWorktreeUnlocked(agentId, sourceWorkspace, existingWorktreeP
const status = (await execGit(['status', '--porcelain', '--untracked-files=all', '--ignore-submodules=none'], existingWorktreePath)).stdout.trim();
const listed = await listWorktrees(sourceWorkspace);
const holder = listed.find(entry => pathsEqual(entry.path, existingWorktreePath));
- if (currentBranch !== branchName || !holder || holder.locked || status) {
- throw Object.assign(new Error('Retained Deep submodule workspace is changed, locked or ambiguous; preserve it for explicit recovery'), { code: 'DEEP_RESUME_PRESERVED' });
- }
+ const refusal = currentBranch !== branchName ? 'branch identity changed'
+ : !holder ? 'worktree registration could not be matched'
+ : holder.locked ? 'worktree is locked' : status ? 'workspace has uncommitted or nested changes' : null;
+ if (refusal) throw new Error(`Retained Deep submodule ${refusal}; preserve it for explicit recovery`);
await execGit(['checkout', '--detach', head], existingWorktreePath);
const branchHead = (await execGit(['rev-parse', `refs/heads/${branchName}`], sourceWorkspace)).stdout.trim();
if (branchHead !== head) throw new Error('Deep resume branch changed during handoff; preserved old workspace');