Skip to content

P1: Durable crew notices and honest restart recovery with consent-gated resume #1426

Closed

Description

@currentbits

From the T3 Code Orchestrator V2 comparison (report: reports/T3 Code orchestrator for Solenta.md on branch coder/i-want-you-to-research-t3-codes-orchestr-fae77a). This is item 2 of 4. The rule borrowed from V2: owed work is a persisted row, not an entry in an in-memory Map.

Problem

  • Pending crew wake-ups (orchNotices, electron/runner.js:1170) and machine-turn counts (autoTurns, :1179) live only in memory.
  • On boot, every working thread is marked failed with "Run interrupted: the app crashed or was force-quit mid-run" (electron/store.js:~1426-1460).
  • Result 1: a lead whose workers were mid-run never learns they died.
  • Result 2: a worker that finished just before the crash may never wake its lead.
  • The worktrees survive on disk, but nothing points anyone at them.

Build

  • Persist the notices. Move orchNotices and autoTurns into the store (add them to the EMPTY shape in electron/store.js). Write immediately when a notice is queued rather than waiting for the 250ms debounce; notices are tiny.
  • Dedupe. Key each notice by worker id + run id, so a replayed finish can't wake the lead twice. V2's rule: "a missed wake is cheaper than a duplicate one".
  • Mark interrupted threads. Boot recovery keeps the failed status, so the sidebar and waiting logic don't change, and adds interruptedBy: "restart".
  • Tell the lead. For each interrupted orchWorker, queue a notice to its lead with the worktree, branch, last checkpoint and whether the tree is dirty.
  • Hold notices after a restart. Don't flush them automatically at boot; V2 holds queued runs until an explicit resume. Show a "Resume crew (N updates)" control on the lead that calls flushOrchNotices (runner.js:1360). Keep the existing budget and auto-turn gates.
  • Skip the rest of V2's outbox. No generic effect outbox, leases or retry worker: Solenta is one process, and wake-ups are the only owed work it currently loses.

Tests

  • Restart while a worker is mid-run: the lead gets an interrupted-worker notice after the user resumes, and only then.
  • A worker that finishes before the crash still wakes its lead after restart.
  • No duplicate notice when the same finish is processed twice.

Size: M. Related: #182 (crash-resume for multi-phase workflows). The replay harness issue (item 4) makes the restart test realistic.

Activity

  1. added
    plan:todo
    on Oct 4, 2026
  2. currentbits commented on Oct 4, 2026

    @currentbits
    OwnerAuthor

    A code-level pass produced a design for this issue. Full detail: reports/T3 Code orchestrator deep dive.md on branch coder/i-want-you-to-research-t3-codes-orchestr-fae77a. Size unchanged: M, about 450–550 lines including tests (3–4 days).

    Corrections to the issue body

    • A clean quit loses notices too. Only a crash marks threads failed (store.js:1413-1461). A clean quit marks them idle through stopAll (runner.js:9074-9121), and neither path tells the lead. So both paths must enqueue an "interrupted" record.
    • Keep the 250ms debounce. saveNow is a synchronous write of the whole envelope, and transcripts already use the debounce.
    • Drop interruptedBy. lastError already says what happened.

    Record contract

    Commit this before forking workers, because #1427 extends it.

    // store.data.orchNoticesByThread[leadId]: OrchNotice[]; store.data.autoTurnsByThread[threadId]: number
    interface OrchNotice {
      id: string;   // worker:<workerId>:<runId> | interrupted:<workerId>:<runId> | line:<uuid>
      kind: "worker" | "interrupted" | "line";
      text: string; workerId?: string; status?: "done" | "failed"; cause?: "crash" | "quit";
      at: number; held?: true; result?: WorkerResult /* #1427 */;
    }

    Key the dedupe on (worker, runId), never on worker alone. T3's #13490/#13331 show what happens when a child's follow-up runs can't wake the parent.

    Design

    • Store (store.js):
      • Add both keys to EMPTY (78-104), to the reset literal (4125-4141) and to the load whitelist next to tasksByCrew (2451-2456).
      • normalizeNotices sets held:true on everything loaded from disk.
      • The *ByThread suffix gets cleanup in deleteThread for free.
      • recoverInterruptedRuns appends a held interrupted record to each recovered orchWorker's lead.
    • Runner:
      • Delete the Maps (1163-1179).
      • enqueueNotice dedupes by id and goes through the store.
      • flushOrchNotices returns early when any record is held.
      • stopAll enqueues cause:"quit" records.
      • New resumeCrew({threadId}): clears held, flushes, pushes, and returns {released}. The budget gate and 25-turn cap are unchanged, and the wake turn stays fromNotice, so the lead still can't land work on it.
    • IPC and UI:
      • Put heldNotices on ThreadDetail, not ThreadInfo (listThreads caches rows by identity).
      • Wire runs.resumeCrew like resumeQuotaWait: ipcChannels.ts:182, then sync-ipc-preload.js, ipc.ts, ipc.js:1538, useCoder, and the devCoder stub.
      • Add a strip next to the quota-wait strip (ThreadView.tsx:8346-8385): "Solenta restarted while this crew was working — N updates are waiting" with a Resume crew (N) button. Reuse styles.retryBtn; no new .module.css.

    Tests

    • store.test: reload produces a held record; records round-trip; deleteThread cleans up.
    • crew-notices.test (CODER_SIMULATE):
      • nothing starts after stopAll and a reload;
      • resumeCrew starts a fromNotice run;
      • a persisted cap of 25 yields "Not delivered";
      • a duplicate enqueue lands once.
    • A renderer test, plus npx vite build and typecheck.

    Order: land #1428's harness and the I3 one-line fix from #1425 first. #1427 builds on the record shape above.

  3. added
    plan:doing
    and removed
    plan:todo
    on Oct 12, 2026
  4. added
    plan:done
    and removed
    plan:doing
    on Oct 13, 2026
  5. currentbits commented on Oct 13, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "P1: Durable crew notices and honest restart recovery with co" (PR #1613). Closed on merge.

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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions