patch_eval_decision/
patch_eval_decision.rs1use serde_json::json;
2use yoagent_state::{
3 ActorRef, ArtifactRef, ExpectedEffect, MemoryEventStore, NodeId, PatchId, PatchStatus,
4 Precondition, StatePatch, YoAgentState,
5};
6
7#[tokio::main]
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let actor = ActorRef::agent("yoyo-evolve");
11
12 let failure = NodeId::new("failure_17");
13 state
14 .record_failure(
15 actor.clone(),
16 failure.clone(),
17 "tool_retry_survives_timeout fails",
18 "Retry state is lost when timeout cancels the future.",
19 )
20 .await?;
21
22 let patch_id = PatchId::new("patch_42");
23 let mut patch = StatePatch::new(
24 patch_id.clone(),
25 "Persist retry state across timeout",
26 "Add RetryState and keep attempt count outside the cancelled future.",
27 actor.clone(),
28 );
29 patch.evidence.push(failure);
30 patch.preconditions.push(Precondition::TestStillFailing {
31 name: "tool_retry_survives_timeout".to_string(),
32 });
33 patch.expected_effects.push(ExpectedEffect::TestPasses {
34 name: "tool_retry_survives_timeout".to_string(),
35 });
36 patch.artifacts.push(
37 ArtifactRef::new("git.diff", "file://.yoyo/artifacts/patch_42.diff")
38 .with_summary("Fix retry persistence and add timeout regression test")
39 .with_metadata(json!({
40 "base_commit": "abc123",
41 "files_changed": [
42 "crates/yoagent-runtime/src/tool.rs",
43 "crates/yoagent-runtime/tests/retry.rs"
44 ]
45 })),
46 );
47
48 state.propose_patch(patch).await?;
49 state
50 .record_eval_result(
51 actor,
52 NodeId::new("eval_55"),
53 patch_id.clone(),
54 "cargo test tool_retry_survives_timeout",
55 true,
56 )
57 .await?;
58 state
59 .record_decision(
60 ActorRef::user("yuanhao"),
61 NodeId::new("decision_9"),
62 patch_id.clone(),
63 true,
64 "Eval passed; approve promotion",
65 )
66 .await?;
67 state
68 .update_patch_status(
69 patch_id.clone(),
70 PatchStatus::Approved,
71 Some("Eval passed".to_string()),
72 )
73 .await?;
74 state
75 .update_patch_status(
76 patch_id.clone(),
77 PatchStatus::Promoted,
78 Some("Promoted as commit def456".to_string()),
79 )
80 .await?;
81
82 print!(
83 "{}",
84 state.lineage(NodeId::new(patch_id.0)).await.to_markdown()
85 );
86 Ok(())
87}