feat: statemachine first class - #126
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Theauxm
force-pushed
the
feat/statemachine-first-class
branch
from
August 13, 2026 14:48
71b8917 to
6f170fa
Compare
…an IR differential block Add IMachineBuilder.Differential(d => d.Sample/Seed/Probe/EmptySample) so a machine's cross-language differential inputs (representative per-trigger samples, per-state seed contexts, dense probe contexts) are authored on the C# machine itself. The IR exporter emits them as an optional "differential" block (omitted when empty, so shape-only machines' IR is byte-identical). This makes the C# machine the single source for the differential harness, which can enumerate off the exported IR instead of a hand-written machine.json. Typed overloads serialize records with camelCase names (nulls kept); raw JsonObject overloads give exact control. Only valid on a declaratively-authored machine (it rides the IR).
…ters the SnapshotDbContext + mutations Make state-machine persistence a first-class Trax subsystem. trax.AddStateMachines(assemblies), a step in the AddTrax builder chain, discovers the machines, wires the store/ledger/runner/registry and the four generic stateMachine mutation routes, AUTO-registers the SnapshotDbContext against the provider configured in AddEffects, and contributes the mutations' assembly to the mediator scan. The host no longer calls AddDbContext<SnapshotDbContext> or names StateMachineMutations.Assembly. The DbContext auto-registration uses a new provider-agnostic seam, ITraxFeatureDbConfigurator, registered by UsePostgres/UseSqlite/UseInMemory, so a feature keeps its own change tracker (isolated from the effect journal) while binding to the app's database. TraxBuilder gains ContributedMediatorAssemblies (merged by AddMediator) and a MediatorConfigured flag; AddStateMachines guards on a missing data provider and on being called after AddMediator. The old IServiceCollection AddTraxStateMachines(...) is kept functional but marked [Obsolete] (it cannot auto-wire the DbContext or the mediator scan). Public API baselines updated.
…AddStateMachines builder Unit-cover the .Differential(...) surface (typed and raw samples/seeds/probes, the serialization guard, the declarative-only guard) and its IR export (samples/seeds/contexts), plus DifferentialModel.IsEmpty. Add integration tests for trax.AddStateMachines: the happy path over Postgres (subsystem resolves, the SnapshotDbContext auto-registers and round-trips, the mutations' assembly is contributed to the mediator scan) and the before-AddMediator ordering guard. Closes the patch-coverage gaps on the new code.
Delete the IServiceCollection AddTraxStateMachines(...) overloads outright rather than deprecating them. trax.AddStateMachines(...) replaces them and does strictly more (auto-registers the SnapshotDbContext, contributes the mutations to the mediator scan); the only consumers are ours (samples, E2E host, nwyc), all already migrated, so this is a non-breaking removal, not a 2.0.0. The shared registration helper moves into StateMachinesBuilderExtensions as a private method, and the back-compat test and stale doc/comment references go with it.
Theauxm
force-pushed
the
feat/statemachine-first-class
branch
from
August 13, 2026 15:06
6f170fa to
f4e4e80
Compare
|
This PR is included in version 1.49.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.