basic_lineage/
basic_lineage.rs1use serde_json::json;
2use yoagent_state::{ActorRef, MemoryEventStore, NodeId, StateOp, YoAgentState};
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let state = YoAgentState::load(MemoryEventStore::new()).await?;
7 let actor = ActorRef::agent("example");
8
9 let failure = NodeId::new("failure_retry_timeout");
10 let hypothesis = NodeId::new("hypothesis_retry_state_lost");
11
12 state
13 .apply_ops(
14 actor,
15 vec![
16 StateOp::CreateNode {
17 id: failure.clone(),
18 kind: "failure".to_string(),
19 props: json!({
20 "title": "Retry state is lost after timeout",
21 "summary": "The next retry starts from attempt zero."
22 }),
23 },
24 StateOp::CreateNode {
25 id: hypothesis.clone(),
26 kind: "hypothesis".to_string(),
27 props: json!({
28 "title": "Attempt count is scoped to the cancelled future"
29 }),
30 },
31 StateOp::CreateRelation {
32 from: hypothesis.clone(),
33 rel: "explains".to_string(),
34 to: failure,
35 props: json!({}),
36 },
37 ],
38 )
39 .await?;
40
41 print!("{}", state.lineage(hypothesis).await.to_markdown());
42 Ok(())
43}