Skip to content

Harden statechart modeling and verification - #31

Merged
SandroMaglione merged 1 commit into
mainfrom
codex/statechart-hardening
Aug 7, 2026
Merged

Harden statechart modeling and verification#31
SandroMaglione merged 1 commit into
mainfrom
codex/statechart-hardening

Conversation

@SandroMaglione

@SandroMaglione SandroMaglione commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix supervisor-owned machine terminalization so initialization and runtime self.stop cannot deadlock, while preserving exactly-once cleanup and terminal publication across stop, completion, and failure races.
  • Strengthen public type safety with consistent executable-machine readiness, finite-union event narrowing, exact state-definition validation, and discriminated compiled state-node inspection.
  • Expand MachineTest finite models from event-only transitions to canonical event | always | done triggers, including independent stabilization, completion, cycle, resume, generated-model, and managed-runtime differential verification.
  • Add adversarial snapshot-codec, activity-lifecycle, process-lifecycle, and compiler-instantiation regression coverage.

MachineTest.FiniteTransition now migrates from { source, event, ... } to { source, trigger: { type: "event", event }, ... }; automatic transitions use { type: "always" } or { type: "done" }.

Changeset

  • Added or updated for a library or package-metadata change
  • Not required because this PR does not change src/ or package.json

Validation

  • pnpm check
  • Relevant example checks, when examples changed (not applicable; no examples changed)
  • Reviewed the automated type-performance report, when the public TypeScript API or inference changed

@github-actions

github-actions Bot commented Aug 7, 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.defineStates (3 states) 2,902 2,965 +63 (+2.2%)
Machine.make (3 states, 2 events) 8,668 8,731 +63 (+0.7%)
machine.handle (3 states, 2 transitions) 23,474 23,634 +160 (+0.7%)
machine.handle (depth 8) 112,138 113,023 +885 (+0.8%)
machine.handle (depth 12) 124,580 125,661 +1,081 (+0.9%)
machine.handle (depth 16) 139,726 141,003 +1,277 (+0.9%)
machine.handle (depth 24) 178,130 179,799 +1,669 (+0.9%)
machine.handle (wide depth 16) 208,161 210,137 +1,976 (+0.9%)
machine.handle (parallel/history/choice) 128,876 new
machine.handle (4 successive calls) 129,498 new
machine exact input/output/error/services 107,371 new
execution adapter readiness 122,890 new

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

Scenario Base PR Difference
Import effect-machine 0 0 0
Machine.defineStates (3 states) 2,847 2,910 +63 (+2.2%)
Machine.make (3 states, 2 events) 5,758 5,758 0 (0.0%)
machine.handle (3 states, 2 transitions) 14,806 14,903 +97 (+0.7%)
machine.handle (depth 8) 105,202 105,546 +344 (+0.3%)
machine.handle (depth 12) 116,640 116,984 +344 (+0.3%)
machine.handle (depth 16) 130,782 131,126 +344 (+0.3%)
machine.handle (depth 24) 167,178 167,522 +344 (+0.2%)
machine.handle (wide depth 16) 197,825 198,169 +344 (+0.2%)
machine.handle (parallel/history/choice) 110,514 new
machine.handle (4 successive calls) 114,497 new
machine exact input/output/error/services 95,819 new
execution adapter readiness 96,968 new
Check times (informational)
Scenario Base PR
Effect only 0.03s 0.03s
Import effect-machine 0.03s 0.03s
Machine.defineStates (3 states) 0.09s 0.10s
Machine.make (3 states, 2 events) 0.14s 0.14s
machine.handle (3 states, 2 transitions) 0.21s 0.22s
machine.handle (depth 8) 0.50s 0.49s
machine.handle (depth 12) 0.51s 0.53s
machine.handle (depth 16) 0.57s 0.59s
machine.handle (depth 24) 0.64s 0.65s
machine.handle (wide depth 16) 0.70s 0.71s
machine.handle (parallel/history/choice) 0.61s
machine.handle (4 successive calls) 0.56s
machine exact input/output/error/services 0.50s
execution adapter readiness 0.55s

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

@SandroMaglione
SandroMaglione merged commit 9eac202 into main Aug 7, 2026
8 checks passed
@SandroMaglione
SandroMaglione deleted the codex/statechart-hardening branch August 7, 2026 15:09
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