Skip to content

fix(taskctl): resurrectionScan resets developing tasks to idle instead of advancing to reviewing #252

@randomm

Description

@randomm

Problem

When the opencode binary restarts, resurrectionScan runs on taskctl resume. For tasks with stage: developing where the developer session is no longer alive, resurrection resets them to status: open, stage: idle, assignee: null and removes the worktree.

This destroys completed developer work. A developer that finished before the binary restarted loses all its changes.

Root Cause

resurrectionScan conflates two scenarios:

  1. Crash mid-development: session died unexpectedly → correct to reset and retry
  2. Completed before restart: session finished normally, binary restarted before heartbeat advanced stage → wrong to reset

Both look identical to resurrection: stage: developing + dead session.

Fix

In resurrectionScan, check pipeline.last_activity timestamp. If the session is dead AND the task is in stage: developing, advance to stage: reviewing instead of resetting to idle. Preserve the worktree and branch.

Alternatively: before resetting, check if the worktree has uncommitted changes. If it does, treat as completed and advance to reviewing.

Acceptance Criteria

  • Developer work is preserved across binary restarts
  • Task advances to reviewing when developer session is dead after restart
  • Worktree is NOT removed when advancing to reviewing
  • Crash scenario (mid-development) still correctly resets to idle
  • bun test and bun run typecheck pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions