Complete claim repair admission nerve
This commit is contained in:
parent
59ab73f093
commit
38c41a3bc6
13 changed files with 657 additions and 70 deletions
|
|
@ -315,6 +315,12 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"soul_verdict_receipt_id": {"type": "string", "minLength": 1}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["kind"],
|
||||
"properties": {"kind": {"const": "repair_claim"}},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -335,6 +341,14 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"description": "Exact echo of an explicit typed repo-frontier proposal Modeling request, when supplied."
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"claimRepairRequestId".to_string(),
|
||||
serde_json::json!({
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "Exact echo of the coordinator-bound claim repair request; valid only with purpose repair_claim."
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"statePatch".to_string(),
|
||||
serde_json::json!({
|
||||
|
|
@ -358,23 +372,42 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"additionalProperties": true
|
||||
});
|
||||
if role_id == EpiphanyRoleResultRoleId::Modeling {
|
||||
schema["allOf"] = serde_json::json!([{
|
||||
"if": {
|
||||
"properties": {
|
||||
"repoModelPatch": {
|
||||
"properties": {
|
||||
"purpose": {
|
||||
"properties": {"kind": {"const": "incorporate_frontier_verdict"}},
|
||||
"required": ["kind"]
|
||||
}
|
||||
},
|
||||
"required": ["purpose"]
|
||||
}
|
||||
schema["allOf"] = serde_json::json!([
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"repoModelPatch": {
|
||||
"properties": {
|
||||
"purpose": {
|
||||
"properties": {"kind": {"const": "incorporate_frontier_verdict"}},
|
||||
"required": ["kind"]
|
||||
}
|
||||
},
|
||||
"required": ["purpose"]
|
||||
}
|
||||
},
|
||||
"required": ["repoModelPatch"]
|
||||
},
|
||||
"required": ["repoModelPatch"]
|
||||
"then": {"required": ["repoFrontierModelingRequestId"]}
|
||||
},
|
||||
"then": {"required": ["repoFrontierModelingRequestId"]}
|
||||
}]);
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"repoModelPatch": {
|
||||
"properties": {
|
||||
"purpose": {
|
||||
"properties": {"kind": {"const": "repair_claim"}},
|
||||
"required": ["kind"]
|
||||
}
|
||||
}
|
||||
,"required": ["purpose"]
|
||||
}
|
||||
},
|
||||
"required": ["repoModelPatch"]
|
||||
},
|
||||
"then": {"required": ["claimRepairRequestId"]}
|
||||
}
|
||||
]);
|
||||
}
|
||||
schema
|
||||
}
|
||||
|
|
@ -891,12 +924,12 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn modeling_schema_exposes_only_typed_evolution_or_verdict_incorporation() {
|
||||
fn modeling_schema_exposes_only_typed_authority_purposes() {
|
||||
let schema = epiphany_role_launch_output_schema(EpiphanyRoleResultRoleId::Modeling);
|
||||
let purposes = schema["properties"]["repoModelPatch"]["properties"]["purpose"]["oneOf"]
|
||||
.as_array()
|
||||
.expect("typed Modeling purpose alternatives");
|
||||
assert_eq!(purposes.len(), 2);
|
||||
assert_eq!(purposes.len(), 3);
|
||||
assert_eq!(purposes[0]["properties"]["kind"]["const"], "evolution");
|
||||
assert_eq!(
|
||||
purposes[1]["properties"]["kind"]["const"],
|
||||
|
|
@ -913,6 +946,11 @@ mod tests {
|
|||
schema["allOf"][0]["then"]["required"][0],
|
||||
"repoFrontierModelingRequestId"
|
||||
);
|
||||
assert_eq!(purposes[2]["properties"]["kind"]["const"], "repair_claim");
|
||||
assert_eq!(
|
||||
schema["allOf"][1]["then"]["required"][0],
|
||||
"claimRepairRequestId"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1174,6 +1174,7 @@ mod tests {
|
|||
soul_verdict_receipt_id: String::new(),
|
||||
frontier_modeling_request_id: String::new(),
|
||||
proposal_modeling_request_id: String::new(),
|
||||
claim_repair_request_id: String::new(),
|
||||
},
|
||||
)?;
|
||||
let mut fresh = existing.clone();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ fn commit_coordinator_job_launch_in_cache(
|
|||
let claim_repair_launch = if let Some(request_id) = request.claim_repair_request_id.as_deref() {
|
||||
let (repair, challenge, identity) =
|
||||
validate_claim_repair_launch(cache, current_state, request, request_id)?;
|
||||
let projection = build_claim_repair_context_projection(&repair);
|
||||
let projection = RepoModelClaimRepairContextProjection::from_request(&repair);
|
||||
match &mut effective_launch_document {
|
||||
EpiphanyWorkerLaunchDocument::Role(document) => {
|
||||
if document.proposal_modeling_context.is_some() {
|
||||
|
|
@ -335,32 +335,6 @@ pub fn plan_coordinator_job_launch(
|
|||
})
|
||||
}
|
||||
|
||||
fn build_claim_repair_context_projection(
|
||||
request: &RepoModelClaimRepairRequest,
|
||||
) -> RepoModelClaimRepairContextProjection {
|
||||
RepoModelClaimRepairContextProjection {
|
||||
schema_version: REPO_MODEL_CLAIM_REPAIR_CONTEXT_SCHEMA_VERSION.into(),
|
||||
contract: REPO_MODEL_CLAIM_REPAIR_CONTEXT_CONTRACT.into(),
|
||||
request_id: request.request_id.clone(),
|
||||
challenge_id: request.challenge_id.clone(),
|
||||
challenge_sha256: request.challenge_sha256.clone(),
|
||||
eyes_evidence_packet_id: request.eyes_evidence_packet_id.clone(),
|
||||
eyes_evidence_packet_sha256: request.eyes_evidence_packet_sha256.clone(),
|
||||
source_result_id: request.source_result_id.clone(),
|
||||
source_job_id: request.source_job_id.clone(),
|
||||
original_admission_receipt_id: request.original_admission_receipt_id.clone(),
|
||||
current_admission_receipt_id: request.current_admission_receipt_id.clone(),
|
||||
model_revision: request.model_revision,
|
||||
model_hash: request.model_hash.clone(),
|
||||
target_claim_id: request.target_claim_id.clone(),
|
||||
target_claim_sha256: request.target_claim_sha256.clone(),
|
||||
runtime_id: request.runtime_id.clone(),
|
||||
thread_id: request.thread_id.clone(),
|
||||
affected_frontier: request.affected_frontier.clone(),
|
||||
requested_at: request.requested_at.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_claim_repair_launch(
|
||||
cache: &CultCache,
|
||||
state: &EpiphanyThreadState,
|
||||
|
|
@ -548,7 +522,7 @@ fn terminal_runtime_link_for_binding(
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
|
||||
fn proposal_launch_fixture(
|
||||
|
|
@ -647,7 +621,7 @@ mod tests {
|
|||
Ok((store, state, request, selection))
|
||||
}
|
||||
|
||||
fn claim_repair_launch_fixture(
|
||||
pub(crate) fn claim_repair_launch_fixture(
|
||||
root: &Path,
|
||||
suffix: &str,
|
||||
) -> Result<(
|
||||
|
|
@ -961,7 +935,7 @@ mod tests {
|
|||
&mut forged.launch_document
|
||||
{
|
||||
document.claim_repair_context =
|
||||
Some(build_claim_repair_context_projection(&repair));
|
||||
Some(RepoModelClaimRepairContextProjection::from_request(&repair));
|
||||
}
|
||||
}
|
||||
_ => forged.proposal_modeling_request_id = Some("dual-proposal".into()),
|
||||
|
|
|
|||
|
|
@ -937,6 +937,7 @@ mod tests {
|
|||
frontier_route_id: None,
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: Some(selection.request_id),
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
crate::put_runtime_role_worker_result(store, &result)?;
|
||||
crate::commit_repo_model_admission(
|
||||
|
|
@ -1416,6 +1417,7 @@ mod tests {
|
|||
frontier_route_id: Some(verification_request.route_id.clone()),
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: None,
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
crate::put_runtime_role_worker_result(&runtime_store, &verification_result)?;
|
||||
crate::put_soul_verdict_receipt(
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ use crate::{
|
|||
EpiphanyThreadStateEntry, THREAD_STATE_KEY, THREAD_STATE_TYPE, coordinator_acceptance_cache,
|
||||
};
|
||||
use anyhow::{Result, anyhow};
|
||||
use cultcache_rs::{
|
||||
CacheBackingStore, CultCache, CultCacheEnvelope, SingleFileMessagePackBackingStore,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use cultcache_rs::CacheBackingStore;
|
||||
use cultcache_rs::{CultCache, CultCacheEnvelope, SingleFileMessagePackBackingStore};
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ mod tests {
|
|||
let contract = default_launch_organ_contract(
|
||||
"epiphany.role.verification",
|
||||
"role",
|
||||
"epiphany.worker.role_result.v0",
|
||||
"epiphany.worker.role_result.v1",
|
||||
);
|
||||
assert_eq!(contract.owner_organ, "soul");
|
||||
assert_eq!(contract.dependencies.len(), EPIPHANY_STANDING_ORGANS.len());
|
||||
|
|
@ -446,7 +446,7 @@ mod tests {
|
|||
let contract = default_launch_organ_contract(
|
||||
"epiphany.role.research",
|
||||
"role",
|
||||
"epiphany.worker.role_result.v0",
|
||||
"epiphany.worker.role_result.v1",
|
||||
);
|
||||
let evaluations = evaluate_receipt_proof_profiles(
|
||||
&contract,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ pub const REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION: &str =
|
|||
"epiphany.mind.repo_model_admission_review.v0";
|
||||
pub const REPO_MODEL_ADMISSION_RECEIPT_TYPE: &str = "epiphany.mind.repo_model_admission_receipt";
|
||||
pub const REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.mind.repo_model_admission_receipt.v2";
|
||||
"epiphany.mind.repo_model_admission_receipt.v3";
|
||||
pub const REPO_MODEL_MIGRATION_RECEIPT_TYPE: &str = "epiphany.mind.repo_model_migration_receipt";
|
||||
pub const REPO_MODEL_MIGRATION_RECEIPT_SCHEMA_VERSION: &str =
|
||||
"epiphany.mind.repo_model_migration_receipt.v0";
|
||||
pub const REPO_MODEL_ADMISSION_CONTRACT: &str = "epiphany.repo_model_admission.v2";
|
||||
pub const REPO_MODEL_ADMISSION_CONTRACT: &str = "epiphany.repo_model_admission.v3";
|
||||
pub const REPO_MODEL_MIGRATION_CONTRACT: &str = "epiphany.repo_model_migration.v0";
|
||||
pub const REPO_FRONTIER_ROUTE_TYPE: &str = "epiphany.self.repo_frontier_route";
|
||||
pub const REPO_FRONTIER_ROUTE_SCHEMA_VERSION: &str = "epiphany.self.repo_frontier_route.v0";
|
||||
|
|
@ -636,6 +636,8 @@ pub struct RepoModelAdmissionReceipt {
|
|||
pub frontier_modeling_request_id: String,
|
||||
#[cultcache(key = 17, default)]
|
||||
pub proposal_modeling_request_id: String,
|
||||
#[cultcache(key = 18, default)]
|
||||
pub claim_repair_request_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v0";
|
|||
pub const RUNTIME_WORKER_LAUNCH_REQUEST_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.worker_launch_request.v1";
|
||||
pub const RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.role_worker_result.v0";
|
||||
"epiphany.runtime.role_worker_result.v1";
|
||||
pub const RUNTIME_REORIENT_WORKER_RESULT_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.reorient_worker_result.v0";
|
||||
pub const COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION: &str = "epiphany.coordinator_run_receipt.v0";
|
||||
|
|
@ -403,6 +403,8 @@ pub struct EpiphanyRuntimeRoleWorkerResult {
|
|||
pub repo_frontier_modeling_request_id: Option<String>,
|
||||
#[cultcache(key = 24, default)]
|
||||
pub proposal_modeling_request_id: Option<String>,
|
||||
#[cultcache(key = 25, default)]
|
||||
pub claim_repair_request_id: Option<String>,
|
||||
}
|
||||
|
||||
impl EpiphanyRuntimeRoleWorkerResult {
|
||||
|
|
@ -1429,11 +1431,22 @@ pub fn put_runtime_role_worker_result(
|
|||
"only Modeling results may echo a proposal Modeling request"
|
||||
));
|
||||
}
|
||||
let is_modeling = result.role_id.eq_ignore_ascii_case("modeling");
|
||||
if is_modeling
|
||||
&& result.repo_frontier_modeling_request_id.is_some()
|
||||
&& result.proposal_modeling_request_id.is_some()
|
||||
if result.claim_repair_request_id.is_some() && !result.role_id.eq_ignore_ascii_case("modeling")
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"only Modeling results may echo a claim repair request"
|
||||
));
|
||||
}
|
||||
let is_modeling = result.role_id.eq_ignore_ascii_case("modeling");
|
||||
let modeling_echo_count = [
|
||||
result.repo_frontier_modeling_request_id.is_some(),
|
||||
result.proposal_modeling_request_id.is_some(),
|
||||
result.claim_repair_request_id.is_some(),
|
||||
]
|
||||
.into_iter()
|
||||
.filter(|present| *present)
|
||||
.count();
|
||||
if is_modeling && modeling_echo_count > 1 {
|
||||
return Err(anyhow!(
|
||||
"Modeling result authority echoes are mutually exclusive"
|
||||
));
|
||||
|
|
@ -1445,10 +1458,7 @@ pub fn put_runtime_role_worker_result(
|
|||
"Modeling result cannot claim Verification route authority"
|
||||
));
|
||||
}
|
||||
if is_modeling
|
||||
&& (result.repo_frontier_modeling_request_id.is_some()
|
||||
|| result.proposal_modeling_request_id.is_some())
|
||||
{
|
||||
if is_modeling && (modeling_echo_count == 1 || result.repo_model_patch_msgpack.is_some()) {
|
||||
let patch_bytes = result
|
||||
.repo_model_patch_msgpack
|
||||
.as_deref()
|
||||
|
|
@ -1457,20 +1467,34 @@ pub fn put_runtime_role_worker_result(
|
|||
.context("decode Modeling authority echo repoModelPatch")?;
|
||||
match patch.purpose {
|
||||
crate::RepoModelPatchPurpose::Evolution
|
||||
if result.repo_frontier_modeling_request_id.is_some() =>
|
||||
if result.repo_frontier_modeling_request_id.is_some()
|
||||
|| result.claim_repair_request_id.is_some() =>
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Evolution result cannot echo a verdict-incorporation request"
|
||||
"Evolution result may only echo a proposal Modeling request"
|
||||
));
|
||||
}
|
||||
crate::RepoModelPatchPurpose::IncorporateFrontierVerdict { .. }
|
||||
if result.proposal_modeling_request_id.is_some()
|
||||
|| result.claim_repair_request_id.is_some()
|
||||
|| result.repo_frontier_modeling_request_id.is_none() =>
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"verdict incorporation requires only its frontier Modeling request echo"
|
||||
));
|
||||
}
|
||||
crate::RepoModelPatchPurpose::RepairClaim
|
||||
if result.claim_repair_request_id.is_none()
|
||||
|| result.repo_frontier_modeling_request_id.is_some()
|
||||
|| result.proposal_modeling_request_id.is_some()
|
||||
|| result.state_patch_msgpack.is_some()
|
||||
|| result.self_patch_msgpack.is_some() =>
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"claim repair requires only its claim repair request echo"
|
||||
));
|
||||
}
|
||||
crate::RepoModelPatchPurpose::RepairClaim => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -1656,13 +1680,215 @@ pub fn commit_repo_model_admission(
|
|||
));
|
||||
}
|
||||
|
||||
let receipt_id = format!("repo-model-admission-{}", review.review_id);
|
||||
if patch.purpose == crate::RepoModelPatchPurpose::RepairClaim {
|
||||
match (
|
||||
cache.get::<RepoModelAdmissionReview>(&review.review_id)?,
|
||||
cache.get::<RepoModelAdmissionReceipt>(&receipt_id)?,
|
||||
) {
|
||||
(Some(existing_review), Some(existing_receipt)) if existing_review == *review => {
|
||||
let repair_request_id = result
|
||||
.claim_repair_request_id
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow!("RepairClaim retry is missing its request echo"))?;
|
||||
let repair_request = cache
|
||||
.get::<RepoModelClaimRepairRequest>(repair_request_id)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim retry request disappeared"))?;
|
||||
let current_entry = cache
|
||||
.get::<crate::EpiphanyMemoryGraphEntry>(crate::MEMORY_GRAPH_KEY)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim retry requires canonical RepoModel"))?;
|
||||
let current_model = current_entry.snapshot()?;
|
||||
let current_hash = crate::memory_graph_model_hash(¤t_model)?;
|
||||
if existing_receipt.receipt_id != receipt_id
|
||||
|| existing_receipt.review_id != review.review_id
|
||||
|| existing_receipt.result_id != result_id
|
||||
|| existing_receipt.patch_id != patch.patch_id
|
||||
|| existing_receipt.patch_sha256 != patch_sha256
|
||||
|| existing_receipt.contract != REPO_MODEL_ADMISSION_CONTRACT
|
||||
|| existing_receipt.schema_version
|
||||
!= REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION
|
||||
|| existing_receipt.purpose != patch.purpose
|
||||
|| existing_receipt.claim_repair_request_id != repair_request_id
|
||||
|| existing_receipt.previous_revision != repair_request.model_revision
|
||||
|| existing_receipt.previous_hash != repair_request.model_hash
|
||||
|| existing_receipt.admitted_revision != current_model.model_revision
|
||||
|| existing_receipt.admitted_revision
|
||||
!= existing_receipt.previous_revision.saturating_add(1)
|
||||
|| existing_receipt.admitted_hash != current_hash
|
||||
|| existing_receipt.admitted_at != review.reviewed_at
|
||||
|| !existing_receipt.frontier_route_id.is_empty()
|
||||
|| !existing_receipt.verification_request_id.is_empty()
|
||||
|| !existing_receipt.soul_verdict_receipt_id.is_empty()
|
||||
|| !existing_receipt.frontier_modeling_request_id.is_empty()
|
||||
|| !existing_receipt.proposal_modeling_request_id.is_empty()
|
||||
{
|
||||
return Err(anyhow!("repo model admission receipt identity collision"));
|
||||
}
|
||||
return Ok(existing_receipt);
|
||||
}
|
||||
(None, None) => {}
|
||||
_ => return Err(anyhow!("repo model admission companion identity collision")),
|
||||
}
|
||||
}
|
||||
|
||||
let (
|
||||
frontier_route_id,
|
||||
verification_request_id,
|
||||
soul_verdict_receipt_id,
|
||||
frontier_modeling_request_id,
|
||||
proposal_modeling_request_id,
|
||||
claim_repair_request_id,
|
||||
) = match &patch.purpose {
|
||||
crate::RepoModelPatchPurpose::RepairClaim => {
|
||||
if result.repo_frontier_modeling_request_id.is_some()
|
||||
|| result.proposal_modeling_request_id.is_some()
|
||||
|| result.verification_request_id.is_some()
|
||||
|| result.frontier_route_id.is_some()
|
||||
|| result.state_patch_msgpack.is_some()
|
||||
|| result.self_patch_msgpack.is_some()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"claim repair result may carry only its repair request echo"
|
||||
));
|
||||
}
|
||||
let request_id = result
|
||||
.claim_repair_request_id
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires its exact repair request echo"))?;
|
||||
let request = cache
|
||||
.get::<RepoModelClaimRepairRequest>(request_id)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires its persisted repair request"))?;
|
||||
validate_current_repo_model_claim_repair_request(&cache, &request)?;
|
||||
let challenge = cache
|
||||
.get::<RepoModelClaimChallenge>(&request.challenge_id)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires its exact challenge"))?;
|
||||
let bindings = cache
|
||||
.get_all::<RepoModelClaimRepairLaunchBinding>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.repair_request_id == request.request_id)
|
||||
.collect::<Vec<_>>();
|
||||
if bindings.len() != 1 {
|
||||
return Err(anyhow!(
|
||||
"RepairClaim requires exactly one coordinator launch binding"
|
||||
));
|
||||
}
|
||||
let binding = &bindings[0];
|
||||
let worker_launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(&result.job_id)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires its runtime worker launch"))?;
|
||||
let launch_document = worker_launch.launch_document()?;
|
||||
let launch_projection = match &launch_document {
|
||||
EpiphanyWorkerLaunchDocument::Role(document) => {
|
||||
document.claim_repair_context.as_ref()
|
||||
}
|
||||
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
|
||||
};
|
||||
let identity = require_identity(&cache)?;
|
||||
let thread = cache
|
||||
.get::<crate::EpiphanyThreadStateEntry>(crate::THREAD_STATE_KEY)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires authoritative thread state"))?;
|
||||
let expected_projection =
|
||||
crate::RepoModelClaimRepairContextProjection::from_request(&request);
|
||||
let launch_hash = format!(
|
||||
"{:x}",
|
||||
Sha256::digest(&worker_launch.launch_document_msgpack)
|
||||
);
|
||||
chrono::DateTime::parse_from_rfc3339(&binding.launched_at)
|
||||
.map_err(|_| anyhow!("RepairClaim launch binding timestamp must be RFC3339"))?;
|
||||
if binding.schema_version
|
||||
!= crate::REPO_MODEL_CLAIM_REPAIR_LAUNCH_BINDING_SCHEMA_VERSION
|
||||
|| binding.contract != crate::REPO_MODEL_CLAIM_REPAIR_LAUNCH_BINDING_CONTRACT
|
||||
|| binding.repair_request_id != request.request_id
|
||||
|| binding.challenge_id != request.challenge_id
|
||||
|| binding.challenge_sha256 != request.challenge_sha256
|
||||
|| binding.job_id != result.job_id
|
||||
|| binding.binding_id != crate::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
|| binding.runtime_id != request.runtime_id
|
||||
|| binding.thread_id != request.thread_id
|
||||
|| binding.worker_launch_document_sha256 != launch_hash
|
||||
|| worker_launch.job_id != result.job_id
|
||||
|| worker_launch.role != crate::EPIPHANY_MODELING_OWNER_ROLE
|
||||
|| worker_launch.binding_id != crate::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
|| worker_launch.claim_repair_request_id.as_deref()
|
||||
!= Some(request.request_id.as_str())
|
||||
|| worker_launch.proposal_modeling_request_id.is_some()
|
||||
|| launch_projection != Some(&expected_projection)
|
||||
|| identity.runtime_id != request.runtime_id
|
||||
|| thread.thread_id != request.thread_id
|
||||
|| patch.base_revision != request.model_revision
|
||||
|| patch.base_hash != request.model_hash
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"RepairClaim does not exactly bind request, launch, runtime, thread, and model"
|
||||
));
|
||||
}
|
||||
if patch.operations.len() != 1 {
|
||||
return Err(anyhow!("RepairClaim permits exactly one node revision"));
|
||||
}
|
||||
let crate::RepoModelPatchOperation::ReviseNode { node } = &patch.operations[0] else {
|
||||
return Err(anyhow!("RepairClaim permits only ReviseNode"));
|
||||
};
|
||||
if node.id != request.target_claim_id {
|
||||
return Err(anyhow!("RepairClaim revision targets the wrong claim"));
|
||||
}
|
||||
let current_entry = cache
|
||||
.get::<crate::EpiphanyMemoryGraphEntry>(crate::MEMORY_GRAPH_KEY)?
|
||||
.ok_or_else(|| anyhow!("RepairClaim requires canonical RepoModel"))?;
|
||||
let current_model = current_entry.snapshot()?;
|
||||
let current_node = current_model
|
||||
.nodes
|
||||
.iter()
|
||||
.find(|candidate| candidate.id == request.target_claim_id)
|
||||
.ok_or_else(|| anyhow!("RepairClaim target claim disappeared"))?;
|
||||
let current_node_hash = format!(
|
||||
"{:x}",
|
||||
Sha256::digest(rmp_serde::to_vec_named(current_node)?)
|
||||
);
|
||||
let revised_node_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(node)?));
|
||||
if current_node_hash != request.target_claim_sha256
|
||||
|| revised_node_hash == request.target_claim_sha256
|
||||
|| node.claim == current_node.claim
|
||||
|| node.id != current_node.id
|
||||
|| node.domain_id != current_node.domain_id
|
||||
|| node.profile != current_node.profile
|
||||
|| node.kind != current_node.kind
|
||||
|| node.created_at != current_node.created_at
|
||||
|| node.lifecycle != current_node.lifecycle
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"RepairClaim must change the exact challenged claim while preserving identity anatomy"
|
||||
));
|
||||
}
|
||||
let mut expected_evidence = challenge.evidence_ids.clone();
|
||||
expected_evidence.push(challenge.challenge_id.clone());
|
||||
expected_evidence.push(request.eyes_evidence_packet_id.clone());
|
||||
expected_evidence.sort();
|
||||
expected_evidence.dedup();
|
||||
if result_evidence != expected_evidence {
|
||||
return Err(anyhow!(
|
||||
"RepairClaim evidence must exactly cite its challenge and Eyes evidence chain"
|
||||
));
|
||||
}
|
||||
if cache
|
||||
.get_all::<RepoModelAdmissionReceipt>()?
|
||||
.iter()
|
||||
.any(|receipt| {
|
||||
receipt.claim_repair_request_id == request.request_id
|
||||
&& (receipt.review_id != review.review_id
|
||||
|| receipt.result_id != result.result_id)
|
||||
})
|
||||
{
|
||||
return Err(anyhow!("claim repair request is already incorporated"));
|
||||
}
|
||||
(
|
||||
String::new(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
request.request_id,
|
||||
)
|
||||
}
|
||||
crate::RepoModelPatchPurpose::Evolution => {
|
||||
if result.repo_frontier_modeling_request_id.is_some()
|
||||
|| result.verification_request_id.is_some()
|
||||
|
|
@ -1934,6 +2160,7 @@ pub fn commit_repo_model_admission(
|
|||
String::new(),
|
||||
String::new(),
|
||||
request_id,
|
||||
String::new(),
|
||||
)
|
||||
}
|
||||
crate::RepoModelPatchPurpose::IncorporateFrontierVerdict {
|
||||
|
|
@ -2107,11 +2334,11 @@ pub fn commit_repo_model_admission(
|
|||
verdict.receipt_id,
|
||||
modeling_request.request_id,
|
||||
String::new(),
|
||||
String::new(),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let receipt_id = format!("repo-model-admission-{}", review.review_id);
|
||||
let existing_review = cache.get::<RepoModelAdmissionReview>(&review.review_id)?;
|
||||
let existing_receipt = cache.get::<RepoModelAdmissionReceipt>(&receipt_id)?;
|
||||
match (existing_review, existing_receipt) {
|
||||
|
|
@ -2128,6 +2355,7 @@ pub fn commit_repo_model_admission(
|
|||
|| existing_receipt.soul_verdict_receipt_id != soul_verdict_receipt_id
|
||||
|| existing_receipt.frontier_modeling_request_id != frontier_modeling_request_id
|
||||
|| existing_receipt.proposal_modeling_request_id != proposal_modeling_request_id
|
||||
|| existing_receipt.claim_repair_request_id != claim_repair_request_id
|
||||
{
|
||||
return Err(anyhow!("repo model admission receipt identity collision"));
|
||||
}
|
||||
|
|
@ -2246,6 +2474,7 @@ pub fn commit_repo_model_admission(
|
|||
soul_verdict_receipt_id,
|
||||
frontier_modeling_request_id,
|
||||
proposal_modeling_request_id,
|
||||
claim_repair_request_id,
|
||||
};
|
||||
let (next_model_envelope, _) = cache.prepare_entry(crate::MEMORY_GRAPH_KEY, &next_entry)?;
|
||||
let (review_envelope, _) = cache.prepare_entry(&review.review_id, review)?;
|
||||
|
|
@ -6617,6 +6846,7 @@ pub(crate) mod tests {
|
|||
frontier_route_id: None,
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: Some(selection.request_id),
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
let review = RepoModelAdmissionReview {
|
||||
schema_version: REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION.to_string(),
|
||||
|
|
@ -6666,6 +6896,285 @@ pub(crate) mod tests {
|
|||
Ok((store, result, review))
|
||||
}
|
||||
|
||||
fn claim_repair_admission_fixture(
|
||||
root: &Path,
|
||||
suffix: &str,
|
||||
) -> Result<(
|
||||
PathBuf,
|
||||
EpiphanyRuntimeRoleWorkerResult,
|
||||
RepoModelAdmissionReview,
|
||||
RepoModelClaimRepairRequest,
|
||||
)> {
|
||||
let (store, state, launch, repair) =
|
||||
crate::coordinator_launch::tests::claim_repair_launch_fixture(root, suffix)?;
|
||||
let job_id = format!("claim-repair-job-{suffix}");
|
||||
let plan = crate::plan_coordinator_job_launch(
|
||||
&state,
|
||||
&launch,
|
||||
&store,
|
||||
format!("claim-repair-launcher-{suffix}"),
|
||||
job_id.clone(),
|
||||
)?;
|
||||
crate::commit_coordinator_job_launch(
|
||||
&store,
|
||||
&repair.thread_id,
|
||||
&state,
|
||||
&launch,
|
||||
&plan,
|
||||
"2026-07-14T09:00:03Z".into(),
|
||||
)?;
|
||||
let current = runtime_current_repo_model(&store)?.expect("claim repair model");
|
||||
let mut node = current
|
||||
.nodes
|
||||
.iter()
|
||||
.find(|node| node.id == repair.target_claim_id)
|
||||
.cloned()
|
||||
.expect("challenged node");
|
||||
node.claim = format!("{} Corrected by exact Eyes evidence.", node.claim);
|
||||
node.updated_at = Some("2026-07-14T09:00:04Z".into());
|
||||
let patch = crate::RepoModelPatch {
|
||||
patch_id: format!("claim-repair-patch-{suffix}"),
|
||||
base_revision: current.model_revision,
|
||||
base_hash: crate::memory_graph_model_hash(¤t)?,
|
||||
applied_at: "2026-07-14T09:00:04Z".into(),
|
||||
purpose: crate::RepoModelPatchPurpose::RepairClaim,
|
||||
operations: vec![crate::RepoModelPatchOperation::ReviseNode { node }],
|
||||
};
|
||||
let patch_bytes = rmp_serde::to_vec_named(&patch)?;
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let challenge = cache.get_required::<RepoModelClaimChallenge>(&repair.challenge_id)?;
|
||||
let mut evidence_ids = challenge.evidence_ids.clone();
|
||||
evidence_ids.push(challenge.challenge_id);
|
||||
evidence_ids.push(repair.eyes_evidence_packet_id.clone());
|
||||
evidence_ids.sort();
|
||||
evidence_ids.dedup();
|
||||
let result = EpiphanyRuntimeRoleWorkerResult {
|
||||
schema_version: RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION.into(),
|
||||
result_id: format!("claim-repair-result-{suffix}"),
|
||||
job_id,
|
||||
role_id: "modeling".into(),
|
||||
verdict: "checkpoint-ready".into(),
|
||||
summary: "Proposed the exact challenged claim correction.".into(),
|
||||
next_safe_move: "Mind admission".into(),
|
||||
checkpoint_summary: None,
|
||||
scratch_summary: None,
|
||||
files_inspected: Vec::new(),
|
||||
frontier_node_ids: vec![repair.target_claim_id.clone()],
|
||||
evidence_ids: evidence_ids.clone(),
|
||||
artifact_refs: Vec::new(),
|
||||
open_questions: Vec::new(),
|
||||
evidence_gaps: Vec::new(),
|
||||
risks: Vec::new(),
|
||||
state_patch_msgpack: None,
|
||||
self_patch_msgpack: None,
|
||||
item_error: None,
|
||||
metadata: BTreeMap::new(),
|
||||
repo_model_patch_msgpack: Some(patch_bytes.clone()),
|
||||
verification_request_id: None,
|
||||
frontier_route_id: None,
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: None,
|
||||
claim_repair_request_id: Some(repair.request_id.clone()),
|
||||
};
|
||||
let review = RepoModelAdmissionReview {
|
||||
schema_version: REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION.into(),
|
||||
review_id: format!("claim-repair-review-{suffix}"),
|
||||
result_id: result.result_id.clone(),
|
||||
job_id: result.job_id.clone(),
|
||||
patch_id: patch.patch_id,
|
||||
patch_sha256: format!("{:x}", Sha256::digest(&patch_bytes)),
|
||||
base_revision: patch.base_revision,
|
||||
base_hash: patch.base_hash,
|
||||
decision: MindGatewayDecision::Accept,
|
||||
evidence_ids,
|
||||
reviewed_at: "2026-07-14T09:00:05Z".into(),
|
||||
contract: REPO_MODEL_ADMISSION_CONTRACT.into(),
|
||||
};
|
||||
Ok((store, result, review, repair))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn claim_repair_admission_replays_launch_and_changes_only_the_challenged_node() -> Result<()> {
|
||||
let root = tempfile::tempdir()?;
|
||||
let (store, result, review, repair) = claim_repair_admission_fixture(root.path(), "admit")?;
|
||||
put_runtime_role_worker_result(&store, &result)?;
|
||||
let receipt = commit_repo_model_admission(&store, &result.result_id, &review)?;
|
||||
assert_eq!(receipt.claim_repair_request_id, repair.request_id);
|
||||
assert_eq!(receipt.purpose, crate::RepoModelPatchPurpose::RepairClaim);
|
||||
assert_eq!(
|
||||
commit_repo_model_admission(&store, &result.result_id, &review)?,
|
||||
receipt
|
||||
);
|
||||
let current = runtime_current_repo_model(&store)?.expect("repaired model");
|
||||
let repaired = current
|
||||
.nodes
|
||||
.iter()
|
||||
.find(|node| node.id == repair.target_claim_id)
|
||||
.expect("repaired claim remains present");
|
||||
assert_ne!(
|
||||
format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(repaired)?)),
|
||||
repair.target_claim_sha256
|
||||
);
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let current_hash = crate::memory_graph_model_hash(¤t)?;
|
||||
assert!(current_repo_model_claim_challenges(&cache, ¤t, ¤t_hash)?.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn claim_repair_admission_refuses_substitution_without_model_writes() -> Result<()> {
|
||||
for mutation in [
|
||||
"swapped-request",
|
||||
"missing-evidence",
|
||||
"extra-operation",
|
||||
"wrong-target",
|
||||
"unchanged-claim",
|
||||
"timestamp-only",
|
||||
"identity-mutation",
|
||||
"lifecycle-mutation",
|
||||
"state-patch-smuggling",
|
||||
"self-patch-smuggling",
|
||||
"launch-hash",
|
||||
"counterfeit-retry-receipt",
|
||||
] {
|
||||
let root = tempfile::tempdir()?;
|
||||
let (store, mut result, mut review, repair) =
|
||||
claim_repair_admission_fixture(root.path(), mutation)?;
|
||||
match mutation {
|
||||
"swapped-request" => {
|
||||
result.claim_repair_request_id = Some("adjacent-repair-request".into())
|
||||
}
|
||||
"missing-evidence" => {
|
||||
result.evidence_ids.pop();
|
||||
review.evidence_ids = result.evidence_ids.clone();
|
||||
}
|
||||
"launch-hash" => {
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let key = format!("repo-model-claim-repair-launch-{}", repair.request_id);
|
||||
let mut binding =
|
||||
cache.get_required::<RepoModelClaimRepairLaunchBinding>(&key)?;
|
||||
binding.worker_launch_document_sha256 = "00".repeat(32);
|
||||
overwrite_test_entry(&store, &key, &binding)?;
|
||||
}
|
||||
"state-patch-smuggling" => {
|
||||
result.state_patch_msgpack = Some(vec![0x80]);
|
||||
}
|
||||
"self-patch-smuggling" => {
|
||||
result.self_patch_msgpack = Some(vec![0x80]);
|
||||
}
|
||||
"counterfeit-retry-receipt" => {
|
||||
overwrite_test_entry(&store, &review.review_id, &review)?;
|
||||
let receipt_id = format!("repo-model-admission-{}", review.review_id);
|
||||
overwrite_test_entry(
|
||||
&store,
|
||||
&receipt_id,
|
||||
&RepoModelAdmissionReceipt {
|
||||
schema_version: REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION.into(),
|
||||
receipt_id: receipt_id.clone(),
|
||||
review_id: review.review_id.clone(),
|
||||
result_id: result.result_id.clone(),
|
||||
patch_id: review.patch_id.clone(),
|
||||
patch_sha256: review.patch_sha256.clone(),
|
||||
previous_revision: repair.model_revision,
|
||||
previous_hash: repair.model_hash.clone(),
|
||||
admitted_revision: repair.model_revision + 1,
|
||||
admitted_hash: "counterfeit-admitted-hash".into(),
|
||||
admitted_at: review.reviewed_at.clone(),
|
||||
contract: REPO_MODEL_ADMISSION_CONTRACT.into(),
|
||||
purpose: crate::RepoModelPatchPurpose::RepairClaim,
|
||||
frontier_route_id: String::new(),
|
||||
verification_request_id: String::new(),
|
||||
soul_verdict_receipt_id: String::new(),
|
||||
frontier_modeling_request_id: String::new(),
|
||||
proposal_modeling_request_id: String::new(),
|
||||
claim_repair_request_id: repair.request_id.clone(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
_ => {
|
||||
let mut patch: crate::RepoModelPatch =
|
||||
rmp_serde::from_slice(result.repo_model_patch_msgpack.as_deref().unwrap())?;
|
||||
let current = runtime_current_repo_model(&store)?.expect("current model");
|
||||
let current_node = current
|
||||
.nodes
|
||||
.iter()
|
||||
.find(|node| node.id == repair.target_claim_id)
|
||||
.cloned()
|
||||
.expect("challenged node");
|
||||
match mutation {
|
||||
"extra-operation" => patch.operations.push(patch.operations[0].clone()),
|
||||
"wrong-target" => {
|
||||
let crate::RepoModelPatchOperation::ReviseNode { node } =
|
||||
&mut patch.operations[0]
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
node.id = "wrong-target-claim".into();
|
||||
}
|
||||
"unchanged-claim" => {
|
||||
patch.operations[0] =
|
||||
crate::RepoModelPatchOperation::ReviseNode { node: current_node };
|
||||
}
|
||||
"timestamp-only" => {
|
||||
let mut timestamp_only = current_node;
|
||||
timestamp_only.updated_at = Some("2026-07-14T09:00:04Z".into());
|
||||
patch.operations[0] = crate::RepoModelPatchOperation::ReviseNode {
|
||||
node: timestamp_only,
|
||||
};
|
||||
}
|
||||
"identity-mutation" => {
|
||||
let crate::RepoModelPatchOperation::ReviseNode { node } =
|
||||
&mut patch.operations[0]
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
node.domain_id = "other-domain".into();
|
||||
}
|
||||
"lifecycle-mutation" => {
|
||||
let crate::RepoModelPatchOperation::ReviseNode { node } =
|
||||
&mut patch.operations[0]
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
node.lifecycle = crate::EpiphanyMemoryLifecycle::Retired;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
let bytes = rmp_serde::to_vec_named(&patch)?;
|
||||
result.repo_model_patch_msgpack = Some(bytes.clone());
|
||||
review.patch_id = patch.patch_id;
|
||||
review.patch_sha256 = format!("{:x}", Sha256::digest(&bytes));
|
||||
review.base_revision = patch.base_revision;
|
||||
review.base_hash = patch.base_hash;
|
||||
}
|
||||
}
|
||||
if matches!(mutation, "state-patch-smuggling" | "self-patch-smuggling") {
|
||||
let before = std::fs::read(&store)?;
|
||||
assert!(
|
||||
put_runtime_role_worker_result(&store, &result).is_err(),
|
||||
"mutation {mutation} must be refused at immutable result ingestion"
|
||||
);
|
||||
assert_eq!(std::fs::read(&store)?, before);
|
||||
continue;
|
||||
}
|
||||
put_runtime_role_worker_result(&store, &result)?;
|
||||
let before = std::fs::read(&store)?;
|
||||
assert!(
|
||||
commit_repo_model_admission(&store, &result.result_id, &review).is_err(),
|
||||
"mutation {mutation} must be refused"
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read(&store)?,
|
||||
before,
|
||||
"mutation {mutation} wrote partial admission state"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn assert_proposal_admission_refused_without_state_mutation(
|
||||
store: &Path,
|
||||
result: &EpiphanyRuntimeRoleWorkerResult,
|
||||
|
|
@ -7038,6 +7547,7 @@ pub(crate) mod tests {
|
|||
soul_verdict_receipt_id: String::new(),
|
||||
frontier_modeling_request_id: String::new(),
|
||||
proposal_modeling_request_id: "wrong-proposal-request".into(),
|
||||
claim_repair_request_id: String::new(),
|
||||
};
|
||||
overwrite_test_entry(&store, &review.review_id, &review)?;
|
||||
overwrite_test_entry(&store, &receipt_id, &receipt)?;
|
||||
|
|
@ -7731,6 +8241,7 @@ pub(crate) mod tests {
|
|||
frontier_route_id: Some(route.route_id.clone()),
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: None,
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
put_runtime_role_worker_result(&store, &verification_result)?;
|
||||
let verdict = SoulVerdictReceipt {
|
||||
|
|
@ -7849,6 +8360,7 @@ pub(crate) mod tests {
|
|||
frontier_route_id: None,
|
||||
repo_frontier_modeling_request_id: Some(fixture.modeling_request.request_id.clone()),
|
||||
proposal_modeling_request_id: None,
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
let review = RepoModelAdmissionReview {
|
||||
schema_version: REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION.to_string(),
|
||||
|
|
@ -8124,6 +8636,7 @@ pub(crate) mod tests {
|
|||
frontier_route_id: Some(fixture.route.route_id.clone()),
|
||||
repo_frontier_modeling_request_id: None,
|
||||
proposal_modeling_request_id: None,
|
||||
claim_repair_request_id: None,
|
||||
};
|
||||
put_runtime_role_worker_result(&fixture.store, &adjacent)?;
|
||||
put_soul_verdict_receipt(
|
||||
|
|
@ -8180,6 +8693,7 @@ pub(crate) mod tests {
|
|||
..
|
||||
} => vec![soul_verdict_receipt_id.clone()],
|
||||
crate::RepoModelPatchPurpose::Evolution => vec!["evolution".to_string()],
|
||||
crate::RepoModelPatchPurpose::RepairClaim => vec!["repair".to_string()],
|
||||
};
|
||||
review.patch_id = patch.patch_id.clone();
|
||||
review.patch_sha256 = format!("{:x}", Sha256::digest(&bytes));
|
||||
|
|
@ -9440,11 +9954,11 @@ pub(crate) mod tests {
|
|||
churn: None,
|
||||
},
|
||||
),
|
||||
output_contract_id: "epiphany.worker.role_result.v0".to_string(),
|
||||
output_contract_id: crate::ROLE_WORKER_OUTPUT_CONTRACT_ID.to_string(),
|
||||
organ_launch_contract: crate::default_launch_organ_contract(
|
||||
"epiphany.role.modeling",
|
||||
"role",
|
||||
"epiphany.worker.role_result.v0",
|
||||
crate::ROLE_WORKER_OUTPUT_CONTRACT_ID,
|
||||
),
|
||||
max_runtime_seconds: Some(60),
|
||||
runtime_job_id: "turn-1".to_string(),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use crate::EpiphanyReorientFreshnessStatus;
|
|||
use crate::EpiphanyReorientPressureLevel;
|
||||
use crate::EpiphanyReorientReason;
|
||||
|
||||
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v0";
|
||||
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v1";
|
||||
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
|
||||
pub const REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION: &str =
|
||||
"epiphany.worker.repo_frontier_proposal_modeling_context.v0";
|
||||
|
|
@ -230,6 +230,32 @@ pub struct RepoModelClaimRepairContextProjection {
|
|||
pub requested_at: String,
|
||||
}
|
||||
|
||||
impl RepoModelClaimRepairContextProjection {
|
||||
pub(crate) fn from_request(request: &crate::RepoModelClaimRepairRequest) -> Self {
|
||||
Self {
|
||||
schema_version: REPO_MODEL_CLAIM_REPAIR_CONTEXT_SCHEMA_VERSION.into(),
|
||||
contract: REPO_MODEL_CLAIM_REPAIR_CONTEXT_CONTRACT.into(),
|
||||
request_id: request.request_id.clone(),
|
||||
challenge_id: request.challenge_id.clone(),
|
||||
challenge_sha256: request.challenge_sha256.clone(),
|
||||
eyes_evidence_packet_id: request.eyes_evidence_packet_id.clone(),
|
||||
eyes_evidence_packet_sha256: request.eyes_evidence_packet_sha256.clone(),
|
||||
source_result_id: request.source_result_id.clone(),
|
||||
source_job_id: request.source_job_id.clone(),
|
||||
original_admission_receipt_id: request.original_admission_receipt_id.clone(),
|
||||
current_admission_receipt_id: request.current_admission_receipt_id.clone(),
|
||||
model_revision: request.model_revision,
|
||||
model_hash: request.model_hash.clone(),
|
||||
target_claim_id: request.target_claim_id.clone(),
|
||||
target_claim_sha256: request.target_claim_sha256.clone(),
|
||||
runtime_id: request.runtime_id.clone(),
|
||||
thread_id: request.thread_id.clone(),
|
||||
affected_frontier: request.affected_frontier.clone(),
|
||||
requested_at: request.requested_at.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_reorient_job_launch_request(
|
||||
input: EpiphanyReorientLaunchRequestInput<'_>,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
|
|
|
|||
|
|
@ -835,6 +835,7 @@ pub enum RepoModelPatchPurpose {
|
|||
route_id: String,
|
||||
soul_verdict_receipt_id: String,
|
||||
},
|
||||
RepairClaim,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,34 @@
|
|||
# Fresh Workspace Handoff
|
||||
|
||||
## Eyes-to-Modeling claim correction nerve complete - 2026-07-15
|
||||
|
||||
The Aetheria-shaped corrective nerve is now closed from immutable Eyes
|
||||
contradiction through Modeling proposal to Mind admission. A claim repair launch
|
||||
may produce one immutable role-worker result carrying the exclusive
|
||||
`claimRepairRequestId` echo and `RepairClaim` purpose. Result schema and worker
|
||||
output contract are versioned v1; admission receipts and their contract are v3.
|
||||
Malformed RepairClaim results carrying proposal/frontier echoes, Verification
|
||||
authority, state patches, or self patches are rejected before persistence.
|
||||
|
||||
Mind replays the current repair request, challenge, Eyes packet and admissions,
|
||||
the unique coordinator launch binding, exact worker launch document hash and
|
||||
typed projection, runtime/thread identity, model base, target node hash, and
|
||||
exact evidence set. It permits exactly one `ReviseNode`; the challenged `claim`
|
||||
text must change while id, domain, profile, kind, creation time, and lifecycle
|
||||
remain invariant. Review, next model, and receipt still share the model CAS.
|
||||
Challenge resolution is derived from the target node hash changing; there is no
|
||||
repair flag or cleanup writer. Exact retry validates the persisted receipt and
|
||||
current admitted model. Hostiles cover swapped request, adjacent/missing
|
||||
evidence, extra operation, wrong target, unchanged/timestamp-only claim,
|
||||
identity/lifecycle mutation, state/self authority smuggling, forged launch hash,
|
||||
and counterfeit retry receipt with byte-identical refusal. Soul passed the
|
||||
final boundary; the core library is green at 318 passed, one ignored.
|
||||
|
||||
Next: bind Self's existing frontier planning request to a real Imagination result
|
||||
and Mind Adopt/Refuse/Hold admission, then build the production semantic index
|
||||
over typed graph claims so Modeling's persistent map becomes searchable body
|
||||
knowledge rather than a scan-heavy archive.
|
||||
|
||||
## Runtime worker results are actually immutable - 2026-07-14
|
||||
|
||||
Eyes found that the document called an immutable role-worker result was still
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -714,4 +714,4 @@ current_status:
|
|||
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
|
||||
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
|
||||
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
|
||||
next_action: Complete the Aetheria-shaped corrective nerve from the landed RepoModelClaimRepairRequest and coordinator-owned Modeling launch binding. The request survives unrelated model revisions and exactly binds challenge, Eyes packet, original/current admissions, model, claim, affected frontier, runtime, thread, effective worker document, and one atomic single-use launch without any model-write authority. CoordinatorStateTransaction owns one exact opening cache image and one state-plus-companions CAS; runtime role-worker results are now genuinely absent-only with exact retry, so Mind can bind one persisted worker thought instead of a rewriteable job slot. Next add the exclusive claim-repair result echo, dedicated narrow RepairClaim patch purpose, and Mind full-chain admission that requires exactly one ReviseNode and the exact challenged claim bytes to change. No ambient Modeling result, ordinary Evolution, prompt prose, evidence intersection, UI state, unrelated model revision, losing concurrent launch, or rewritten worker result may clear pressure. After that, bind the existing Self planning request to a real Imagination worker result and Mind Adopt/Refuse/Hold path. Add the production semantic index over typed graph claims. Do not revive Proprioception, epiphany-work, metadata adapters, challenge ids inside RepoModel, or generic Modeling work-order routers. Keep closure's zero-substring invariant.
|
||||
next_action: The Aetheria-shaped Eyes-to-Modeling corrective nerve is complete. Immutable challenge pressure selects one exact repair request and coordinator launch; a v1 immutable Modeling result may carry only the exclusive claim repair echo and RepairClaim purpose; Mind replays the full Eyes/request/launch/model chain and admits exactly one claim-text-changing, lifecycle-preserving ReviseNode through the model CAS. Challenge release is derived from changed target bytes, never a cleanup writer. Next bind the existing Self frontier planning request to a real immutable Imagination worker result and Mind Adopt/Refuse/Hold path, preserving the same exact request-launch-result-admission discipline. Then add the production semantic index over typed graph claims so Modeling maintains a live searchable body map instead of forcing Hands to rediscover anatomy. Do not revive Proprioception, epiphany-work, metadata adapters, challenge ids inside RepoModel, generic work-order routers, or inference from prompt prose/evidence coincidence. Keep closure's zero-substring invariant.
|
||||
|
|
|
|||
Reference in a new issue