refactor(claude): unify subprocess teardown into one idempotent verb (C8)#326558
Draft
TylerLeonhardt wants to merge 1 commit into
Draft
refactor(claude): unify subprocess teardown into one idempotent verb (C8)#326558TylerLeonhardt wants to merge 1 commit into
TylerLeonhardt wants to merge 1 commit into
Conversation
…(C8) Collapses the pipeline's teardown spellings into a single private `_teardown()`, guarded by a `_torndown` flag so the WarmQuery is async-disposed exactly once — idempotency now rests on our own flag, not on the SDK `close()` cleanup happening to be memoized (report 02 H1/H2). - `shutdownAndWait()` is the awaited face (callers that must not reuse the `--session-id` until `<id>.jsonl` is released); `dispose()` fires the same teardown and forgets. Both run `abort -> WarmQuery.asyncDispose -> Query.return` in one place, at most once. - Replaces the two dispose-chain `toDisposable`s (separate abort + async-dispose) with one; the abort still runs synchronously before `dispose()` returns. - C9 already deleted the third spelling (`_rebindQuery`'s manual asyncDispose), so this is the last of the three. Adds a pipeline test pinning the idempotency (shutdownAndWait then dispose async- disposes once). Suites green: claudeSdkPipeline 13, claudePromptQueue 12, claudeAgent 197. typecheck-client / eslint / valid-layers clean. Live smoke suite 19/19 (materialize / reuse / recover-rebuild / abort-churn + reaping). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
C8 — one teardown path, explicitly idempotent. The pipeline had two teardown spellings that both async-disposed the
WarmQuery, and their safety-under-double-call rested on the SDK'sclose()cleanup happening to be memoized (report 02, H1/H2). C8 collapses them into one private_teardown()guarded by a_torndownflag:shutdownAndWait()is the awaited face — used where we must not spawn a fresh subprocess reusing the same--session-iduntil the old one has released<id>.jsonl(yield-restart / rebuild resume).dispose()fires the same_teardown()and forgets. The abort +WarmQuery.asyncDisposerun synchronously beforedispose()returns, so the subprocess is still signalled to stop promptly.abort → WarmQuery.asyncDispose → Query.returnin one place, at most once, regardless of which caller wins.toDisposables (separate abort + async-dispose) with one.C9 already deleted the third spelling (
_rebindQuery's manualasyncDispose), so this closes out the set.Why it's safe
_torndown), not an SDK implementation detail. AshutdownAndWaitfollowed bydispose(the rebuild path) is a guarded no-op instead of a redundant double-dispose.shutdownAndWaitstill awaits actual process exit;disposestill fires-and-forgets.Validation
claudeSdkPipeline13,claudePromptQueue12,claudeAgent197.typecheck-client/eslint/valid-layers-checkclean.test/agent-host-e2e/): materialize / warm reuse / recover-rebuild / abort-churn with subprocess reaping — the scenarios that exercise teardown end-to-end against a real subprocess.🤖 Generated with Claude Code