Replace role graph cargo with memory patch candidates

This commit is contained in:
Meta Vens 2026-05-18 03:40:21 +01:00
commit 735e31f2a6
9 changed files with 67 additions and 12 deletions

View file

@ -286,6 +286,8 @@ pub struct EpiphanyRuntimeRoleWorkerResult {
pub item_error: Option<String>,
#[cultcache(key = 19, default)]
pub metadata: BTreeMap<String, String>,
#[cultcache(key = 20, default)]
pub memory_patch_candidates_msgpack: Option<Vec<u8>>,
}
impl EpiphanyRuntimeRoleWorkerResult {
@ -299,6 +301,14 @@ impl EpiphanyRuntimeRoleWorkerResult {
pub fn self_patch(&self) -> Result<Option<crate::AgentSelfPatch>> {
decode_optional_msgpack(self.self_patch_msgpack.as_deref(), "role worker selfPatch")
}
pub fn memory_patch_candidates(&self) -> Result<Vec<crate::EpiphanyMemoryPatchCandidate>> {
decode_optional_msgpack(
self.memory_patch_candidates_msgpack.as_deref(),
"role worker memoryPatchCandidates",
)
.map(|candidates| candidates.unwrap_or_default())
}
}
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]

View file

@ -40,6 +40,7 @@ pub struct EpiphanyRoleFindingInterpretation {
pub risks: Vec<String>,
pub state_patch: Option<EpiphanyRoleStatePatchDocument>,
pub self_patch: Option<AgentSelfPatch>,
pub memory_patch_candidates: Vec<crate::EpiphanyMemoryPatchCandidate>,
pub self_persistence: Option<EpiphanyRoleSelfPersistenceReview>,
pub job_error: Option<String>,
pub item_error: Option<String>,
@ -167,6 +168,7 @@ fn interpret_role_finding(
risks: json_string_array_field(raw_result, "risks"),
state_patch,
self_patch,
memory_patch_candidates: Vec::new(),
self_persistence,
job_error,
item_error,
@ -211,6 +213,11 @@ pub fn interpret_runtime_role_worker_result(
.as_ref()
.ok()
.and_then(|patch| patch.clone());
let memory_patch_candidates_result = result.memory_patch_candidates();
let memory_patch_candidates = memory_patch_candidates_result
.as_ref()
.cloned()
.unwrap_or_default();
let item_error = merge_item_error(
result.item_error.clone(),
state_patch_result.as_ref().err().map(ToString::to_string),
@ -219,6 +226,13 @@ pub fn interpret_runtime_role_worker_result(
item_error,
self_patch_result.as_ref().err().map(ToString::to_string),
);
let item_error = merge_item_error(
item_error,
memory_patch_candidates_result
.as_ref()
.err()
.map(ToString::to_string),
);
EpiphanyRoleFindingInterpretation {
verdict: Some(result.verdict.clone()),
summary: Some(result.summary.clone()),
@ -236,6 +250,7 @@ pub fn interpret_runtime_role_worker_result(
risks: result.risks.clone(),
state_patch: state_patch.clone(),
self_patch,
memory_patch_candidates,
self_persistence: None,
job_error: None,
item_error: match role_id {