Skip to content

Unify state construction and forward fresh root input - #214

Merged
SandroMaglione merged 2 commits into
mainfrom
codex/object-construction-input
Sep 10, 2026
Merged

Unify state construction and forward fresh root input#214
SandroMaglione merged 2 commits into
mainfrom
codex/object-construction-input

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Summary

Root initial constructors now receive machine input directly, so one-off values can belong to the initial child without being retained at root. Root transitions require fresh input and reuse those constructors; root data updates retain the current child configuration.

Replace event initial with target. Named selectors and history fallbacks now take construction objects with data, a per-node decoded flag, states, and declared owner update values. Preserve source-local parallel retention, explicit choice routing, complete history fallbacks, and inspectable branch destinations. Remove the unused fluent-builder runtime and migrate examples, tests, and guides.

Changeset

  • Added or updated for a library or package-metadata change
  • Not required because this PR does not change a publishable package

Minor changeset with direct migration examples; the fixed package group releases together.

Validation

  • pnpm check
  • Automated type-performance measurement passed or was not required
  • Automated runtime- and memory-performance measurement passed or was not required

Local type budgets and runtime/memory smoke measurements passed. New coverage checks root-input requirements, nested-input exclusion, subtree and owner types, root reentry, validation failure before commit, explicit parallel choices, and generic-versus-indexed execution. Paired CI reports will be reviewed before merge.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Type performance

Measured with TypeScript 6.0.3 and skipLibCheck=true.

Scenario Base PR Difference
Effect only 55 55 0 (0.0%)
Import effect-machine 55 55 0 (0.0%)
Machine.state (3 children) 3,521 3,521 0 (0.0%)
Machine.make (3 states, 2 events) 9,491 9,488 -3 (-0.0%)
machine.handle (3 states, 2 transitions) 49,816 49,981 +165 (+0.3%)
declared transition (10 named branches) 66,784 63,038 -3,746 (-5.6%)
atomic construction, guards, and reentry 91,682 88,529 -3,153 (-3.4%)
registered invocation (input-taking Effect) 49,109 49,785 +676 (+1.4%)
machine.handle (depth 24) 197,583 197,380 -203 (-0.1%)
machine.handle (wide depth 16) 221,254 221,123 -131 (-0.1%)
machine.handle (parallel/history/choice) 101,203 95,104 -6,099 (-6.0%)
machine definition (3 independent implementations) 102,696 100,566 -2,130 (-2.1%)
machine exact input/output/error/services 88,468 85,901 -2,567 (-2.9%)
execution adapter readiness 75,683 73,376 -2,307 (-3.0%)

Marginal instantiations are measured against the matching setup without that API call:

Scenario Base PR Difference
Import effect-machine 0 0 0
Machine.state (3 children) 3,466 3,466 0 (0.0%)
Machine.make (3 states, 2 events) 5,962 5,959 -3 (-0.1%)
machine.handle (3 states, 2 transitions) 40,325 40,493 +168 (+0.4%)
declared transition (10 named branches) 57,673 53,930 -3,743 (-6.5%)
atomic construction, guards, and reentry 75,870 72,720 -3,150 (-4.2%)
registered invocation (input-taking Effect) 41,409 42,088 +679 (+1.6%)
machine.handle (depth 24) 179,729 179,529 -200 (-0.1%)
machine.handle (wide depth 16) 204,178 204,050 -128 (-0.1%)
machine.handle (parallel/history/choice) 88,160 82,064 -6,096 (-6.9%)
machine definition (3 independent implementations) 91,471 89,344 -2,127 (-2.3%)
machine exact input/output/error/services 75,730 73,166 -2,564 (-3.4%)
execution adapter readiness 23,335 23,179 -156 (-0.7%)
Check times (informational)
Scenario Base PR
Effect only 0.02s 0.02s
Import effect-machine 0.02s 0.02s
Machine.state (3 children) 0.08s 0.08s
Machine.make (3 states, 2 events) 0.11s 0.11s
machine.handle (3 states, 2 transitions) 0.25s 0.25s
declared transition (10 named branches) 0.31s 0.32s
atomic construction, guards, and reentry 0.38s 0.38s
registered invocation (input-taking Effect) 0.25s 0.25s
machine.handle (depth 24) 0.47s 0.47s
machine.handle (wide depth 16) 0.51s 0.51s
machine.handle (parallel/history/choice) 0.39s 0.38s
machine definition (3 independent implementations) 0.41s 0.41s
machine exact input/output/error/services 0.39s 0.38s
execution adapter readiness 0.33s 0.33s

Type instantiations are the comparison metric. Check time varies with runner load and is informational only.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Runtime performance

Median of 5 independent benchmark processes on AMD EPYC 7763 64-Core Processor with Node v24.20.0.

Pull request baseline

Scenario Effect Machine
Plan counter transitions 107,716 transitions/s
Drain burst with terminal fence 368,728 increments/s
Drain burst with a change observer 346,391 increments/s
Lookup and send to one child 303,366 increments/s
Start and stop a machine 111,272 machines/s
Start and stop a parent with one child 23,748 families/s
Plan transitions through a compound state 96,117 transitions/s
Plan transitions through parallel regions 75,815 transitions/s
Drain burst through a compound state 317,683 events/s
Drain burst through two parallel regions 293,693 events/s
Drain a compound-state burst with a change observer 300,407 events/s

Process runtime reference points

Scenario Effect Machine
Start and stop a raw generic process 15,410 processes/s
Start and stop a raw compiled process 60,680 processes/s
Memory profile Effect Machine
Idle machine 1.9 KiB
Raw generic managed process 13.9 KiB
Raw compiled process 3.2 KiB
Two independent idle machines 3.5 KiB
Idle parent with one child 6.0 KiB
Parent with observed child registry 10.0 KiB
Parent with observed invoked child snapshots 6.5 KiB

Effect Machine change from base

Metric Base Base variability PR PR variability Difference
Plan counter transitions 109,232 transitions/s 1.9% MAD 107,716 transitions/s 1.7% MAD -1.4%
Drain burst with terminal fence 367,987 increments/s 1.7% MAD 368,728 increments/s 0.6% MAD +0.2%
Drain burst with a change observer 345,881 increments/s 0.6% MAD 346,391 increments/s 0.7% MAD +0.1%
Lookup and send to one child 299,191 increments/s 1.0% MAD 303,366 increments/s 0.6% MAD +1.4%
Start and stop a machine 112,905 machines/s 0.4% MAD 111,272 machines/s 1.5% MAD -1.4%
Start and stop a parent with one child 23,425 families/s 2.2% MAD 23,748 families/s 1.5% MAD +1.4%
Plan transitions through a compound state 92,861 transitions/s 1.9% MAD 96,117 transitions/s 1.5% MAD +3.5%
Plan transitions through parallel regions 74,803 transitions/s 1.8% MAD 75,815 transitions/s 2.9% MAD +1.4%
Drain burst through a compound state 291,246 events/s 0.8% MAD 317,683 events/s 1.7% MAD +9.1%
Drain burst through two parallel regions 272,997 events/s 0.5% MAD 293,693 events/s 1.2% MAD +7.6%
Drain a compound-state burst with a change observer 276,060 events/s 0.3% MAD 300,407 events/s 0.9% MAD +8.8%
Idle machine heap per unit 1.9 KiB 0.1% MAD 1.9 KiB 0.6% MAD +0.2%
Raw generic managed process heap per unit 13.9 KiB 0.0% MAD 13.9 KiB 0.0% MAD +0.0%
Raw compiled process heap per unit 3.2 KiB 0.3% MAD 3.2 KiB 0.5% MAD -1.2%
Two independent idle machines heap per unit 3.6 KiB 0.6% MAD 3.5 KiB 0.0% MAD -0.4%
Idle parent with one child heap per unit 5.9 KiB 0.0% MAD 6.0 KiB 0.0% MAD +0.1%
Parent with observed child registry heap per unit 10.0 KiB 0.0% MAD 10.0 KiB 0.0% MAD +0.1%
Parent with observed invoked child snapshots heap per unit 6.5 KiB 0.1% MAD 6.5 KiB 0.0% MAD +0.1%

Process runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw generic process 15,281 processes/s 0.5% MAD 15,410 processes/s 0.5% MAD +0.8%
Start and stop a raw compiled process 61,084 processes/s 0.4% MAD 60,680 processes/s 0.5% MAD -0.7%

Regression guard

No large, noise-adjusted throughput or heap regressions detected.

Versions and interpretation
  • Effect Machine: 0.35.0

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.

@SandroMaglione
SandroMaglione merged commit 21fbf58 into main Sep 10, 2026
8 checks passed
@SandroMaglione
SandroMaglione deleted the codex/object-construction-input branch September 10, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant