Repository navigation
Conversation
StateModel
Fodesu
marked this pull request as ready for review
October 3, 2026 13:23
StateModel
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
Add the version-bound Run state machine and its command/fact transition model.
State model
MachineStateis the complete semantic state of one Run:ModelSteporToolStepModel and tool effects are represented by stable
EffectIDs. Executionattempts, workers, leases, and backend ownership remain outside the Run state.
Content bodies are also kept outside the state machine. Facts retain canonical
digests, while frozen request/result stores own the corresponding bodies.
Transition model
The machine exposes two pure operations:
Decide: validates a command against the current state and emits facts.Evolve: validates and folds one fact into the next state.Supported transitions cover:
Commands and facts are sealed variants. Stale step, effect, call, and response
identifiers are rejected by the transition guards.
Identity and replay
The machine is bound to explicit canonicalization and identity rules. It does
not compute digests or derive IDs itself, so a Run replays under the rules of
the schema version that created it.
Unknown external outcomes are represented explicitly rather than guessed:
unknown model outcomes terminate the Run, while unknown tool outcomes settle
the call as uncertain and leave the Run active.
Operational characteristics
Transitions are in-memory and deterministic. Their work is proportional to the
command/fact payload and the affected current step; they do not scan the full
Run history. History replay is performed by repeatedly applying
Evolve.