MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / write_improvement_artifacts

Function write_improvement_artifacts

src/automation/artifacts.rs:66–177  ·  view source on GitHub ↗
(
    dashboard_root: &Path,
    run_id: &str,
    task: AgentTaskKind,
    request: &AgentTaskRequest,
    response: &AgentTaskResponse,
    record: &AutomationRunLedgerRecord,
)

Source from the content-addressed store, hash-verified

64}
65
66pub(crate) async fn write_improvement_artifacts(
67 dashboard_root: &Path,
68 run_id: &str,
69 task: AgentTaskKind,
70 request: &AgentTaskRequest,
71 response: &AgentTaskResponse,
72 record: &AutomationRunLedgerRecord,
73) -> Result<Vec<AutomationRunArtifact>> {
74 let created_at = current_timestamp().to_string();
75 let task_key = task_key(task);
76 let prompt_version = prompt_version(task);
77 let policy = artifact_policy(task);
78 // A missing or unreadable outcomes snapshot must never block the run's
79 // artifact trail; it only means no post-approval signal is available yet.
80 let outcomes = load_outcomes_snapshot(dashboard_root)
81 .await
82 .unwrap_or_default();
83 let ctx = ArtifactPayloadContext {
84 run_id,
85 task,
86 task_key,
87 prompt_version,
88 policy,
89 request,
90 response,
91 record,
92 outcomes: &outcomes,
93 };
94 let mut writer = ImprovementArtifactWriter::new(dashboard_root, run_id, &created_at);
95
96 let trace_ref = writer
97 .write(
98 AutomationRunArtifactKind::Traces,
99 &traces_payload(&ctx),
100 Some(format!("{task_key} trace and hash references")),
101 )
102 .await?;
103
104 let feedback_ref = writer
105 .write(
106 AutomationRunArtifactKind::Feedback,
107 &feedback_payload(&ctx, &trace_ref),
108 Some("feedback derived from validation outcomes".to_string()),
109 )
110 .await?;
111
112 let evals = generated_eval_payloads(&ctx);
113 let generated_evals_ref = writer
114 .write(
115 AutomationRunArtifactKind::GeneratedEvals,
116 &generated_evals_payload(&ctx, (&trace_ref, &feedback_ref), &evals),
117 Some("evals generated from validation outcomes".to_string()),
118 )
119 .await?;
120
121 let gate = improvement_gate_payload(&ctx, &evals);
122 let validation_gate_ref = writer
123 .write(

Callers 2

append_success_recordMethod · 0.85

Calls 15

current_timestampFunction · 0.85
task_keyFunction · 0.85
prompt_versionFunction · 0.85
artifact_policyFunction · 0.85
load_outcomes_snapshotFunction · 0.85
traces_payloadFunction · 0.85
feedback_payloadFunction · 0.85
generated_eval_payloadsFunction · 0.85
generated_evals_payloadFunction · 0.85
improvement_gate_payloadFunction · 0.85
validation_gate_payloadFunction · 0.85

Tested by

no test coverage detected