Skip to content

test: make HTTP lifecycle qualification independent of provider speed - #23

Merged
ThorFuchs merged 7 commits into
mainfrom
fix/stalled-writer-lifecycle-tests
Nov 23, 2026
Merged

ThorFuchs merged 7 commits into
mainfrom
fix/stalled-writer-lifecycle-tests

Conversation

@ThorFuchs

@ThorFuchs ThorFuchs commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Problem

The stalled-writer test assumes a finite provider must still be running when its output times out. Core event emission acknowledges bounded queue admission, so a provider may already have returned while its request still owns the drain. The old cancelled counter also counts every error caught in the emission loop; it does not identify Swift task cancellation specifically. This makes the release assertion depend on scheduling and throughput.

Change

This candidate includes PR #20's existing connection-admission change, and replaces the ambiguous lifecycle expectation with complementary contracts:

  • A finite provider may return normally or end through cancellation/stream failure; a stalled native writer must still time out once and fully release resources.
  • A provider held behind an unfulfilled cancellation-aware signal must actually receive CancellationError.
  • A deterministic public-Core sink gate holds output after the provider reaches its normal return path, proves ownership is retained, then fails delivery and proves cleanup with no second write.
  • Both native stall cases require Core and HTTP resource counts to reach zero before client reading or listener shutdown, and a new request must succeed on the same listener with a one-connection ceiling.

The frame count, payload size and I/O deadline remain unchanged. The runbook/runner pins the exact HTTP commit, checks clean fresh checkouts and lock identity, verifies actual nonempty test execution, and archives partial logs. Referee builds now honor the two-job setting. Release fixture tests receive the exact optimized server path through MCP_REFEREE_FIXTURE, with an executable check. The fixture now checks its actual two-component started/joined report, and the subprocess test requires one cancellation notification before one graceful completion, consistent with the frozen subscription-teardown rules. The lifecycle document separately identifies the response-head/static-output deadline coverage gap.

Validation

Tested head: 7ed6fc14ff86ee69064e2249c836c931df86e1c5, tree 3c9b8c6be010fac09692460f8f85408e60c5690d. CI's synthetic merge commit e0b014d448cce063416e823a4234bec4a8355171 has the same tree. This PR was merged on 2026-11-23 as 7287b61910e713b5790f57e111e8d9273f46996c; that commit is the current main at review time and has exactly the same tree.

  • Focused macOS run 45077957715 PASS: four named tests in Debug and four in Release; actual nonempty execution, root/fixture graph and final source integrity all passed. Both native provider variants observed actual cancellation, complete cleanup and same-listener recovery.
  • Independent Mac Studio focused run PASS, 2026-11-23 08:15:45–08:22:01 UTC, exact tested head above: four named tests actually executed in Debug and four in Release, exit 0, no failed or blocked steps. Root and fixture lockfiles before and after execution are byte-identical to the MacBook focused artifacts (29 pins each); clean checkout and final source integrity passed. Studio Release finite provider: timeout=1 returned=1 cancelled=0 admitted=32 received=660404; deliberately live provider: timeout=1 returned=0 cancelled=1 admitted=32 received=660404. Both pass resource cleanup before client reading/listener shutdown and successful same-listener recovery. Debug also passes, with actual cancellation in both native cases. This independently confirms both intended lifecycle contracts on the Studio; it does not establish timestamp ordering for the original failing run. Reviewed archive: studio-focused-7ed6fc14ff86-20261123T081545Z-1Rb26E.tar.gz, SHA-256 b5be35f5a8031acd41146d20faa1d326e2e3a04e6b201154547805250d27be9c. The separate Studio full run is still in progress.
  • Full CI 45077961678: macOS Debug PASS (115 SDK tests, three existing early-EOF known issues; server referee 37/37 required plus 13/13 implemented extensions; client referee 37 scenarios and 399/399 checks). Linux optimized builds and both fixture links PASS. Full macOS Release PASS: 115 SDK tests (the same three known issues), seven fixture tests including both subprocess variants, server referee 37/37 required plus 13/13 extensions, and client referee 37 scenarios / 399 checks with no warnings.
  • Both current Debug and Release referee artifacts contain the actual process receipt FIXTURE_STOPPED started=2 joined=2 active=0.
  • The first Release attempt linked both fixtures and passed all 115 SDK tests, then exposed the missing MCP_REFEREE_FIXTURE environment. Tracing that previously unreached subprocess path also identified the stale single-component receipt and the outdated negative subscription-cancellation assertion; these are corrected in the current head.
  • Local Bash syntax and whitespace checks passed. This editing environment has no Swift compiler; native compilation and execution use the existing macOS runner.
  • Original diagnostic run 45072919323: instrumented Debug and Release both passed; Release admitted 31 of 32 attempted events and received an actual CancellationError. That instrumented run did not reproduce the normal-return case. The final full Release run now does: the finite native case reports timeout=1 returned=1 cancelled=0 admitted=32 received=660404, while the deliberately live provider reports timeout=1 returned=0 cancelled=1 admitted=32 received=660404. Both pass cleanup and recovery. This is a native observation of the intended alternative lifecycle, not a retrospective reconstruction or precise return/timeout timestamp ordering for the original Studio execution.

Scope and remaining blockers

This PR builds on PR #20; it does not include PR #21's dependency upgrade. The separate PR20 + HTTP-server 0.5.0 link probe removed the Connection link error but retained the Reader metadata errors, independently reproduced without MCP. Symbol inspection shows private-external Reader metadata becomes local during Swift Build's intermediate object link. The native-backend comparison now passes the same combined server and all four Release probes. The full graph is byte-identical across the two backend runs (29 pins); the mini graph is separately byte-identical across its runs (24 pins). Both use -O and whole-module optimization. Native links the original object files, preserving the private-external definitions needed by the consumer. The selected toolchain marks the native backend deprecated, and this is link qualification only: no shipping backend/dependency switch is included.

The existing Darwin early-EOF known issues (#12 / apple/swift-nio#3783), immutable Core release dependency (#14), and response-head/static-output deadline qualification remain separate. The required CI is reviewed and green with the explicitly retained known issues. This PR is now merged. The independent Studio focused comparison is also reviewed and green; the separate local Studio full qualification remains pending.

Refs #13, #20, #22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant