Repository navigation
Scope ChildAlreadyExistsError to caller-chosen invocation ids and add readable diagnostics - #237
Merged
Merged
Conversation
Effect, Stream, and timer invocations run under runtime-reserved child ids, so their machines no longer carry ChildAlreadyExistsError and fixed-child parents need onFailure only when the child's own error is reachable. Invocation ids within one state must be distinct, and constraint failures for required parents and unreachable invoke channels now carry readable diagnostics instead of never. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHnF2EL6ReDTKwoM9TVH7L
Contributor
Type performanceMeasured with TypeScript 6.0.3 and
Marginal instantiations are measured against the matching setup without that API call:
Check times (informational)
Type instantiations are the comparison metric. Check time varies with runner load and is informational only. |
Contributor
Runtime performanceMedian of 5 independent benchmark processes on Pull request baseline
Process runtime reference points
Effect Machine change from base
Process runtime reference change from base
Regression guardNo large, noise-adjusted throughput or heap regressions detected. Versions and interpretation
Higher throughput is better; lower heap is better. Variability is the median absolute deviation across independent processes, relative to their median. Small differences on shared GitHub-hosted hardware remain informational; the required guard rejects only large changes beyond the measured noise allowance. |
Runtime-owned Effect, Stream, and timer invocation ids no longer pay for the reservation check on every start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHnF2EL6ReDTKwoM9TVH7L
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
Machine.InvokeErrornow addsChildAlreadyExistsErroronly for invocations whose child id is caller-chosen: logic invocations (address) andMachine.childinvocations. Effect, Stream, and timer invocations run under runtime-owned ids (Machine.invocation:<len>:<path><id>), so a machine with only such invocations hasMachine.Error=never, and itsjoinfails only withInfiniteTransitionError | MachineSchemaDecodeError | StoppedError.Machine.childthroughchildrenneedsonFailureexactly when the child's ownErroris reachable.onFailure: { none: true }for a child that cannot fail is now rejected as unreachable. At runtime, the parent'sonFailurestill receives only the child's typed failures (isFrameworkFailureis unchanged).invoke: [{ src: "a" }, { src: "a" }]failed at runtime withChildAlreadyExistsError. It is now a type error ("Invocation id 'a' is declared more than once in this state") and is rejected whenhandlecaptures the definition. That rejection backstops widestringids.Machine.invocation:id namespace is reserved. A caller-chosen id in that namespace (family/Logic.Spawnids, logic addresses, child descriptor ids) is treated as already taken and fails withChildAlreadyExistsError, in a channel that already declares it. Runtime duplicate detection is otherwise unchanged.never:RootCompatibleresolves toRootCompatibilityError<"Machine declares a required parent and cannot run as a root; invoke or spawn it from an owning machine">. This applies tostart,resume,prepare,planInitial, and the AtomMachine root APIs.InvocationDefinitionError<...>, for exampleInvocation 'forever' never completes, so onDone is unreachable,cannot fail, so onFailure is unreachable,emits no Stream elements, so onElement is unreachable, andhas no snapshots; onSnapshot applies only to logic and child invocations. The set of accepted configurations is unchanged.test/machine/InvocationIds.test.tscovers reserved-id spoofing, parallel regions and reentry under the same lifecycle id, collisions of fixed children and addressed logic across parallel regions, and definition-time duplicate rejection.typetest/machine/InvocationErrors.tst.ts.onFailurehandlers that are now unreachable. The parallel-owner example keeps two deep transitions through a reachableChildSignalevent.ChildAlreadyExistsError.Changeset
.changeset/invoke-error-channels-and-diagnostics.md)Validation
pnpm checkdprint checkcould not download plugins in the local sandbox (plugins.dprint.dev blocked). Formatting was applied with the identical plugin versions (typescript 0.93.4, markdown 0.20.0, json 0.21.1) loaded locally.devtools/test/StaticSite.test.tshit its 5s timeout once under full-suite load. It passes in isolation.pnpm test:types,test:consumer, and the pack checks pass.pnpm perf:typesstays within the configured budgets locally; see the CI comparison)pnpm perf:runtimesmoke run completed; see the CI comparison)Generated by Claude Code