Repository navigation
Run LocalMachine on the owned step, as one driver - #323
Merged
Merged
Conversation
… for a transition that throws send of a local reference decodes the event and rejects one that the schema refuses with MachineSchemaDecodeError, and the machine keeps running. Deliveries from work, children, parents and commands are decoded as they enter the mailbox and fail the machine as before. The drains plan decoded events, so nothing is decoded twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
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. |
The endpoint delivers through prototype methods, the event decoder is shared per machine, and logic that neither decodes nor is inspected offers directly, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
…e compiled process A machine of LocalMachine runs as a compiled process whose drain takes each message to its owned step. Work runs through the child registry of the process, and its outcomes come back through the mailbox. The generic loop over machines is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
…untime Logic other than a machine runs as a resident program of the local process: it starts in its starter's turn, receives from the same mailbox, and its exit ends the process. The generic runtime, the invocation host and its generation bookkeeping are gone; the step owns those rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
An event whose transitions start, stop and emit nothing now moves the owned state in place of building a Step, so a drain burst allocates as it did before the one driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
An array that a push grows from empty reserves seventeen slots, and the running work stays on the machine's state while it is idle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNdA7BM5kaFHqECsKFr
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.
Requested by Sandro · project thread
Summary
Third of three steps that make the pure step function the base of every host.
LocalMachinenow has one driver, the local process inruntimeCompiled.ts:stepHost.ts). Each message goes to the step; the host runs itscommands, stopsstop, commits, emits, startsstart, and stopsstopAfterthrough the child registry. Outcomes of work come back through the mailbox asWorkMessages and are planned in a later turn. The host extendsStep.PlanningBase, so an idle machine keeps one compact object for both.Machine.logic(and logic spawned by a machine) runs on the same process as a resident program: it starts in its starter's turn, receives from the same mailbox, and its exit ends the process. Changes of state are applied one at a time, as before.runtimeGeneric.ts,invocation.ts,invocationGeneration.ts, the generic drain loop inprocess.ts, and the generation bookkeeping of the child registry. Late outcomes, run order, stop order, and invocation lifecycle are decided bystep.tsonly.AtomMachinekeeps usingLocalMachineunchanged."generic"strategy, now passingExecutionPlan.referenceExecutionPlan(machine)on the same driver) and the indexed planner (ExecutionPlan.compileExecutionPlan(machine)).Decided behaviour changes
sendof aLocalMachinereference rejects an event that the schema refuses withMachineSchemaDecodeError, and the machine keeps running. TheMachine.toStepconformance column has no recorded difference left.Work.Timer.duration()returns oneExit(a throwing mapper or source, or an input that names no duration).MachineRef.send: the error goes to the sender when one waits, otherwise the machine fails.Structural follow-ups
1. Planner passed as a value, not a name
Step.kernel,StepHost.makeExecution, andprocess.tsthreaded a"Compiled" | "Reference"string;"Reference"calledExecutionPlan.selectExecutionPlanForTesting(machine, "generic").planfrom production code.ExecutionPlan.referenceExecutionPlan(machine)is a cached, non-test production helper inexecutionPlan.ts(reused bycompileExecutionPlanwhen a machine cannot be indexed).Step.kernel(machine, ownership, plan),StepHost.makeExecution, andprocess.tstakeCompiledExecutionPlandirectly, withStep.kernelcached by(ownership, plan).builddocuments every difference between"Owned"and"Persistent"in one place, unused duplicatemovewas collapsed into a singleKernel.move, andmove,retain,ambient,rest, andfromSnapshotare documented onKerneland covered by forced compiled-vs-reference and owned-vs-persistent differential tests instepDifferential.test.ts.2. Invocation outcome decisions owned by
step.tsonlystepHost.tsimportedinvocationOutcome.jsand calledInvocationOutcome.decide,decideSnapshot, anddecideElementdirectly inonOutcome,onSnapshot, and streamprogramLogic, routing failures toscope.failCausewithout going through the step.stepHost.tsreports raw work exits/elements/snapshots viaWorkMessageandstep.tsdecides every outcome insettle/element/report. Pre-step queries needed before stepping (observesSnapshots,settleEvent,elementEvent,snapshotEvent) live onStep.Kernelinstep.ts;runtimeCompiled.tsskips wrappingWorkMessagein an inspected event envelope whensettleEventreturnsundefined(direct failure), preserving the exact existing inspection event order.scripts/check-architecture.mjsenforcesARCH015forbidding host modules (includingstepHost.ts) from importinginvocationOutcome.ts, tested inscripts/check-architecture.test.mjs.3. End-of-machine stop order owned by
step.tsstep.tsconcatenated exited work and non-exited remaining work into[...stop, ...latestFirst(kept)], andstepHost.ts(continueEffectful) splitstep.stopback apart usingnew Set(step.exited)so non-exited work stopped after publishing the final state and emitted events, whileMachineStep.Stepand the docs only described onestopgroup before publishing.stops work of states that stay active after publishing the final state and emissions, running across all 5 host columns;Machine.toStepfailed before the change and passes after).step.tsnow emitsstop(exited states' work, or all work on failure/owner stop) andstopAfter(non-exited states' remaining work, latest first, on a final step) directly onMachineStep.Step.stepHost.ts,clusterInstance.ts(progressAfterandalignWork), and the conformancestepHostcarry out both groups without deriving them fromexited. UpdatedMachineStep.StepJSDoc inMachine.ts,ai-docs/src/37_new-host/index.md, regeneratedLLMS.md, and.changeset/local-rejects-refused-events.md.outer) relative to the final state and emitted events (and keeps exited workinnerrunning so both groups are populated), becauseClusterMachinecommits state and enqueues emissions inside one storage transaction beforealignWorkinterrupts in-memory fibers (so onClusterMachine, bothstopandstopAfterrun after the transaction commits, instop-then-stopAfterorder). All 5 conformance columns run the scenario without adding a new difference entry.Performance & heap fixes (since
a260598)isEventConstruction, lazy cached result decoders,makeEventDecoderSync, and deferred error-option object allocation to failure paths only.PlanningBase(avoiding duplicated slots onHost), in-placerestInPlaceand childless ownedmove(zeroState/Stepallocation per drain-burst event), synchronous childless uninspected startup onplan.initial, single acknowledgment check per drained message, and lazy capability resolution with cached staticChildInvocations.CompiledAddressandOwnedChildParent, synchronousnextSessionIdSync(), in-place single-child registry replacement, and single-passofferMessage.Changeset
.changeset/local-rejects-refused-events.md, minor — includesMachineStep.Step.stopAfter)Validation
pnpm format:check&pnpm lint(0 errors, 0 warnings)pnpm check:architecture(includingARCH015test) &pnpm check:cipnpm ai-docgen:check,pnpm docs:api:check,pnpm docs:site:checkpnpm typecheck,pnpm typecheck:ts7,pnpm buildpnpm test,pnpm doctest,pnpm doctest:types,pnpm test:types,pnpm test:consumer, pack checkspnpm perf:types(within budgets)pnpm perf:runtime(local smoke test and heap profiles improved vsmain; awaiting authoritative CI base-vs-PR comparison)