Enforce Soul verdicts for verification
This commit is contained in:
parent
2a88bf1de9
commit
5e97e3464e
8 changed files with 180 additions and 11 deletions
|
|
@ -422,6 +422,7 @@ pub use runtime_spine::put_mind_gateway_review;
|
|||
pub use runtime_spine::put_mind_state_commit_receipt;
|
||||
pub use runtime_spine::put_runtime_reorient_worker_result;
|
||||
pub use runtime_spine::put_runtime_role_worker_result;
|
||||
pub use runtime_spine::put_soul_verdict_receipt;
|
||||
pub use runtime_spine::put_substrate_gate_repo_access_grant_receipt;
|
||||
pub use runtime_spine::replace_or_append_epiphany_job_binding;
|
||||
pub use runtime_spine::runtime_eyes_evidence_packet;
|
||||
|
|
@ -432,6 +433,7 @@ pub use runtime_spine::runtime_mind_state_commit_receipt;
|
|||
pub use runtime_spine::runtime_reorient_worker_result;
|
||||
pub use runtime_spine::runtime_role_worker_result;
|
||||
pub use runtime_spine::runtime_schema_catalog_response;
|
||||
pub use runtime_spine::runtime_soul_verdict_receipt;
|
||||
pub use runtime_spine::runtime_spine_cache;
|
||||
pub use runtime_spine::runtime_spine_status;
|
||||
pub use runtime_spine::runtime_substrate_gate_repo_access_grant_receipt;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use crate::mind_gateway::MIND_VERSE_ADOPTION_RECEIPT_TYPE;
|
|||
use crate::mind_gateway::MindGatewayReview;
|
||||
use crate::mind_gateway::MindStateCommitReceipt;
|
||||
use crate::organ_dependencies::EpiphanyLaunchOrganContract;
|
||||
use crate::soul_gateway::SoulVerdictReceipt;
|
||||
use crate::soul_gateway::*;
|
||||
use crate::state_ledger::STATE_LEDGER_SCHEMA_VERSION;
|
||||
use crate::state_ledger::STATE_LEDGER_STORE_TYPE;
|
||||
|
|
@ -715,6 +716,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
cache.register_entry_type::<MindStateCommitReceipt>()?;
|
||||
cache.register_entry_type::<EyesEvidencePacket>()?;
|
||||
cache.register_entry_type::<SubstrateGateRepoAccessGrantReceipt>()?;
|
||||
cache.register_entry_type::<SoulVerdictReceipt>()?;
|
||||
cache.register_entry_type::<EpiphanyOpenAiAdapterStatus>()?;
|
||||
cache.register_entry_type::<EpiphanyOpenAiModelRequest>()?;
|
||||
cache.register_entry_type::<EpiphanyOpenAiStreamEvent>()?;
|
||||
|
|
@ -1249,6 +1251,32 @@ pub fn runtime_substrate_gate_repo_access_grant_receipt(
|
|||
cache.get::<SubstrateGateRepoAccessGrantReceipt>(receipt_id)
|
||||
}
|
||||
|
||||
pub fn put_soul_verdict_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt: &SoulVerdictReceipt,
|
||||
) -> Result<()> {
|
||||
validate_non_empty(&receipt.receipt_id, "Soul verdict receipt id")?;
|
||||
validate_non_empty(&receipt.source_result_id, "Soul verdict source result")?;
|
||||
validate_non_empty(&receipt.source_job_id, "Soul verdict source job")?;
|
||||
validate_non_empty(&receipt.verdict, "Soul verdict")?;
|
||||
validate_non_empty(&receipt.emitted_at, "Soul verdict timestamp")?;
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
cache.put(&receipt.receipt_id, receipt)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn runtime_soul_verdict_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt_id: &str,
|
||||
) -> Result<Option<SoulVerdictReceipt>> {
|
||||
validate_non_empty(receipt_id, "Soul verdict receipt id")?;
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
cache.get::<SoulVerdictReceipt>(receipt_id)
|
||||
}
|
||||
|
||||
pub fn put_coordinator_run_receipt(
|
||||
store_path: impl AsRef<Path>,
|
||||
receipt: &EpiphanyCoordinatorRunReceipt,
|
||||
|
|
@ -3226,6 +3254,19 @@ mod tests {
|
|||
contract: "Substrate Gate grant persists as runtime-spine proof.".to_string(),
|
||||
};
|
||||
put_substrate_gate_repo_access_grant_receipt(&store, &substrate_grant)?;
|
||||
let soul_verdict = SoulVerdictReceipt {
|
||||
schema_version: crate::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: "soul-verdict-1".to_string(),
|
||||
source_result_id: "result-verify-1".to_string(),
|
||||
source_job_id: "job-verify-1".to_string(),
|
||||
verdict: "passed".to_string(),
|
||||
summary: "Verification passed.".to_string(),
|
||||
evidence_ids: vec!["ev-check".to_string()],
|
||||
risks: Vec::new(),
|
||||
emitted_at: "2026-05-06T00:07:00Z".to_string(),
|
||||
contract: "Soul verdict persists as runtime-spine proof.".to_string(),
|
||||
};
|
||||
put_soul_verdict_receipt(&store, &soul_verdict)?;
|
||||
|
||||
let stored = runtime_mind_gateway_review(&store, "mind-role-modeling-job-1")?
|
||||
.expect("Mind review receipt should persist");
|
||||
|
|
@ -3240,6 +3281,9 @@ mod tests {
|
|||
runtime_substrate_gate_repo_access_grant_receipt(&store, "substrate-grant-1")?
|
||||
.expect("Substrate Gate grant should persist");
|
||||
assert_eq!(stored_grant, substrate_grant);
|
||||
let stored_verdict = runtime_soul_verdict_receipt(&store, "soul-verdict-1")?
|
||||
.expect("Soul verdict should persist");
|
||||
assert_eq!(stored_verdict, soul_verdict);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use crate::EpiphanyRoleFindingInterpretation;
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
@ -16,6 +18,31 @@ pub const SOUL_REVIEW_RECEIPT_SCHEMA_VERSION: &str = "epiphany.soul.review_recei
|
|||
pub const SOUL_VERIFICATION_REFUSAL_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.soul.verification_refusal_receipt.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "epiphany.soul.verdict_receipt", schema = "SoulVerdictReceipt")]
|
||||
pub struct SoulVerdictReceipt {
|
||||
#[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 verdict: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub summary: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub evidence_ids: Vec<String>,
|
||||
#[cultcache(key = 7)]
|
||||
pub risks: Vec<String>,
|
||||
#[cultcache(key = 8)]
|
||||
pub emitted_at: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SoulCultNetContract {
|
||||
|
|
@ -111,6 +138,25 @@ pub fn default_soul_cultnet_contracts() -> Vec<SoulCultNetContract> {
|
|||
]
|
||||
}
|
||||
|
||||
pub fn soul_verdict_receipt_from_verification_finding(
|
||||
receipt_id: String,
|
||||
finding: &EpiphanyRoleFindingInterpretation,
|
||||
emitted_at: String,
|
||||
) -> SoulVerdictReceipt {
|
||||
SoulVerdictReceipt {
|
||||
schema_version: SOUL_VERDICT_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(),
|
||||
verdict: finding.verdict.clone().unwrap_or_else(|| "unknown".to_string()),
|
||||
summary: finding.summary.clone().unwrap_or_default(),
|
||||
evidence_ids: finding.evidence_ids.clone(),
|
||||
risks: finding.risks.clone(),
|
||||
emitted_at,
|
||||
contract: "Soul verdict emitted from a reviewed Verification lane finding; it is proof of verification judgment before Mind admission.".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -137,4 +183,36 @@ mod tests {
|
|||
.contains(&SOUL_VERDICT_RECEIPT_TYPE.to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verification_finding_builds_soul_verdict_receipt() {
|
||||
let finding = EpiphanyRoleFindingInterpretation {
|
||||
verdict: Some("passed".to_string()),
|
||||
summary: Some("Checks passed.".to_string()),
|
||||
next_safe_move: Some("Proceed.".to_string()),
|
||||
checkpoint_summary: None,
|
||||
scratch_summary: None,
|
||||
files_inspected: vec!["src/lib.rs".to_string()],
|
||||
frontier_node_ids: Vec::new(),
|
||||
evidence_ids: vec!["ev-check".to_string()],
|
||||
artifact_refs: Vec::new(),
|
||||
runtime_result_id: Some("result-1".to_string()),
|
||||
runtime_job_id: Some("job-1".to_string()),
|
||||
open_questions: Vec::new(),
|
||||
evidence_gaps: Vec::new(),
|
||||
risks: Vec::new(),
|
||||
state_patch: None,
|
||||
self_patch: None,
|
||||
self_persistence: None,
|
||||
job_error: None,
|
||||
item_error: None,
|
||||
};
|
||||
let receipt = soul_verdict_receipt_from_verification_finding(
|
||||
"soul-verdict-1".to_string(),
|
||||
&finding,
|
||||
"2026-05-30T00:00:00Z".to_string(),
|
||||
);
|
||||
assert_eq!(receipt.verdict, "passed");
|
||||
assert!(receipt.evidence_ids.contains(&"ev-check".to_string()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue