Skip to report

Runtime schema validation connects to XState’s core

Follow XState’s opt-in validation from the new xstate/validation entry point into state machines and actor logic, where Standard Schema validators check input, incoming events, and snapshot results.

statelyai/xstate #5622 · PR by davidkpiano · Merged

statelyai/xstate 63a8a4bd..5f0c9068

base and head as given

  • A runtime validation subsystem was added to the core package.
  • Core now exposes validator configuration, requests, and structured validation errors.
files changed
20
in a component
13
lines in components
1,084
components
4
public routes changed
0
schema statements
0
new dependencies
0
excluded by role
7
Based on 10 of 13 eligible changed files

Runtime schema validation

Added
Before
Runtime schema validation did not exist
After
Actors validate schemas at runtime

Applications can install a Standard Schema validator on machines and actor logic. It rejects invalid inputs, events, results, outputs and emitted events with structured errors; the build-size benchmark includes a validated machine.

In favour

  • In favour: Structured errors identify the failed boundary, actor, event, and schema issues
  • In favour: Validation remains optional for actor logic without validator configuration

Against

  • Against: Enabled validators run for every input, event, and transition result
Files changed in 4 components. Dependencies shown: 1 new, 2 unchanged
unchanged · 2new · 11 component added

1 new dependency between components — Validation → Core Source

What else could behave differently

20 components · 95 files

These components import changed code, directly or through other files. A traced dependency is a place to review, not a confirmed runtime failure.

Reached 3

ComponentSymbolCited atFilesReached by
Core Sourcepackages/core/src/Signature changed 1 of 25 changed symbols reaching itpackages/core/src/actors/callback.ts:240-3083323 direct · 10 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Actors
  2. Core Source

Later steps follow file imports; they do not prove this symbol is called.

packages/xstate-store/src/Signature changed 1 of 25 changed symbols reaching itpackages/core/src/types.ts:2209-230221 direct · 1 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Core Source
  2. packages/xstate-store/src/

Later steps follow file imports; they do not prove this symbol is called.

scripts/type-error-fixtures/Signature changed 1 of 25 changed symbols reaching itpackages/core/src/actors/callback.ts:240-3083none direct · 3 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Actors
  2. Core Source
  3. scripts/type-error-fixtures/

Later steps follow file imports; they do not prove this symbol is called.

Held back 6

ComponentFilesReached byResolution
packages/xstate-store-angular/src/1none direct · 1 at three stepsprecise
packages/xstate-store-preact/src/1none direct · 1 at three stepsprecise
packages/xstate-store-react/src/1none direct · 1 at three stepsprecise
packages/xstate-store-solid/src/1none direct · 1 at three stepsprecise
packages/xstate-store-svelte/src/1none direct · 1 at three stepsprecise
packages/xstate-store-vue/src/1none direct · 1 at three stepsprecise

Ranked lower 11

ComponentFilesReached by
packages/xstate-react/src/64 direct · 2 at two steps
packages/core/src/actors/87 direct · 1 at two steps
packages/xstate-solid/src/53 direct · 2 at two steps
packages/xstate-svelte/src/53 direct · 2 at two steps
packages/xstate-vue/src/53 direct · 2 at two steps
templates/react-ts/src/3none direct · 2 at two steps · 1 at three steps
templates/vanilla-ts/src/2none direct · 2 at two steps
templates/svelte-ts/src/1none direct · 1 at two steps
templates/vue-ts/src/1none direct · 1 at two steps
packages/core/src/graph/148 direct · 6 at two steps
packages/core/src/validation/11 direct

Statements 3

The createCallbackLogic signature change reached 33 files in core source. 2310
packages/core/src/actors/callback.ts:240-308
The ActorLogic signature change reached 2 files in xstate-store. 11
packages/core/src/types.ts:2209-2302
The createCallbackLogic signature change reached 3 files in type-error fixtures. 3
packages/core/src/actors/callback.ts:240-308

248 reached files belong to no component — tests, docs and config.

Routes, schema, dependencies

No public URL, no migration and no new package.

Inspect components, files and symbols

Component

Core SourceModified
packages/core/src/

7 files · 551 lines

13 dependents

Core source exported ActorLogicValidator, ActorValidationBoundary, ActorValidationEventOrigin, ActorValidationRequest, and assertValid.
ScriptsModified
scripts/

1 file · 27 lines

ActorsModified
packages/core/src/actors/

4 files · 123 lines

2 dependents

ValidationAdded
packages/core/src/validation/

1 file · 383 lines

Validation exported ActorLogicValidator, ActorValidationBoundary, ActorValidationError, ActorValidationErrorOptions, ActorValidationEventOrigin, ActorValidationReason, ActorValidationRequest, StandardSchemaValidatorOptions, isActorValidationError, and standardSchemaValidator.

File

Core Sourcepackages/core/src/
packages/core/src/setup.ts

+283 −31

Core Sourcepackages/core/src/
packages/core/src/StateMachine.ts

+96 −43

Core Sourcepackages/core/src/
packages/core/src/validation.types.ts

+42 −0

Core Sourcepackages/core/src/
packages/core/src/createActor.ts

+25 −7

Core Sourcepackages/core/src/
packages/core/src/validation.ts

+14 −0

Core Sourcepackages/core/src/
packages/core/src/index.ts

+6 −0

Core Sourcepackages/core/src/
packages/core/src/types.ts

+4 −0

Scriptsscripts/
scripts/bundle-size.mjs

+26 −1

Actorspackages/core/src/actors/
packages/core/src/actors/logic.ts

+38 −13

Actorspackages/core/src/actors/
packages/core/src/actors/observable.ts

+25 −16

Actorspackages/core/src/actors/
packages/core/src/actors/promise.ts

+6 −12

Actorspackages/core/src/actors/
packages/core/src/actors/callback.ts

+8 −5

Validationpackages/core/src/validation/
packages/core/src/validation/index.ts

+383 −0

Function

imports what changeddownstream of it, one mark per step

Actor()packages/core/src/createActor.ts

reaches 6 components

The Actor signature change reached 6 files in xstate-react. 42
packages/core/src/createActor.ts:115-1028
The Actor signature change reached 5 files in xstate-svelte. 32
packages/core/src/createActor.ts:115-1028
The Actor signature change reached 5 files in xstate-vue. 32
packages/core/src/createActor.ts:115-1028
The Actor signature change reached 3 files in the React TypeScript template. 21
packages/core/src/createActor.ts:115-1028
The Actor signature change reached 1 file in the Svelte TypeScript template. 1
packages/core/src/createActor.ts:115-1028
The Actor signature change reached 1 file in the Vue TypeScript template. 1
packages/core/src/createActor.ts:115-1028
ActorLogic()packages/core/src/types.ts

reaches 6 components

The ActorLogic signature change reached 1 file in xstate-store-angular. 1
packages/core/src/types.ts:2209-2302
The ActorLogic signature change reached 1 file in xstate-store-preact. 1
packages/core/src/types.ts:2209-2302
The ActorLogic signature change reached 1 file in xstate-store-react. 1
packages/core/src/types.ts:2209-2302
The ActorLogic signature change reached 1 file in xstate-store-solid. 1
packages/core/src/types.ts:2209-2302
The ActorLogic signature change reached 1 file in xstate-store-svelte. 1
packages/core/src/types.ts:2209-2302
The ActorLogic signature change reached 1 file in xstate-store-vue. 1
packages/core/src/types.ts:2209-2302

Diff

Core Sourcepackages/core/src/
packages/core/src/setup.ts

2–2, 70–73, 75–75 and 23 more spans

Core Sourcepackages/core/src/
packages/core/src/StateMachine.ts

86–87, 238–239, 324–345 and 11 more spans

Core Sourcepackages/core/src/
packages/core/src/validation.types.ts

1–42

Core Sourcepackages/core/src/
packages/core/src/createActor.ts

386–391, 393–395, 468–474 and 3 more spans

Core Sourcepackages/core/src/
packages/core/src/validation.ts

1–14

Core Sourcepackages/core/src/
packages/core/src/index.ts

46–51

Core Sourcepackages/core/src/
packages/core/src/types.ts

1111–1111, 2218–2219, 2306–2306

Scriptsscripts/
scripts/bundle-size.mjs

3–3, 88–109, 158–160

Actorspackages/core/src/actors/
packages/core/src/actors/logic.ts

5–6, 96–96, 233–233 and 6 more spans

Actorspackages/core/src/actors/
packages/core/src/actors/observable.ts

4–5, 119–119, 148–148 and 8 more spans

Actorspackages/core/src/actors/
packages/core/src/actors/promise.ts

5–5, 109–109, 238–238 and 3 more spans

Actorspackages/core/src/actors/
packages/core/src/actors/callback.ts

12–12, 134–134, 218–218 and 2 more spans

Validationpackages/core/src/validation/
packages/core/src/validation/index.ts

1–383

Analysis scope

1126 → 4
  1. 1,126
    files at head
  2. 26
    components
  3. 4
    changed by this change

Where the new files landed

3 new files
New fileBelongs toUsed byCallsServes
packages/core/src/2 new files
Core Sourcebase frame
ActorsValidation
nothing outside its own component
packages/core/src/validation/index.ts
Validationnew territory
nothing in the existing application
Core Source

4 added files carry no component — 2 test, 1 config, 1 docs.

4components changed
17reached, not changed
1components added/removed
1dependencies added between components
0dependencies removed between components
0files moved to another path

20 files changed, 26 claims stated. 20 components reached in total.

naming: “model

narrative: “model

analyzer 0.2.0, config v1.9.0-phase8

Every line above is derived from 63a8a4bd..5f0c9068 and nothing else.