Add typed frontier execution amendment

This commit is contained in:
Meta Vens 2026-08-08 12:27:44 +01:00
commit 12c8241bb3
13 changed files with 594 additions and 29 deletions

View file

@ -0,0 +1,69 @@
use anyhow::{Result, anyhow};
use epiphany_core::{RepoFrontierExecutionAmendment, amend_repo_frontier_execution};
use sha2::{Digest, Sha256};
use std::{collections::BTreeMap, env, path::PathBuf};
fn main() -> Result<()> {
let mut values = BTreeMap::new();
let mut args = env::args().skip(1);
let command = args.next().ok_or_else(|| anyhow!(usage()))?;
if command != "amend-frontier-execution" {
return Err(anyhow!("unknown command {command}\n{}", usage()));
}
while let Some(flag) = args.next() {
let value = args
.next()
.ok_or_else(|| anyhow!("missing value for {flag}"))?;
if values.insert(flag.clone(), value).is_some() {
return Err(anyhow!("duplicate option {flag}"));
}
}
let take = |name: &str| {
values
.get(name)
.cloned()
.ok_or_else(|| anyhow!("missing {name}"))
};
let store = PathBuf::from(take("--store")?);
let route_id = take("--route-id")?;
let source_actor_id = take("--source-actor-id")?;
let command_id = take("--command-id")?;
let admission_id = take("--admission-id")?;
let packet_sha256 = take("--packet-sha256")?;
let previous_action = take("--previous-action")?;
let previous_command = take("--previous-command")?;
let action = take("--action")?;
let replacement_command = take("--replacement-command")?;
let rationale = take("--rationale")?;
let amended_at = take("--amended-at")?;
let semantic = format!(
"{route_id}\0{source_actor_id}\0{command_id}\0{admission_id}\0{packet_sha256}\0{action}\0{replacement_command}\0{rationale}\0{amended_at}"
);
let amendment_id = format!(
"repo-frontier-execution-amendment-{:x}",
Sha256::digest(semantic.as_bytes())
);
let receipt = amend_repo_frontier_execution(
store,
RepoFrontierExecutionAmendment {
amendment_id,
replaces_route_id: route_id,
source_actor_id,
command_id,
admission_id,
packet_sha256,
previous_action_sha256: format!("{:x}", Sha256::digest(previous_action.as_bytes())),
previous_command_sha256: format!("{:x}", Sha256::digest(previous_command.as_bytes())),
action,
command: replacement_command,
rationale,
amended_at,
},
)?;
println!("{}", serde_json::to_string_pretty(&receipt)?);
Ok(())
}
fn usage() -> &'static str {
"usage: epiphany-mind-repair amend-frontier-execution --store PATH --route-id ID --source-actor-id ID --command-id ID --admission-id ID --packet-sha256 SHA256 --previous-action TEXT --previous-command TEXT --action TEXT --replacement-command TEXT --rationale TEXT --amended-at RFC3339"
}

View file

@ -1286,7 +1286,7 @@ fn record_hands_implementation_gate(
plan_action: route
.adopted_plan
.as_ref()
.map(|plan| plan.action.clone())
.map(|plan| plan.effective_action().to_string())
.unwrap_or_default(),
};
put_hands_action_intent(runtime_store, &intent)?;
@ -1343,12 +1343,25 @@ fn record_hands_implementation_gate(
"frontierItemId": route.frontier_item_id,
"requestedPaths": requested_paths,
"requiredReceipts": review.required_receipts,
"recordPassCommand": hands_record_pass_command(runtime_store, artifact_dir),
"plannedAction": route.adopted_plan.as_ref().map(|plan| plan.effective_action()),
"plannedCommand": route.adopted_plan.as_ref().map(|plan| plan.effective_command()),
"originalPlannedAction": route.adopted_plan.as_ref().map(|plan| plan.action.as_str()),
"originalPlannedCommand": route.adopted_plan.as_ref().map(|plan| plan.command.as_str()),
"executionAmendmentId": route.adopted_plan.as_ref().and_then(|plan| plan.execution_amendment.as_ref()).map(|amendment| amendment.amendment_id.as_str()),
"plannedChecks": route.adopted_plan.as_ref().map(|plan| plan.checks.as_slice()),
"plannedStopConditions": route.adopted_plan.as_ref().map(|plan| plan.stop_conditions.as_slice()),
"plannedRollbackSteps": route.adopted_plan.as_ref().map(|plan| plan.rollback_steps.as_slice()),
"plannedCommitMessage": route.adopted_plan.as_ref().map(|plan| plan.commit_message.as_str()),
"recordPassCommand": hands_record_pass_command(runtime_store, artifact_dir, route.adopted_plan.as_ref()),
"store": runtime_store,
}))
}
fn hands_record_pass_command(runtime_store: &Path, artifact_dir: &Path) -> Value {
fn hands_record_pass_command(
runtime_store: &Path,
artifact_dir: &Path,
adopted_plan: Option<&epiphany_core::RepoFrontierAdoptedPlan>,
) -> Value {
json!({
"executable": "epiphany-hands-action",
"args": [
@ -1362,7 +1375,9 @@ fn hands_record_pass_command(runtime_store: &Path, artifact_dir: &Path) -> Value
"--changed-path",
"<changed path>",
"--command",
"<verification command>",
adopted_plan
.map(|plan| plan.effective_command())
.unwrap_or("<verification command>"),
"--exit-code",
"<exit code>",
"--stdout-artifact",
@ -1851,8 +1866,10 @@ fn launch_reorient(
let checkpoint = match state.investigation_checkpoint.clone() {
Some(checkpoint) => checkpoint,
None => {
let projection = epiphany_core::runtime_modeling_semantic_projection_input(runtime_store)
.context("cannot launch reorientation without a valid admitted RepoModel checkpoint")?;
let projection = epiphany_core::runtime_modeling_semantic_projection_input(
runtime_store,
)
.context("cannot launch reorientation without a valid admitted RepoModel checkpoint")?;
epiphany_state_model::reorient_checkpoint_from_admitted_repo_model(
projection.snapshot(),
&projection.obligation().obligation_id,
@ -2549,6 +2566,16 @@ mod tests {
.and_then(serde_json::Value::as_str),
Some("epiphany-hands-action")
);
assert_eq!(
gate["plannedCommand"].as_str(),
Some("cargo test --bin epiphany-mvp-coordinator")
);
assert_eq!(
gate.pointer("/recordPassCommand/args/10")
.and_then(serde_json::Value::as_str),
Some("cargo test --bin epiphany-mvp-coordinator"),
"the operator command surface must carry the exact Mind-admitted command"
);
assert_eq!(
review.required_receipts,
vec![
@ -2615,6 +2642,7 @@ mod tests {
stop_conditions: vec!["authority scope changes".to_string()],
rollback_steps: vec!["revert the bounded change".to_string()],
commit_message: "Bind Hands intent to adopted plan".to_string(),
execution_amendment: None,
});
let mut model = epiphany_core::EpiphanyMemoryGraphSnapshot {
schema_version: Some(epiphany_core::MEMORY_GRAPH_SCHEMA_VERSION.to_string()),

View file

@ -2637,6 +2637,13 @@ pub(crate) mod tests {
"wrong command".into(),
"2026-07-15T09:00:13Z".into(),
);
let before_substituted_command = std::fs::read(&store)?;
assert!(crate::put_hands_command_receipt(&store, &wrong_command).is_err());
assert!(
crate::runtime_hands_command_receipt(&store, &wrong_command.receipt_id)?.is_none(),
"a command substituted after Mind adoption must never become consequence evidence"
);
assert_eq!(std::fs::read(&store)?, before_substituted_command);
let commit_receipt = crate::hands_commit_receipt_for_review(
"adopt-hands-commit".into(),
&intent,

View file

@ -755,6 +755,7 @@ pub use memory_graph::MemorySemanticProjectorPulseOutcome;
pub use memory_graph::MemorySemanticProjectorPulseStatus;
pub use memory_graph::MemorySemanticProjectorRecoveryAuthorization;
pub use memory_graph::RepoFrontierAdoptedPlan;
pub use memory_graph::RepoFrontierExecutionAmendment;
pub use memory_graph::RepoFrontierItem;
pub use memory_graph::RepoFrontierStatus;
pub use memory_graph::RepoMemoryGraphRefresh;
@ -997,6 +998,7 @@ pub use runtime_spine::RuntimeSpineInitOptions;
pub use runtime_spine::RuntimeSpineJobOptions;
pub use runtime_spine::RuntimeSpineJobResultOptions;
pub use runtime_spine::RuntimeSpineSessionOptions;
pub use runtime_spine::amend_repo_frontier_execution;
pub use runtime_spine::append_runtime_event;
pub use runtime_spine::bind_runtime_repository_domain;
pub use runtime_spine::bind_runtime_to_agent_memory_swarm;

View file

@ -29,6 +29,7 @@ pub use epiphany_state_model::EpiphanyMemoryPatchCandidate;
pub use epiphany_state_model::EpiphanyMemoryProfile;
pub use epiphany_state_model::EpiphanyMemorySummary;
pub use epiphany_state_model::RepoFrontierAdoptedPlan;
pub use epiphany_state_model::RepoFrontierExecutionAmendment;
pub use epiphany_state_model::RepoFrontierItem;
pub use epiphany_state_model::RepoFrontierStatus;
pub use epiphany_state_model::RepoModelPatch;

View file

@ -261,12 +261,38 @@ pub fn derive_repo_model_patch(
));
}
}
epiphany_state_model::RepoModelPatchPurpose::AmendFrontierExecution {
route_id,
amendment_id,
} => {
if patch.operations.len() != 1 {
return Err(anyhow!(
"AmendFrontierExecution purpose requires exactly one dedicated operation"
));
}
let RepoModelPatchOperation::AmendFrontierExecution { amendment, .. } =
&patch.operations[0]
else {
return Err(anyhow!(
"AmendFrontierExecution purpose requires its dedicated operation"
));
};
if amendment.replaces_route_id != *route_id || amendment.amendment_id != *amendment_id {
return Err(anyhow!(
"AmendFrontierExecution purpose and operation provenance mismatch"
));
}
}
_ if patch.operations.iter().any(|operation| {
matches!(operation, RepoModelPatchOperation::AdoptFrontierPlan { .. })
matches!(
operation,
RepoModelPatchOperation::AdoptFrontierPlan { .. }
| RepoModelPatchOperation::AmendFrontierExecution { .. }
)
}) =>
{
return Err(anyhow!(
"only AdoptFrontierPlan purpose may carry the dedicated adoption operation"
"only its Mind-owned purpose may carry a dedicated plan operation"
));
}
_ => {}
@ -501,6 +527,49 @@ fn apply_operation(
item.recommended_next_organ = "Hands".to_string();
item.updated_at = Some(applied_at.to_string());
}
RepoModelPatchOperation::AmendFrontierExecution {
frontier_item_id,
expected_frontier_item_hash,
amendment,
} => {
let item = snapshot
.frontier
.iter_mut()
.find(|item| &item.id == frontier_item_id)
.ok_or_else(|| {
anyhow!("cannot amend execution for missing frontier item {frontier_item_id}")
})?;
let current_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(&*item)?));
let plan = item
.adopted_plan
.as_mut()
.ok_or_else(|| anyhow!("frontier execution amendment requires an adopted plan"))?;
let previous_action_sha256 = format!("{:x}", Sha256::digest(plan.action.as_bytes()));
let previous_command_sha256 = format!("{:x}", Sha256::digest(plan.command.as_bytes()));
if current_hash != *expected_frontier_item_hash
|| item.status != RepoFrontierStatus::Active
|| item.recommended_next_organ != "Hands"
|| plan.execution_amendment.is_some()
|| amendment.amendment_id.trim().is_empty()
|| amendment.replaces_route_id.trim().is_empty()
|| amendment.source_actor_id.trim().is_empty()
|| amendment.command_id.trim().is_empty()
|| amendment.admission_id.trim().is_empty()
|| amendment.packet_sha256.trim().is_empty()
|| amendment.action.trim().is_empty()
|| amendment.command.trim().is_empty()
|| amendment.rationale.trim().is_empty()
|| amendment.previous_action_sha256 != previous_action_sha256
|| amendment.previous_command_sha256 != previous_command_sha256
|| chrono::DateTime::parse_from_rfc3339(&amendment.amended_at).is_err()
{
return Err(anyhow!(
"frontier execution amendment requires the exact current Hands plan and complete authenticated provenance"
));
}
plan.execution_amendment = Some(amendment.clone());
item.updated_at = Some(applied_at.to_string());
}
}
Ok(())
}

View file

@ -2,6 +2,7 @@ use super::*;
use anyhow::Result;
use epiphany_state_model::EpiphanyMemoryEdgeKind;
use epiphany_state_model::EpiphanyMemoryNodeKind;
use sha2::Digest;
fn anchor(id: &str, hash: &str) -> EpiphanyMemoryAnchor {
EpiphanyMemoryAnchor {
@ -733,6 +734,7 @@ fn verdict_incorporation_closes_adopted_frontier_without_rewriting_execution_pla
stop_conditions: vec!["scope changes".into()],
rollback_steps: vec!["revert commit".into()],
commit_message: "Implement exact bounded change".into(),
execution_amendment: None,
});
snapshot.frontier = vec![item.clone()];
make_canonical(&mut snapshot, 1);
@ -768,6 +770,78 @@ fn verdict_incorporation_closes_adopted_frontier_without_rewriting_execution_pla
Ok(())
}
#[test]
fn execution_amendment_is_exact_single_use_and_mind_owned() -> Result<()> {
let mut snapshot = fixture_snapshot();
let claim = snapshot.nodes[0].id.clone();
let mut item = frontier_item("amended-work", &claim);
item.recommended_next_organ = "Hands".into();
item.adopted_plan = Some(epiphany_state_model::RepoFrontierAdoptedPlan {
planning_request_id: "planning-1".into(),
result_id: "result-1".into(),
job_id: "job-1".into(),
candidate_id: "candidate-1".into(),
candidate_sha256: "candidate-hash".into(),
safe_paths: item.source_scope.clone(),
action: "Draft a plan".into(),
command: "Describe the checks".into(),
checks: vec!["focused tests pass".into()],
stop_conditions: vec!["scope changes".into()],
rollback_steps: vec!["revert commit".into()],
commit_message: "Implement bounded change".into(),
execution_amendment: None,
});
snapshot.frontier = vec![item.clone()];
make_canonical(&mut snapshot, 5);
let item_hash = format!(
"{:x}",
sha2::Sha256::digest(rmp_serde::to_vec_named(&item)?)
);
let amendment = epiphany_state_model::RepoFrontierExecutionAmendment {
amendment_id: "amendment-1".into(),
replaces_route_id: "route-1".into(),
source_actor_id: "supervisor-1".into(),
command_id: "command-1".into(),
admission_id: "admission-1".into(),
packet_sha256: "a".repeat(64),
previous_action_sha256: format!("{:x}", sha2::Sha256::digest(b"Draft a plan")),
previous_command_sha256: format!("{:x}", sha2::Sha256::digest(b"Describe the checks")),
action: "Verify the admitted implementation".into(),
command: "cargo test --lib".into(),
rationale: "Repair a non-executable adopted command without erasing it.".into(),
amended_at: "2026-08-08T12:30:00Z".into(),
};
let patch = RepoModelPatch {
patch_id: "amend-execution-1".into(),
base_revision: snapshot.model_revision,
base_hash: memory_graph_model_hash(&snapshot)?,
applied_at: amendment.amended_at.clone(),
purpose: RepoModelPatchPurpose::AmendFrontierExecution {
route_id: amendment.replaces_route_id.clone(),
amendment_id: amendment.amendment_id.clone(),
},
operations: vec![RepoModelPatchOperation::AmendFrontierExecution {
frontier_item_id: item.id.clone(),
expected_frontier_item_hash: item_hash,
amendment: amendment.clone(),
}],
};
let next = derive_repo_model_patch(&snapshot, &patch)?;
let plan = next.frontier[0].adopted_plan.as_ref().unwrap();
assert_eq!(plan.command, "Describe the checks");
assert_eq!(plan.effective_command(), "cargo test --lib");
let mut repeated = patch.clone();
repeated.base_revision = next.model_revision;
repeated.base_hash = memory_graph_model_hash(&next)?;
assert!(derive_repo_model_patch(&next, &repeated).is_err());
let mut generic = patch;
generic.purpose = RepoModelPatchPurpose::Evolution;
assert!(derive_repo_model_patch(&snapshot, &generic).is_err());
Ok(())
}
#[test]
fn memory_context_projects_frontier_prerequisites_first_under_budget() {
let mut snapshot = fixture_snapshot();

View file

@ -46,6 +46,10 @@ pub const REPO_FRONTIER_RELINQUISHMENT_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.repo_frontier_relinquishment_receipt.v0";
pub const REPO_FRONTIER_RELINQUISHMENT_RECEIPT_CONTRACT: &str =
"epiphany.repo_frontier_relinquishment.v0";
pub const REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.repo_frontier_execution_amendment_receipt.v0";
pub const REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_CONTRACT: &str =
"epiphany.repo_frontier_execution_amendment.v0";
pub const REPO_FRONTIER_MODELING_REQUEST_TYPE: &str =
"epiphany.modeling.repo_frontier_verdict_request";
pub const REPO_FRONTIER_MODELING_REQUEST_SCHEMA_VERSION: &str =
@ -938,6 +942,54 @@ pub struct RepoFrontierRelinquishmentReceipt {
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.mind.repo_frontier_execution_amendment_receipt",
schema = "RepoFrontierExecutionAmendmentReceipt"
)]
pub struct RepoFrontierExecutionAmendmentReceipt {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub amendment_id: String,
#[cultcache(key = 3)]
pub replaced_route_id: String,
#[cultcache(key = 4)]
pub frontier_item_id: String,
#[cultcache(key = 5)]
pub previous_frontier_item_hash: String,
#[cultcache(key = 6)]
pub previous_model_revision: u64,
#[cultcache(key = 7)]
pub previous_model_hash: String,
#[cultcache(key = 8)]
pub admitted_model_revision: u64,
#[cultcache(key = 9)]
pub admitted_model_hash: String,
#[cultcache(key = 10)]
pub model_admission_receipt_id: String,
#[cultcache(key = 11)]
pub source_actor_id: String,
#[cultcache(key = 12)]
pub command_id: String,
#[cultcache(key = 13)]
pub admission_id: String,
#[cultcache(key = 14)]
pub packet_sha256: String,
#[cultcache(key = 15)]
pub replacement_action: String,
#[cultcache(key = 16)]
pub replacement_command: String,
#[cultcache(key = 17)]
pub rationale: String,
#[cultcache(key = 18)]
pub amended_at: String,
#[cultcache(key = 19)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.mind.repo_model_admission_review",

View file

@ -52,6 +52,8 @@ use crate::organ_dependencies::EpiphanyLaunchOrganContract;
use crate::repo_model_gateway::{
REPO_FRONTIER_AUTONOMOUS_PROPOSAL_BINDING_CONTRACT,
REPO_FRONTIER_AUTONOMOUS_PROPOSAL_BINDING_SCHEMA_VERSION,
REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_CONTRACT,
REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_SCHEMA_VERSION,
REPO_FRONTIER_HANDS_AUTHORITY_CONTRACT, REPO_FRONTIER_HANDS_AUTHORITY_SCHEMA_VERSION,
REPO_FRONTIER_MODELING_REQUEST_CONTRACT, REPO_FRONTIER_MODELING_REQUEST_SCHEMA_VERSION,
REPO_FRONTIER_PLAN_CANDIDATE_SCHEMA_VERSION, REPO_FRONTIER_PLAN_DECISION_CONTRACT,
@ -75,10 +77,10 @@ use crate::repo_model_gateway::{
REPO_MODEL_MIGRATION_CONTRACT, REPO_MODEL_MIGRATION_RECEIPT_SCHEMA_VERSION,
REPO_MODEL_MIGRATION_RECEIPT_TYPE, RUNTIME_REPOSITORY_DOMAIN_BINDING_CONTRACT,
RUNTIME_REPOSITORY_DOMAIN_BINDING_KEY, RUNTIME_REPOSITORY_DOMAIN_BINDING_SCHEMA_VERSION,
RepoFrontierAutonomousProposalBinding, RepoFrontierHandsAuthority, RepoFrontierModelingRequest,
RepoFrontierNextOrgan, RepoFrontierPlanCandidate, RepoFrontierPlanDecision,
RepoFrontierPlanDecisionReceipt, RepoFrontierPlanMindDecision,
RepoFrontierPlanMindLaunchBinding, RepoFrontierPlanMindRequest,
RepoFrontierAutonomousProposalBinding, RepoFrontierExecutionAmendmentReceipt,
RepoFrontierHandsAuthority, RepoFrontierModelingRequest, RepoFrontierNextOrgan,
RepoFrontierPlanCandidate, RepoFrontierPlanDecision, RepoFrontierPlanDecisionReceipt,
RepoFrontierPlanMindDecision, RepoFrontierPlanMindLaunchBinding, RepoFrontierPlanMindRequest,
RepoFrontierPlanningCandidateEligibility, RepoFrontierPlanningEligibility,
RepoFrontierPlanningLaunchBinding, RepoFrontierPlanningLifecycle,
RepoFrontierPlanningLifecycleStage, RepoFrontierPlanningRequest,
@ -902,6 +904,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
cache.register_entry_type::<RepoFrontierHandsAuthority>()?;
cache.register_entry_type::<HandsActionRefusalReceipt>()?;
cache.register_entry_type::<RepoFrontierRelinquishmentReceipt>()?;
cache.register_entry_type::<RepoFrontierExecutionAmendmentReceipt>()?;
cache.register_entry_type::<RepoFrontierModelingRequest>()?;
cache.register_entry_type::<RepoFrontierWorkProposal>()?;
cache.register_entry_type::<RepoFrontierAutonomousProposalBinding>()?;
@ -2739,6 +2742,11 @@ pub fn commit_repo_model_admission(
"frontier route relinquishment is a Mind-owned transaction and cannot enter through generic repo model admission"
));
}
crate::RepoModelPatchPurpose::AmendFrontierExecution { .. } => {
return Err(anyhow!(
"frontier execution amendment is a Mind-owned supervisor transaction and cannot enter through generic repo model admission"
));
}
crate::RepoModelPatchPurpose::RepairClaim => {
if result.repo_frontier_modeling_request_id.is_some()
|| result.proposal_modeling_request_id.is_some()
@ -5784,6 +5792,7 @@ fn commit_repo_frontier_plan_decision_inner(
stop_conditions: candidate.stop_conditions.clone(),
rollback_steps: candidate.rollback_steps.clone(),
commit_message: candidate.commit_message.clone(),
execution_amendment: None,
};
let patch = crate::RepoModelPatch {
patch_id: format!("repo-frontier-plan-adopt-patch-{}", request.request_id),
@ -6875,7 +6884,7 @@ fn validate_repo_frontier_hands_authority_chain(
Some(plan) => {
intent.frontier_route_id == route.route_id
&& intent.plan_candidate_sha256 == plan.candidate_sha256
&& intent.plan_action == plan.action
&& intent.plan_action == plan.effective_action()
}
None => {
intent.frontier_route_id.is_empty()
@ -7278,6 +7287,165 @@ pub fn relinquish_repo_frontier_hands_route(
Ok(relinquishment)
}
/// Mind-owned repair for a route whose immutable adopted plan cannot bind the
/// already-observed consequence. The original plan and route remain intact;
/// only an authenticated, single-use execution amendment enters RepoModel.
pub fn amend_repo_frontier_execution(
store_path: impl AsRef<Path>,
amendment: crate::RepoFrontierExecutionAmendment,
) -> Result<RepoFrontierExecutionAmendmentReceipt> {
let store_path = store_path.as_ref();
if chrono::DateTime::parse_from_rfc3339(&amendment.amended_at).is_err() {
return Err(anyhow!("execution amendment amended_at must be RFC3339"));
}
let cache = runtime_spine_cache(store_path)?;
if cache
.get::<RepoFrontierExecutionAmendmentReceipt>(&amendment.amendment_id)?
.is_some()
{
return Err(anyhow!("execution amendment has already been consumed"));
}
let route = cache
.get::<RepoFrontierRoute>(&amendment.replaces_route_id)?
.ok_or_else(|| anyhow!("execution amendment requires the exact replaced route"))?;
let backing = SingleFileMessagePackBackingStore::new(store_path);
let current_envelope = backing
.pull_all()?
.into_iter()
.find(|entry| {
entry.r#type == crate::MEMORY_GRAPH_TYPE && entry.key == crate::MEMORY_GRAPH_KEY
})
.ok_or_else(|| anyhow!("execution amendment requires canonical RepoModel"))?;
let current_entry: crate::EpiphanyMemoryGraphEntry =
rmp_serde::from_slice(&current_envelope.payload)?;
crate::validate_memory_graph_entry(&current_entry)?;
let current = current_entry.snapshot()?;
let current_hash = crate::memory_graph_model_hash(&current)?;
if current.model_revision != route.model_revision || current_hash != route.model_hash {
return Err(anyhow!(
"execution amendment replaced route is no longer current"
));
}
let item = current
.frontier
.iter()
.find(|item| item.id == route.frontier_item_id)
.ok_or_else(|| anyhow!("execution amendment frontier item disappeared"))?;
let item_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(item)?));
if item_hash != route.frontier_item_hash {
return Err(anyhow!("execution amendment route frontier hash is stale"));
}
let patch = crate::RepoModelPatch {
patch_id: format!(
"repo-frontier-execution-amendment-patch-{}",
amendment.amendment_id
),
base_revision: current.model_revision,
base_hash: current_hash.clone(),
applied_at: amendment.amended_at.clone(),
purpose: crate::RepoModelPatchPurpose::AmendFrontierExecution {
route_id: route.route_id.clone(),
amendment_id: amendment.amendment_id.clone(),
},
operations: vec![crate::RepoModelPatchOperation::AmendFrontierExecution {
frontier_item_id: route.frontier_item_id.clone(),
expected_frontier_item_hash: route.frontier_item_hash.clone(),
amendment: amendment.clone(),
}],
};
let patch_bytes = rmp_serde::to_vec_named(&patch)?;
let patch_sha256 = format!("{:x}", Sha256::digest(&patch_bytes));
let next = crate::derive_repo_model_patch(&current, &patch)?;
let next_entry = crate::EpiphanyMemoryGraphEntry::from_snapshot(&next)?;
let review = RepoModelAdmissionReview {
schema_version: REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION.into(),
review_id: format!("repo-model-review-{}", amendment.amendment_id),
result_id: None,
job_id: None,
patch_id: patch.patch_id.clone(),
patch_sha256: patch_sha256.clone(),
base_revision: current.model_revision,
base_hash: current_hash.clone(),
decision: MindGatewayDecision::Accept,
evidence_ids: vec![
route.route_id.clone(),
amendment.command_id.clone(),
amendment.admission_id.clone(),
],
reviewed_at: amendment.amended_at.clone(),
contract: REPO_MODEL_ADMISSION_CONTRACT.into(),
repository_body_observation_basis: None,
admission_source: None,
};
let admission = RepoModelAdmissionReceipt {
schema_version: REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: format!("repo-model-admission-{}", amendment.amendment_id),
review_id: review.review_id.clone(),
result_id: None,
patch_id: patch.patch_id.clone(),
patch_sha256,
previous_revision: current.model_revision,
previous_hash: current_hash,
admitted_revision: next.model_revision,
admitted_hash: next.model_hash.clone(),
admitted_at: amendment.amended_at.clone(),
contract: REPO_MODEL_ADMISSION_CONTRACT.into(),
purpose: patch.purpose,
frontier_route_id: route.route_id.clone(),
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: String::new(),
frontier_plan_decision_id: String::new(),
repository_body_observation_basis: None,
admission_source: None,
};
let receipt = RepoFrontierExecutionAmendmentReceipt {
schema_version: REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: amendment.amendment_id.clone(),
amendment_id: amendment.amendment_id.clone(),
replaced_route_id: route.route_id,
frontier_item_id: route.frontier_item_id,
previous_frontier_item_hash: item_hash,
previous_model_revision: current.model_revision,
previous_model_hash: admission.previous_hash.clone(),
admitted_model_revision: next.model_revision,
admitted_model_hash: next.model_hash.clone(),
model_admission_receipt_id: admission.receipt_id.clone(),
source_actor_id: amendment.source_actor_id,
command_id: amendment.command_id,
admission_id: amendment.admission_id,
packet_sha256: amendment.packet_sha256,
replacement_action: amendment.action,
replacement_command: amendment.command,
rationale: amendment.rationale,
amended_at: amendment.amended_at.clone(),
contract: REPO_FRONTIER_EXECUTION_AMENDMENT_RECEIPT_CONTRACT.into(),
};
let obligation = modeling_projection_obligation(
&cache,
&next,
&admission.receipt_id,
&admission.admitted_at,
)?;
let writes = vec![
cache.prepare_entry(crate::MEMORY_GRAPH_KEY, &next_entry)?.0,
cache.prepare_entry(&review.review_id, &review)?.0,
cache.prepare_entry(&admission.receipt_id, &admission)?.0,
cache.prepare_entry(&receipt.receipt_id, &receipt)?.0,
cache
.prepare_entry(&obligation.obligation_id, &obligation)?
.0,
];
if !backing.compare_and_swap_batch(&[current_envelope], writes)? {
return Err(anyhow!(
"execution amendment lost the RepoModel compare-and-swap"
));
}
Ok(receipt)
}
pub fn put_repo_frontier_verification_request(
store_path: impl AsRef<Path>,
request: &RepoFrontierVerificationRequest,
@ -7341,10 +7509,10 @@ pub fn put_repo_frontier_verification_request(
if intent.plan_candidate_sha256 != plan.candidate_sha256 {
mismatches.push("intent.plan.candidate");
}
if intent.plan_action != plan.action {
if intent.plan_action != plan.effective_action() {
mismatches.push("intent.plan.action");
}
if command.command != plan.command {
if command.command != plan.effective_command() {
mismatches.push("command.plan.command");
}
mismatches
@ -7700,6 +7868,7 @@ fn validate_hands_consequence_grant(
operation: &str,
changed_paths: &[String],
stated_grant_id: Option<&str>,
stated_command: Option<&str>,
) -> Result<()> {
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
@ -7755,6 +7924,12 @@ fn validate_hands_consequence_grant(
.iter()
.any(|allowed| allowed == operation)
|| stated_grant_id.is_some_and(|id| id != grant.receipt_id)
|| stated_command.is_some_and(|command| {
route
.adopted_plan
.as_ref()
.is_some_and(|plan| command != plan.effective_command())
})
|| !paths_covered
|| authority.schema_version != REPO_FRONTIER_HANDS_AUTHORITY_SCHEMA_VERSION
|| authority.contract != REPO_FRONTIER_HANDS_AUTHORITY_CONTRACT
@ -7803,6 +7978,7 @@ pub fn validate_hands_action_authority(
operation,
changed_paths,
Some(stated_grant_id),
None,
)
}
@ -7832,6 +8008,7 @@ pub fn put_hands_patch_receipt(
"patch",
&receipt.changed_paths,
Some(&receipt.substrate_gate_grant_receipt_id),
None,
)?;
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
@ -7884,6 +8061,7 @@ pub fn put_hands_command_receipt(
"command",
&[],
Some(&receipt.substrate_gate_grant_receipt_id),
Some(&receipt.command),
)?;
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
@ -7936,6 +8114,7 @@ pub fn put_hands_commit_receipt(
"commit",
&receipt.changed_paths,
None,
None,
)?;
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
@ -9081,7 +9260,9 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
CultNetMutationAuthority::ReadOnly,
vec![],
vec![],
vec!["Mind relinquishment receipts prove that an exact Hands refusal retired route authority without a repository consequence."],
vec![
"Mind relinquishment receipts prove that an exact Hands refusal retired route authority without a repository consequence.",
],
),
mutation_contract(
SOUL_VERIFICATION_REQUEST_TYPE,
@ -12618,6 +12799,9 @@ pub(crate) mod tests {
crate::RepoModelPatchPurpose::RelinquishFrontierRoute { .. } => {
vec!["relinquish".to_string()]
}
crate::RepoModelPatchPurpose::AmendFrontierExecution { .. } => {
vec!["amend".to_string()]
}
};
review.patch_id = patch.patch_id.clone();
review.patch_sha256 = format!("{:x}", Sha256::digest(&bytes));

View file

@ -824,6 +824,41 @@ pub struct RepoFrontierAdoptedPlan {
#[ts(type = "Array<string>")]
pub rollback_steps: Vec<String>,
pub commit_message: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(type = "RepoFrontierExecutionAmendment | null")]
pub execution_amendment: Option<RepoFrontierExecutionAmendment>,
}
impl RepoFrontierAdoptedPlan {
pub fn effective_action(&self) -> &str {
self.execution_amendment
.as_ref()
.map_or(self.action.as_str(), |amendment| amendment.action.as_str())
}
pub fn effective_command(&self) -> &str {
self.execution_amendment
.as_ref()
.map_or(self.command.as_str(), |amendment| {
amendment.command.as_str()
})
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
pub struct RepoFrontierExecutionAmendment {
pub amendment_id: String,
pub replaces_route_id: String,
pub source_actor_id: String,
pub command_id: String,
pub admission_id: String,
pub packet_sha256: String,
pub previous_action_sha256: String,
pub previous_command_sha256: String,
pub action: String,
pub command: String,
pub rationale: String,
pub amended_at: String,
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
@ -871,6 +906,10 @@ pub enum RepoModelPatchPurpose {
route_id: String,
hands_refusal_receipt_id: String,
},
AmendFrontierExecution {
route_id: String,
amendment_id: String,
},
}
pub fn reorient_checkpoint_from_admitted_repo_model(
@ -885,9 +924,7 @@ pub fn reorient_checkpoint_from_admitted_repo_model(
summary: Some(
"Derived from the authenticated current RepoModel semantic projection.".to_string(),
),
next_action: Some(
"Resume from the current Mind-admitted RepoModel frontier.".to_string(),
),
next_action: Some("Resume from the current Mind-admitted RepoModel frontier.".to_string()),
captured_at_turn_id: None,
open_questions: Vec::new(),
code_refs: snapshot
@ -947,6 +984,11 @@ pub enum RepoModelPatchOperation {
expected_frontier_item_hash: String,
adopted_plan: RepoFrontierAdoptedPlan,
},
AmendFrontierExecution {
frontier_item_id: String,
expected_frontier_item_hash: String,
amendment: RepoFrontierExecutionAmendment,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS)]

View file

@ -1436,6 +1436,34 @@ to own the decision. Without a Hands frontier, the consumed proposal still
fails closed at `awaitFrontierProposal`; ordinary non-proposal failures still
route back to Modeling.
## Supervisor execution-amendment authority
Owner: Mind owns a single-use repair when an immutable adopted plan contains a
non-executable command that cannot bind an already-observed Hands consequence.
The original Imagination plan and Self route remain immutable evidence.
Inputs: one exact current route, the exact current frontier-item hash, hashes of
the original action and command, authenticated supervisor actor/command/admission
and packet provenance, one replacement action and command, rationale, and an
operator-owned timestamp.
Outputs: one new RepoModel revision plus Mind review, admission, execution-
amendment, and Modeling-projection receipts in one compare-and-swap. Self must
derive a fresh route from the amended model; the old route cannot become current
again. Hands command receipts bind `effective_command`, and the gate projects
both original and effective values for inspection.
Forbidden writers: generic Modeling admission cannot carry the amendment
operation; Hands cannot substitute a command; a stale route cannot be amended;
and an already-amended plan cannot be amended again. The amendment is not a
repair loop and does not erase failed Soul launches or historical Hands receipts.
Verification layer: focused derivation tests prove exact success, original-plan
preservation, single-use refusal, and generic-purpose refusal. The Hands receipt
test proves a mismatched stated command leaves the store byte-identical before
the exact command succeeds. Live v53 migration and renewed Soul verification are
the remaining end-to-end proof.
## Exact release build cache ownership
The root release-bundle manifest owns release profile policy. Measured on the

View file

@ -7,7 +7,7 @@ growth.
## Authoritative live state
- Branch: `codex/epiphany-shakedown-live`
- Pushed HEAD: `189091bf` (`Keep rejected Modeling behind pending Soul`)
- Pushed HEAD before the current verified repair pass: `583c09c3` (`Expose Soul binding mismatch`)
- Live workspace: `F:\Projects\.epiphany-runtime\shakedown\live-20260808-v53-hands-precedence`
- Sealed evidence: v49 through v52. Do not mutate them.
- Current published release: commit `253ef34084c7b450e587c1938a68cd3e983ed79b`, release `sha256-e0a4fd22df335401d56295453e009f31aa2e82253634614426bfba298dd2d3f0`, witness `sha256-65cbc2f21f0774c4da00a60537c959d130e970a4b860de5629a7b929b8185b2c`.
@ -54,6 +54,16 @@ granting Hands authority. Do not weaken Soul and do not forge an empty command
receipt. Preserve the failed launches (`v53-soul-r24`, `r25`, `r27`, diagnostic
`r28`/`r29`) as receipts of the corrupted seam.
The current verified repair pass makes command substitution fail before a Hands
command receipt can persist. Hands gates expose the exact effective command.
RepoModel now supports one Mind-owned, single-use execution amendment whose
authenticated provenance and hashes preserve the original adopted plan while
atomically committing a new model revision, Mind review, admission receipt,
amendment receipt, and Modeling projection. The narrow operator mouth is
`epiphany-mind-repair amend-frontier-execution`. Focused amendment and Hands-gate
tests pass; their builds took 73 and 64 seconds respectively while test execution
was sub-second, strengthening the case for the pending core crate split.
## Receipts
- Final Hands patch: `hands-patch-34b421a7-867f-4414-8265-36f2eb191afb`
@ -65,11 +75,10 @@ receipt. Preserve the failed launches (`v53-soul-r24`, `r25`, `r27`, diagnostic
## Next action
Finish the operator-safe mismatch diagnostic in `runtime_spine.rs` and commit
it. Add fail-closed admission coverage so a non-executable adopted-plan command
cannot produce Hands authority. Then implement one labeled typed supervisor
migration for the live route, preserving the original route and every failed
Soul launch as evidence, and retry Soul against the repaired binding.
Commit and push the typed repair pass. Then use the Mind repair CLI to amend the
live v53 plan with explicit supervisor command/admission provenance, derive a
fresh route, replay the exact Hands receipts against that amended route, and
retry Soul. Preserve the original route and every failed Soul launch.
Build iteration is also an active architectural defect: a tiny
`runtime_spine.rs` diagnostic edit forced 18-29 second debug rebuilds, while

View file

@ -34,9 +34,9 @@ invariants:
- Evidence and git retain history; this map retains only state that changes future decisions.
current_status:
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Live v53 completed the adopted RepoModel revision 5 Hands consequence through commit 0763fcbe94257eb9adbe92ab814b5a487f65551d. Reorientation and Eyes regather were accepted; the resulting causal Modeling attempt was correctly rejected because Evolution cannot bypass the active route. HEAD 189091bf routes the still-unverified Hands consequence to Soul ahead of that rejected Modeling result. Soul now fails closed because the adopted plan command does not match the complete Hands command receipt, exposing an Imagination/Mind admission defect rather than a Soul defect. Persona consequence, retention, endurance, restart closure, and Linux/Yggdrasil cognition remain open.
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Live v53 completed the adopted RepoModel revision 5 Hands consequence through commit 0763fcbe94257eb9adbe92ab814b5a487f65551d. Soul correctly failed closed on a substituted plan command. The repair pass now prevents a mismatched Hands command receipt, projects the exact effective command in the gate, and adds a Mind-owned single-use execution amendment that preserves the original plan and route while atomically emitting review, admission, amendment, and Modeling-projection receipts. Live v53 migration and renewed Soul proof remain next. Persona consequence, retention, endurance, restart closure, and Linux/Yggdrasil cognition remain open.
operational_state:
local_worktree: soul_binding_diagnostic_mid_pass
local_worktree: typed_execution_amendment_verified_pending_commit
operator_wireguard: restored
yggdrasil: canonical_small_public_crossing_body
starfire: temporary_epiphany_cognition_body
@ -52,8 +52,8 @@ current_status:
bifrost_feedback_crossing: authenticated_transport_only
yggdrasil_epiphany_services: absent
resident_physiology: heartbeat_and_self_running
unresolved_authority: The active route admitted a plan whose command cannot bind the completed Hands consequence. Soul reports only command.plan.command after supervisor-supplied exact receipt-chain retries, so the live state is fail-closed and must not be bypassed. Prevent empty or non-executable plan commands from reaching Mind adoption, then migrate the live route through a labeled typed supervisor repair. Exact HEAD packaging remains required. The adopted Mind decision also carries a model-supplied 2025 timestamp; timestamp ownership remains a separate provenance audit item.
next_action: Finish and commit the Soul mismatch diagnostic, add admission coverage that rejects a non-executable adopted-plan command before Hands authority exists, then design one typed supervisor migration that repairs the live route and emits receipts without erasing the rejected state. Retry Soul only after the repaired route and current Hands consequence bind exactly. Separately map and split the monolithic epiphany-core runtime spine/build graph; tiny runtime-spine edits currently force 18-29 second debug rebuilds and multi-minute exact packages.
unresolved_authority: The active v53 route still contains the original non-executable plan command and remains fail-closed. The typed repair mechanism is locally verified but has not yet migrated live state or produced a fresh route. Exact HEAD packaging remains required. The adopted Mind decision also carries a model-supplied 2025 timestamp; timestamp ownership remains a separate provenance audit item.
next_action: Commit and push the verified command-binding and typed execution-amendment pass. Use the narrow Mind repair CLI to migrate live v53 with authenticated supervisor provenance, derive a fresh route, replay exact Hands evidence against the amended command, then launch and accept Soul. Separately map and split the monolithic epiphany-core runtime spine/build graph; focused tests for this pass each required 64-73 seconds of compilation while execution took under one second.
active_subgoals:
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.