Skip to content

fix(dag): block restart when stale cancel fails #213

Closed

Description

@LeXwDeX

Symptom

Crash recovery treats a pending/queued node with a stale childSessionId as a restart orphan. If cancelling that old child Session fails, recovery swallows the error and immediately makes the node eligible for spawnReady, allowing the old and replacement executions to overlap.

Reproduction

Baseline: dev@3642796de

cd packages/opencode
bun test test/dag/dag-recovery.test.ts --test-name-pattern "aborts recovery when a stale restart-orphan session cannot be cancelled"

Observed deterministic red result: Exit.isFailure(exit) was false; the cancellation error was discarded.

Root cause

The restart-orphan branch in reconcileWorkflow runs cancelSession(...).pipe(Effect.catch(() => Effect.void)) and then continues. Its own comment requires the old child to be cancelled before re-scheduling, but the implementation turns a failed cancellation into successful reconciliation.

recoverWorkflow already catches a reconciliation failure and abandons adoption, so propagating this error prevents spawnReady until a later recovery attempt can establish single execution ownership.

Expected contract

A restart orphan may re-enter scheduling only after the stale child Session cancellation succeeds. A cancellation failure must abort this recovery attempt without inventing a node terminal event.

Acceptance criteria

  • Retain a red test at the reconcileWorkflow seam.
  • Propagate stale-child cancellation failure for pending and queued restart orphans.
  • Preserve best-effort cancellation for already-running ownership-loss nodes, because those nodes are terminalized and cannot be re-spawned.
  • Publish no node event for the aborted restart-orphan recovery.
  • Run the full recovery test file, OpenCode DAG suite, and package typecheck.

Activity

  1. added
    bugSomething isn't working
    ready-for-agentFully specified and ready for an agent
    on Aug 9, 2026
  2. LeXwDeX commented on Aug 9, 2026

    @LeXwDeX
    OwnerAuthor

    已完成并发布:修复由 PR #217 合入 dev,随后经晋级 PR #218 合入 main(bcb00086f7fbf1df1fbfd19cf21b238c2863f724)。PR 门禁与 main 独立全量 CI 均通过,正式版 graphagent-v1.0.1 已发布。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions