Skip to content

Clean up internal type safety checks - #83

Merged
SandroMaglione merged 2 commits into
mainfrom
codex/strict-internal-cleanup
Aug 10, 2026
Merged

Clean up internal type safety checks#83
SandroMaglione merged 2 commits into
mainfrom
codex/strict-internal-cleanup

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Summary

  • Remove unused internal declarations, imports, copied facade helpers, and obsolete test fixtures.
  • Enable noUnusedLocals and noUncheckedIndexedAccess, encoding existing array and record ownership invariants explicitly.
  • Replace 31 unnecessary internal type assertions with discriminated-union narrowing and already-inferred types, while retaining casts that represent genuine schema or generic boundaries.
  • Preserve the public API, runtime behavior, type inference, and benchmark profile.

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
  • Reviewed the automated type-performance report, when the public TypeScript API or inference changed
  • Reviewed the automated runtime-performance report, when runtime behavior changed
  • pnpm perf:types
  • pnpm perf:runtime

No examples, public TypeScript API, inference behavior, or runtime semantics changed. The manual type-performance instantiation counts were unchanged, and runtime throughput and memory remained within normal benchmark variance.

@github-actions

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,965 2,965 0 (0.0%)
Machine.make (3 states, 2 events) 8,715 8,715 0 (0.0%)
machine.handle (3 states, 2 transitions) 23,492 23,492 0 (0.0%)
machine.handle (depth 8) 117,075 117,075 0 (0.0%)
machine.handle (depth 12) 129,713 129,713 0 (0.0%)
machine.handle (depth 16) 145,055 145,055 0 (0.0%)
machine.handle (depth 24) 183,851 183,851 0 (0.0%)
machine.handle (wide depth 16) 214,189 214,189 0 (0.0%)
machine.handle (parallel/history/choice) 132,667 132,667 0 (0.0%)
machine.handle (4 successive calls) 128,674 128,674 0 (0.0%)
machine exact input/output/error/services 110,584 110,584 0 (0.0%)
execution adapter readiness 127,854 127,854 0 (0.0%)

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,910 2,910 0 (0.0%)
Machine.make (3 states, 2 events) 5,742 5,742 0 (0.0%)
machine.handle (3 states, 2 transitions) 14,777 14,777 0 (0.0%)
machine.handle (depth 8) 109,601 109,601 0 (0.0%)
machine.handle (depth 12) 121,039 121,039 0 (0.0%)
machine.handle (depth 16) 135,181 135,181 0 (0.0%)
machine.handle (depth 24) 171,577 171,577 0 (0.0%)
machine.handle (wide depth 16) 202,224 202,224 0 (0.0%)
machine.handle (parallel/history/choice) 114,331 114,331 0 (0.0%)
machine.handle (4 successive calls) 113,703 113,703 0 (0.0%)
machine exact input/output/error/services 100,670 100,670 0 (0.0%)
execution adapter readiness 102,092 102,092 0 (0.0%)
Check times (informational)
Scenario Base PR
Effect only 0.02s 0.02s
Import effect-machine 0.02s 0.02s
Machine.defineStates (3 states) 0.07s 0.07s
Machine.make (3 states, 2 events) 0.10s 0.11s
machine.handle (3 states, 2 transitions) 0.17s 0.15s
machine.handle (depth 8) 0.37s 0.33s
machine.handle (depth 12) 0.36s 0.36s
machine.handle (depth 16) 0.38s 0.39s
machine.handle (depth 24) 0.44s 0.44s
machine.handle (wide depth 16) 0.46s 0.47s
machine.handle (parallel/history/choice) 0.41s 0.40s
machine.handle (4 successive calls) 0.36s 0.37s
machine exact input/output/error/services 0.34s 0.33s
execution adapter readiness 0.37s 0.38s

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

@SandroMaglione
SandroMaglione marked this pull request as ready for review August 10, 2026 13:18
@github-actions

Copy link
Copy Markdown
Contributor

Runtime performance

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

Pull request baseline

Scenario Effect Machine XState 5 XState 6 alpha
Plan counter transitions 135,348 transitions/s 135,966 transitions/s 13,510 transitions/s
Drain burst with terminal fence 557,060 increments/s 405,444 increments/s 200,023 increments/s
Drain burst with a change observer 506,197 increments/s 401,529 increments/s 198,344 increments/s
Lookup and send to one child 427,303 increments/s 389,214 increments/s 191,975 increments/s
Start and stop a machine 173,280 machines/s 185,529 machines/s 147,863 machines/s
Start and stop a parent with one child 39,990 families/s 68,890 families/s 42,116 families/s
Plan transitions through a compound state 122,866 transitions/s
Plan transitions through parallel regions 92,260 transitions/s
Drain burst through a compound state 543,316 events/s 348,677 events/s 197,579 events/s
Drain burst through two parallel regions 493,278 events/s 263,926 events/s 147,339 events/s
Drain a compound-state burst with a change observer 488,317 events/s

Effect runtime reference points

Scenario Effect Machine Effect runtime primitives
Start and stop a raw generic process 17,760 processes/s
Start and stop a raw compiled process 70,892 processes/s
Start and interrupt a suspended fiber 168,862 fibers/s
Start and stop a queue worker 116,741 workers/s
Start and stop an actor shell 105,396 actors/s
Start and stop two actor shells 66,587 families/s
Update an owner-only mutable snapshot 316,856,781 updates/s
Update a synchronized snapshot 1,555,166 updates/s
Create, resolve, and await a terminal latch 1,461,852 latches/s
Memory profile Effect Machine XState 5 XState 6 alpha Effect runtime primitives
Idle machine 1.5 KiB 3.8 KiB 2.2 KiB
Raw generic managed process 12.1 KiB
Raw compiled process 2.6 KiB
Two independent idle machines 2.9 KiB 7.3 KiB 3.9 KiB
Idle parent with one child 4.8 KiB 5.5 KiB 4.0 KiB
Parent with observed child registry 8.9 KiB
Parent with observed invoked child snapshots 5.0 KiB
Suspended Effect fiber 0.6 KiB
Effect queue with waiting fiber 2.8 KiB
Effect mailbox actor shell 3.2 KiB
Two Effect actor shells 6.8 KiB

Effect Machine change from base

Metric Base Base variability PR PR variability Difference
Plan counter transitions 134,036 transitions/s 0.8% MAD 135,348 transitions/s 0.2% MAD +1.0%
Drain burst with terminal fence 554,780 increments/s 3.4% MAD 557,060 increments/s 1.8% MAD +0.4%
Drain burst with a change observer 504,926 increments/s 2.7% MAD 506,197 increments/s 0.9% MAD +0.3%
Lookup and send to one child 425,934 increments/s 1.8% MAD 427,303 increments/s 1.9% MAD +0.3%
Start and stop a machine 177,936 machines/s 5.2% MAD 173,280 machines/s 1.4% MAD -2.6%
Start and stop a parent with one child 36,415 families/s 5.7% MAD 39,990 families/s 4.3% MAD +9.8%
Plan transitions through a compound state 126,345 transitions/s 3.6% MAD 122,866 transitions/s 1.1% MAD -2.8%
Plan transitions through parallel regions 93,791 transitions/s 2.9% MAD 92,260 transitions/s 0.7% MAD -1.6%
Drain burst through a compound state 553,228 events/s 1.4% MAD 543,316 events/s 1.8% MAD -1.8%
Drain burst through two parallel regions 502,445 events/s 1.5% MAD 493,278 events/s 1.7% MAD -1.8%
Drain a compound-state burst with a change observer 505,817 events/s 2.2% MAD 488,317 events/s 4.1% MAD -3.5%
Idle machine heap per unit 1.5 KiB 0.1% MAD 1.5 KiB 0.0% MAD -0.0%
Raw generic managed process heap per unit 12.1 KiB 0.0% MAD 12.1 KiB 0.0% MAD -0.0%
Raw compiled process heap per unit 2.6 KiB 0.0% MAD 2.6 KiB 0.1% MAD +0.1%
Two independent idle machines heap per unit 2.9 KiB 0.0% MAD 2.9 KiB 0.2% MAD -0.0%
Idle parent with one child heap per unit 4.8 KiB 0.0% MAD 4.8 KiB 0.0% MAD -0.0%
Parent with observed child registry heap per unit 8.9 KiB 0.0% MAD 8.9 KiB 0.0% MAD -0.0%
Parent with observed invoked child snapshots heap per unit 5.0 KiB 0.2% MAD 5.0 KiB 0.2% MAD -0.0%

Effect runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw generic process 18,358 processes/s 1.4% MAD 17,760 processes/s 4.3% MAD -3.3%
Start and stop a raw compiled process 70,244 processes/s 0.9% MAD 70,892 processes/s 2.7% MAD +0.9%
Start and interrupt a suspended fiber 169,176 fibers/s 0.5% MAD 168,862 fibers/s 0.5% MAD -0.2%
Start and stop a queue worker 117,702 workers/s 2.9% MAD 116,741 workers/s 0.2% MAD -0.8%
Start and stop an actor shell 107,910 actors/s 2.9% MAD 105,396 actors/s 1.7% MAD -2.3%
Start and stop two actor shells 67,577 families/s 3.3% MAD 66,587 families/s 0.7% MAD -1.5%
Update an owner-only mutable snapshot 317,863,954 updates/s 0.0% MAD 316,856,781 updates/s 0.0% MAD -0.3%
Update a synchronized snapshot 1,642,403 updates/s 0.4% MAD 1,555,166 updates/s 2.0% MAD -5.3%
Create, resolve, and await a terminal latch 1,449,811 latches/s 2.8% MAD 1,461,852 latches/s 3.8% MAD +0.8%
Versions and interpretation
  • Effect Machine: 0.3.0
  • XState 5: 5.32.5
  • XState 6 alpha: 6.0.0-alpha.31
  • Effect runtime primitives: 4.0.0-beta.107

Higher throughput is better; lower heap is better. Variability is the median absolute deviation across independent processes, relative to their median. Runtime measurements on shared GitHub-hosted hardware remain informational, so small differences should be confirmed across multiple workflow runs.

@SandroMaglione
SandroMaglione merged commit 7ac8ddd into main Aug 10, 2026
9 checks passed
@SandroMaglione
SandroMaglione deleted the codex/strict-internal-cleanup branch August 10, 2026 13:24
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