fix(core): fail runs when app commands exit after readiness
Why
- A run must fail when its managed app exits after readiness.
- The startup listener kept later exit status locally, so tests could pass against a dead app.
What changed
- Interrupt active tests and skip queued tests only for dependent targets with unfinished work.
- Notify every owner of a shared command and ignore exits after owners finish, including teardown.
- Report the exit code or signal with a bounded, redacted log excerpt when available.
- Give navigation recovery advice that accounts for an existing command.
Applies to e2e run, including MCP run_tests.
Hosted openHost sessions and interactive MCP open_session sessions do not yet forward managed command exits into session cancellation.
flowchart LR
App[Managed app exits] --> Owners[Declaring targets]
Owners --> Pending{Unfinished work?}
Pending -->|Yes| Stop[Interrupt active work and skip queue]
Pending -->|No| Ignore[Ignore exit]
Issue
Fixes #1532
Verified
Ran it locally: yes
Ran the built CLI with real HTTP apps and Chromium using e2e run --reporter list.
Fourteen fresh CLI reports covered shared commands, healthy targets, startup buffering, teardown, Ctrl-C, forced worker termination, log redaction, and navigation hints.
Each report passed schema, unique-result and process-cleanup checks.
Two further CLI scenarios forced the watchdog to kill ordinary and serial workers before the app-exit grace timer, with --max-failures 1.
Both preserved healthy active and queued tests.
| Scenario | main 732ea8af | this branch |
|---|---|---|
| App exits 1 or 0, or receives SIGTERM | Exit 0, queued work runs | Exit 3, active test interrupted, queued work skipped |
| App exits while a separate target remains healthy | App death goes unreported | Only dependent target stops. Healthy target finishes both tests |
| App exits during final disposal | Exit 0 | Exit 0 |
Built CLI output from the watchdog-first scenario:
× |a| tests/repro.e2e.ts > blocked a (interrupted)
↓ |a| tests/repro.e2e.ts > a queued [target "a" command exited with code 1 after becoming ready]
✓ |b| tests/repro.e2e.ts > healthy active
✓ |b| tests/repro.e2e.ts > healthy queued
ERROR infrastructure error APP_UNREACHABLE
target "a" command exited with code 1 after becoming ready
output in .e2e/logs/a.log since target "a" command started:
app a exits
The command returned 3 without TEST_TIMEOUT or a failure-limit event.
The scheduler returns the affected target set directly.
Twelve built-CLI scenarios matched before and after the reduction, including exit codes, skip reasons, interrupted attempts, and diagnostics.
The buffered-exit regression waits for runner-confirmed readiness, then confirms the first app is dead before letting a second app finish startup.
Four further mutations fail their regressions: dropping buffered delivery, removing serial exit-code handling, replacing the returned-unit skip reason, and iterating the live worker array.
A real Ctrl-C after a separate app failure still returns 130.
Three further built-CLI Chromium checks covered refused navigation with a log, without a log, and without a managed command.
The managed hint explains how to enable output capture.
Six paired testbed forms runs matched outcomes, step sequences, and every counter.
Every measured CLI run exited 0.
The suite interval stayed within the configured 5% threshold.
The host had background CPU load, so no speedup is claimed.
| Metric | main median | this branch median | Paired change, 95% interval |
|---|---|---|---|
| Suite attempts | 3.02 s | 3.01 s | -0.1%, -2.5% to +4.5% |
Reviewed with sol-loop: 5 rounds with gpt-6.1-sol on xhigh. Sol verdict: approved
Created with GPT-6.1 Sol in T3 Code.