Skip to content

Runtime Host startup fails when a ScheduledTask admission outlives its pending fire #4133

Closed

Description

@me2seeks

What happened

Runtime Host recovery aborts the entire workspace when a non-terminal ScheduledTask root admission still exists after its pending fire has already been settled or removed.

During hosted execution recovery, assertRecoveryAdmission() requires every non-terminal ScheduledTask admission to have an exact matching pending fire. If the process stops after fire settlement but before the AgentRun terminal fact is committed, the next startup throws:

ScheduledTask admission <turn-id> has no matching pending fire

The error is surfaced to CLI/TUI as INTERNAL_STARTUP_FAILURE, so unrelated Sessions in the same workspace cannot be opened even though the SQLite database remains valid.

Expected behavior: recovery should reconcile this crash boundary into a durable terminal Run state, or otherwise isolate the affected admission, without preventing the workspace from starting.

How to reproduce

This requires an interruption at a specific durable-state boundary and may be intermittent:

  1. Allow a ScheduledTask fire to create its root admission and AgentRun.
  2. Let the pending fire be settled or removed.
  3. Stop the process before the corresponding AgentRun receives a terminal RuntimeEvent/header update.
  4. Restart Runtime Host for the same workspace.
  5. Startup fails while validating the ScheduledTask admission.

The current source path demonstrates the ordering:

  • packages/runtime-host/src/server/hosted-execution-recovery.ts:80-86 validates every non-terminal ScheduledTask admission before ordinary recovery closure.
  • packages/runtime-host/src/server/scheduled-task-coordinator.ts:168-187 throws whenever no exact pending-fire match exists.

The missing state combination is:

root admission: present
AgentRun: running
pending fire: absent
terminal RuntimeEvent: absent

Environment

  • Maka commit: b21392287 (origin/main, verified 2026-08-29)
  • OS: Linux
  • Surface: CLI/TUI and Runtime Host
  • Node.js: 26.3.0

Logs, screenshots, or additional context

The database integrity check can still report ok; this is a cross-record recovery invariant gap rather than SQLite corruption.

The repair should preserve the Session, messages, ScheduledTask record, and admission history. Only the interrupted execution needs a canonical terminal/recovery fact. A regression test should construct the four-record state above and verify that Runtime Host reaches ready state without replaying the ScheduledTask effect.

Activity

  1. me2seeks commented on Aug 29, 2026

    @me2seeks
    ContributorAuthor

    I'd like to work on this. I'll open a PR once the fix and tests are ready.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions