Skip to content

Stop heartbeats for a released dispatch - #43

Merged
nachumi-a2zoperations merged 4 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/fork-5
Nov 14, 2026
Merged

nachumi-a2zoperations merged 4 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/fork-5

Conversation

@nachumi-a2zoperations

@nachumi-a2zoperations nachumi-a2zoperations commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #5
Refs #44

Removed

The agent-pane session reap is gone. agent-pane-session-reap.ts, darwin-getsid.ts, the runtime-compiled helper, the teardown call, and their tests are deleted. Closing a pane follows the base teardown order again: the descendant sweep, then the root.

The reap was removed for three reasons:

  • On the macOS daemon, getsid() is 1. The reap treated a session id of 1 or less as "no session" and did nothing. That is the process that hosts agent panes.
  • The orphan in Orchestration: rejected heartbeats from a stale terminal handle keep being delivered to the run (released dispatch) #5 is a Claude Code tool shell. Those shells call setsid, so they are a different session from the pane. Reaping the pane's session never sees them.
  • Where the reap did fire, it SIGKILLed every group in the session, including the root, before killWithDescendantSweep. That skipped the graceful sweep and turned a close into SIGKILL.

Heartbeats

Orca withholds a heartbeat only when the dispatch is released or stopped: release_state or ownership_state is released, or the worker state is stopped or abandoned. The heartbeat is marked read and delivered, the run is not notified, and one warning is logged. The send receipt is a rejection with code dispatch_released and reason dispatch released: stop sending.

stop_unknown, a status change by itself, user_kept, and retained stay deliverable. A rejection on an active dispatch is still delivered.

worker_done, escalation, and decision_gate rejections on a live dispatch are delivered every time, with the reason. A second copy is withheld only when that dispatch is released or stopped.

CLI

orca orchestration send of a heartbeat that comes back dispatch_released prints one line, dispatch released: stop sending, and exits 76. A heartbeat loop must stop on exit 76 and must not send another heartbeat. Other heartbeat rejections still exit 1. The worker preamble has no heartbeat loop. The contract is in the orchestration send notes and the CLI docs.

Follow-up

Refs #44. Record the pane's descendant set while the agent is alive, kill that recorded set with start-time identity checks, and reach setsid tool shells. That is the process-ownership half of #5. This PR is the delivery half, so #5 stays open.

Gate

  • typecheck:node: exit 0 on 41e80ba
  • typecheck:web: exit 0
  • typecheck:cli: exit 0. The direct RuntimeClient assertion failed tsconfig.tc.cli until 625671d changed the fixture to as unknown as RuntimeClient.
  • oxlint: exit 0
  • oxfmt --check: exit 0
  • Affected suite for the dedupe commit: send.test.ts, 21 passed, exit 0. Earlier affected vitest (4 files, 64 tests) and the exit-76 file (13 tests) also exited 0.
  • Full pnpm test with the JSON reporter.
    • HEAD 41e80ba7e7bce85372c17bbb92c362a4dba2715a: exit 1, 433 failed, 42588 passed, 1316 pending, 44339 total.
    • BASE 9b56fa143556d8051559a5ba015322e11ce7448d: exit 1, 429 failed, 42580 passed, 1316 pending, 44327 total.
    • 427 failed on both.
    • 2 failed only on base:
      • src/main/git/command-runner/git-admission-storm-measurement.test.ts — git admission storm measurement bounds real children and drains interactive work before the background backlog
      • src/main/persistence/profile-state/profile-state-backup-worker.test.ts — profile state backup worker cleans a terminated cancel worker only after exit
    • 6 failed only on HEAD. All six are in Electron files this diff does not touch, and each passed on the first isolated rerun:
      • browser-extension-toolbar.electron.test.ts — keeps action state per tab, opens a sized popup under the button and activates tabs
      • browser-extension-native-messaging.electron.test.ts — answers sendNativeMessage once and kills that host after the reply
      • browser-extension-native-messaging.electron.test.ts — kills the host when the worker disconnects its port
      • browser-extension-native-messaging.electron.test.ts — reports a missing host, a forbidden extension and an exiting host with Chrome's errors
      • browser-extension-native-messaging.electron.test.ts — round-trips with a registered host from the worker, passing Chrome's arguments
      • browser-extension-lifecycle.electron.test.ts — installs once, starts up on the next launch, and updates on a new version or reload
  • check:changed against 9b56fa14355 was last run before 41e80ba and exited 1. The CLI typecheck failure is fixed in 625671d. The remaining unit failure is ephemeral-vm-provisioned-root-ref.test.ts, which this diff does not touch: the local commit-msg hook refuses fixture author Test <[email protected]>. That check was not re-run on 41e80ba.

Head is 41e80ba7e7bce85372c17bbb92c362a4dba2715a.

…a released dispatch.

A nohup heartbeat loop in the pane's session outlived worker-release once its tty was gone, and each rejected heartbeat was still delivered to the run. Closing a launchAgent pane now SIGKILLs the groups snapshotted in that session, and a rejected report for a released or stopped dispatch is marked read without waking the run.
The session reap was a no-op in the macOS daemon session, missed tool shells that run in their own session, and SIGKILLed the root before the descendant sweep. A heartbeat for a released or stopped dispatch now exits 76 so the loop can stop. Other rejected reports are still delivered once.
tsconfig.tc.cli rejects a direct RuntimeClient assertion, so the fixture goes through unknown the way the other handler tests do.
@nachumi-a2zoperations nachumi-a2zoperations changed the title Reap a released agent pane's session and withhold its rejected heartbeats Stop heartbeats for a released dispatch Nov 14, 2026
A second worker_done or escalation rejection on a live dispatch was withheld. Dedupe now uses the same released-or-stopped check as the heartbeat withhold.
@nachumi-a2zoperations
nachumi-a2zoperations merged commit 4ca06a9 into blowzer/fork-only Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant