Enforce Continuity recovery for reorientation
This commit is contained in:
parent
5e97e3464e
commit
3d36944fdd
8 changed files with 234 additions and 39 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use crate::EpiphanyReorientFindingInterpretation;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
@ -19,6 +21,38 @@ pub const CONTINUITY_STALE_TURN_REPAIR_SCHEMA_VERSION: &str =
|
|||
pub const CONTINUITY_REFUSAL_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.continuity.refusal_receipt.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.continuity.recovery_receipt",
|
||||
schema = "ContinuityRecoveryReceipt"
|
||||
)]
|
||||
pub struct ContinuityRecoveryReceipt {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub receipt_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub source_result_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub source_job_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub binding_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub mode: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub checkpoint_still_valid: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub summary: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub next_safe_move: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub files_inspected: Vec<String>,
|
||||
#[cultcache(key = 10)]
|
||||
pub emitted_at: String,
|
||||
#[cultcache(key = 11)]
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ContinuityCultNetContract {
|
||||
|
|
@ -114,6 +148,31 @@ pub fn default_continuity_cultnet_contracts() -> Vec<ContinuityCultNetContract>
|
|||
]
|
||||
}
|
||||
|
||||
pub fn continuity_recovery_receipt_from_reorient_finding(
|
||||
receipt_id: String,
|
||||
binding_id: String,
|
||||
finding: &EpiphanyReorientFindingInterpretation,
|
||||
emitted_at: String,
|
||||
) -> ContinuityRecoveryReceipt {
|
||||
ContinuityRecoveryReceipt {
|
||||
schema_version: CONTINUITY_RECOVERY_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id,
|
||||
source_result_id: finding.runtime_result_id.clone().unwrap_or_default(),
|
||||
source_job_id: finding.runtime_job_id.clone().unwrap_or_default(),
|
||||
binding_id,
|
||||
mode: finding.mode.clone().unwrap_or_else(|| "unknown".to_string()),
|
||||
checkpoint_still_valid: finding
|
||||
.checkpoint_still_valid
|
||||
.map(|value| value.to_string())
|
||||
.unwrap_or_else(|| "unknown".to_string()),
|
||||
summary: finding.summary.clone().unwrap_or_default(),
|
||||
next_safe_move: finding.next_safe_move.clone().unwrap_or_default(),
|
||||
files_inspected: finding.files_inspected.clone(),
|
||||
emitted_at,
|
||||
contract: "Continuity recovery emitted from a reviewed reorientation finding; it proves what survived rupture before Mind admits recovery state.".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -140,4 +199,33 @@ mod tests {
|
|||
.contains(&CONTINUITY_RECOVERY_RECEIPT_TYPE.to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reorient_finding_builds_continuity_recovery_receipt() {
|
||||
let finding = EpiphanyReorientFindingInterpretation {
|
||||
mode: Some("resume".to_string()),
|
||||
summary: Some("Checkpoint remains valid.".to_string()),
|
||||
next_safe_move: Some("Continue bounded implementation.".to_string()),
|
||||
checkpoint_still_valid: Some(true),
|
||||
files_inspected: vec!["state/map.yaml".to_string()],
|
||||
frontier_node_ids: Vec::new(),
|
||||
evidence_ids: Vec::new(),
|
||||
artifact_refs: Vec::new(),
|
||||
runtime_result_id: Some("result-1".to_string()),
|
||||
runtime_job_id: Some("job-1".to_string()),
|
||||
job_error: None,
|
||||
item_error: None,
|
||||
};
|
||||
let receipt = continuity_recovery_receipt_from_reorient_finding(
|
||||
"continuity-recovery-1".to_string(),
|
||||
"reorientation-worker".to_string(),
|
||||
&finding,
|
||||
"2026-05-30T00:00:00Z".to_string(),
|
||||
);
|
||||
|
||||
assert_eq!(receipt.source_result_id, "result-1");
|
||||
assert_eq!(receipt.source_job_id, "job-1");
|
||||
assert_eq!(receipt.mode, "resume");
|
||||
assert_eq!(receipt.checkpoint_still_valid, "true");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue