action_receipt/
action_receipt.rs1use cel_contracts::{
6 DispatchRoute, EffectExpectation, ExecutionReceipt, ObservedEffect, PlannedAction,
7 ReceiptStatus,
8};
9
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11 let action = PlannedAction::Click {
12 target_id: "dom:button:deploy".into(),
13 expect_after: Some(EffectExpectation::SelectorTextContains {
14 selector: "#status".into(),
15 substring: "Deploy started".into(),
16 timeout_ms: 2_000,
17 }),
18 };
19
20 let receipt = ExecutionReceipt {
21 receipt_id: "receipt-001".into(),
22 run_id: Some("run-42".into()),
23 trace_id: Some("trace-abc".into()),
24 action_kind: "click".into(),
25 target: Some("dom:button:deploy".into()),
26 route: DispatchRoute::Cdp,
27 observed_effect: ObservedEffect::selector_observed(
28 EffectExpectation::SelectorTextContains {
29 selector: "#status".into(),
30 substring: "Deploy started".into(),
31 timeout_ms: 2_000,
32 },
33 ),
34 evidence: Vec::new(),
35 requested_at_ms: 1_700_000_000_000,
36 completed_at_ms: 1_700_000_000_120,
37 duration_ms: 120,
38 status: ReceiptStatus::Ok,
39 error: None,
40 };
41
42 println!(
43 "planned action:\n{}",
44 serde_json::to_string_pretty(&action)?
45 );
46 println!(
47 "\nexecution receipt:\n{}",
48 serde_json::to_string_pretty(&receipt)?
49 );
50 Ok(())
51}