ironflow-engine 2.38.4

Workflow orchestration engine for ironflow with FSM-based run lifecycle
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
//! Unit tests for [`WorkflowContext`].
//!
//! A descendant module of `context`, so the tests can assert on the private
//! fields the public API only exposes indirectly.

use super::*;
use chrono::{TimeDelta, Utc};
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_core::providers::record_replay::RecordReplayProvider;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::models::{
    Assignee, NewRun, NewStep, Run, RunActor, RunFilter, StepKind, StepStatus, StepUpdate,
    TriggerKind, step_trace_id,
};
use ironflow_store::store::RunStore;
use serde_json::json;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use uuid::Uuid;

use crate::config::ApprovalConfig;
use crate::error::EngineError;

/// Helper to create a test provider with fixtures
fn create_test_provider() -> Arc<dyn ironflow_core::provider::AgentProvider> {
    let inner = ClaudeCodeProvider::new();
    Arc::new(RecordReplayProvider::replay(
        inner,
        "/tmp/ironflow-fixtures",
    ))
}

/// Helper to create a test context
fn create_test_context() -> WorkflowContext {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();
    let run_id = Uuid::now_v7();
    WorkflowContext::new(run_id, "test".to_string(), store, provider)
}

#[test]
fn context_new_initializes_correctly() {
    let ctx = create_test_context();
    assert_eq!(ctx.position, 0);
    assert_eq!(ctx.total_cost_usd, Decimal::ZERO);
    assert_eq!(ctx.total_duration_ms, 0);
    assert!(ctx.last_step_ids.is_empty());
    assert!(ctx.replay_steps.is_empty());
    assert!(ctx.log_sender.is_none());
}

#[test]
fn context_run_id_returns_correct_id() {
    let run_id = Uuid::now_v7();
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();
    let ctx = WorkflowContext::new(run_id, "test".to_string(), store, provider);
    assert_eq!(ctx.run_id(), run_id);
}

#[test]
fn context_total_cost_usd_initially_zero() {
    let ctx = create_test_context();
    assert_eq!(ctx.total_cost_usd(), Decimal::ZERO);
}

#[test]
fn context_total_duration_ms_initially_zero() {
    let ctx = create_test_context();
    assert_eq!(ctx.total_duration_ms(), 0);
}

#[test]
fn context_with_handler_resolver_creates_context_with_resolver() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();
    let run_id = Uuid::now_v7();

    let called = Arc::new(AtomicBool::new(false));
    let called_clone = called.clone();

    let resolver: HandlerResolver = Arc::new(move |_name: &str| {
        called_clone.store(true, Ordering::SeqCst);
        None
    });

    let ctx = WorkflowContext::with_handler_resolver(
        run_id,
        "test".to_string(),
        store,
        provider,
        resolver,
    );

    assert_eq!(ctx.run_id(), run_id);
    assert!(ctx.handler_resolver.is_some());
}

#[tokio::test]
async fn context_set_log_sender_attaches_sender() {
    let mut ctx = create_test_context();
    let (sender, _receiver) = crate::log_sender::channel();
    ctx.set_log_sender(sender);
    assert!(ctx.log_sender.is_some());
}

#[tokio::test]
async fn context_skip_creates_skipped_step() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    // Create the run first using RunStore trait
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    let mut ctx = WorkflowContext::new(created_run_id, "test".to_string(), store.clone(), provider);
    let initial_position = ctx.position;

    ctx.skip("skip-step", "condition not met")
        .await
        .expect("skip failed");

    assert_eq!(ctx.position, initial_position + 1);
    assert!(!ctx.last_step_ids.is_empty());

    // Verify the step was recorded with Skipped status
    let steps = store
        .list_steps(created_run_id)
        .await
        .expect("failed to list steps");
    assert_eq!(steps.len(), 1);
    assert_eq!(steps[0].status.state, StepStatus::Skipped);
}

/// Sub-workflow handler that records no steps, so the child run reaches a
/// terminal state without touching the filesystem or the network.
struct NoopSubWorkflow;

impl WorkflowHandler for NoopSubWorkflow {
    fn name(&self) -> &str {
        "noop-sub"
    }

    fn execute<'a>(&'a self, _ctx: &'a mut WorkflowContext) -> crate::handler::HandlerFuture<'a> {
        Box::pin(async move { Ok(()) })
    }
}

/// Run a parent workflow authored by `created_by` and return the child run
/// created by its sub-workflow step.
async fn child_run_of_parent_authored_by(created_by: Option<RunActor>) -> Run {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    let parent = store
        .create_run(NewRun {
            workflow_name: "parent".to_string(),
            trigger: TriggerKind::Api,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            created_by,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create parent run")
        .into_run();

    let resolver: HandlerResolver = Arc::new(|name: &str| match name {
        "noop-sub" => Some(Arc::new(NoopSubWorkflow) as Arc<dyn WorkflowHandler>),
        _ => None,
    });

    let mut ctx = WorkflowContext::with_handler_resolver(
        parent.id,
        "parent".to_string(),
        store.clone(),
        provider,
        resolver,
    );
    ctx.workflow(&NoopSubWorkflow, json!({}))
        .await
        .expect("sub-workflow failed");

    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    runs.items
        .into_iter()
        .find(|r| r.workflow_name == "noop-sub")
        .expect("child run was created")
}

#[tokio::test]
async fn child_run_inherits_the_parent_author() {
    let user_id = Uuid::now_v7();
    let child = child_run_of_parent_authored_by(Some(RunActor::User { user_id })).await;

    assert_eq!(child.created_by, Some(RunActor::User { user_id }));
}

#[tokio::test]
async fn child_run_of_an_unattributed_parent_has_no_author() {
    let child = child_run_of_parent_authored_by(None).await;

    assert!(child.created_by.is_none());
}

#[tokio::test]
async fn context_parallel_empty_steps_returns_empty_vec() {
    let mut ctx = create_test_context();
    let results = ctx
        .parallel(vec![], true)
        .await
        .expect("parallel should not fail on empty input");
    assert!(results.is_empty());
}

#[tokio::test]
async fn context_approval_first_execution_returns_error() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    // Create the run first
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    let mut ctx = WorkflowContext::new(created_run_id, "test".to_string(), store.clone(), provider);

    let result = ctx
        .approval(
            "approve-step",
            crate::config::ApprovalConfig::new("Continue?"),
        )
        .await;

    // First execution should return ApprovalRequired error
    assert!(matches!(result, Err(EngineError::ApprovalRequired { .. })));

    // Verify position incremented
    assert_eq!(ctx.position, 1);

    // Verify step was created with AwaitingApproval status
    let steps = store
        .list_steps(created_run_id)
        .await
        .expect("failed to list steps");
    assert_eq!(steps.len(), 1);
    assert_eq!(steps[0].status.state, StepStatus::AwaitingApproval);
}

#[tokio::test]
async fn context_approval_replay_returns_ok() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    // Create the run first
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    // Create an approval step that's already in AwaitingApproval state
    let step = store
        .create_step(NewStep {
            run_id: created_run_id,
            trace_id: step_trace_id(created_run_id, "approval", 0),
            name: "approval".to_string(),
            kind: StepKind::Approval,
            position: 0,
            input: None,
            is_error_handler: false,
        })
        .await
        .expect("failed to create step");

    // Transition through proper states: Pending -> Running -> AwaitingApproval
    store
        .update_step(
            step.id,
            StepUpdate {
                status: Some(StepStatus::Running),
                started_at: Some(Utc::now()),
                ..StepUpdate::default()
            },
        )
        .await
        .expect("failed to update step to Running");

    store
        .update_step(
            step.id,
            StepUpdate {
                status: Some(StepStatus::AwaitingApproval),
                ..StepUpdate::default()
            },
        )
        .await
        .expect("failed to update step to AwaitingApproval");

    // Create context and load replay steps
    let mut ctx = WorkflowContext::new(created_run_id, "test".to_string(), store.clone(), provider);
    ctx.load_replay_steps()
        .await
        .expect("failed to load replay steps");

    // Now approval should succeed (replay)
    let result = ctx
        .approval("approval", crate::config::ApprovalConfig::new("Continue?"))
        .await;

    assert!(result.is_ok());

    // Verify the step was marked Completed
    let steps = store
        .list_steps(created_run_id)
        .await
        .expect("failed to list steps");
    assert_eq!(steps.len(), 1);
    assert_eq!(steps[0].status.state, StepStatus::Completed);
}

#[tokio::test]
async fn context_load_replay_steps_loads_completed_steps() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    // Create the run first
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    // Create multiple steps with different statuses
    let completed_step = store
        .create_step(NewStep {
            run_id: created_run_id,
            trace_id: step_trace_id(created_run_id, "completed", 0),
            name: "completed".to_string(),
            kind: StepKind::Shell,
            position: 0,
            input: None,
            is_error_handler: false,
        })
        .await
        .expect("failed to create step");

    // Transition to Running then Completed
    store
        .update_step(
            completed_step.id,
            StepUpdate {
                status: Some(StepStatus::Running),
                started_at: Some(Utc::now()),
                ..StepUpdate::default()
            },
        )
        .await
        .expect("failed to update step to Running");

    store
        .update_step(
            completed_step.id,
            StepUpdate {
                status: Some(StepStatus::Completed),
                completed_at: Some(Utc::now()),
                ..StepUpdate::default()
            },
        )
        .await
        .expect("failed to update step to Completed");

    let _pending_step = store
        .create_step(NewStep {
            run_id: created_run_id,
            trace_id: step_trace_id(created_run_id, "pending", 1),
            name: "pending".to_string(),
            kind: StepKind::Shell,
            position: 1,
            input: None,
            is_error_handler: false,
        })
        .await
        .expect("failed to create step");

    // Load replay steps
    let mut ctx = WorkflowContext::new(created_run_id, "test".to_string(), store, provider);
    ctx.load_replay_steps()
        .await
        .expect("failed to load replay steps");

    // Only completed step should be in replay_steps
    assert_eq!(ctx.replay_steps.len(), 1);
    assert!(ctx.replay_steps.contains_key(&0));
    assert!(!ctx.replay_steps.contains_key(&1));
}

#[tokio::test]
async fn context_payload_returns_run_payload() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();
    let test_payload = json!({"key": "value", "number": 42});

    // Create the run first
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: test_payload.clone(),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    let ctx = WorkflowContext::new(created_run_id, "test".to_string(), store, provider);
    let payload = ctx.payload().await.expect("failed to get payload");

    assert_eq!(payload, test_payload);
}

#[tokio::test]
async fn context_payload_returns_error_for_nonexistent_run() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();
    let run_id = Uuid::now_v7();

    let ctx = WorkflowContext::new(run_id, "test".to_string(), store, provider);
    let result = ctx.payload().await;

    assert!(result.is_err());
}

#[tokio::test]
async fn context_store_returns_reference() {
    let ctx = create_test_context();
    let _store = ctx.store();
    // store() returns a reference to the Arc<dyn Store>, which is always available
}

#[test]
fn context_debug_formatting() {
    let ctx = create_test_context();
    let debug_str = format!("{:?}", ctx);
    assert!(debug_str.contains("WorkflowContext"));
    assert!(debug_str.contains("run_id"));
}

#[tokio::test]
async fn context_last_step_ids_tracks_executed_steps() {
    let store = Arc::new(InMemoryStore::new());
    let provider = create_test_provider();

    // Create the run first
    store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    // Get the created run to extract its ID
    let runs = store
        .list_runs(RunFilter::default(), 1, 10)
        .await
        .expect("failed to list runs");
    let created_run_id = runs.items[0].id;

    let mut ctx = WorkflowContext::new(created_run_id, "test".to_string(), store, provider);
    assert!(ctx.last_step_ids.is_empty());

    ctx.skip("step1", "reason").await.expect("skip failed");

    assert_eq!(ctx.last_step_ids.len(), 1);

    ctx.skip("step2", "reason").await.expect("skip failed");

    // last_step_ids should now contain only step2's ID
    assert_eq!(ctx.last_step_ids.len(), 1);
}

// -- approval SLA timers --

/// A context wired to a freshly created run on a shared store.
async fn context_with_run() -> (Arc<InMemoryStore>, WorkflowContext) {
    let store = Arc::new(InMemoryStore::new());
    let run = store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    let ctx = WorkflowContext::new(
        run.id,
        "test".to_string(),
        store.clone(),
        create_test_provider(),
    );
    (store, ctx)
}

#[tokio::test]
async fn approval_without_deadline_leaves_timer_unset() {
    let (store, mut ctx) = context_with_run().await;

    let err = ctx
        .approval("gate", ApprovalConfig::new("Approve?"))
        .await
        .expect_err("approval suspends the run");
    assert!(matches!(err, EngineError::ApprovalRequired { .. }));

    let steps = store.list_steps(ctx.run_id()).await.expect("list steps");
    assert_eq!(steps.len(), 1);
    assert_eq!(steps[0].status.state, StepStatus::AwaitingApproval);
    assert!(steps[0].approval_deadline_at.is_none());
    assert_eq!(steps[0].approval_stage, 0);
    assert!(steps[0].approval_assignee.is_none());
}

#[tokio::test]
async fn approval_with_deadline_arms_timer() {
    let (store, mut ctx) = context_with_run().await;

    let before = Utc::now();
    let config = ApprovalConfig::new("Approve?")
        .with_deadline_secs(3600)
        .assigned_to(Assignee::group("release-managers"));
    ctx.approval("gate", config)
        .await
        .expect_err("approval suspends the run");

    let steps = store.list_steps(ctx.run_id()).await.expect("list steps");
    let deadline = steps[0].approval_deadline_at.expect("timer is armed");
    assert!(deadline >= before + TimeDelta::seconds(3600));
    assert!(deadline <= Utc::now() + TimeDelta::seconds(3600));
    assert_eq!(steps[0].approval_stage, 0);
    assert_eq!(
        steps[0].approval_assignee,
        Some(Assignee::group("release-managers"))
    );
}

#[tokio::test]
async fn approval_honours_the_legacy_timeout_seconds() {
    let (store, mut ctx) = context_with_run().await;

    ctx.approval(
        "gate",
        ApprovalConfig::new("Approve?").with_timeout_seconds(60),
    )
    .await
    .expect_err("approval suspends the run");

    let steps = store.list_steps(ctx.run_id()).await.expect("list steps");
    assert!(steps[0].approval_deadline_at.is_some());
}

#[tokio::test]
async fn approval_replay_clears_deadline() {
    let (store, mut ctx) = context_with_run().await;

    ctx.approval(
        "gate",
        ApprovalConfig::new("Approve?").with_deadline_secs(3600),
    )
    .await
    .expect_err("approval suspends the run");

    // Replay the handler the way resume_run does.
    let mut resumed = WorkflowContext::new(
        ctx.run_id(),
        "test".to_string(),
        store.clone(),
        create_test_provider(),
    );
    resumed
        .load_replay_steps()
        .await
        .expect("load replay steps");
    resumed
        .approval(
            "gate",
            ApprovalConfig::new("Approve?").with_deadline_secs(3600),
        )
        .await
        .expect("replayed gate continues");

    let steps = store.list_steps(ctx.run_id()).await.expect("list steps");
    assert_eq!(steps[0].status.state, StepStatus::Completed);
    assert!(steps[0].approval_deadline_at.is_none());
}

#[tokio::test]
async fn when_applies_the_predicate_to_the_payload() {
    let store = Arc::new(InMemoryStore::new());
    let run = store
        .create_run(NewRun {
            created_by: None,
            workflow_name: "test".to_string(),
            trigger: TriggerKind::Manual,
            payload: json!({"env": "prod"}),
            max_retries: 0,
            handler_version: None,
            labels: Default::default(),
            scheduled_at: None,
            idempotency_key: None,
            max_cost_usd: None,
        })
        .await
        .expect("failed to create run")
        .into_run();

    let mut ctx = WorkflowContext::new(
        run.id,
        "test".to_string(),
        store.clone(),
        create_test_provider(),
    );

    assert!(
        ctx.when("env == prod", |p| p["env"] == "prod")
            .await
            .expect("condition evaluated")
    );
    assert!(
        !ctx.when("env == dev", |p| p["env"] == "dev")
            .await
            .expect("condition evaluated")
    );
}

#[test]
fn when_dynamic_returns_its_argument_unchanged() {
    let mut ctx = create_test_context();
    assert!(ctx.when_dynamic("build succeeded", true));
    assert!(!ctx.when_dynamic("build succeeded", false));
}

#[test]
fn a_normal_context_is_not_planning() {
    let ctx = create_test_context();
    assert!(!ctx.is_planning());
    assert!(ctx.plan().is_none());
}