Skip to content

test(runtime-host): bound owned-Host lifecycle tests to kernel contracts - #4814

Open
ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/host-lifecycle-test-bounds
Open

test(runtime-host): bound owned-Host lifecycle tests to kernel contracts#4814
ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/host-lifecycle-test-bounds

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4776 (intermittent owned-Host lifecycle failures). The root-cause analysis and the fix shape are @UncertaintyDeterminesYou4ndMe's, proposed in #4784 and donated to the issue after that PR was withdrawn; this commit implements the test-side fix so the findings are not lost, with small adaptations to the current tree.

Three waits were bounded by numbers the kernel does not promise:

  1. Launch-owner exit test gated its assertion on the Client's own connection.closed — the Client aborts that transport after a 2 s unanswered liveness probe, so a merely busy Host resolved it while still running, and the exit budget started at a moment unrelated to shutdown. The assertion now waits on the process directly (waitForProcessExit(pid, 20_000)), a bound derived from the kernel contract: owner loss cannot close a composition before startup settles, and the following shutdown is bounded by shutdownGraceMs (10 s). 20 s sits above every legitimate exit and below the launcher's new 60 s idle grace, so an idle exit cannot satisfy it.
  2. The owned-launch fixture ran with idleGraceMs: 10_000, which could expire mid-test and let an idle exit masquerade as an owner-loss exit. It now runs at 60 s with an explicit initialConnectionTimeoutMs: 10_000 so a Candidate no Client ever reaches still exits on its own.
  3. "Owned Host exits promptly" conflated shutdown start with shutdown duration, and its 5 s settle bound sat inside the kernel's own 10 s shutdownGraceMs — a starved-but-clean Host was force-terminated and reported false !== true. The test now asserts shutdown start separately (polling the control directory until the registration disappears or reports draining, the state the kernel publishes before any shutdown work) and then settles at 15 s.

Verification

Claim Command Result
Focused tests pass with the fix node --test --test-name-pattern=… on both dist tests (fresh build) both pass
owned-candidate file complete node --test owned-candidate.test.js 11 tests, 11 pass, 0 fail
host-kernel file complete node --test host-kernel.test.js 70 tests: 64 pass, 5 skipped, 1 fail — answers an admitted bootstrap with draining after shutdown commits (EPIPE)
That failure is pre-existing on Windows, not from this diff control run with the three changed files stashed, rebuilt, same focused test fails identically on the clean tree
Format npm run format:check exit 0

Honest limits: the full Runtime Host suite was also started on this Windows machine and stalled after ~350 tests on a file unrelated to this diff (an environment issue worth its own investigation; the UDS-inspect tests adjacent to the stall are Windows-skipped). The authoritative full-suite result will come from CI on Linux/macOS. The flake itself was reported on macOS arm64; per the issue's data (2/10 and 1/10 focused failures) the tightened bounds remove both timing holes the analysis identified.

AI use

Implemented with ZCode (GLM-5.3-Flash) from @UncertaintyDeterminesYou4ndMe's donated analysis and #4784 patch, adapted to the current tree and re-verified. The commit carries the Generated-by trailer.

Checklist

  • Test-only diff; no production code changed
  • Analysis credit to the original finder in commit message and PR
  • New bounds derived from kernel contracts (shutdownGraceMs, idle grace), not magic numbers
  • Pre-existing Windows failures disclosed with control-experiment evidence

Fixes the intermittent failures reported in apache#4776. The test-side analysis
and fix shape are @UncertaintyDeterminesYou4ndMe's (proposed in apache#4784 and
donated in the issue after that PR was withdrawn); this commit implements
it so the findings are not lost.

- The launch-owner exit test gated its assertion on the Client's own
  `connection.closed`, which the Client aborts after a 2 s unanswered
  liveness probe, so a merely busy Host resolved it while still running.
  The assertion now waits on the process itself with a 20 s bound derived
  from the kernel's `shutdownGraceMs` contract, below the launcher's new
  60 s idle grace.
- The owned launch fixture's `idleGraceMs` (10 s) could expire mid-test
  and let an idle exit masquerade as an owner-loss exit; it now sits at
  60 s with an explicit `initialConnectionTimeoutMs`.
- "Exits promptly" now asserts shutdown start (the kernel's published
  `draining` registration) separately from shutdown completion, and the
  settle bound (15 s) sits above the kernel's own 10 s grace instead of
  inside it, so a starved-but-clean Host no longer reports an unclean
  exit.

Fixes apache#4776

Generated-by: GLM-5.3-Flash (ZCode)
@github-actions github-actions Bot added the effort/S Under 100 readable lines label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/S Under 100 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky(runtime-host): owned Host lifecycle tests intermittently fail to observe process exit

1 participant