Learn · Hidden Machines · Part II
budding
Every Child Needs an Owner
Structured concurrency, capabilities, and error kernels.
You will recover a task tree from detached work, pass authority explicitly as capabilities, and place failure handling at a supervision boundary that can take meaningful action.
The roster closes before the field trip ends
An HTTP request starts inventory, price, and recommendation queries. Inventory answers, so the handler returns. The other tasks later write to request-owned buffers and log errors no caller can interpret.
Structured concurrency organizes tasks as a tree. Creation establishes a ownership edge. Scope exit joins children; failure or cancellation follows a declared policy along those edges. The invariant is lifetime containment: a child cannot outlive the scope owning resources it may touch.
Failures find the layer that can act
Every intermediate layer catching, logging, and wrapping the same error creates noise and loses causality. A layer handles a failure only when it can retry safely, choose a fallback, compensate, or turn it into a meaningful boundary diagnostic. Otherwise it passes the typed failure upward intact. The small supervision boundary that can act is the error kernel.
Where the model stops
Long-lived daemons and application supervisors intentionally outlive requests; they still need explicit owners. Structured concurrency is not “everything is lexical” so much as “every lifetime edge is owned.” A child must not be canceled merely because a sibling fails unless the scope's policy says their outcomes are coupled.
Lessons
- Every child task belongs to a lifetime scope.
- Cancellation is a request; joining proves termination.
- Capabilities expose authority and nondeterminism as inputs.
- Failures should be handled by the nearest layer able to act meaningfully.
Practice
- Draw the task tree for a request that races two replicas and writes one response.
- Separate an explicit capability environment from a service locator.
- Transfer the ownership rule to a UI component starting timers and network work.
Owned work still competes for finite resources. The next chapter treats capacity as conserved credit.
References
- “OpenJDK JEP 525, “Structured Concurrency”.” — task groups as units of lifetime, cancellation, and observability.
- “Joe Duffy, “15 Years of Concurrency”.” — production context for structured task lifetimes and error propagation.