Transport lifecycle hardening: explicit quiescence boundary and session state - #2
Merged
Merged
Conversation
TCP/UDP teardown relied on implicit, unowned background work and implicit session state; make both explicit. Ownership: DurableCaptureBundle owns the native pools and the single shared SetupExecutor; the coordinators take them as required ctor deps and never dispose injected collaborators. TCP: relay DisposeAsync awaits Completion (fault observed and swallowed); the acceptor awaits its terminal relay observation and owns the session lifetime, so the store's "await AcceptLoop" is a real quiescence wait; attach failure now tears the session down outside the setup try; RegisterSession releases the claimed listener/alias/token on a construction fault; the setup-failure cooldown is written inside the store inflight section. UDP: per-session linked lifetime CTS (idle expiry no longer fabricates a receive failure); UdpSessionState/UdpTeardownReason enums; SendSpanAsync returns bool and drops fail-closed (counted, rate-limited) instead of throwing; the coordinator drains in-flight failure teardowns on dispose. Gates: format clean, Release build 0 warnings, 744 tests green, jb 0 issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the TCP/UDP transport teardown boundary and session state explicit, replacing implicit unowned background work and implicit state.
Task:
09-20-transport-lifecycle(archived under.trellis/tasks/archive/2026-09/).Ownership (R6)
DurableCaptureBundleis the sole owner of the native buffer pools and the single sharedSetupExecutor._ownsXflags and create-if-null branches removed;TcpProxyCoordinator.DisposeAsyncis single-flight.TCP quiescence (R1/R2)
TcpProxyRelay.DisposeAsyncawaitsCompletion(fault observed and swallowed).await session.AcceptLoopis a real quiescence wait; the lifetime CTS is disposed after its last reader.try;RegisterSessionAsyncreleases the claimed listener/alias/token on a partial failure; the setup-failure cooldown is written inside the store inflight section.TcpRelayFaultObserver.Observesites were duplicates — they are distinct discard paths.UDP lifecycle (R3/R4/R5)
_receiveFailure.UdpSessionState/UdpTeardownReasonmake the state machine and the teardown reason explicit; onlySetupFailurearms the setup cooldown.SendSpanAsyncreturnsValueTask<bool>; a send against an expiring/faulted session is a counted, rate-limited fail-closed drop instead of anIOExceptionreaching the dispatcher; the sender never removes the slot.Gates
dotnet format WinForward.slnx --severity info --verify-no-changes --no-restoredotnet build WinForward.slnx -c Releasedotnet test WinForward.slnx -c Releasejb inspectcode -f=Xml -e=HINTSpec
Updated
tcp-local-redirect.md,udp-relay.md,error-handling.md,quality-guidelines.md.Notes
TcpProxyCoordinator.csis at 395/400 effective lines — the next change should plan a split.GcSoakScenario.csremains over the 400 effective-line limit (pre-existing).TaskScope) + lifetime analyzers.