fix: evaluate conditions against tick-start state (order independence)#36
Merged
Conversation
Activator and connection conditions used to read live pool values mid tick while pulls, gates and converters mutate source pools immediately during the fire phase, so whether a condition passed could depend on node storage order (contradicting docs/CONCEPTS.md section 1). doStep now snapshots every node's state value before the fire phase; _nodeEnabled and _connFires read it via the new _condValueOf. Trigger and reverse-trigger cascades are the deliberate exception: they pass live=true and keep reading mid-step state, because a cascade's order is causal (graph-defined) and therefore deterministic. Movement (rates, fair allocation, capacity, converter/gate mechanics) still reads live state, and variable-referencing conditions keep their documented one-step lag. Adds an insertion-order repro test, a node-array permutation property test and a cascade live-read test; documents the semantics in docs/CONCEPTS.md section 7. All 11 built-in demos produce byte-identical 300-step seeded traces before and after this change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes the last open item from the codebase review: activator and connection conditions read live pool values while pulls, gates, and converters mutate mid-tick, so a step's result could depend on node storage order, contradicting CONCEPTS.md section 1.
Semantics (hybrid synchronous)
doStepsnapshots every node's state value before the fire phase; activator checks (_nodeEnabled) and source-value connection conditions (_connFires) read the snapshot through a single seam,_condValueOfliveflag): a cascade is a causal reaction within the step whose order comes from the graph, not storage, so live reads there are deterministic and intentionalEvidence