feat(cmd/crucible): add simulate subcommand to trace events through an IR#184
Merged
Conversation
…n IR crucible simulate fires an ordered event sequence against a machine assembled from an IR and prints the per-event step trace (from/to state, outcome, emitted effects) and the final state, in text or -format json. - Events come from -events (comma list) or -events-file (a bare name array or a conformance scenario JSON); exactly one is required. - A headless IR carries no real behavior, so guards return seeded verdicts: -guard name=bool (repeatable), unseeded guards default to false; actions, reducers, and services are no-ops. -initial overrides the declared start state. - A guard-blocked or invalid transition is a normal observable outcome (exit 0); an unknown event or action failure exits non-zero. - Reuses state/conformance.RunAgainst and classifies the result error with errors.As to keep blocked-but-valid traces distinct from real failures. Closes #175.
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 #175. Follow-up tracked in #183 (CEL-from-context guard evaluation).
What
crucible simulate <ir.json>fires an ordered event sequence through a machine assembled from the IR and prints the per-event step trace (from/to state, outcome, emitted effects) and the final state — for debugging and CI snapshot tests.-events(comma list) or-events-file(a bare["a","b"]array or aconformance.Scenarioobject); exactly one required.-guard name=bool(repeatable); unseeded guards default tofalse. Actions/reducers/services are no-ops.-initialoverrides the IR's declared start state;-format text|json.Design notes
state/conformance.RunAgainst(no reimplemented Fire loop).*conformance.ErrUnknownEvent) or a real replay/action failure → exit 1; arg/validation errors → exit 2. The result error is classified witherrors.Asso blocked-but-valid traces stay distinct from failures.conformance.TraceStep(scalar states, real outcome enum values).Verification
go build/go vet/go test(86 pass) /golangci-lint(0 issues) — all green incmd/crucible.GuardFailed, exit 0);-events-file,-initial, JSON output, unknown-event→exit 1, and all validation errors→exit 2 behave as specified.