test(senpi-task): fail the tripwire marker test fast naming the hung stage

SU
21d ago
+58-12

Fixes #12957.

Problem

The pinned Senpi API surface marker test (packages/senpi-task/src/senpi-api-tripwire.test.ts:84) intermittently hangs on test (windows-latest, 2/2) until the runner-wide 30 s per-test timeout, then fails. CI run 42725867255 failed after 30264.31 ms with this test timed out after 30000ms, and the log never says which of the two awaits hung (loader reload vs session boot). The same test passes in about 3.7 s on the previous green Windows run.

Fix

Bound each boot stage at 15 s with a stage-named timeout, so a hang fails fast with the stage that did not complete instead of hitting the 30 s ceil:

  • defaultLoader.reload() is raced as stage "loader reload".
  • createAgentSession({...}) is raced as stage "session boot".
  • The helper withStageTimeout lives in the test file only; no production code changed.
  • Two unit tests pin the helper: a never-settling promise rejects naming the stage (50 ms timeout in the test), and a fast promise resolves with its value.

QA & Evidence

bun test packages/senpi-task/src/senpi-api-tripwire.test.ts
7 pass, 0 fail, 21 expect() calls
- marker test (real session boot): pass in 864 ms
- hung-promise stage-timeout test: pass in 50.67 ms
tsgo --noEmit -p packages/senpi-task/tsconfig.json
exit 0, no errors

RED (from the issue): CI 42725867255, marker test failed after 30264.31 ms with no stage named. GREEN (local, Linux): 7/7 pass, including the stage-named rejection test.

No changelog fragment: the change touches only a *.test.ts file, which the changelog gate exempts as non-user-facing.

Residual risk

The root cause of the Windows hang itself is still unknown; this change names the hung stage so the next failure is diagnosable, it does not fix the hang.


Summary by cubic

Fixes the intermittent Windows hang in the Senpi API marker test so it fails fast and names the stage that did not complete.

  • Wraps the loader reload and session boot awaits with a 15-second, stage-named timeout instead of letting either hang until the runner-wide 30-second ceiling.
  • Adds two unit tests for the new withStageTimeout helper: one for a hung promise rejecting with the stage name, one for a fast promise resolving normally.
  • Test-only change; no production code modified. The underlying Windows hang cause remains unknown.