Delete Discord operator control plane

This commit is contained in:
Meta Vens 2026-08-22 06:16:40 +02:00
commit 39adf3a4d9
27 changed files with 89 additions and 4143 deletions

View file

@ -23,7 +23,6 @@ use epiphany_core::EpiphanyProcessObservation as ProcessObservation;
use epiphany_core::MemorySemanticProjectionInput;
use epiphany_core::agent_memory_semantic_projection_input;
use epiphany_core::authenticate_epiphany_cultmesh_semantic_projector_launch;
use epiphany_core::authenticate_operator_command_service_health;
use epiphany_core::authenticate_resident_provider_pair;
use epiphany_core::epiphany_cultmesh_daemon_poke_intent_from_status;
use epiphany_core::epiphany_cultmesh_daemon_poke_receipt_for_intent;
@ -43,7 +42,6 @@ use epiphany_core::load_latest_epiphany_cultmesh_daemon_service_lifecycle_receip
use epiphany_core::migrate_memory_semantic_projection_attempts_v0;
use epiphany_core::observe_native_process as observe_process;
use epiphany_core::query_epiphany_local_verse_context;
use epiphany_core::read_operator_command_trust_anchor;
use epiphany_core::retire_epiphany_cultmesh_operator_status_documents;
use epiphany_core::retire_memory_semantic_projection_claims_v0;
use epiphany_core::retire_orphaned_memory_semantic_projection_attempts_v0;
@ -1000,61 +998,6 @@ fn publish_managed_service_iteration_health(
contradictions
.push("resident health requires both heartbeat and Self provider stores".into());
}
match (
args.operator_service_readiness_store.as_deref(),
args.operator_executor_trust_anchor.as_deref(),
args.operator_service_bind.as_deref(),
) {
(Some(store), Some(anchor_path), Some(bind)) => {
expected += 1;
let result = read_operator_command_trust_anchor(anchor_path).and_then(|anchor| {
authenticate_operator_command_service_health(
store,
&args.runtime_id,
&release.release_id,
authenticated_release_witness_sha256,
&release.source_commit_sha,
bind,
&anchor,
Utc::now().timestamp_millis().max(0) as u64,
15_000,
)
});
match result {
Ok(health) => {
let expected_executable =
epiphany_packaged_release_binary_path(release, "operator-command")
.and_then(|path| fs::canonicalize(path).map_err(Into::into));
let observed = capture_process_instance(health.process_id);
match (expected_executable, observed) {
(Ok(expected_executable), Ok(process))
if process.creation_token == health.process_creation_token
&& process.executable_path == expected_executable
&& process.executable_path.display().to_string()
== health.process_executable_path =>
{
terminal_current += 1
}
(Ok(_), Ok(_)) => contradictions.push(
"operator service process identity is not the signed packaged sibling"
.into(),
),
(Err(error), _) | (_, Err(error)) => contradictions.push(format!(
"operator service process cannot be authenticated: {error:#}"
)),
}
}
Err(error) => contradictions.push(format!(
"operator service signed readiness is invalid: {error:#}"
)),
}
}
(None, None, None) => {}
_ => {
expected += 1;
contradictions.push("operator service health requires readiness store, executor trust anchor, and exact bind".into());
}
}
for service_id in required {
let Some(policy) = policies
.iter()
@ -5297,9 +5240,6 @@ struct Args {
resident_heartbeat_store: Option<PathBuf>,
resident_self_store: Option<PathBuf>,
resident_provider_stale_seconds: u64,
operator_service_readiness_store: Option<PathBuf>,
operator_executor_trust_anchor: Option<PathBuf>,
operator_service_bind: Option<String>,
}
impl Args {
@ -5359,9 +5299,6 @@ impl Args {
let mut resident_heartbeat_store = None;
let mut resident_self_store = None;
let mut resident_provider_stale_seconds = 180_u64;
let mut operator_service_readiness_store = None;
let mut operator_executor_trust_anchor = None;
let mut operator_service_bind = None;
while let Some(arg) = values.next() {
match arg.as_str() {
@ -5600,26 +5537,6 @@ impl Args {
anyhow::bail!("--resident-provider-stale-seconds must be positive");
}
}
"--operator-service-readiness-store" => {
operator_service_readiness_store =
Some(PathBuf::from(values.next().context(
"missing --operator-service-readiness-store value",
)?))
}
"--operator-executor-trust-anchor" => {
operator_executor_trust_anchor = Some(PathBuf::from(
values
.next()
.context("missing --operator-executor-trust-anchor value")?,
))
}
"--operator-service-bind" => {
operator_service_bind = Some(
values
.next()
.context("missing --operator-service-bind value")?,
)
}
other => anyhow::bail!("unknown argument {other:?}"),
}
}
@ -5767,19 +5684,6 @@ impl Args {
);
}
}
let operator_health_fields = [
operator_service_readiness_store.is_some(),
operator_executor_trust_anchor.is_some(),
operator_service_bind.is_some(),
];
if operator_health_fields.into_iter().any(|value| value)
&& !operator_health_fields.into_iter().all(|value| value)
{
anyhow::bail!(
"operator service health store, executor trust anchor, and bind are all-or-none"
);
}
Ok(Self {
command,
store,
@ -5834,9 +5738,6 @@ impl Args {
resident_heartbeat_store,
resident_self_store,
resident_provider_stale_seconds,
operator_service_readiness_store,
operator_executor_trust_anchor,
operator_service_bind,
})
}
}

View file

@ -1,124 +0,0 @@
use anyhow::{Result, anyhow};
use epiphany_core::{
RepoFrontierExecutionAmendment, RepoFrontierPlanDecisionReceipt, RepoFrontierRoute,
amend_repo_frontier_execution, assemble_repo_model_view, runtime_spine_cache,
validate_frontier_plan_decision_chain,
};
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" && command != "inspect-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")?;
if command == "inspect-frontier-execution" {
let mut cache = runtime_spine_cache(&store)?;
cache.pull_all_backing_stores()?;
let routes = cache.get_all::<RepoFrontierRoute>()?;
let available = routes
.iter()
.map(|route| route.route_id.as_str())
.collect::<Vec<_>>()
.join(", ");
let route = routes
.into_iter()
.find(|route| route.route_id == route_id)
.ok_or_else(|| anyhow!("route {route_id} does not exist; available: {available}"))?;
let plan = route
.adopted_plan
.as_ref()
.ok_or_else(|| anyhow!("route {route_id} has no adopted plan"))?;
let current_model = assemble_repo_model_view(&store)?;
let mut plan_decisions = cache
.get_all::<RepoFrontierPlanDecisionReceipt>()?
.into_iter()
.filter(|decision| decision.planning_request_id == plan.planning_request_id)
.collect::<Vec<_>>();
if plan_decisions.len() != 1 {
return Err(anyhow!(
"route {route_id} requires exactly one typed plan decision; found {}",
plan_decisions.len()
));
}
let plan_decision = plan_decisions.pop().expect("one decision checked above");
validate_frontier_plan_decision_chain(&plan_decision, &route, &current_model)
.map_err(anyhow::Error::msg)?;
println!(
"{}",
serde_json::to_string_pretty(&serde_json::json!({
"routeId": route.route_id,
"modelProjectionDigest": route.model_projection_digest,
"modelSourceDocuments": route.model_source_documents,
"frontierPlanDecisionId": plan_decision.decision_id,
"frontierPlanDecision": plan_decision,
"frontierItemId": route.frontier_item_id,
"frontierItemHash": route.frontier_item_hash,
"originalAction": plan.action,
"originalCommand": plan.command,
"effectiveAction": plan.effective_action(),
"effectiveCommand": plan.effective_command(),
"executionAmendment": plan.execution_amendment,
}))?
);
return Ok(());
}
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-frontier-execution inspect-frontier-execution --store PATH --route-id ID\n epiphany-frontier-execution 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

@ -930,7 +930,6 @@ mod tests {
stop_conditions: vec!["A check fails.".into()],
rollback_steps: vec!["Revert the fixture change.".into()],
commit_message: "Exercise exact Hands authority".into(),
execution_amendment: None,
}),
status: RepoFrontierStatus::Active,
..Default::default()

View file

@ -1669,7 +1669,6 @@ fn record_hands_implementation_gate(
"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()),

View file

@ -1,13 +0,0 @@
use anyhow::{Context, Result};
use epiphany_core::write_operator_command_interop_fixture;
use std::path::PathBuf;
fn main() -> Result<()> {
let output = std::env::args_os()
.nth(1)
.map(PathBuf::from)
.context("usage: epiphany-operator-command-fixture <output-directory>")?;
let manifest = write_operator_command_interop_fixture(&output)?;
println!("{}", serde_json::to_string_pretty(&manifest)?);
Ok(())
}

View file

@ -1,235 +0,0 @@
use anyhow::{Context, Result, anyhow, bail};
use epiphany_core::{
OperatorCapability, OperatorCommandPolicy, OperatorCommandServiceConfig,
OperatorCommandServiceReadiness, OperatorStatusProviderHealthConfig, open_host_identity_at,
read_operator_command_trust_anchor, serve_operator_command_rudp,
};
use std::collections::BTreeMap;
use std::net::{SocketAddr, UdpSocket};
use std::path::PathBuf;
fn main() -> Result<()> {
let args = Args::parse(std::env::args().skip(1))?;
let signer = open_host_identity_at(&args.executor_identity_store)?;
let config = OperatorCommandServiceConfig {
command_store: args.command_store.clone(),
local_verse_store: args.local_verse_store.clone(),
resident_self_store: args.resident_self_store.clone(),
runtime_store: args.runtime_store.clone(),
policy: OperatorCommandPolicy {
runtime_id: args.runtime_id.clone(),
discord_guild_id: args.guild_id.clone(),
allowed_channel_ids: args.channel_ids.clone(),
actor_capabilities: args.actor_capabilities.clone(),
max_ttl_seconds: args.max_ttl_seconds,
},
trusted_bifrost_identity: read_operator_command_trust_anchor(&args.bifrost_trust_anchor)?,
provider_health: OperatorStatusProviderHealthConfig {
query_endpoint: args.idunn_provider_query,
idunn_runtime_id: args.idunn_runtime_id.clone(),
trust_anchor_store: args.idunn_projection_anchor.clone(),
admission_store: args.provider_admission_store.clone(),
max_local_age_millis: args.provider_ttl_millis,
deployment_id: args.deployment_id.clone(),
release_id: args.release_id.clone(),
release_witness_sha256: args.release_witness_sha256.clone(),
source_commit: args.source_commit.clone(),
},
};
if args.status_only {
print_readiness(&args, &signer, "configured")?;
return Ok(());
}
let socket = UdpSocket::bind(args.bind).with_context(|| {
format!(
"binding Epiphany operator command RUDP service at {}",
args.bind
)
})?;
print_readiness(&args, &signer, "serving")?;
let health = epiphany_core::OperatorCommandServiceHealthConfig {
store: args.readiness_store.clone(),
bind: args.bind.to_string(),
release_id: args.release_id.clone(),
release_witness_sha256: args.release_witness_sha256.clone(),
source_commit: args.source_commit.clone(),
};
serve_operator_command_rudp(socket, &config, &signer, &health)
}
fn print_readiness(
args: &Args,
signer: &epiphany_core::HostIdentitySigner,
status: &str,
) -> Result<()> {
println!(
"{}",
serde_json::to_string(&OperatorCommandServiceReadiness {
schema_version: "epiphany.operator_command.service_readiness.v0".into(),
status: status.into(),
runtime_id: args.runtime_id.clone(),
bind: args.bind.to_string(),
executor_identity_id: signer.entry().identity_id.clone(),
private_state_exposed: false,
})?
);
Ok(())
}
struct Args {
bind: SocketAddr,
runtime_id: String,
bifrost_trust_anchor: PathBuf,
executor_identity_store: PathBuf,
command_store: PathBuf,
local_verse_store: PathBuf,
resident_self_store: PathBuf,
runtime_store: PathBuf,
guild_id: String,
channel_ids: Vec<String>,
actor_capabilities: BTreeMap<String, Vec<OperatorCapability>>,
max_ttl_seconds: i64,
readiness_store: PathBuf,
release_id: String,
release_witness_sha256: String,
source_commit: String,
deployment_id: String,
idunn_provider_query: SocketAddr,
idunn_runtime_id: String,
idunn_projection_anchor: PathBuf,
provider_admission_store: PathBuf,
provider_ttl_millis: u64,
status_only: bool,
}
impl Args {
fn parse(values: impl Iterator<Item = String>) -> Result<Self> {
let mut values = values.peekable();
let mut fields = BTreeMap::<String, String>::new();
let mut channels = Vec::new();
let mut actors = BTreeMap::new();
let mut status_only = false;
while let Some(flag) = values.next() {
match flag.as_str() {
"--status" => status_only = true,
"--channel-id" => channels.push(values.next().context("missing --channel-id")?),
"--actor-capabilities" => {
let value = values.next().context("missing --actor-capabilities")?;
let (actor, capabilities) = value.split_once('=').context(
"--actor-capabilities must be actor=status,sleep,wake,directive",
)?;
if actor.trim().is_empty() || actors.contains_key(actor) {
bail!("operator actor capability binding is empty or duplicated");
}
let parsed = capabilities
.split(',')
.map(parse_capability)
.collect::<Result<Vec<_>>>()?;
if parsed.is_empty() {
bail!("operator actor requires at least one capability");
}
actors.insert(actor.to_string(), parsed);
}
"--bind"
| "--runtime-id"
| "--bifrost-trust-anchor"
| "--executor-identity-store"
| "--command-store"
| "--local-verse-store"
| "--resident-self-store"
| "--runtime-store"
| "--guild-id"
| "--readiness-store"
| "--release-id"
| "--release-witness-sha256"
| "--source-commit"
| "--deployment-id"
| "--idunn-provider-query"
| "--idunn-runtime-id"
| "--idunn-projection-anchor"
| "--provider-admission-store"
| "--provider-ttl-millis"
| "--max-ttl-seconds" => {
let value = values
.next()
.ok_or_else(|| anyhow!("missing value for {flag}"))?;
if fields.insert(flag.clone(), value).is_some() {
bail!("duplicate operator service argument {flag}");
}
}
_ => bail!("unknown operator service argument {flag}"),
}
}
let required = |name: &str| {
fields
.get(name)
.cloned()
.ok_or_else(|| anyhow!("missing {name}"))
};
if channels.is_empty() || actors.is_empty() {
bail!("operator service requires channels and actor capabilities");
}
let max_ttl_seconds = fields
.get("--max-ttl-seconds")
.map(String::as_str)
.unwrap_or("60")
.parse()?;
if !(1..=60).contains(&max_ttl_seconds) {
bail!("operator service max TTL must be 1..=60 seconds");
}
let provider_ttl_millis = required("--provider-ttl-millis")?.parse()?;
if provider_ttl_millis == 0 {
bail!("provider health TTL must be nonzero");
}
Ok(Self {
bind: required("--bind")?.parse()?,
runtime_id: required("--runtime-id")?,
bifrost_trust_anchor: required("--bifrost-trust-anchor")?.into(),
executor_identity_store: required("--executor-identity-store")?.into(),
command_store: required("--command-store")?.into(),
local_verse_store: required("--local-verse-store")?.into(),
resident_self_store: required("--resident-self-store")?.into(),
runtime_store: required("--runtime-store")?.into(),
guild_id: required("--guild-id")?,
channel_ids: channels,
actor_capabilities: actors,
max_ttl_seconds,
readiness_store: required("--readiness-store")?.into(),
release_id: required("--release-id")?,
release_witness_sha256: required("--release-witness-sha256")?,
source_commit: required("--source-commit")?,
deployment_id: required("--deployment-id")?,
idunn_provider_query: required("--idunn-provider-query")?.parse()?,
idunn_runtime_id: required("--idunn-runtime-id")?,
idunn_projection_anchor: required("--idunn-projection-anchor")?.into(),
provider_admission_store: required("--provider-admission-store")?.into(),
provider_ttl_millis,
status_only,
})
}
}
fn parse_capability(value: &str) -> Result<OperatorCapability> {
match value {
"status" => Ok(OperatorCapability::Status),
"sleep" => Ok(OperatorCapability::Sleep),
"wake" => Ok(OperatorCapability::Wake),
"directive" => Ok(OperatorCapability::Directive),
"reviews" => Ok(OperatorCapability::Reviews),
"review" => Ok(OperatorCapability::Review),
_ => bail!("unknown operator capability {value}"),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parser_has_no_argv_or_store_selector_escape_hatch() {
assert!(Args::parse(["--argv".into(), "whoami".into()].into_iter()).is_err());
assert!(
Args::parse(["--actor-capabilities".into(), "actor=shell".into()].into_iter()).is_err()
);
}
}

View file

@ -4248,7 +4248,7 @@ pub fn default_epiphany_cultmesh_swarm_brake(
}
/// The single runtime brake identity shared by deployment, resident readiness,
/// and authenticated operator commands. A caller identity is provenance, not
/// and local typed control surfaces. A caller identity is provenance, not
/// brake ownership, and must not be substituted into either constant.
pub const EPIPHANY_CANONICAL_SWARM_BRAKE_ID: &str = "epiphany/swarm-brake";
pub const EPIPHANY_CANONICAL_SWARM_BRAKE_OWNER: &str = "epiphany.swarm-brake";

View file

@ -15,14 +15,6 @@ pub fn validate_frontier_plan_decision_chain(
Some(crate::RepoFrontierPlanDecisionSource::MindWorker { result_id, job_id }) => {
!result_id.trim().is_empty() && !job_id.trim().is_empty()
}
Some(crate::RepoFrontierPlanDecisionSource::AuthenticatedOperatorReview {
command_id,
admission_id,
packet_sha256,
source_actor_id,
}) => [command_id, admission_id, packet_sha256, source_actor_id]
.into_iter()
.all(|value| !value.trim().is_empty()),
None => false,
};
let decision_basis = crate::EpiphanyRepoModelBasis {

View file

@ -20,8 +20,6 @@ mod imagination_consideration;
mod memory_graph;
mod mind_contracts;
mod mind_documents;
mod operator_command;
mod operator_command_service;
mod organ_dependencies;
mod packaged_release;
mod persona_conversation;
@ -724,7 +722,6 @@ 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::SEMANTIC_PROJECTION_SCHEMA_VERSION;
@ -776,27 +773,6 @@ pub use memory_graph::validate_memory_semantic_projection_obligation;
pub use mind_contracts::MindCultNetContract;
pub use mind_contracts::default_mind_cultnet_contracts;
pub use mind_documents::*;
pub use operator_command::{
BIFROST_OPERATOR_COMMAND_ADMISSION_SCHEMA_VERSION, BIFROST_OPERATOR_COMMAND_DELIVERY_TYPE,
BifrostOperatorCommandAdmission, LOCAL_OPERATOR_COMMAND_ADMISSION_SCHEMA_VERSION,
LocalAdmittedOperatorCommand, OPERATOR_COMMAND_RESULT_SCHEMA_VERSION, OperatorCapability,
OperatorCommand, OperatorCommandPacket, OperatorCommandPolicy, OperatorCommandResult,
OperatorCommandResultDisposition, admit_and_execute_bifrost_operator_command,
operator_command_admission_signing_payload, operator_command_admission_signing_purpose,
operator_command_packet_sha256,
};
pub use operator_command_service::{
EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_SCHEMA_VERSION,
EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_TYPE, EPIPHANY_OPERATOR_COMMAND_RUDP_CONNECTION_ID,
EpiphanyOperatorCommandResultReceipt, EpiphanyOperatorCommandServiceHealth,
EpiphanyOperatorCommandWireResult, EpiphanyOperatorStatusProviderV2, EpiphanyOperatorStatusV2,
OperatorCommandInteropFixtureManifest, OperatorCommandServiceConfig,
OperatorCommandServiceHealthConfig, OperatorCommandServiceReadiness,
OperatorStatusProviderHealthConfig, authenticate_operator_command_service_health,
execute_operator_command_admission, operator_command_result_receipt_signing_payload,
operator_command_result_receipt_signing_purpose, read_operator_command_trust_anchor,
serve_operator_command_rudp, write_operator_command_interop_fixture,
};
pub use organ_dependencies::EPIPHANY_LAUNCH_ORGAN_CONTRACT_SCHEMA_VERSION;
pub use organ_dependencies::EPIPHANY_ORGAN_DEPENDENCY_SCHEMA_VERSION;
pub use organ_dependencies::EPIPHANY_STANDING_ORGANS;
@ -964,7 +940,6 @@ pub use runtime_spine::RuntimeSpineSessionOptions;
pub use runtime_spine::RuntimeTypedFulfillmentEvidence;
pub use runtime_spine::abandon_unactivated_runtime_worker_process;
pub use runtime_spine::activate_runtime_worker_process;
pub use runtime_spine::amend_repo_frontier_execution;
pub use runtime_spine::append_runtime_event;
pub use runtime_spine::archive_completed_coordinator_session;
pub use runtime_spine::archive_completed_model_session;
@ -975,7 +950,6 @@ pub use runtime_spine::bind_runtime_to_agent_memory_swarm;
pub use runtime_spine::canonical_repo_frontier_plan_candidate_id;
pub use runtime_spine::claim_runtime_worker_process;
pub use runtime_spine::close_runtime_session;
pub use runtime_spine::commit_operator_repo_frontier_plan_review;
pub use runtime_spine::commit_repo_frontier_modeling_request;
pub use runtime_spine::commit_repo_frontier_plan_decision;
pub use runtime_spine::commit_repo_frontier_plan_mind_request;
@ -994,8 +968,6 @@ pub use runtime_spine::model_pass_failure_for_request;
pub use runtime_spine::open_coordinator_run;
pub use runtime_spine::open_runtime_model_execution;
pub use runtime_spine::open_runtime_spine_heartbeat_job;
pub use runtime_spine::operator_repo_frontier_plan_review_is_current;
pub use runtime_spine::pending_repo_frontier_plan_reviews;
pub use runtime_spine::prepare_runtime_spine_heartbeat_job;
pub use runtime_spine::promote_autonomous_direction_options_for_modeling;
pub use runtime_spine::put_coordinator_run_receipt;
@ -1047,7 +1019,6 @@ pub use runtime_spine::runtime_latest_repo_frontier_relinquishment;
pub use runtime_spine::runtime_modeling_semantic_projection_input;
pub use runtime_spine::runtime_registered_document_types;
pub use runtime_spine::runtime_reorient_worker_result;
pub use runtime_spine::runtime_repo_frontier_execution_amendment;
pub use runtime_spine::runtime_repo_frontier_plan_decision;
pub use runtime_spine::runtime_repo_frontier_planning_eligibility;
pub use runtime_spine::runtime_repo_frontier_planning_lifecycle;

View file

@ -27,7 +27,6 @@ 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;

View file

@ -384,7 +384,6 @@ pub(crate) fn register_mind_document_types(cache: &mut CultCache) -> Result<()>
crate::repo_model_documents::register_repo_model_document_types(cache)?;
cache.register_entry_type::<crate::RepoFrontierPlanDecisionReceipt>()?;
cache.register_entry_type::<crate::RepoFrontierRelinquishmentReceipt>()?;
cache.register_entry_type::<crate::RepoFrontierExecutionAmendmentReceipt>()?;
cache.register_entry_type::<crate::AtlasSurfaceOffer>()?;
cache.register_entry_type::<crate::AtlasDependencyClaim>()?;
cache.register_entry_type::<crate::AtlasDependencyVerification>()?;
@ -422,9 +421,6 @@ pub(crate) fn validate_mind_write_envelope(envelope: &CultCacheEnvelope) -> Resu
} else if envelope.r#type == crate::RepoFrontierRelinquishmentReceipt::TYPE {
rmp_serde::from_slice::<crate::RepoFrontierRelinquishmentReceipt>(&envelope.payload)?
.receipt_id
} else if envelope.r#type == crate::RepoFrontierExecutionAmendmentReceipt::TYPE {
rmp_serde::from_slice::<crate::RepoFrontierExecutionAmendmentReceipt>(&envelope.payload)?
.receipt_id
} else if envelope.r#type == crate::AtlasSurfaceOffer::TYPE {
let value: crate::AtlasSurfaceOffer = rmp_serde::from_slice(&envelope.payload)?;
value.validate()?;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -49,10 +49,6 @@ 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 =
@ -729,47 +725,7 @@ pub struct RepoFrontierPlanDecisionReceipt {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
pub enum RepoFrontierPlanDecisionSource {
MindWorker {
result_id: String,
job_id: String,
},
AuthenticatedOperatorReview {
command_id: String,
admission_id: String,
packet_sha256: String,
source_actor_id: String,
},
}
/// Operator-safe identity projection of one current Mind review candidate.
/// Proposal text, commands, paths, and private state deliberately remain in
/// the canonical runtime store owned by Mind.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct RepoFrontierPlanReviewSummary {
pub mind_request_id: String,
pub candidate_id: String,
pub candidate_sha256: String,
pub model_projection_digest: String,
pub model_source_documents: Vec<crate::EpiphanyMindDocumentVersion>,
pub frontier_item_id: String,
pub requested_at: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct RepoFrontierPlanOperatorReview {
pub command_id: String,
pub admission_id: String,
pub packet_sha256: String,
pub source_actor_id: String,
pub mind_request_id: String,
pub candidate_id: String,
pub candidate_sha256: String,
pub expected_model_projection_digest: String,
pub expected_model_source_documents: Vec<crate::EpiphanyMindDocumentVersion>,
pub decision: RepoFrontierPlanDecision,
pub decided_at: String,
MindWorker { result_id: String, job_id: String },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@ -946,49 +902,3 @@ pub struct RepoFrontierRelinquishmentReceipt {
#[cultcache(key = 10)]
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_projection_digest: String,
#[cultcache(key = 7)]
pub previous_model_source_documents: Vec<crate::EpiphanyMindDocumentVersion>,
#[cultcache(key = 8)]
pub admitted_model_projection_digest: String,
#[cultcache(key = 9)]
pub admitted_model_source_documents: Vec<crate::EpiphanyMindDocumentVersion>,
#[cultcache(key = 10)]
pub source_actor_id: String,
#[cultcache(key = 11)]
pub command_id: String,
#[cultcache(key = 12)]
pub admission_id: String,
#[cultcache(key = 13)]
pub packet_sha256: String,
#[cultcache(key = 14)]
pub replacement_action: String,
#[cultcache(key = 15)]
pub replacement_command: String,
#[cultcache(key = 16)]
pub rationale: String,
#[cultcache(key = 17)]
pub amended_at: String,
#[cultcache(key = 18)]
pub contract: String,
}

View file

@ -36,8 +36,6 @@ 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,
@ -59,10 +57,9 @@ use crate::repo_model_gateway::{
REPO_MODEL_CLAIM_CHALLENGE_CONTRACT, REPO_MODEL_CLAIM_CHALLENGE_SCHEMA_VERSION,
RUNTIME_REPOSITORY_DOMAIN_BINDING_CONTRACT, RUNTIME_REPOSITORY_DOMAIN_BINDING_KEY,
RUNTIME_REPOSITORY_DOMAIN_BINDING_SCHEMA_VERSION, RepoFrontierAutonomousProposalBinding,
RepoFrontierExecutionAmendmentReceipt, RepoFrontierHandsAuthority, RepoFrontierModelingRequest,
RepoFrontierNextOrgan, RepoFrontierPlanCandidate, RepoFrontierPlanDecision,
RepoFrontierPlanDecisionReceipt, RepoFrontierPlanMindDecision,
RepoFrontierPlanMindLaunchBinding, RepoFrontierPlanMindRequest,
RepoFrontierHandsAuthority, RepoFrontierModelingRequest, RepoFrontierNextOrgan,
RepoFrontierPlanCandidate, RepoFrontierPlanDecision, RepoFrontierPlanDecisionReceipt,
RepoFrontierPlanMindDecision, RepoFrontierPlanMindLaunchBinding, RepoFrontierPlanMindRequest,
RepoFrontierPlanningCandidateEligibility, RepoFrontierPlanningEligibility,
RepoFrontierPlanningFailureReview, RepoFrontierPlanningLaunchBinding,
RepoFrontierPlanningLifecycle, RepoFrontierPlanningLifecycleStage, RepoFrontierPlanningRequest,
@ -7578,129 +7575,6 @@ pub fn commit_repo_frontier_plan_decision(
enum FrontierPlanDecisionSource<'a> {
MindWorker(&'a str),
Operator(&'a crate::RepoFrontierPlanOperatorReview),
}
/// Read-only, bounded identities for candidates already routed to canonical
/// Mind review. Invalid, stale, or terminal candidates are not projected.
pub fn pending_repo_frontier_plan_reviews(
runtime_store: impl AsRef<Path>,
limit: usize,
) -> Result<Vec<crate::RepoFrontierPlanReviewSummary>> {
if limit == 0 || limit > 25 {
return Err(anyhow!(
"Mind review projection limit must be within 1..=25"
));
}
let mut cache = runtime_spine_cache(runtime_store.as_ref())?;
cache.pull_all_backing_stores()?;
let terminal = cache
.get_all::<RepoFrontierPlanDecisionReceipt>()?
.into_iter()
.map(|receipt| receipt.planning_request_id)
.collect::<std::collections::BTreeSet<_>>();
let mut summaries = Vec::new();
for request in cache.get_all::<RepoFrontierPlanMindRequest>()? {
let Ok((planning, candidate)) = validate_repo_frontier_plan_mind_request(&cache, &request)
else {
continue;
};
if terminal.contains(&planning.request_id) {
continue;
}
summaries.push(crate::RepoFrontierPlanReviewSummary {
mind_request_id: request.request_id,
candidate_id: candidate.candidate_id,
candidate_sha256: request.candidate_sha256,
model_projection_digest: planning.model_projection_digest,
model_source_documents: planning.model_source_documents,
frontier_item_id: planning.frontier_item_id,
requested_at: request.requested_at,
});
}
summaries.sort_by(|a, b| {
a.requested_at
.cmp(&b.requested_at)
.then_with(|| a.mind_request_id.cmp(&b.mind_request_id))
});
summaries.truncate(limit);
Ok(summaries)
}
/// Canonical Mind commit path for an authenticated operator's exact review
/// request. The operator selects a disposition; Mind revalidates the complete
/// immutable candidate and current model before performing the same atomic
/// terminal transition used by a Mind worker.
pub fn commit_operator_repo_frontier_plan_review(
runtime_store: impl AsRef<Path>,
review: &crate::RepoFrontierPlanOperatorReview,
) -> Result<RepoFrontierPlanDecisionReceipt> {
commit_repo_frontier_plan_decision_inner(
runtime_store,
FrontierPlanDecisionSource::Operator(review),
None,
)
}
/// Classifies only operator-visible precondition refusal. Store corruption,
/// decoding failure, and I/O remain errors and must never be fossilized as a
/// terminal Refused command result.
pub fn operator_repo_frontier_plan_review_is_current(
runtime_store: impl AsRef<Path>,
review: &crate::RepoFrontierPlanOperatorReview,
) -> Result<bool> {
let mut cache = runtime_spine_cache(runtime_store.as_ref())?;
cache.pull_all_backing_stores()?;
let Some(request) = cache.get::<RepoFrontierPlanMindRequest>(&review.mind_request_id)? else {
return Ok(false);
};
let (planning, candidate) =
validate_repo_frontier_plan_mind_request_identity(&cache, &request)?;
if review.candidate_id != candidate.candidate_id
|| review.candidate_sha256 != request.candidate_sha256
|| review.expected_model_projection_digest != planning.model_projection_digest
|| review.expected_model_source_documents != planning.model_source_documents
{
return Ok(false);
}
let terminal = cache
.get_all::<RepoFrontierPlanDecisionReceipt>()?
.into_iter()
.filter(|receipt| receipt.planning_request_id == planning.request_id)
.collect::<Vec<_>>();
if !terminal.is_empty() {
if terminal.len() != 1 {
return Err(anyhow!(
"Mind review candidate has multiple terminal decisions"
));
}
let receipt = &terminal[0];
return Ok(receipt.decision == review.decision
&& receipt.candidate_id == review.candidate_id
&& receipt.candidate_sha256 == review.candidate_sha256
&& receipt.model_projection_digest == review.expected_model_projection_digest
&& receipt.model_source_documents == review.expected_model_source_documents
&& receipt.decision_source.as_ref()
== Some(
&crate::RepoFrontierPlanDecisionSource::AuthenticatedOperatorReview {
command_id: review.command_id.clone(),
admission_id: review.admission_id.clone(),
packet_sha256: review.packet_sha256.clone(),
source_actor_id: review.source_actor_id.clone(),
},
));
}
if require_keyed_repo_model_basis(
&cache,
&planning.model_projection_digest,
&planning.model_source_documents,
)
.is_err()
{
return Ok(false);
}
validate_repo_frontier_plan_candidate_against_request(&cache, &candidate, &planning)?;
Ok(true)
}
fn commit_repo_frontier_plan_decision_inner(
@ -7711,69 +7585,33 @@ fn commit_repo_frontier_plan_decision_inner(
let runtime_store = runtime_store.as_ref();
let mut cache = runtime_spine_cache(runtime_store)?;
cache.pull_all_backing_stores()?;
let (
mind_request_id,
decision,
rationale,
decided_at,
decision_source,
decision_context_id,
operator_provenance,
) = match source {
FrontierPlanDecisionSource::MindWorker(result_id) => {
let result = cache
.get_all::<EpiphanyRuntimeRoleWorkerResult>()?
.into_iter()
.find(|result| result.result_id == result_id)
.ok_or_else(|| anyhow!("frontier plan decision lost its Mind result"))?;
let typed = result
.frontier_plan_mind_decision()?
.ok_or_else(|| anyhow!("frontier plan decision requires a typed Mind decision"))?;
(
result
.frontier_plan_mind_request_id
.clone()
.ok_or_else(|| anyhow!("Mind result lacks its plan request echo"))?,
typed.decision,
typed.rationale,
typed.decided_at,
crate::RepoFrontierPlanDecisionSource::MindWorker {
result_id: result.result_id,
job_id: result.job_id,
},
Some(result.decision_context_id),
None,
)
}
FrontierPlanDecisionSource::Operator(review) => {
let admitted = cache
.get::<crate::LocalAdmittedOperatorCommand>(&review.command_id)?
.ok_or_else(|| anyhow!("operator review lost its admitted command"))?;
if admitted.admission_id != review.admission_id
|| admitted.packet_sha256 != review.packet_sha256
|| admitted.source_actor_id != review.source_actor_id
{
return Err(anyhow!("operator review provenance mismatch"));
let (mind_request_id, decision, rationale, decided_at, decision_source, decision_context_id) =
match source {
FrontierPlanDecisionSource::MindWorker(result_id) => {
let result = cache
.get_all::<EpiphanyRuntimeRoleWorkerResult>()?
.into_iter()
.find(|result| result.result_id == result_id)
.ok_or_else(|| anyhow!("frontier plan decision lost its Mind result"))?;
let typed = result.frontier_plan_mind_decision()?.ok_or_else(|| {
anyhow!("frontier plan decision requires a typed Mind decision")
})?;
(
result
.frontier_plan_mind_request_id
.clone()
.ok_or_else(|| anyhow!("Mind result lacks its plan request echo"))?,
typed.decision,
typed.rationale,
typed.decided_at,
crate::RepoFrontierPlanDecisionSource::MindWorker {
result_id: result.result_id,
job_id: result.job_id,
},
Some(result.decision_context_id),
)
}
let provenance = cache
.get_envelope::<crate::LocalAdmittedOperatorCommand>(&review.command_id)?
.ok_or_else(|| anyhow!("operator review provenance envelope disappeared"))?;
(
review.mind_request_id.clone(),
review.decision,
format!("Authenticated operator requested {:?}.", review.decision).to_lowercase(),
review.decided_at.clone(),
crate::RepoFrontierPlanDecisionSource::AuthenticatedOperatorReview {
command_id: review.command_id.clone(),
admission_id: review.admission_id.clone(),
packet_sha256: review.packet_sha256.clone(),
source_actor_id: review.source_actor_id.clone(),
},
None,
Some(provenance),
)
}
};
};
chrono::DateTime::parse_from_rfc3339(&decided_at)
.map_err(|_| anyhow!("frontier plan decision time must be RFC3339"))?;
let mind_request = cache
@ -7781,17 +7619,6 @@ fn commit_repo_frontier_plan_decision_inner(
.ok_or_else(|| anyhow!("frontier plan decision requires its typed Mind request"))?;
let (planning, candidate) =
validate_repo_frontier_plan_mind_request_identity(&cache, &mind_request)?;
if let FrontierPlanDecisionSource::Operator(review) = source {
if review.candidate_id != candidate.candidate_id
|| review.candidate_sha256 != mind_request.candidate_sha256
|| review.expected_model_projection_digest != planning.model_projection_digest
|| review.expected_model_source_documents != planning.model_source_documents
{
return Err(anyhow!(
"operator review does not bind the exact keyed model"
));
}
}
let candidate_sha256 = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(&candidate)?));
let decision_id = format!(
"repo-frontier-plan-decision-{:x}",
@ -7858,13 +7685,12 @@ fn commit_repo_frontier_plan_decision_inner(
{
strong_reads.push(envelope);
}
if let crate::RepoFrontierPlanDecisionSource::MindWorker { job_id, .. } = &decision_source {
strong_reads.push(
cache
.get_envelope::<EpiphanyRuntimeRoleWorkerResult>(job_id)?
.ok_or_else(|| anyhow!("frontier plan decision lost its Mind result envelope"))?,
);
}
let crate::RepoFrontierPlanDecisionSource::MindWorker { job_id, .. } = &decision_source;
strong_reads.push(
cache
.get_envelope::<EpiphanyRuntimeRoleWorkerResult>(job_id)?
.ok_or_else(|| anyhow!("frontier plan decision lost its Mind result envelope"))?,
);
let mut writes = Vec::new();
if decision == RepoFrontierPlanDecision::Adopt {
let item = cache
@ -7887,7 +7713,6 @@ 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,
});
writes.push(
cache
@ -7908,26 +7733,16 @@ fn commit_repo_frontier_plan_decision_inner(
if let Some(pre_cas) = pre_cas {
pre_cas();
}
let outcome = if let Some(context_id) = decision_context_id {
crate::commit_mind_mutation(
runtime_store,
&context_id,
"Mind.repo_frontier_plan_decision",
strong_reads,
writes,
&decided_at,
)?
} else {
crate::commit_operator_mind_mutation(
runtime_store,
operator_provenance
.ok_or_else(|| anyhow!("operator plan decision lacks provenance"))?,
"Mind.repo_frontier_plan_decision",
strong_reads,
writes,
&decided_at,
)?
};
let context_id = decision_context_id
.ok_or_else(|| anyhow!("Mind plan decision lacks its decision context"))?;
let outcome = crate::commit_mind_mutation(
runtime_store,
&context_id,
"Mind.repo_frontier_plan_decision",
strong_reads,
writes,
&decided_at,
)?;
match outcome {
crate::EpiphanyMindCommitOutcome::Committed(_) => Ok(receipt),
crate::EpiphanyMindCommitOutcome::Conflict { .. } => {
@ -9903,124 +9718,6 @@ fn worker_result_has_keyed_mind_commit(
}))
}
/// 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();
chrono::DateTime::parse_from_rfc3339(&amendment.amended_at)
.map_err(|_| anyhow!("execution amendment amended_at must be RFC3339"))?;
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
if let Some(existing) =
cache.get::<RepoFrontierExecutionAmendmentReceipt>(&amendment.amendment_id)?
{
return Ok(existing);
}
let route = cache
.get::<RepoFrontierRoute>(&amendment.replaces_route_id)?
.ok_or_else(|| anyhow!("execution amendment requires the exact route"))?;
let provenance = cache
.get_envelope::<crate::LocalAdmittedOperatorCommand>(&amendment.command_id)?
.ok_or_else(|| anyhow!("execution amendment lost its admitted operator command"))?;
let admitted = cache
.get::<crate::LocalAdmittedOperatorCommand>(&amendment.command_id)?
.ok_or_else(|| anyhow!("execution amendment lost operator provenance"))?;
if admitted.admission_id != amendment.admission_id
|| admitted.packet_sha256 != amendment.packet_sha256
|| admitted.source_actor_id != amendment.source_actor_id
{
return Err(anyhow!("execution amendment operator provenance mismatch"));
}
let basis = crate::EpiphanyRepoModelBasis {
projection_digest: route.model_projection_digest.clone(),
source_documents: route.model_source_documents.clone(),
};
let view =
require_keyed_repo_model_basis(&cache, &basis.projection_digest, &basis.source_documents)?;
let mut item = view
.frontier
.into_iter()
.find(|item| item.id == route.frontier_item_id)
.ok_or_else(|| anyhow!("execution amendment frontier disappeared"))?;
let previous_frontier_item_hash = repo_frontier_item_hash(&item)?;
if previous_frontier_item_hash != route.frontier_item_hash {
return Err(anyhow!("execution amendment route is stale"));
}
let plan = item
.adopted_plan
.as_mut()
.ok_or_else(|| anyhow!("execution amendment requires an adopted plan"))?;
if plan.execution_amendment.is_some() {
return Err(anyhow!(
"execution amendment cannot replace another amendment"
));
}
plan.execution_amendment = Some(amendment.clone());
let proposal = crate::EpiphanyRepoModelMutationProposal::new(
format!(
"repo-frontier-execution-amendment-{}",
amendment.amendment_id
),
amendment.command_id.clone(),
amendment.amendment_id.clone(),
vec![
amendment.admission_id.clone(),
amendment.packet_sha256.clone(),
],
crate::load_current_runtime_repository_body_basis(store_path)?,
vec![crate::EpiphanyRepoModelMutationOperation::PutFrontier { item }],
)?;
let mutation = crate::plan_repo_model_mutation(store_path, &proposal)?;
let admitted_basis = keyed_repo_model_basis_after_writes(&basis, &mutation.writes)?;
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,
previous_model_projection_digest: basis.projection_digest,
previous_model_source_documents: basis.source_documents,
admitted_model_projection_digest: admitted_basis.projection_digest,
admitted_model_source_documents: admitted_basis.source_documents,
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 mut writes = mutation.writes;
writes.push(cache.prepare_entry(&receipt.receipt_id, &receipt)?.0);
match crate::commit_operator_mind_mutation(
store_path,
provenance,
"Mind.repo_frontier_execution_amendment",
mutation.strong_reads,
writes,
&amendment.amended_at,
)? {
crate::EpiphanyMindCommitOutcome::Committed(_) => Ok(receipt),
crate::EpiphanyMindCommitOutcome::Conflict { .. } => {
let mut reloaded = runtime_spine_cache(store_path)?;
reloaded.pull_all_backing_stores()?;
match reloaded.get::<RepoFrontierExecutionAmendmentReceipt>(&receipt.receipt_id)? {
Some(existing) if existing == receipt => Ok(existing),
_ => Err(anyhow!(
"execution amendment lost its exact keyed-model CAS"
)),
}
}
}
}
pub(crate) fn validate_repo_frontier_verification_request_intrinsic(
request: &RepoFrontierVerificationRequest,
) -> Result<crate::RepoFrontierItem> {
@ -10349,15 +10046,6 @@ pub fn runtime_repo_frontier_plan_decision(
.find(|receipt| receipt.decision_id == decision_id))
}
pub fn runtime_repo_frontier_execution_amendment(
store_path: impl AsRef<Path>,
receipt_id: &str,
) -> Result<Option<RepoFrontierExecutionAmendmentReceipt>> {
let mut cache = runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
cache.get::<RepoFrontierExecutionAmendmentReceipt>(receipt_id)
}
pub fn runtime_latest_repo_frontier_relinquishment(
store_path: impl AsRef<Path>,
) -> Result<Option<RepoFrontierRelinquishmentReceipt>> {