Skip to content

feat(stepfunctions): add Choice and Wait states to ASL interpreter#244

Merged
vieiralucas merged 1 commit intomainfrom
worktree-batch-4-choice-wait-states
Apr 11, 2026
Merged

feat(stepfunctions): add Choice and Wait states to ASL interpreter#244
vieiralucas merged 1 commit intomainfrom
worktree-batch-4-choice-wait-states

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 11, 2026

Summary

  • Adds Choice state with comprehensive comparison operators: string (7 ops), numeric (6 ops), boolean (2 ops), timestamp (5 ops), presence/type checks (6 ops), logical operators (And/Or/Not), Default fallback, and States.NoChoiceMatched error
  • Adds Wait state with Seconds, SecondsPath, Timestamp, and TimestampPath support
  • Includes history events: ChoiceStateEntered/Exited, WaitStateEntered/Exited

Test plan

  • 16 unit tests for choice evaluation (string, numeric, boolean, And/Or/Not, IsPresent/IsNull/IsNumeric, timestamps, path comparisons, StringMatches, evaluate_choice with default/matching/no-match)
  • 10 new E2E tests: Choice string routing, numeric grading, boolean+compound And, Not operator, NoChoiceMatched error, IsPresent, Wait Seconds, Wait SecondsPath, Choice+Wait workflow, Choice history events
  • 14 conformance tests pass
  • All 43 E2E tests pass (including all Batch 2-3 tests)
  • cargo clippy --workspace --all-targets -- -D warnings clean

Summary 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.

  • New Features
    • Choice: string (equals/path/</>/<=/>=/matches), numeric (equals/path/</>/<=/>=), boolean (equals/path), timestamp (equals/</>/<=/>=), presence/type checks, And/Or/Not, Default fallback, and States.NoChoiceMatched.
    • Wait: supports Seconds, SecondsPath, Timestamp, and TimestampPath.
    • History: emits ChoiceStateEntered/Exited and WaitStateEntered/Exited.

Written for commit 1e2d957. Summary will update on new commits.

- 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
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

}

/// Execute a Wait state: pause execution for a specified duration or until a timestamp.
async fn execute_wait_state(state_def: &Value, input: &Value) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

@vieiralucas vieiralucas merged commit ddec5d9 into main Apr 11, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-batch-4-choice-wait-states branch April 11, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant