fix(runtime-host): pause WorkHub result polling during handoff - #5733
Conversation
Generated-by: OpenAI Codex
hqhq1025
left a comment
There was a problem hiding this comment.
I reviewed PR #5733 at the current head 7dfa1759a4f2d58b318f5d0f26ed434badb74121. I found no substantiated P0–P3 issue in the inspected handoff/result-polling paths.
The new WorkHub result hold stops pending polls and prevents a stale timer callback from crossing the hold (packages/runtime-host/src/server/workhub-result-coordinator.ts:123-181); it waits for an already-admitted reconciliation and its residency to settle before root handoff (packages/runtime-host/src/server/execution-composition.ts:3145-3177). Cancellation releases the hold and schedules a fresh poll, while detach leaves the predecessor held until drain. The added coordinator and production-composition tests exercise pending and in-flight polls, cancellation, residency settlement, and detach. I also checked result delivery/close paths and found no schema or migration changes.
The current-head test and label checks passed. The diff check and synthetic merge onto freshly fetched main are clean. GitHub reports the PR as OPEN and mergeable, but its mergeable state is blocked; this comment is not a merge approval. I did not run local tests (Node 18/no installed dependencies) or a multi-process production handoff.
Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
Astro-Han
left a comment
There was a problem hiding this comment.
Approved at @Astro-Han's explicit request: a small, focused fix with no blocking findings in the automated review of this head and green CI.
Summary
WorkHub result polling could acquire a
hosted-executiondrain residency while Runtime Host handoff was preparing its proof, causing an otherwise idle handoff to be rejected. Pause that scheduler alongside Goals, scheduled tasks, and Daily Review, and wait for any admitted poll to finish before freezing Root executions. Cancellation resumes polling; a detached predecessor keeps it paused.Timer identity checks also reject callbacks queued before a hold. The exact residency proof and Root handoff behavior remain unchanged.
Fixes #5698
Verification
A deterministic production composition regression fails on the original code and passes with the fix. Coordinator tests cover pending and stale callbacks, cancellation, shutdown, and in-flight delivery without duplicate results.
git diff --checkpassed.Validated on macOS with Node 24.20.0. The original Linux CPU-contention environment was not rerun; deterministic timers cover the missing scheduler-pause boundary.
AI use
Select exactly one:
Tool(s) and scope: OpenAI Codex investigated the race, implemented the fix and regression tests, ran local validation, and prepared this submission on behalf of hbw00111. Human maintainer review is still required.
Checklist
Does this PR entail a change in behavior?