feat(stepfunctions): add Choice and Wait states to ASL interpreter#244
Merged
vieiralucas merged 1 commit intomainfrom Apr 11, 2026
Merged
feat(stepfunctions): add Choice and Wait states to ASL interpreter#244vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
- Add Choice state with full comparison operator support:
- String: StringEquals, StringEqualsPath, StringLessThan, StringGreaterThan,
StringLessThanEquals, StringGreaterThanEquals, StringMatches (glob)
- Numeric: NumericEquals, NumericEqualsPath, NumericLessThan, NumericGreaterThan,
NumericLessThanEquals, NumericGreaterThanEquals
- Boolean: BooleanEquals, BooleanEqualsPath
- Timestamp: TimestampEquals, TimestampLessThan, TimestampGreaterThan,
TimestampLessThanEquals, TimestampGreaterThanEquals
- Presence/type: IsPresent, IsNull, IsNumeric, IsString, IsBoolean, IsTimestamp
- Logical: And, Or, Not (compound rules)
- Default fallback and States.NoChoiceMatched error
- Add Wait state with Seconds, SecondsPath, Timestamp, TimestampPath
- Add choice.rs with evaluate_choice() and 16 unit tests
- Add 10 E2E tests: Choice branching (string/numeric/boolean/compound/Not/IsPresent/NoChoiceMatched/history), Wait (Seconds/SecondsPath), combined Choice+Wait workflow
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/fakecloud-stepfunctions/src/choice.rs">
<violation number="1" location="crates/fakecloud-stepfunctions/src/choice.rs:42">
P1: `IsPresent` is evaluated via `!value.is_null()`, so present-but-null fields are treated as absent.</violation>
</file>
<file name="crates/fakecloud-stepfunctions/src/interpreter.rs">
<violation number="1" location="crates/fakecloud-stepfunctions/src/interpreter.rs:407">
P1: Wait states silently succeed on invalid or missing wait parameters instead of failing execution.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| // Presence/type checks | ||
| if let Some(expected) = rule.get("IsPresent") { | ||
| let is_present = !value.is_null(); |
There was a problem hiding this comment.
P1: IsPresent is evaluated via !value.is_null(), so present-but-null fields are treated as absent.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-stepfunctions/src/choice.rs, line 42:
<comment>`IsPresent` is evaluated via `!value.is_null()`, so present-but-null fields are treated as absent.</comment>
<file context>
@@ -0,0 +1,491 @@
+
+ // Presence/type checks
+ if let Some(expected) = rule.get("IsPresent") {
+ let is_present = !value.is_null();
+ return expected.as_bool().unwrap_or(false) == is_present;
+ }
</file context>
| } | ||
|
|
||
| /// Execute a Wait state: pause execution for a specified duration or until a timestamp. | ||
| async fn execute_wait_state(state_def: &Value, input: &Value) { |
There was a problem hiding this comment.
P1: Wait states silently succeed on invalid or missing wait parameters instead of failing execution.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-stepfunctions/src/interpreter.rs, line 407:
<comment>Wait states silently succeed on invalid or missing wait parameters instead of failing execution.</comment>
<file context>
@@ -316,6 +403,52 @@ pub async fn execute_state_machine(
}
+/// Execute a Wait state: pause execution for a specified duration or until a timestamp.
+async fn execute_wait_state(state_def: &Value, input: &Value) {
+ // Seconds: fixed number of seconds
+ if let Some(seconds) = state_def["Seconds"].as_u64() {
</file context>
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
Test plan
cargo clippy --workspace --all-targets -- -D warningscleanSummary by cubic
Adds Choice and Wait states to the ASL interpreter, enabling branching and time-based delays with full operator support and execution history events.
Written for commit 1e2d957. Summary will update on new commits.