You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(harness): report background task health truthfully #5237
Background tasks can report running even when their endpoint is not listening or reachable. Add explicit lifecycle states, endpoint health checks, PID and bind address, startup and exit logs, and prevent unverified ready claims. Relates to #5213
Observed evidence from the H5 session: the background-task wrapper reported status running for a Python HTTP server, while a later curl request to 127.0.0.1:8765 returned connection refused. This proves process state alone was insufficient evidence of endpoint readiness. It does not prove the root cause; implementation must expose the cause.
#5216 is now merged. The remaining harness gap is still independent: background-task status must distinguish process tracking from endpoint readiness, expose lifecycle/health evidence, and prevent unverified ready claims. This issue remains open for a dedicated harness implementation.
I traced the misleading state to the managed Bash lifecycle: ShellRunProcessManager marks a durable run as running after the child process spawns, while the canonical shell_run result currently exposes neither the child PID nor endpoint-readiness evidence. I would keep running as a process-lifecycle fact instead of redefining it as “ready.”
Proposed implementation:
Add an optional, strict health_check declaration for background Bash. It will accept a bounded loopback HTTP endpoint (127.0.0.1 or ::1, explicit port/path, no credentials/query/fragment) and reject foreground or non-loopback use. The runtime will not guess a bind address by parsing arbitrary shell commands.
Persist and project the spawned PID, declared host/port, and endpoint state separately from process state. The endpoint state will distinguish checking, healthy (successful HTTP response), listening (HTTP responded but was unhealthy), and unreachable, with a check timestamp and safe status/cause fields but no response body.
Make the initial background handoff perform the bounded check, and refresh it when an active task is read. Process exit wins the race and remains represented by the existing terminal status, exit code, timestamps, and captured stdout/stderr. Only health_check.status === "healthy" supports a ready claim.
Extend the canonical record/result validation rather than adding a parallel status source. Focused coverage will include a spawned process with no listener, a delayed healthy listener, non-2xx listening, exit before readiness, invalid/non-loopback declarations, persistence/projection, and the unchanged no-health-check path.
This stays separate from the broader capability preflight and managed Artifact preview work in #5234/#5238, and preserves the Browser/file-URL boundaries established around #5216.
Automated contribution proposal generated with Codex.
Implemented in PR #5261. The change keeps process tracking and endpoint readiness separate, persists/exposes the native PID, adds policy-controlled HTTP(S) probing via BackgroundTaskHealth, fails closed for privacy/credential restrictions, and includes focused regression tests. CI is running.
This was implemented by #5261, merged as bf6e94229. packages/runtime/src/background-task-health-tool.ts keeps process lifecycle separate from endpoint readiness, persists and exposes the native PID and the declared host/port, performs a bounded loopback probe, and reports the endpoint state rather than inferring readiness from a spawned process, with regression coverage in packages/runtime/src/__tests__/background-task-health-tool.test.ts. Closing as completed.
Activity
liugddx commentedon Sep 12, 2026
Observed evidence from the H5 session: the background-task wrapper reported status running for a Python HTTP server, while a later curl request to 127.0.0.1:8765 returned connection refused. This proves process state alone was insufficient evidence of endpoint readiness. It does not prove the root cause; implementation must expose the cause.
liugddx commentedon Sep 13, 2026
#5216 is now merged. The remaining harness gap is still independent: background-task status must distinguish process tracking from endpoint readiness, expose lifecycle/health evidence, and prevent unverified ready claims. This issue remains open for a dedicated harness implementation.
Dante-dan commentedon Sep 13, 2026
I traced the misleading state to the managed Bash lifecycle:
ShellRunProcessManagermarks a durable run asrunningafter the child process spawns, while the canonicalshell_runresult currently exposes neither the child PID nor endpoint-readiness evidence. I would keeprunningas a process-lifecycle fact instead of redefining it as “ready.”Proposed implementation:
health_checkdeclaration for background Bash. It will accept a bounded loopback HTTP endpoint (127.0.0.1or::1, explicit port/path, no credentials/query/fragment) and reject foreground or non-loopback use. The runtime will not guess a bind address by parsing arbitrary shell commands.checking,healthy(successful HTTP response),listening(HTTP responded but was unhealthy), andunreachable, with a check timestamp and safe status/cause fields but no response body.health_check.status === "healthy"supports a ready claim.This stays separate from the broader capability preflight and managed Artifact preview work in #5234/#5238, and preserves the Browser/file-URL boundaries established around #5216.
Automated contribution proposal generated with Codex.
Dante-dan commentedon Sep 13, 2026
take
liugddx commentedon Sep 13, 2026
Implemented in PR #5261. The change keeps process tracking and endpoint readiness separate, persists/exposes the native PID, adds policy-controlled HTTP(S) probing via BackgroundTaskHealth, fails closed for privacy/credential restrictions, and includes focused regression tests. CI is running.
Astro-Han commentedon Sep 17, 2026
This was implemented by #5261, merged as
bf6e94229.packages/runtime/src/background-task-health-tool.tskeeps process lifecycle separate from endpoint readiness, persists and exposes the native PID and the declared host/port, performs a bounded loopback probe, and reports the endpoint state rather than inferring readiness from a spawned process, with regression coverage inpackages/runtime/src/__tests__/background-task-health-tool.test.ts. Closing as completed.