huskies: merge 1243 refactor Merge jobs stop bloating replicated CRDT state

This commit is contained in:
Huskies Agent
2026-07-21 15:25:34 +00:00
parent 2ea633a2f1
commit 013a5da60b
3 changed files with 203 additions and 4 deletions
@@ -299,10 +299,17 @@ impl AgentPool {
crate::db::write_content(crate::db::ContentKey::MergeSuccess(&sid), "1");
}
// Update CRDT with terminal status.
// Update CRDT with terminal status. The full untruncated output is
// already on disk (write_merge_report, called from
// run_merge_pipeline for the Ok(r) case above, or below for the
// Err(e) case) — only a bounded summary plus that pointer goes
// into the replicated `merge_jobs.error` field, so a large gate
// failure doesn't bloat every node's CRDT state.
match &report {
Ok(r) => {
let report_json = serde_json::to_string(r).unwrap_or_else(|_| String::new());
let bounded = crate::service::merge::bound_report_for_storage(r);
let report_json =
serde_json::to_string(&bounded).unwrap_or_else(|_| String::new());
crate::crdt_state::write_merge_job(
&sid,
"completed",
@@ -312,12 +319,15 @@ impl AgentPool {
);
}
Err(e) => {
let report_path = crate::service::merge::io::write_merge_report(&root, &sid, e);
let bounded =
crate::service::merge::bound_plain_error(e, report_path.as_deref());
crate::crdt_state::write_merge_job(
&sid,
"failed",
started_at,
Some(finished_at),
Some(e),
Some(&bounded),
);
}
}