Add chapter: subprocesses and external streams (structured teardown)#22
Open
adamw wants to merge 1 commit into
Open
Add chapter: subprocesses and external streams (structured teardown)#22adamw wants to merge 1 commit into
adamw wants to merge 1 commit into
Conversation
Adds guidance for the case structured concurrency is easiest to get subtly wrong: driving a long-lived subprocess (or socket/SSE) whose output is read line-by-line. The reader is a fork whose return value is the result; the killer is teardown — a blocking native read ignores interruption, and Ox joins forks before running `releaseAfterScope` finalizers, so the resource must be destroyed in the scope body's `finally` (before the join), and a launcher subprocess needs its whole tree killed or an orphan keeps the pipe open. - New chapter 170-subprocesses-and-external-streams.md. - SKILL.md: two always-loaded design rules so the agent decides the owning scope and the teardown point UP FRONT (model readers as forks with return-value results; never return a live fork-owning handle; destroy blocking resources in the body finally, not releaseAfterScope), plus the index entry. Grounded in Ox's documented scope-teardown semantics (interruptAllAndJoin runs in the body finally; finalizers after). Co-Authored-By: Claude Opus 4.8 (1M context) <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
Adds guidance for the case structured concurrency is easiest to get subtly wrong: driving a long-lived subprocess (or socket / SSE) whose output is read line by line.
170-subprocesses-and-external-streams.md:supervisedscope; the reader's return value is the result (fork{…}.join()), not a cross-threadAtomicReference/CAS;releaseAfterScopefinalizers — so destroy/close the resource in the scope body'sfinally, before the join;SKILL.md: two always-loaded design rules (decide the owning scope first; result is the fork's return value; never return a fork-owning handle; destroy blocking resources in the bodyfinally, notreleaseAfterScope; tree-kill launchers) plus the index entry.Why
The detailed how lives in the chapter; the decision triggers live in the always-loaded
SKILL.mdso the agent picks the right ownership and teardown shape before writing code — the failure mode here is a shutdown-time deadlock that doesn't show up until teardown.Grounded in Ox's documented scope-teardown semantics (
interruptAllAndJoinUntilCompletedruns in the scope body'sfinally;releaseAfterScopefinalizers run after).🤖 Generated with Claude Code