Skip to content

feat:msm vocabulary primitives - #124

Merged
Theauxm merged 3 commits into
mainfrom
feat/sm-vocabulary-primitives
Aug 12, 2026
Merged

feat:msm vocabulary primitives#124
Theauxm merged 3 commits into
mainfrom
feat/sm-vocabulary-primitives

Conversation

@Theauxm

@Theauxm Theauxm commented Aug 12, 2026

Copy link
Copy Markdown
Member

No description provided.

…ule primitives

Adds three declarative guards the vocabulary was missing for real form/wizard machines:
Length (a string field's length vs a constant, the string peer of Count), BoolEquals (a
boolean field equals true/false), and ArrayOf (every element of an array is a given JSON
type). Each is evaluated by RuleEvaluator (total: a missing or wrong-typed field is false),
authored via the Rules helpers (LengthAtLeast/LengthGreaterThan, IsTrue/IsFalse, ArrayOf),
and serialized by IrExporter (length/boolEquals/arrayOf). The TypeScript interpreter mirror
and the schema-reflection wiring follow.
…y/enum constraints

A state's context validator can now be more than its shape. .Requires(rule) layers a
per-state policy on top of .Context<T>() (composed, ANDed, chainable), so a state can demand
a complete draft or an absent receipt while every state shares one context record. The
requirements export as a per-state `invariants` block in the IR (omitted when a machine has
none, so shape-only machines are unchanged). SchemaReflection also now derives an ArrayOf
constraint from a typed collection property (int[] -> number, string[] -> string) and a OneOf
constraint from [AllowedValues], so element typing and enum domains fall out of the record.
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.50562% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...Trax.Effect.StateMachine/Rules/SchemaReflection.cs 88.88% 0 Missing and 3 partials ⚠️
src/Trax.Effect.StateMachine/Fluent.cs 96.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…, and schema branches

Fills the coverage Codecov flagged on the vocabulary work: the Rules helpers
(LengthGreaterThan/IsTrue/IsFalse/ArrayOf), the IrExporter boolEquals/arrayOf cases (the
StateInvariant machine now carries a boolean requirement and an int[] field, so its export
exercises both), and the SchemaReflection element-type branches (bool[] -> boolean, an array
of objects and a non-generic collection -> no element constraint). The lines that stay
uncovered are the exhaustiveness `default:` throws on the closed rule/reduction unions.
@Theauxm
Theauxm merged commit a7c515e into main Aug 12, 2026
2 checks passed
@Theauxm
Theauxm deleted the feat/sm-vocabulary-primitives branch August 12, 2026 18:42
@github-actions

Copy link
Copy Markdown

This PR is included in version 1.48.0

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