[v0.8 Core 7] overlap refinement drain with kernel teardown - #1335
Open
sethkarten wants to merge 2 commits into
Open
[v0.8 Core 7] overlap refinement drain with kernel teardown#1335sethkarten wants to merge 2 commits into
sethkarten wants to merge 2 commits into
Conversation
Reconstruct the unique net delta from PR #1265, excluding propagation merges.
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.
Replacement scope
This PR reconstructs and supersedes the unique implementation delta reviewed in #1265 without rewriting that historical branch. The original PR remains the immutable discussion record: #1265
v080/core-split-c4-sibling-validationv080/core-split-c7-lifecycle2cab0cd1003432619b9e253dd58f01febae93a4f77b188b92dc91365cb2bc41bdb46a50669d104a8) is the shared foundation. For reconstructed deltas it is a proven tree-compatible base, not an ancestry claim about the historical PR stack.Validation
tsgo --noEmit: passNo original PR was retargeted, closed, merged, or otherwise mutated.
Note
Medium Risk
Changes session shutdown ordering and error surfacing for kernel teardown and concurrent dispose callers; behavior is well covered by new tests but affects core lifecycle paths.
Overview
AgentSession.disposeAsyncis reworked so graceful shutdown overlaps refinement drain and IPython kernel disposal instead of awaiting them strictly in sequence. Both start before the firstawait, run underPromise.allSettled, and rejections surface as a single error or anAggregateErrorwhen both fail—while synchronous cleanup still runs viadispose()in afinallypath.Concurrent and late
disposeAsynccallers now always join the same in-flight_disposeAsyncPromise, including when_disposedis already true, so they observe the same terminal outcome (success or failure). Kerneldispose()is no longer invoked from_disposeAsyncOnce(where failures were previously swallowed).A new
_asyncTeardownStartedflag is set at the start of async teardown;reload()and_buildRuntime()throw if called while disposal is underway, preventing the runtime from replacing the kernel mid-teardown.Tests in
agent-session-concurrent.test.tscover parallel start order, failure propagation, single finalization, late callers, reload blocking, and dual failure aggregation.Reviewed by Cursor Bugbot for commit 3055505. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Overlap refinement drain with kernel teardown in
AgentSession.disposeAsyncdisposeAsyncnow runs_drainPendingRefinementForDisposal()and_ipythonKernelProvisioner?.dispose()concurrently viaPromise.allSettled, aggregating failures into anAggregateErrorwhen both reject._disposedis already true) share the same terminal promise result, including any rejection._disposeAsyncOnce, which previously silently swallowed kernel disposal errors._asyncTeardownStartedflag causes_buildRuntimeandreloadto throw immediately if called after async teardown has begun.Macroscope summarized 3055505.