Machine surface
buildMachineSurface (src/core/machine.ts) creates the public machine object once. Its grouped
methods close over a runtime; they do not hold independent copies of journey state.
machine getSnapshot() controls.* start, pause, resume, complete, terminate, restart navigate.* goToStepById, goToNextStep, goToPreviousStep, goToLastVisitedStep subscriptions.* subscribe, subscribeEvent context.update() async.clearError() plugins.* one namespaced entry per plugin dispose() send() graph onlyThe object (and every nested group) is referentially stable for the machine’s lifetime, so it can be captured once, passed through props or context, and used in effect dependencies without re-subscribing. Everything that changes is read from the immutable snapshot.
Group responsibilities
Section titled “Group responsibilities”controls— synchronous lifecycle verbs. Each returns a boolean indicating whether the status change applied.navigate— Promise-based movement, resolving to anok-discriminatedNavigationResult. Linear machines additionally exposegoToStepByIndex(index).send(event)— graph machines only, at the top level. Its presence is the machine-type discriminant: linear machines have no event system.subscriptions— synchronous subscribe calls returning unsubscribe functions, delegated to the store.context.update— synchronous context replacement.async.clearError— clears the current step’s work or hook error.plugins— the namespaced API record contributed by pluginsetup()calls.