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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): keep the resume pointer through an orphan cooldown
[._.]/ Adam Eivyf48d9ab947c6
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.jsindex c32147ad94..26b76aeb49 100644--- a/server/services/cosTaskStore.js+++ b/server/services/cosTaskStore.js@@ -448,14 +448,20 @@ export async function updateTask(taskId, updates, taskType = 'user', { now = Dat// Drop the resume pointer once the task reaches a terminal state. `existingBranch`// + `resumeWorktreePath` + `resumedFromAgentId` are stamped by- // `recordTaskResumePointer` so a FAILED or ORPHANED task's retry picks up the+ // `resolveTaskResumePatch` so a FAILED or ORPHANED task's retry picks up the// branch (and worktree) its dead agent left behind and resumes instead of// restarting. Once the task is done (or blocked for a human), that pointer is// spent: a PERPETUAL task type re-queues the same task id for unrelated future// work, and a stale `existingBranch` would silently attach that fresh run to a// long-merged branch. Only cleared on terminal statuses — a `pending` retry is// exactly who needs the pointer intact.- if (isTerminalTaskStatus(updates.status)) {+ //+ // An `orphan-cooldown` block is the exception: it is a TIMED PAUSE, not a+ // terminal state — `unblockExpiredOrphanCooldowns` (cosTaskGenerator.js) flips it+ // back to `pending` on its own once `cooldownUntil` passes. Stripping the pointer+ // there means the revived task starts clean and abandons the worktree its dead+ // agent left behind, which is exactly the recovery this mechanism exists for.+ if (isTerminalTaskStatus(updates.status) && updatedMetadata.blockedCategory !== 'orphan-cooldown') {delete updatedMetadata.existingBranch;delete updatedMetadata.resumedFromAgentId;delete updatedMetadata.resumeWorktreePath;diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex b58787126d..38270af128 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -483,6 +483,37 @@ describe('cosTaskStore.updateTask', () => {expect(reopened.metadata.blockedCategory).toBeUndefined();});+ // The pointer is spent once a task is done or parked for a human: a PERPETUAL+ // task id gets re-queued for unrelated work later, and a stale existingBranch+ // would attach that fresh run to a long-merged branch.+ it('drops the resume pointer on a terminal status', async () => {+ await addTask({ description: 'res', id: 'task-res' }, 'user');+ await updateTask('task-res', {+ metadata: { existingBranch: 'cos/b', resumedFromAgentId: 'agent-x', resumeWorktreePath: '/w/agent-x' }+ }, 'user');+ const done = await updateTask('task-res', { status: 'completed' }, 'user');+ expect(done.metadata.existingBranch).toBeUndefined();+ expect(done.metadata.resumedFromAgentId).toBeUndefined();+ expect(done.metadata.resumeWorktreePath).toBeUndefined();+ });++ // ...but an orphan-cooldown block is a TIMED PAUSE that unblockExpiredOrphanCooldowns+ // flips back to pending on its own. Stripping the pointer there means the revived+ // task starts clean and abandons the worktree its dead agent left behind.+ it('keeps the resume pointer through an orphan-cooldown block', async () => {+ await addTask({ description: 'cool', id: 'task-cool' }, 'user');+ await updateTask('task-cool', {+ metadata: { existingBranch: 'cos/b', resumedFromAgentId: 'agent-x', resumeWorktreePath: '/w/agent-x' }+ }, 'user');+ const cooled = await updateTask('task-cool', {+ status: 'blocked',+ metadata: { blockedCategory: 'orphan-cooldown', cooldownUntil: '2026-01-01T00:30:00.000Z' }+ }, 'user');+ expect(cooled.metadata.existingBranch).toBe('cos/b');+ expect(cooled.metadata.resumedFromAgentId).toBe('agent-x');+ expect(cooled.metadata.resumeWorktreePath).toBe('/w/agent-x');+ });+it('releases the federation claim/lease when a task leaves in_progress (#1563)', async () => {await addTask({ description: 'claimed', id: 'task-claimed' }, 'user');// Spawn-time claim: status in_progress carries the claim metadata.