Add atomic Hands route relinquishment

This commit is contained in:
Meta Vens 2026-08-08 09:52:42 +01:00
commit 182a591369
12 changed files with 662 additions and 36 deletions

View file

@ -10,6 +10,7 @@ use epiphany_core::hands_patch_receipt_for_review;
use epiphany_core::put_hands_command_receipt;
use epiphany_core::put_hands_commit_receipt;
use epiphany_core::put_hands_patch_receipt;
use epiphany_core::relinquish_repo_frontier_hands_route;
use epiphany_core::runtime_hands_action_intent;
use epiphany_core::runtime_hands_action_review;
use serde_json::json;
@ -26,6 +27,7 @@ fn main() -> Result<()> {
Command::RecordCommand(command) => record_command(&args.store, command)?,
Command::RecordCommit(command) => record_commit(&args.store, command)?,
Command::RecordPass(command) => record_pass(&args.store, command)?,
Command::RecordRefusal(command) => record_refusal(&args.store, command)?,
};
println!("{}", serde_json::to_string_pretty(&output)?);
Ok(())
@ -43,6 +45,7 @@ enum Command {
RecordCommand(RecordCommandArgs),
RecordCommit(RecordCommitArgs),
RecordPass(RecordPassArgs),
RecordRefusal(RecordRefusalArgs),
}
#[derive(Debug, Clone)]
@ -91,6 +94,12 @@ struct RecordPassArgs {
validate_commit_sha: bool,
}
#[derive(Debug)]
struct RecordRefusalArgs {
gate: GateArgs,
missing_required_paths: Vec<String>,
}
impl Args {
fn parse() -> Result<Self> {
let mut tokens = env::args().skip(1).peekable();
@ -105,12 +114,29 @@ impl Args {
"record-command" => Command::RecordCommand(parse_record_command(tokens)?),
"record-commit" => Command::RecordCommit(parse_record_commit(tokens)?),
"record-pass" => Command::RecordPass(parse_record_pass(tokens)?),
"record-refusal" => Command::RecordRefusal(parse_record_refusal(tokens)?),
_ => return Err(anyhow!("unknown command {command_name}\n{}", usage())),
};
Ok(Self { store, command })
}
}
fn parse_record_refusal(tokens: impl Iterator<Item = String>) -> Result<RecordRefusalArgs> {
let mut options = ParsedOptions::parse(tokens)?;
let gate = options.take_gate()?;
let missing_required_paths = options.take_many("--missing-required-path");
options.finish()?;
if missing_required_paths.is_empty() {
return Err(anyhow!(
"record-refusal requires at least one --missing-required-path"
));
}
Ok(RecordRefusalArgs {
gate,
missing_required_paths,
})
}
fn parse_record_patch(tokens: impl Iterator<Item = String>) -> Result<RecordPatchArgs> {
let mut options = ParsedOptions::parse(tokens)?;
let gate = options.take_gate()?;
@ -399,6 +425,35 @@ fn record_pass(store: &PathBuf, args: RecordPassArgs) -> Result<serde_json::Valu
}))
}
fn record_refusal(store: &PathBuf, args: RecordRefusalArgs) -> Result<serde_json::Value> {
let resolved = resolve_gate(&args.gate)?;
let receipt_id = args
.gate
.receipt_id
.unwrap_or_else(|| generated_receipt_id("hands-refusal"));
let receipt = relinquish_repo_frontier_hands_route(
store,
&resolved.intent_id,
&resolved.review_id,
&receipt_id,
normalize_paths(args.missing_required_paths),
args.gate.summary,
now(),
)?;
Ok(json!({
"status": "ok",
"type": "epiphany.mind.repo_frontier_relinquishment_receipt",
"receiptId": receipt.receipt_id,
"handsRefusalReceiptId": receipt.hands_refusal_receipt_id,
"routeId": receipt.route_id,
"frontierItemId": receipt.frontier_item_id,
"admittedModelRevision": receipt.admitted_model_revision,
"admittedModelHash": receipt.admitted_model_hash,
"modelAdmissionReceiptId": receipt.model_admission_receipt_id,
"store": store,
}))
}
fn pass_gate(gate: &GateArgs, operation: &str) -> GateArgs {
let mut gate = gate.clone();
gate.receipt_id = None;
@ -570,7 +625,7 @@ fn take_value(tokens: &mut impl Iterator<Item = String>, name: &str) -> Result<S
}
fn usage() -> &'static str {
"usage: epiphany-hands-action [--store path] <record-patch|record-command|record-commit|record-pass> (--gate-summary path | --intent-id id --review-id id) --summary text ..."
"usage: epiphany-hands-action [--store path] <record-patch|record-command|record-commit|record-pass|record-refusal> (--gate-summary path | --intent-id id --review-id id) --summary text ..."
}
#[cfg(test)]

View file

@ -472,6 +472,9 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
let frontier_planning =
epiphany_core::runtime_repo_frontier_planning_lifecycle(&runtime_store_path)
.context("failed to derive frontier planning lifecycle from runtime-spine state")?;
let frontier_relinquishment =
epiphany_core::runtime_latest_repo_frontier_relinquishment(&runtime_store_path)
.context("failed to derive latest frontier relinquishment from runtime-spine state")?;
let pending_proposal =
epiphany_core::runtime_pending_repo_frontier_proposal_modeling_request(&runtime_store_path)
.context("failed to derive pending proposal Modeling authority")?;
@ -591,6 +594,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
"lifecycle": frontier_planning,
"eligibility": frontier_planning_eligibility,
},
"frontierRelinquishment": frontier_relinquishment,
"roleResults": {
"imagination": native_role_result(state_ref, &runtime_store_path, IMAGINATION_BINDING_ID, EpiphanyRoleResultRoleId::Imagination),
"research": native_role_result(state_ref, &runtime_store_path, RESEARCH_BINDING_ID, EpiphanyRoleResultRoleId::Research),

View file

@ -19,6 +19,8 @@ pub const HANDS_PR_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.pr_receipt.v0"
pub const HANDS_ROLLBACK_RECEIPT_SCHEMA_VERSION: &str = "epiphany.hands.rollback_receipt.v0";
pub const HANDS_ACTION_REFUSAL_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.hands.action_refusal_receipt.v0";
pub const HANDS_ACTION_REFUSAL_RECEIPT_CONTRACT: &str =
"epiphany.hands.action_refusal.v0";
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "epiphany.hands.action_intent", schema = "HandsActionIntent")]
@ -76,6 +78,44 @@ pub struct HandsActionReview {
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.hands.action_refusal_receipt",
schema = "HandsActionRefusalReceipt"
)]
pub struct HandsActionRefusalReceipt {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub route_id: String,
#[cultcache(key = 3)]
pub authority_id: String,
#[cultcache(key = 4)]
pub intent_id: String,
#[cultcache(key = 5)]
pub review_id: String,
#[cultcache(key = 6)]
pub substrate_gate_grant_receipt_id: String,
#[cultcache(key = 7)]
pub model_revision: u64,
#[cultcache(key = 8)]
pub model_hash: String,
#[cultcache(key = 9)]
pub frontier_item_id: String,
#[cultcache(key = 10)]
pub frontier_item_hash: String,
#[cultcache(key = 11)]
pub missing_required_paths: Vec<String>,
#[cultcache(key = 12)]
pub summary: String,
#[cultcache(key = 13)]
pub refused_at: String,
#[cultcache(key = 14)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "epiphany.hands.patch_receipt", schema = "HandsPatchReceipt")]
pub struct HandsPatchReceipt {

View file

@ -1044,6 +1044,7 @@ pub use runtime_spine::put_runtime_reorient_worker_result;
pub use runtime_spine::put_runtime_role_worker_result;
pub use runtime_spine::put_soul_verdict_receipt;
pub use runtime_spine::put_substrate_gate_repo_access_grant_receipt;
pub use runtime_spine::relinquish_repo_frontier_hands_route;
pub use runtime_spine::replace_or_append_epiphany_job_binding;
pub use runtime_spine::runtime_continuity_recovery_receipt;
pub use runtime_spine::runtime_current_repo_model;
@ -1061,6 +1062,7 @@ pub use runtime_spine::runtime_has_actionable_imagination_frontier;
pub use runtime_spine::runtime_hello_frame;
pub use runtime_spine::runtime_job_snapshot;
pub use runtime_spine::runtime_latest_hands_receipt_chain_after;
pub use runtime_spine::runtime_latest_repo_frontier_relinquishment;
pub use runtime_spine::runtime_mind_gateway_review;
pub use runtime_spine::runtime_mind_state_commit_receipt;
pub use runtime_spine::runtime_modeling_semantic_projection_input;

View file

@ -249,6 +249,18 @@ pub fn derive_repo_model_patch(
));
}
}
epiphany_state_model::RepoModelPatchPurpose::RelinquishFrontierRoute { .. } => {
if patch.operations.len() != 1
|| !matches!(
patch.operations[0],
RepoModelPatchOperation::RetireFrontier { .. }
)
{
return Err(anyhow!(
"RelinquishFrontierRoute purpose requires exactly one frontier retirement"
));
}
}
_ if patch.operations.iter().any(|operation| {
matches!(operation, RepoModelPatchOperation::AdoptFrontierPlan { .. })
}) =>
@ -417,6 +429,19 @@ fn apply_operation(
.iter_mut()
.find(|item| &item.id == item_id)
.ok_or_else(|| anyhow!("cannot retire missing frontier item {item_id}"))?;
if item.adopted_plan.is_some()
&& !matches!(
purpose,
epiphany_state_model::RepoModelPatchPurpose::RelinquishFrontierRoute {
route_id: _,
hands_refusal_receipt_id: _
}
)
{
return Err(anyhow!(
"only route relinquishment may retire an adopted frontier without a Soul verdict"
));
}
item.status = if superseded_by.is_some() {
RepoFrontierStatus::Superseded
} else {

View file

@ -40,6 +40,12 @@ pub const REPO_FRONTIER_HANDS_AUTHORITY_SCHEMA_VERSION: &str =
pub const REPO_FRONTIER_ROUTE_CONTRACT: &str = "epiphany.repo_frontier_route.v1";
pub const REPO_FRONTIER_HANDS_AUTHORITY_CONTRACT: &str =
"epiphany.repo_frontier_hands_authority.v0";
pub const REPO_FRONTIER_RELINQUISHMENT_RECEIPT_TYPE: &str =
"epiphany.mind.repo_frontier_relinquishment_receipt";
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_MODELING_REQUEST_TYPE: &str =
"epiphany.modeling.repo_frontier_verdict_request";
pub const REPO_FRONTIER_MODELING_REQUEST_SCHEMA_VERSION: &str =
@ -900,6 +906,38 @@ pub struct RepoFrontierHandsAuthority {
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.mind.repo_frontier_relinquishment_receipt",
schema = "RepoFrontierRelinquishmentReceipt"
)]
pub struct RepoFrontierRelinquishmentReceipt {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub hands_refusal_receipt_id: String,
#[cultcache(key = 3)]
pub route_id: String,
#[cultcache(key = 4)]
pub frontier_item_id: String,
#[cultcache(key = 5)]
pub previous_model_revision: u64,
#[cultcache(key = 6)]
pub previous_model_hash: String,
#[cultcache(key = 7)]
pub admitted_model_revision: u64,
#[cultcache(key = 8)]
pub admitted_model_hash: String,
#[cultcache(key = 9)]
pub model_admission_receipt_id: String,
#[cultcache(key = 10)]
pub relinquished_at: String,
#[cultcache(key = 11)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.mind.repo_model_admission_review",
@ -941,6 +979,7 @@ pub struct RepoModelAdmissionReview {
pub enum RepoModelAdmissionSource {
WorkerResult { result_id: String, job_id: String },
FrontierPlanDecision { decision_id: String },
HandsRelinquishment { receipt_id: String },
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]

View file

@ -83,9 +83,9 @@ use crate::repo_model_gateway::{
RepoFrontierPlanningLaunchBinding, RepoFrontierPlanningLifecycle,
RepoFrontierPlanningLifecycleStage, RepoFrontierPlanningRequest,
RepoFrontierProposalModelingLaunchBinding, RepoFrontierProposalModelingRequest,
RepoFrontierRoute, RepoFrontierVerdictDisposition, RepoFrontierWorkProposal,
RepoModelAdmissionReceipt, RepoModelAdmissionReview, RepoModelClaimChallenge,
RepoModelClaimRepairFrontierRef, RepoModelClaimRepairLaunchBinding,
RepoFrontierRelinquishmentReceipt, RepoFrontierRoute, RepoFrontierVerdictDisposition,
RepoFrontierWorkProposal, RepoModelAdmissionReceipt, RepoModelAdmissionReview,
RepoModelClaimChallenge, RepoModelClaimRepairFrontierRef, RepoModelClaimRepairLaunchBinding,
RepoModelClaimRepairRequest, RepoModelMigrationReceipt, RuntimeRepositoryDomainBinding,
};
use crate::soul_gateway::SoulVerdictReceipt;
@ -900,6 +900,8 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
cache.register_entry_type::<RepoModelClaimRepairLaunchBinding>()?;
cache.register_entry_type::<RepoFrontierRoute>()?;
cache.register_entry_type::<RepoFrontierHandsAuthority>()?;
cache.register_entry_type::<HandsActionRefusalReceipt>()?;
cache.register_entry_type::<RepoFrontierRelinquishmentReceipt>()?;
cache.register_entry_type::<RepoFrontierModelingRequest>()?;
cache.register_entry_type::<RepoFrontierWorkProposal>()?;
cache.register_entry_type::<RepoFrontierAutonomousProposalBinding>()?;
@ -2725,6 +2727,11 @@ pub fn commit_repo_model_admission(
"frontier plan adoption is Mind-owned and cannot enter through generic repo model admission"
));
}
crate::RepoModelPatchPurpose::RelinquishFrontierRoute { .. } => {
return Err(anyhow!(
"frontier route relinquishment is a Mind-owned 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()
@ -7019,6 +7026,251 @@ pub fn put_repo_frontier_hands_authority(
}
}
/// Atomically records Hands' inability to act under an exact route and lets
/// Mind retire that route's frontier. The historical route and authority stay
/// immutable, while the admitted model revision makes them structurally stale.
pub fn relinquish_repo_frontier_hands_route(
store_path: impl AsRef<Path>,
intent_id: &str,
review_id: &str,
refusal_receipt_id: &str,
missing_required_paths: Vec<String>,
summary: String,
relinquished_at: String,
) -> Result<RepoFrontierRelinquishmentReceipt> {
let store_path = store_path.as_ref();
validate_non_empty(intent_id, "Hands intent id")?;
validate_non_empty(review_id, "Hands review id")?;
validate_non_empty(refusal_receipt_id, "Hands refusal receipt id")?;
validate_non_empty(&summary, "Hands refusal summary")?;
if !safe_sorted_unique_paths(&missing_required_paths) || missing_required_paths.is_empty() {
return Err(anyhow!(
"Hands refusal requires non-empty safe missing paths in strict sorted order"
));
}
chrono::DateTime::parse_from_rfc3339(&relinquished_at)
.map_err(|_| anyhow!("Hands refusal timestamp must be RFC3339"))?;
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
require_identity(&cache)?;
if let Some(existing) = cache.get::<HandsActionRefusalReceipt>(refusal_receipt_id)? {
if existing.intent_id != intent_id
|| existing.review_id != review_id
|| existing.missing_required_paths != missing_required_paths
|| existing.summary != summary
|| existing.refused_at != relinquished_at
{
return Err(anyhow!("Hands refusal receipt ids are immutable"));
}
let matches = cache
.get_all::<RepoFrontierRelinquishmentReceipt>()?
.into_iter()
.filter(|receipt| receipt.hands_refusal_receipt_id == existing.receipt_id)
.collect::<Vec<_>>();
return match matches.as_slice() {
[receipt] => Ok(receipt.clone()),
_ => Err(anyhow!(
"Hands refusal replay lost its unique Mind relinquishment receipt"
)),
};
}
let authorities = cache
.get_all::<RepoFrontierHandsAuthority>()?
.into_iter()
.filter(|authority| {
authority.hands_intent_id == intent_id && authority.hands_review_id == review_id
})
.collect::<Vec<_>>();
let [authority] = authorities.as_slice() else {
return Err(anyhow!(
"Hands refusal requires exactly one current route authority"
));
};
validate_repo_frontier_hands_authority_chain(&cache, authority)?;
let route = cache
.get::<RepoFrontierRoute>(&authority.route_id)?
.ok_or_else(|| anyhow!("Hands refusal lost its route"))?;
if missing_required_paths.iter().all(|path| {
route.source_scope.iter().any(|scope| {
path == scope || path.starts_with(&format!("{}/", scope.trim_end_matches(['/', '\\'])))
})
}) {
return Err(anyhow!(
"Hands refusal must identify at least one required path outside the adopted route scope"
));
}
let has_consequence = cache
.get_all::<HandsPatchReceipt>()?
.iter()
.any(|receipt| receipt.intent_id == intent_id)
|| cache
.get_all::<HandsCommandReceipt>()?
.iter()
.any(|receipt| receipt.intent_id == intent_id)
|| cache
.get_all::<HandsCommitReceipt>()?
.iter()
.any(|receipt| receipt.intent_id == intent_id)
|| cache
.get_all::<HandsPrReceipt>()?
.iter()
.any(|receipt| receipt.intent_id == intent_id);
if has_consequence {
return Err(anyhow!(
"Hands cannot relinquish a route after mutation consequences exist"
));
}
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!("Hands refusal 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!("Hands refusal route is no longer current"));
}
let refusal = HandsActionRefusalReceipt {
schema_version: HANDS_ACTION_REFUSAL_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: refusal_receipt_id.to_string(),
route_id: route.route_id.clone(),
authority_id: authority.authority_id.clone(),
intent_id: intent_id.to_string(),
review_id: review_id.to_string(),
substrate_gate_grant_receipt_id: authority.substrate_grant_receipt_id.clone(),
model_revision: route.model_revision,
model_hash: route.model_hash.clone(),
frontier_item_id: route.frontier_item_id.clone(),
frontier_item_hash: route.frontier_item_hash.clone(),
missing_required_paths: missing_required_paths.clone(),
summary: summary.clone(),
refused_at: relinquished_at.clone(),
contract: HANDS_ACTION_REFUSAL_RECEIPT_CONTRACT.into(),
};
let relinquishment_id = format!(
"repo-frontier-relinquishment-{:x}",
Sha256::digest(format!("{}:{}", route.route_id, refusal.receipt_id).as_bytes())
);
let patch = crate::RepoModelPatch {
patch_id: format!("repo-frontier-relinquishment-patch-{}", refusal.receipt_id),
base_revision: current.model_revision,
base_hash: current_hash.clone(),
applied_at: relinquished_at.clone(),
purpose: crate::RepoModelPatchPurpose::RelinquishFrontierRoute {
route_id: route.route_id.clone(),
hands_refusal_receipt_id: refusal.receipt_id.clone(),
},
operations: vec![crate::RepoModelPatchOperation::RetireFrontier {
item_id: route.frontier_item_id.clone(),
retired_at: Some(relinquished_at.clone()),
superseded_by: None,
}],
};
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_id_value = format!("repo-model-review-{relinquishment_id}");
let admission_id = format!("repo-model-admission-{relinquishment_id}");
let source = crate::RepoModelAdmissionSource::HandsRelinquishment {
receipt_id: refusal.receipt_id.clone(),
};
let review = RepoModelAdmissionReview {
schema_version: REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION.into(),
review_id: review_id_value.clone(),
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(), refusal.receipt_id.clone()],
reviewed_at: relinquished_at.clone(),
contract: REPO_MODEL_ADMISSION_CONTRACT.into(),
repository_body_observation_basis: None,
admission_source: Some(source.clone()),
};
let admission = RepoModelAdmissionReceipt {
schema_version: REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: admission_id.clone(),
review_id: review_id_value,
result_id: None,
patch_id: patch.patch_id,
patch_sha256,
previous_revision: current.model_revision,
previous_hash: current_hash,
admitted_revision: next.model_revision,
admitted_hash: next.model_hash.clone(),
admitted_at: relinquished_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: Some(source),
};
let relinquishment = RepoFrontierRelinquishmentReceipt {
schema_version: crate::REPO_FRONTIER_RELINQUISHMENT_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: relinquishment_id,
hands_refusal_receipt_id: refusal.receipt_id.clone(),
route_id: route.route_id,
frontier_item_id: route.frontier_item_id,
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_id,
relinquished_at: relinquished_at.clone(),
contract: crate::REPO_FRONTIER_RELINQUISHMENT_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(&refusal.receipt_id, &refusal)?.0,
cache.prepare_entry(&review.review_id, &review)?.0,
cache.prepare_entry(&admission.receipt_id, &admission)?.0,
cache
.prepare_entry(&relinquishment.receipt_id, &relinquishment)?
.0,
cache
.prepare_entry(&obligation.obligation_id, &obligation)?
.0,
];
if !backing.compare_and_swap_batch(&[current_envelope], writes)? {
return relinquish_repo_frontier_hands_route(
store_path,
intent_id,
review_id,
refusal_receipt_id,
missing_required_paths,
summary,
relinquished_at,
);
}
Ok(relinquishment)
}
pub fn put_repo_frontier_verification_request(
store_path: impl AsRef<Path>,
request: &RepoFrontierVerificationRequest,
@ -7157,6 +7409,20 @@ pub fn runtime_repo_frontier_route(
cache.get::<RepoFrontierRoute>(route_id)
}
pub fn runtime_latest_repo_frontier_relinquishment(
store_path: impl AsRef<Path>,
) -> Result<Option<RepoFrontierRelinquishmentReceipt>> {
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
let mut receipts = cache.get_all::<RepoFrontierRelinquishmentReceipt>()?;
receipts.sort_by(|left, right| {
left.relinquished_at
.cmp(&right.relinquished_at)
.then_with(|| left.receipt_id.cmp(&right.receipt_id))
});
Ok(receipts.pop())
}
pub fn commit_repo_frontier_modeling_request(
store_path: impl AsRef<Path>,
acceptance: &epiphany_state_model::EpiphanyAcceptanceReceipt,
@ -8782,6 +9048,18 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
vec![],
vec!["Hands refusal receipts preserve why an action intent was denied."],
),
mutation_contract(
crate::REPO_FRONTIER_RELINQUISHMENT_RECEIPT_TYPE,
crate::REPO_FRONTIER_RELINQUISHMENT_RECEIPT_SCHEMA_VERSION,
vec![
CultNetDocumentOperation::Snapshot,
CultNetDocumentOperation::ReceiptWatch,
],
CultNetMutationAuthority::ReadOnly,
vec![],
vec![],
vec!["Mind relinquishment receipts prove that an exact Hands refusal retired route authority without a repository consequence."],
),
mutation_contract(
SOUL_VERIFICATION_REQUEST_TYPE,
SOUL_VERIFICATION_REQUEST_SCHEMA_VERSION,
@ -11457,6 +11735,122 @@ pub(crate) mod tests {
Ok((route, authority))
}
#[test]
fn hands_relinquishment_atomically_retires_route_authority_without_consequences() -> Result<()>
{
let temp = tempdir()?;
let store = temp.path().join("runtime.cc");
initialize_runtime_spine(
&store,
RuntimeSpineInitOptions {
runtime_id: "relinquishment-runtime".to_string(),
display_name: "Relinquishment".to_string(),
created_at: "2026-08-08T12:00:00Z".to_string(),
},
)?;
let paths = vec!["epiphany-core/src/runtime_spine.rs".to_string()];
let grant = crate::substrate_gate_coordinator_implementation_grant(
"relinquishment-grant".to_string(),
"relinquishment-job".to_string(),
paths.clone(),
"2026-08-08T12:00:01Z".to_string(),
);
put_substrate_gate_repo_access_grant_receipt(&store, &grant)?;
let intent = HandsActionIntent {
schema_version: HANDS_ACTION_INTENT_SCHEMA_VERSION.to_string(),
intent_id: "relinquishment-intent".to_string(),
runtime_job_id: grant.runtime_job_id.clone(),
binding_id: grant.binding_id.clone(),
role: grant.role.clone(),
authority_scope: grant.authority_scope.clone(),
requested_action: "patch".to_string(),
requested_paths: paths,
substrate_gate_grant_receipt_id: grant.receipt_id.clone(),
requested_at: "2026-08-08T12:00:02Z".to_string(),
contract: "test".to_string(),
frontier_route_id: String::new(),
plan_candidate_sha256: String::new(),
plan_action: String::new(),
};
put_hands_action_intent(&store, &intent)?;
let review = crate::hands_action_review_for_intent(
"relinquishment-review".to_string(),
&intent,
"approved".to_string(),
vec!["patch".to_string()],
vec!["bounded route".to_string()],
"2026-08-08T12:00:03Z".to_string(),
);
put_hands_action_review(&store, &review)?;
let (route, authority) =
admit_route_and_authorize_hands(&store, &intent, &review, "relinquishment")?;
let before = runtime_current_repo_model(&store)?.expect("current model");
assert!(
relinquish_repo_frontier_hands_route(
&store,
&intent.intent_id,
&review.review_id,
"hands-refusal-not-a-gap",
vec!["epiphany-core/src/runtime_spine.rs".to_string()],
"This path was already authorized.".to_string(),
"2026-08-08T12:00:04Z".to_string(),
)
.is_err()
);
assert_eq!(runtime_current_repo_model(&store)?.unwrap(), before);
let receipt = relinquish_repo_frontier_hands_route(
&store,
&intent.intent_id,
&review.review_id,
"hands-refusal-relinquishment",
vec!["epiphany-state-model/src/lib.rs".to_string()],
"The adopted path ceiling cannot express the required authority transfer.".to_string(),
"2026-08-08T12:00:04Z".to_string(),
)?;
let after = runtime_current_repo_model(&store)?.expect("current model");
assert_eq!(receipt.route_id, route.route_id);
assert_eq!(receipt.previous_model_revision, before.model_revision);
assert_eq!(receipt.admitted_model_revision, before.model_revision + 1);
assert_eq!(after.model_revision, receipt.admitted_model_revision);
assert_eq!(
after
.frontier
.iter()
.find(|item| item.id == route.frontier_item_id)
.expect("retained frontier")
.status,
crate::RepoFrontierStatus::Retired
);
assert!(!runtime_has_actionable_hands_frontier(&store)?);
assert!(put_repo_frontier_hands_authority(&store, &authority).is_err());
assert_eq!(
relinquish_repo_frontier_hands_route(
&store,
&intent.intent_id,
&review.review_id,
"hands-refusal-relinquishment",
vec!["epiphany-state-model/src/lib.rs".to_string()],
"The adopted path ceiling cannot express the required authority transfer."
.to_string(),
"2026-08-08T12:00:04Z".to_string(),
)?,
receipt
);
assert!(
relinquish_repo_frontier_hands_route(
&store,
&intent.intent_id,
&review.review_id,
"hands-refusal-relinquishment",
vec!["epiphany-state-model/src/lib.rs".to_string()],
"collision".to_string(),
"2026-08-08T12:00:04Z".to_string(),
)
.is_err()
);
Ok(())
}
struct FrontierVerdictFixture {
store: std::path::PathBuf,
route: RepoFrontierRoute,
@ -11650,6 +12044,34 @@ pub(crate) mod tests {
})
}
#[test]
fn hands_relinquishment_refuses_to_erase_existing_consequences() -> Result<()> {
let temp = tempdir()?;
let fixture = frontier_verdict_fixture(temp.path(), "relinquish-after-work", "pass")?;
let mut cache = runtime_spine_cache(&fixture.store)?;
cache.pull_all_backing_stores()?;
let authority = cache
.get_all::<RepoFrontierHandsAuthority>()?
.into_iter()
.find(|authority| authority.route_id == fixture.route.route_id)
.expect("route authority");
let before = fs::read(&fixture.store)?;
assert!(
relinquish_repo_frontier_hands_route(
&fixture.store,
&authority.hands_intent_id,
&authority.hands_review_id,
"hands-refusal-after-consequence",
vec!["epiphany-state-model/src/lib.rs".to_string()],
"Too late to claim no consequence.".to_string(),
"2026-08-08T12:00:09Z".to_string(),
)
.is_err()
);
assert_eq!(fs::read(&fixture.store)?, before);
Ok(())
}
fn incorporation_result_and_review(
fixture: &FrontierVerdictFixture,
suffix: &str,
@ -12170,6 +12592,9 @@ pub(crate) mod tests {
crate::RepoModelPatchPurpose::AdoptFrontierPlan { .. } => {
vec!["adopt".to_string()]
}
crate::RepoModelPatchPurpose::RelinquishFrontierRoute { .. } => {
vec!["relinquish".to_string()]
}
};
review.patch_id = patch.patch_id.clone();
review.patch_sha256 = format!("{:x}", Sha256::digest(&bytes));

View file

@ -867,6 +867,10 @@ pub enum RepoModelPatchPurpose {
result_id: String,
candidate_id: String,
},
RelinquishFrontierRoute {
route_id: String,
hands_refusal_receipt_id: String,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS)]

View file

@ -1331,29 +1331,30 @@ the continuity checkpoint deterministically from accepted RepoModel evidence,
or CRRC consumes canonical RepoModel admission directly. Canonical Imagination
and dedicated Mind must adopt the choice before Hands changes the seam.
Fresh v44 then proved that planning path through canonical Imagination and
dedicated Mind adoption. Inspection at the Hands boundary found the adopted
safe-path set omitted `epiphany-core/src/bin/epiphany-mvp-status.rs`, the actual
composition owner. The gate correctly forbids editing it. The route cannot yet
return this falsified plan to planning authority: the Hands contract catalogs
an action-refusal receipt, but no typed record, writer, CLI transition, or
frontier lifecycle effect implements it. A route currently terminates only
after a complete mutation, verification, Soul verdict, and Modeling
incorporation chain. Hands must gain a typed refusal/relinquish consequence
before the checkpoint repair can continue without fabricating work.
Fresh v49 proves the current planning path through canonical Imagination and
dedicated Mind adoption. Its six safe paths are the complete implementation
owner set at that revision; the previously named vendored app-server owner does
not exist. The route is nevertheless preserved as incomplete evidence because
the machine itself lacked the newly required relinquishment transaction when
Mind adopted that plan. Historical route authority is never widened after the
fact.
The repair boundary is split deliberately. Hands owns an immutable refusal
receipt bound to the exact route, action intent, review, adopted-plan digest,
and current model/frontier hashes; it may state that inspection proved the
authorized path ceiling insufficient, but it may not revise RepoModel. Mind
owns the companion frontier transition: after validating exactly one matching
Hands refusal against the still-current route and model, it may retire or
supersede that frontier item and admit the revised model through the normal
model CAS. The route remains historical selection evidence and is not mutated
into a second lifecycle owner. Evolution remains forbidden from bypassing a
current route, and the full consequence/Soul path remains the only route to a
`Resolved` frontier. The old route can neither authorize edits after
relinquishment nor be hidden by a later repair loop.
The live repair boundary is split deliberately. `hands_gateway.rs` defines the
immutable refusal receipt. `runtime_spine.rs::relinquish_repo_frontier_hands_route`
requires exactly one still-current route/authority/intent/review/grant chain,
requires at least one safe missing path outside the adopted scope, and refuses
to run after patch, command, commit, or PR consequences exist. Hands attests
inability; it does not revise RepoModel. In the same compare-and-swap, Mind
writes its review and admission receipts, retires the exact frontier through
`RepoModelPatchPurpose::RelinquishFrontierRoute`, emits the next Modeling
projection obligation, and records the companion relinquishment receipt. The
route and authority remain immutable historical evidence. Their old
model revision/hash can no longer validate after the retirement admission, so
they are structurally unable to authorize edits. Native status projects the
latest relinquishment; `epiphany-hands-action record-refusal` is the operator
mouth. Generic Modeling admission explicitly rejects this Mind-owned purpose,
and the full consequence/Soul path remains the only route to a `Resolved`
frontier.
Planning failure has two adjacent authorities. The generic runtime job owns
process and transport terminal status. The typed role result owns what Self may

View file

@ -175,8 +175,39 @@ Self derived exact Hands route
`repo-frontier-route-d4d595821804c3f5bbe24d06084762ed19c3185a945827dfa6b10c53df798e2e`.
The operator-safe gate is
`.epiphany-dogfood/v49-hands-gate-r7/coordinator-summary.json`. Its six paths
include `epiphany-mvp-status.rs` but omit the app-server projection owner after
the proposal Modeling worker's only failed source read. Do not mutate source
under this incomplete gate. Preserve v49 and implement the missing typed
relinquishment path as a labeled supervisor intervention across all mapped
owners, then exercise it against a fresh incomplete route.
are the complete implementation owner set at that revision. The earlier claim
that `vendor/codex/codex-rs/app-server/src/epiphany.rs` was an omitted owner was
stale archaeology: that source does not exist and the vendored app-server has
no Epiphany projection. Do not mutate source under the historical v49 route,
because the newly discovered relinquishment transaction was never part of its
adopted plan. Preserve v49 and implement the missing typed relinquishment path
as a labeled supervisor intervention across the state model and real six-file
owner set, then exercise it against a fresh incomplete route.
The labeled supervisor implementation is now local. Hands persists
`HandsActionRefusalReceipt`; Mind atomically retires the exact frontier and
writes review, admission, projection-obligation, and
`RepoFrontierRelinquishmentReceipt` companions through
`relinquish_repo_frontier_hands_route`. The transaction requires one current
route authority, at least one missing safe path outside route scope, and zero
patch/command/commit/PR consequences. Exact replay is idempotent; collision,
already-authorized paths, existing consequences, and reuse of the stale route
fail closed. `epiphany-hands-action record-refusal` is the operator mouth and
native status projects `frontierRelinquishment`.
Focused proof is green: two relinquishment tests, all five existing Hands CLI
tests, both native status tests, and the state-model test pass. A broad
645-test library run passed 642 with one ignored and found two failures in
unchanged test bodies: autonomous direction ingestion expected one pressure
but observed zero, and the route eligibility test attempted to admit a
non-active proposal frontier that current admission already forbids. Both
failures reproduce unchanged in an isolated worktree at pushed HEAD
`d1d9cd10`; they are pre-existing suite corrosion, not regressions from the new
patch-purpose enum. The temporary baseline worktree was removed after the
comparison. Commit and push this pass, then package its exact source once.
The baseline worktree used temporary junctions for gitlink dependencies; its
forced removal cleared the live `cultcache-rs` and `cultnet-rs` submodule
worktrees. The evidence write caught the damage immediately. Both were restored
with `git submodule update --init --checkout` to pinned SHAs `7676a4c2` and
`fab5b31d`, and `git submodule status` is clean. Do not reuse junctioned live
submodule targets for future baseline archives.

Binary file not shown.

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. Exact a6c23872 packages as sha256-5605ff00ffea1fce8f679868ae1081215707ef881cc5795172385aae27f96f0c with witness sha256-d9ed1d70a3e1db42b23761991a961f8e9c60531bd480ba01db7e8669a8bfd0e2. v46/v47 remain sealed negative evidence. Fresh route-free v49 proves proposal Modeling, canonical Imagination, dedicated Mind adoption, terminal planning lifecycle, and exact Hands gate without overrides. Canonicalized candidate ingress succeeded live; test evidence covers typed failure and reviewed immutable retries. The adopted v49 path ceiling includes the gateway, Hands CLI, runtime spine, and status composition but omits app-server projection after that source read failed, so mutation is not yet truthful. Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open.
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact a6c23872 packages as sha256-5605ff00ffea1fce8f679868ae1081215707ef881cc5795172385aae27f96f0c with witness sha256-d9ed1d70a3e1db42b23761991a961f8e9c60531bd480ba01db7e8669a8bfd0e2. v46/v47 remain sealed negative evidence. Fresh route-free v49 proves proposal Modeling, canonical Imagination, dedicated Mind adoption, terminal planning lifecycle, and exact Hands gate without overrides. The historical v49 route remains immutable and cannot authorize the new relinquishment implementation. A labeled supervisor pass now gives Hands a typed refusal and Mind one atomic route-retirement admission; focused tests prove replay, collision, insufficient-gap, old-authority, and existing-consequence negatives. Persona consequence, retention, endurance, and Linux/Yggdrasil cognition remain open.
operational_state:
local_worktree: v49_planning_proven_supervisor_relinquishment_implementation_next
local_worktree: supervisor_relinquishment_implemented_verification_and_commit_next
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: v49 proves the repaired live planning circuit through terminal Mind adoption. Its exact Hands gate still omits vendor/codex/codex-rs/app-server/src/epiphany.rs after the proposal Modeling worker failed that source read. The cataloged Hands action-refusal receipt still has no typed persistence or route-lifecycle transition, so v49 cannot lawfully relinquish its incomplete route and the source must not be mutated under that gate.
next_action: Preserve v49 as sealed planning and incomplete-gate evidence. Under the operator-authorized labeled supervisor intervention, implement the mapped Hands refusal receipt and Mind-owned frontier/route retirement path across the gateway, CLI, runtime spine, status composition, and app-server projection owners. Prove exact binding, replay refusal, stale model/frontier, old-route-authority, and no-fabricated-consequence negatives. Package, exercise the refusal against a fresh incomplete plan, then replay sealed v44 through corrected replanning, CRRC, accepted Reorientation, Continuity recovery, and Soul closure.
unresolved_authority: The supervisor implementation is local and verified but not yet committed, pushed, packaged, or exercised against a live coordinator-created route. The broad 645-test library run passed 642 with one ignored. Its two failures (`autonomous_direction_option_is_atomically_bound_and_selected_for_modeling` and `repo_frontier_route_refuses_unadmitted_and_ineligible_models`) reproduce unchanged against isolated pushed HEAD d1d9cd10, so they are pre-existing suite corrosion rather than relinquishment regressions. Focused relinquishment, Hands CLI, status, and state-model checks pass.
next_action: Commit and push the completed supervisor relinquishment pass with the isolated d1d9cd10 baseline comparison as its failure receipt. Package the exact source once, exercise `record-refusal` against a fresh incomplete coordinator route, prove native status and the retired model authority in-process, then replan and continue CRRC, accepted Reorientation, Continuity recovery, and Soul closure.
active_subgoals:
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.