Commit Graph
1 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 aa287aa2cf fix(hosted): a one-shot runner drains its work before it exits, so the thread hears (#721)
A hosted dispatch ran, Hermes did the task, the run closed `done/success`
with its summary — and the conversation that asked for it never heard a word.
Nothing errored. Nothing logged.

`updateOrchestrationRun` fires `void notifyRunClosed(...)` — its contract is
never to slow a close — and that call is what writes the outcome turn. The web
server outlives such a promise for free. `hosted-runner.ts --once` is a
45-second cron tick: it drained the command and called `process.exit(0)`
while the write was still in flight.

- settle-background-work.ts: a bounded drain window (5s,
  HOSTED_RUNNER_DRAIN_MS), paid only by a tick that actually drained
  something. A window rather than a promise registry, because the void-call is
  this codebase's convention at dozens of sites and threading bookkeeping
  through all of them to repair one process boundary is the larger change.
- loki-loop-e2e.ts now reads the run's state when no turn arrives, so the two
  halves can never be confused again: a CLOSED run with no turn is a lost
  notification (the work happened); an OPEN one is a stuck builder. That
  distinction cost an hour today.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:08:42 -07:00