Harden state exploration with fail-fast validation and immutable graph diagnostics - #40
Open
Tomás Pérez Álvarez (Tomperez98) wants to merge 1 commit into
Open
Conversation
Tomás Pérez Álvarez (Tomperez98)
force-pushed
the
harden-state-exploration
branch
from
September 9, 2026 17:16
c4717fa to
f182483
Compare
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.
Summary
This change hardens Accordant's state exploration and system-checking boundaries so invalid models fail close to their source instead of producing delayed or ambiguous failures. It also makes graph construction deterministic and safer to test by snapshotting externally-owned collections, protecting graph objects from mutation, and preserving actionable exception context.
The implementation keeps the fast path inexpensive: already-frozen states avoid recomputation, and expensive canonical comparisons remain limited to hash/signature collision paths.
What changed
Fail-fast input and model validation
StateGraph.ExploreStateGraphinputs at the public boundary:SystemCheckerbatches before executing any step function or hook.StateProfileentries when assigned, including state and step-function invariants.State immutability and mutation detection
IStepFunctionimplementations.IStateimplementation does not become frozen afterFreeze().Safer and more deterministic state graphs
Step-function contract hardening
BaseStepFunction.Applyarguments.BaseStepFunctionidentifier while retaining GUID-backed default identity.AsyncOperation.Exception diagnostics
StepFunctionApplicationExceptiondiagnostic properties read-only.PathToNodeso later mutations cannot corrupt failure diagnostics.Test-generation safety
Tests
Added coverage for:
SystemCheckerbatchesValidation
The following checks pass:
The targeted core test suite passes 40 tests and the operations test suite passes 182 tests.
Compatibility notes
This hardens previously mutable public surfaces. Callers should no longer rely on mutating these objects after construction or graph creation:
StateProfilecollections are snapshotted and read-only.StateGraphNodeandStateGraphEdgeproperties are read-only.StepFunctionApplicationExceptiondiagnostics are read-only snapshots.Freeze()establishIsFrozen.ContractStepFunctionpredecessor IDs must be configured before application.Stateinstance rather than through a static global property.