Skip to content

CLI and MCP each reimplement the tracked-run lifecycle; one RunLifecycle, second Ctrl-C still finalizes #1663

Closed

Description

@nc9

Tracked cloud runs (register, running, terminal) are driven by apps/cli/src/lib/run-tracker.ts (createRunFinalizer, ~690) for the CLI and again by mcp/billed-audit.ts:109-170 (RunLifecycle, closeRun, lifecycles map, shuttingDown) for MCP. Both reimplement at-most-once terminal. The SIGINT handler is process.once, so a second Ctrl-C skips finalize, and the run waits for the server-side reaper.

Approach: one RunLifecycle (register, markRunning, close(terminal)) with at-most-once close and bounded retries, used by both. Handle SIGINT so a second signal still sends the terminal status before exit (with a short cap).

Acceptance Criteria

  • CLI audit and the MCP server use the same lifecycle module
  • Test: close() called twice sends one terminal update
  • Test: a second SIGINT during finalize still sends the terminal status (or exits after a documented cap)
  • markRunning after close is a no-op (test)

Activity

  1. added
    P2
    size: M
    on Nov 10, 2026
  2. added theissue type on Nov 10, 2026
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

    P2clisize: M

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions