Repository navigation
Deliver early atom machine commands and add bridge helper types - #234
Merged
Merged
Conversation
Writes to MachineAtom and ChildMachineAtom send/stop made while the machine is still starting are now held and delivered in write order instead of failing with NotReadyError, which is removed. Adds MachineAtom.Any/State/Event and ChildMachineAtom.Any/State helpers. Co-Authored-By: Claude Fable 5.1 <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. |
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
MachineAtom.send/stopandChildMachineAtom.send/stopno longer drop writes made while the machine is still starting (for example while a boundAtom.runtimelayer builds after hydration). Such writes are held, the write result iswaiting, and they are delivered in write order once the ref is ready. They settle toSuccess, to the command failure, or to the startup failure. Later writes queue behind held writes so they cannot overtake them. Writes after stop/completion still fail withStoppedErrorimmediately; child writes still fail withChildNotActiveErrorwhen the owning state is inactive.NotReadyErroris removed fromAtomMachineand from thesend/stopfailure types. No alias is kept.AtomMachine.MachineAtom.Any,MachineAtom.State<A>,MachineAtom.Event<A>,ChildMachineAtom.Any,ChildMachineAtom.State<A>. An event-less bridge (Event = never) is assignable toMachineAtom.Any. The internalAnyMachineAtom/FamilyBridgealiases (core and react) now use them.AtomRegistry.getResult. Nothing blocks or busy-waits. The write context gets the registry through an internal keep-aliveget.registryatom.test/unstable/reactivity/AtomMachineCommands.test.tscovers the async-runtime reproduction, write order across readiness,StoppedErrorafter stop, startup failure settling held writes, stop before ready, child writes before parent readiness, andChildNotActiveError. There is also a React test that usesuseAtomSet(machine.send)in a first-mountuseEffectwith an async runtime, plus typetests for the helpers and command failure types. The new runtime tests fail against the previous implementation.effect-atom-react.mddescribes early writes and adds a "Generic helpers" section.Changeset
One minor changeset for
@typeonce/effect-machine. The react package only swaps an internal alias, and its public API is unchanged (same fixed group).Validation
pnpm check. Every step passed locally exceptformat:check, because the dprint plugin host is unreachable from the dev sandbox. Changed files were checked with the same dprint plugin versions installed from npm. One unrelated devtoolsStaticSitetest hit its 5s timeout under load and passed when rerun alone.pnpm perf:typespassed locally within budgets.pnpm perf:runtimewas run locally as a smoke test; the CI comparison is authoritative.Generated by Claude Code