Delete duplicate Planning launch bindings
This commit is contained in:
parent
bae9d338e4
commit
b55e96eaf9
3 changed files with 216 additions and 260 deletions
|
|
@ -1099,6 +1099,24 @@ pub fn current_frontier_verification_review_job_id(
|
|||
.and_then(|work| work.attempt.job_id))
|
||||
}
|
||||
|
||||
pub(crate) fn frontier_planning_attempt_ordinal(request_id: &str, job_id: &str) -> Result<usize> {
|
||||
let prefix = format!("frontier-planning-{request_id}-attempt-");
|
||||
job_id
|
||||
.strip_prefix(&prefix)
|
||||
.ok_or_else(|| anyhow!("frontier Planning job identity is not canonical"))?
|
||||
.parse::<usize>()
|
||||
.map_err(|_| anyhow!("frontier Planning attempt ordinal is invalid"))
|
||||
}
|
||||
|
||||
pub(crate) fn frontier_plan_mind_attempt_ordinal(request_id: &str, job_id: &str) -> Result<usize> {
|
||||
let prefix = format!("frontier-plan-mind-{request_id}-attempt-");
|
||||
job_id
|
||||
.strip_prefix(&prefix)
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind job identity is not canonical"))?
|
||||
.parse::<usize>()
|
||||
.map_err(|_| anyhow!("frontier plan Mind attempt ordinal is invalid"))
|
||||
}
|
||||
|
||||
pub fn launch_current_frontier_planning_work(
|
||||
store_path: impl AsRef<Path>,
|
||||
created_at: &str,
|
||||
|
|
@ -1123,25 +1141,39 @@ pub fn launch_current_frontier_planning_work(
|
|||
.get::<crate::EpiphanyRuntimeIdentity>(crate::RUNTIME_IDENTITY_KEY)?
|
||||
.ok_or_else(|| anyhow!("frontier Planning launch requires runtime identity"))?;
|
||||
let mut prior = cache
|
||||
.get_all::<crate::RepoFrontierPlanningLaunchBinding>()?
|
||||
.get_all::<crate::EpiphanyRuntimeWorkerLaunchRequest>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.planning_request_id == request.request_id)
|
||||
.collect::<Vec<_>>();
|
||||
prior.sort_by_key(|binding| binding.attempt_ordinal);
|
||||
let attempt_ordinal = prior.len() as u64;
|
||||
let superseded_failure_result_id = if let Some(latest) = prior.last() {
|
||||
.filter(|launch| {
|
||||
launch.frontier_planning_request_id.as_deref() == Some(request.request_id.as_str())
|
||||
})
|
||||
.map(|launch| {
|
||||
Ok((
|
||||
frontier_planning_attempt_ordinal(&request.request_id, &launch.job_id)?,
|
||||
launch,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
prior.sort_by_key(|(ordinal, _)| *ordinal);
|
||||
for (expected, (ordinal, _)) in prior.iter().enumerate() {
|
||||
if *ordinal != expected {
|
||||
return Err(anyhow!(
|
||||
"frontier Planning request has noncontiguous attempt identity"
|
||||
));
|
||||
}
|
||||
}
|
||||
let attempt_ordinal = prior.len();
|
||||
let retry_authority = if let Some((_, latest)) = prior.last() {
|
||||
let result = cache
|
||||
.get::<crate::EpiphanyRuntimeRoleWorkerResult>(&latest.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry lost its failure result"))?;
|
||||
crate::runtime_spine::repo_frontier_planning_failure_review(
|
||||
let review = crate::runtime_spine::repo_frontier_planning_failure_review(
|
||||
&cache,
|
||||
&request.request_id,
|
||||
"imagination",
|
||||
&result,
|
||||
)?
|
||||
.map(|review| review.result_id)
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry is not reviewed"))?
|
||||
.into()
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry is not reviewed"))?;
|
||||
Some((result, review))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -1195,40 +1227,6 @@ pub fn launch_current_frontier_planning_work(
|
|||
created_at: created_at.into(),
|
||||
},
|
||||
)?;
|
||||
let launch = prepared
|
||||
.iter()
|
||||
.find(|envelope| {
|
||||
envelope.r#type == crate::EpiphanyRuntimeWorkerLaunchRequest::TYPE
|
||||
&& envelope.key == job_id
|
||||
})
|
||||
.ok_or_else(|| anyhow!("frontier Planning launch preparation lost its worker"))?;
|
||||
let worker_launch: crate::EpiphanyRuntimeWorkerLaunchRequest =
|
||||
rmp_serde::from_slice(&launch.payload)?;
|
||||
let binding_record_id = if attempt_ordinal == 0 {
|
||||
format!("repo-frontier-planning-launch-{}", request.request_id)
|
||||
} else {
|
||||
format!(
|
||||
"repo-frontier-planning-launch-{}-attempt-{attempt_ordinal}",
|
||||
request.request_id
|
||||
)
|
||||
};
|
||||
let binding = crate::RepoFrontierPlanningLaunchBinding {
|
||||
schema_version: crate::REPO_FRONTIER_PLANNING_LAUNCH_BINDING_SCHEMA_VERSION.into(),
|
||||
binding_record_id,
|
||||
planning_request_id: request.request_id.clone(),
|
||||
job_id: job_id.clone(),
|
||||
binding_id: crate::EPIPHANY_IMAGINATION_ROLE_BINDING_ID.into(),
|
||||
runtime_id: identity.runtime_id,
|
||||
thread_id: job_id.clone(),
|
||||
launched_at: created_at.into(),
|
||||
worker_launch_document_sha256: format!(
|
||||
"{:x}",
|
||||
Sha256::digest(&worker_launch.launch_document_msgpack)
|
||||
),
|
||||
contract: crate::REPO_FRONTIER_PLANNING_LAUNCH_BINDING_CONTRACT.into(),
|
||||
attempt_ordinal,
|
||||
superseded_failure_result_id,
|
||||
};
|
||||
let snapshot = cache.snapshot_envelopes();
|
||||
let mut expected = vec![
|
||||
cache
|
||||
|
|
@ -1251,12 +1249,31 @@ pub fn launch_current_frontier_planning_work(
|
|||
}
|
||||
expected.push(envelope.clone());
|
||||
}
|
||||
for (_, launch) in &prior {
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::EpiphanyRuntimeWorkerLaunchRequest>(&launch.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry lost its prior launch envelope"))?,
|
||||
);
|
||||
}
|
||||
if let Some((result, review)) = retry_authority {
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::EpiphanyRuntimeRoleWorkerResult>(&result.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry lost its result envelope"))?,
|
||||
);
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::RepoFrontierPlanningFailureReview>(&review.review_id)?
|
||||
.ok_or_else(|| anyhow!("frontier Planning retry lost its review envelope"))?,
|
||||
);
|
||||
}
|
||||
commit_current_work_launch(
|
||||
store_path,
|
||||
&cache,
|
||||
expected,
|
||||
prepared,
|
||||
vec![cache.prepare_entry(&binding.binding_record_id, &binding)?.0],
|
||||
Vec::new(),
|
||||
"frontier Planning",
|
||||
)?;
|
||||
Ok(job_id)
|
||||
|
|
@ -1295,25 +1312,39 @@ pub fn launch_current_frontier_plan_mind_work(
|
|||
.get::<crate::EpiphanyRuntimeIdentity>(crate::RUNTIME_IDENTITY_KEY)?
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind launch requires runtime identity"))?;
|
||||
let mut prior = cache
|
||||
.get_all::<crate::RepoFrontierPlanMindLaunchBinding>()?
|
||||
.get_all::<crate::EpiphanyRuntimeWorkerLaunchRequest>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.mind_request_id == request.request_id)
|
||||
.collect::<Vec<_>>();
|
||||
prior.sort_by_key(|binding| binding.attempt_ordinal);
|
||||
let attempt_ordinal = prior.len() as u64;
|
||||
let superseded_failure_result_id = if let Some(latest) = prior.last() {
|
||||
.filter(|launch| {
|
||||
launch.frontier_plan_mind_request_id.as_deref() == Some(request.request_id.as_str())
|
||||
})
|
||||
.map(|launch| {
|
||||
Ok((
|
||||
frontier_plan_mind_attempt_ordinal(&request.request_id, &launch.job_id)?,
|
||||
launch,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
prior.sort_by_key(|(ordinal, _)| *ordinal);
|
||||
for (expected, (ordinal, _)) in prior.iter().enumerate() {
|
||||
if *ordinal != expected {
|
||||
return Err(anyhow!(
|
||||
"frontier plan Mind request has noncontiguous attempt identity"
|
||||
));
|
||||
}
|
||||
}
|
||||
let attempt_ordinal = prior.len();
|
||||
let retry_authority = if let Some((_, latest)) = prior.last() {
|
||||
let result = cache
|
||||
.get::<crate::EpiphanyRuntimeRoleWorkerResult>(&latest.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind retry lost its failure result"))?;
|
||||
crate::runtime_spine::repo_frontier_planning_failure_review(
|
||||
let review = crate::runtime_spine::repo_frontier_planning_failure_review(
|
||||
&cache,
|
||||
&planning.request_id,
|
||||
"mind",
|
||||
&result,
|
||||
)?
|
||||
.map(|review| review.result_id)
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind retry is not reviewed"))?
|
||||
.into()
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind retry is not reviewed"))?;
|
||||
Some((result, review))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -1367,40 +1398,6 @@ pub fn launch_current_frontier_plan_mind_work(
|
|||
created_at: created_at.into(),
|
||||
},
|
||||
)?;
|
||||
let worker_envelope = prepared
|
||||
.iter()
|
||||
.find(|envelope| {
|
||||
envelope.r#type == crate::EpiphanyRuntimeWorkerLaunchRequest::TYPE
|
||||
&& envelope.key == job_id
|
||||
})
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind preparation lost its worker"))?;
|
||||
let worker_launch: crate::EpiphanyRuntimeWorkerLaunchRequest =
|
||||
rmp_serde::from_slice(&worker_envelope.payload)?;
|
||||
let binding_record_id = if attempt_ordinal == 0 {
|
||||
format!("repo-frontier-plan-mind-launch-{}", request.request_id)
|
||||
} else {
|
||||
format!(
|
||||
"repo-frontier-plan-mind-launch-{}-attempt-{attempt_ordinal}",
|
||||
request.request_id
|
||||
)
|
||||
};
|
||||
let binding = crate::RepoFrontierPlanMindLaunchBinding {
|
||||
schema_version: crate::REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_SCHEMA_VERSION.into(),
|
||||
binding_record_id,
|
||||
mind_request_id: request.request_id.clone(),
|
||||
job_id: job_id.clone(),
|
||||
binding_id: crate::EPIPHANY_MIND_ROLE_BINDING_ID.into(),
|
||||
runtime_id: identity.runtime_id,
|
||||
thread_id: job_id.clone(),
|
||||
launched_at: created_at.into(),
|
||||
worker_launch_document_sha256: format!(
|
||||
"{:x}",
|
||||
Sha256::digest(&worker_launch.launch_document_msgpack)
|
||||
),
|
||||
contract: crate::REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_CONTRACT.into(),
|
||||
attempt_ordinal,
|
||||
superseded_failure_result_id,
|
||||
};
|
||||
let snapshot = cache.snapshot_envelopes();
|
||||
let mut expected = Vec::new();
|
||||
for (document_type, document_key) in [
|
||||
|
|
@ -1441,12 +1438,33 @@ pub fn launch_current_frontier_plan_mind_work(
|
|||
}
|
||||
expected.push(envelope.clone());
|
||||
}
|
||||
for (_, launch) in &prior {
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::EpiphanyRuntimeWorkerLaunchRequest>(&launch.job_id)?
|
||||
.ok_or_else(|| {
|
||||
anyhow!("frontier plan Mind retry lost its prior launch envelope")
|
||||
})?,
|
||||
);
|
||||
}
|
||||
if let Some((result, review)) = retry_authority {
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::EpiphanyRuntimeRoleWorkerResult>(&result.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind retry lost its result envelope"))?,
|
||||
);
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<crate::RepoFrontierPlanningFailureReview>(&review.review_id)?
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind retry lost its review envelope"))?,
|
||||
);
|
||||
}
|
||||
commit_current_work_launch(
|
||||
store_path,
|
||||
&cache,
|
||||
expected,
|
||||
prepared,
|
||||
vec![cache.prepare_entry(&binding.binding_record_id, &binding)?.0],
|
||||
Vec::new(),
|
||||
"frontier plan Mind",
|
||||
)?;
|
||||
Ok(job_id)
|
||||
|
|
@ -4408,11 +4426,8 @@ mod tests {
|
|||
.action,
|
||||
EpiphanyAgentPassContinuationAction::Review
|
||||
);
|
||||
let proposal_outcome = accept_proposal_modeling_result(
|
||||
&store,
|
||||
&proposal_job_id,
|
||||
"2026-08-17T00:00:13Z",
|
||||
)?;
|
||||
let proposal_outcome =
|
||||
accept_proposal_modeling_result(&store, &proposal_job_id, "2026-08-17T00:00:13Z")?;
|
||||
let EpiphanyAgentPassAdmissionOutcome::Refused {
|
||||
refusal,
|
||||
commit: refusal_commit,
|
||||
|
|
@ -4558,11 +4573,8 @@ mod tests {
|
|||
.action,
|
||||
EpiphanyAgentPassContinuationAction::Review
|
||||
);
|
||||
let proposal_outcome = accept_proposal_modeling_result(
|
||||
&store,
|
||||
&proposal_job_id,
|
||||
"2026-08-17T00:00:14Z",
|
||||
)?;
|
||||
let proposal_outcome =
|
||||
accept_proposal_modeling_result(&store, &proposal_job_id, "2026-08-17T00:00:14Z")?;
|
||||
let EpiphanyAgentPassAdmissionOutcome::Committed(proposal_commit) = proposal_outcome else {
|
||||
panic!("corrected proposal Modeling result must commit")
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,18 +71,10 @@ pub const REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_SCHEMA_VERSION: &str =
|
|||
"epiphany.coordinator.repo_frontier_proposal_modeling_request.v0";
|
||||
pub const REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT: &str =
|
||||
"epiphany.repo_frontier_proposal_modeling_request.v0";
|
||||
pub const REPO_FRONTIER_PLANNING_LAUNCH_BINDING_SCHEMA_VERSION: &str =
|
||||
"epiphany.coordinator.repo_frontier_planning_launch_binding.v0";
|
||||
pub const REPO_FRONTIER_PLANNING_LAUNCH_BINDING_CONTRACT: &str =
|
||||
"epiphany.repo_frontier_planning_launch_binding.v0";
|
||||
pub const REPO_FRONTIER_PLAN_MIND_REQUEST_SCHEMA_VERSION: &str =
|
||||
"epiphany.self.repo_frontier_plan_mind_request.v1";
|
||||
pub const REPO_FRONTIER_PLAN_MIND_REQUEST_CONTRACT: &str =
|
||||
"epiphany.repo_frontier_plan_mind_request.v1";
|
||||
pub const REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_SCHEMA_VERSION: &str =
|
||||
"epiphany.coordinator.repo_frontier_plan_mind_launch_binding.v0";
|
||||
pub const REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_CONTRACT: &str =
|
||||
"epiphany.repo_frontier_plan_mind_launch_binding.v0";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
|
|
@ -230,38 +222,6 @@ pub struct RepoFrontierPlanningRequest {
|
|||
pub claim_obligation_documents: Vec<crate::EpiphanyMindDocumentVersion>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.coordinator.repo_frontier_planning_launch_binding",
|
||||
schema = "RepoFrontierPlanningLaunchBinding"
|
||||
)]
|
||||
pub struct RepoFrontierPlanningLaunchBinding {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub binding_record_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub planning_request_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub job_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub binding_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub runtime_id: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub thread_id: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub launched_at: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub worker_launch_document_sha256: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub contract: String,
|
||||
#[cultcache(key = 10, default)]
|
||||
pub attempt_ordinal: u64,
|
||||
#[cultcache(key = 11, default)]
|
||||
pub superseded_failure_result_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.self.repo_frontier_research_request",
|
||||
|
|
@ -405,38 +365,6 @@ pub struct RepoFrontierPlanMindRequest {
|
|||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.coordinator.repo_frontier_plan_mind_launch_binding",
|
||||
schema = "RepoFrontierPlanMindLaunchBinding"
|
||||
)]
|
||||
pub struct RepoFrontierPlanMindLaunchBinding {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub binding_record_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub mind_request_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub job_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub binding_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub runtime_id: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub thread_id: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub launched_at: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub worker_launch_document_sha256: String,
|
||||
#[cultcache(key = 9)]
|
||||
pub contract: String,
|
||||
#[cultcache(key = 10, default)]
|
||||
pub attempt_ordinal: u64,
|
||||
#[cultcache(key = 11, default)]
|
||||
pub superseded_failure_result_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct RepoFrontierPlanMindDecision {
|
||||
pub mind_request_id: String,
|
||||
|
|
|
|||
|
|
@ -14,13 +14,9 @@ use crate::repo_model_gateway::{
|
|||
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,
|
||||
REPO_FRONTIER_PLAN_DECISION_RECEIPT_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_CONTRACT,
|
||||
REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLAN_MIND_REQUEST_CONTRACT, REPO_FRONTIER_PLAN_MIND_REQUEST_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLANNING_CONTRACT, REPO_FRONTIER_PLANNING_FAILURE_REVIEW_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLANNING_LAUNCH_BINDING_CONTRACT,
|
||||
REPO_FRONTIER_PLANNING_LAUNCH_BINDING_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLAN_DECISION_RECEIPT_SCHEMA_VERSION, REPO_FRONTIER_PLAN_MIND_REQUEST_CONTRACT,
|
||||
REPO_FRONTIER_PLAN_MIND_REQUEST_SCHEMA_VERSION, REPO_FRONTIER_PLANNING_CONTRACT,
|
||||
REPO_FRONTIER_PLANNING_FAILURE_REVIEW_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PLANNING_REQUEST_SCHEMA_VERSION,
|
||||
REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT,
|
||||
REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_SCHEMA_VERSION,
|
||||
|
|
@ -31,12 +27,10 @@ use crate::repo_model_gateway::{
|
|||
RUNTIME_REPOSITORY_DOMAIN_BINDING_SCHEMA_VERSION, RepoFrontierAutonomousProposalBinding,
|
||||
RepoFrontierHandsAuthority, RepoFrontierModelingRequest, RepoFrontierNextOrgan,
|
||||
RepoFrontierPlanCandidate, RepoFrontierPlanDecision, RepoFrontierPlanDecisionReceipt,
|
||||
RepoFrontierPlanMindDecision, RepoFrontierPlanMindLaunchBinding, RepoFrontierPlanMindRequest,
|
||||
RepoFrontierPlanningFailureReview, RepoFrontierPlanningLaunchBinding,
|
||||
RepoFrontierPlanMindDecision, RepoFrontierPlanMindRequest, RepoFrontierPlanningFailureReview,
|
||||
RepoFrontierPlanningLifecycle, RepoFrontierPlanningLifecycleStage, RepoFrontierPlanningRequest,
|
||||
RepoFrontierProposalModelingRequest,
|
||||
RepoFrontierResearchRequest, RepoFrontierRoute, RepoFrontierVerdictDisposition,
|
||||
RepoFrontierWorkProposal, RuntimeRepositoryDomainBinding,
|
||||
RepoFrontierProposalModelingRequest, RepoFrontierResearchRequest, RepoFrontierRoute,
|
||||
RepoFrontierVerdictDisposition, RepoFrontierWorkProposal, RuntimeRepositoryDomainBinding,
|
||||
};
|
||||
use crate::runtime_store_backend::{
|
||||
RuntimeSpineBackingStore as SingleFileMessagePackBackingStore, runtime_spine_backing_store,
|
||||
|
|
@ -94,7 +88,7 @@ pub const COORDINATOR_RUN_RECEIPT_TYPE: &str = "epiphany.coordinator_run_receipt
|
|||
pub const RUNTIME_IDENTITY_KEY: &str = "self";
|
||||
pub const RUNTIME_SWARM_BINDING_KEY: &str = "runtime-swarm-binding";
|
||||
pub const RUNTIME_SWARM_BINDING_SCHEMA_VERSION: &str = "epiphany.runtime.swarm_binding.v1";
|
||||
pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v17";
|
||||
pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v18";
|
||||
pub const EPIPHANY_RUNTIME_ROOT_SESSION_ID: &str = "epiphany-main";
|
||||
pub const RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.model_execution_binding.v0";
|
||||
|
|
@ -868,7 +862,6 @@ fn runtime_spine_schema_cache() -> Result<CultCache> {
|
|||
cache.register_entry_type::<RepoFrontierProposalModelingRequest>()?;
|
||||
cache.register_entry_type::<RepoFrontierPlanningRequest>()?;
|
||||
cache.register_entry_type::<RepoFrontierResearchRequest>()?;
|
||||
cache.register_entry_type::<RepoFrontierPlanningLaunchBinding>()?;
|
||||
cache.register_entry_type::<RepoFrontierPlanningFailureReview>()?;
|
||||
cache.register_entry_type::<crate::ImaginationConsiderationRequest>()?;
|
||||
cache.register_entry_type::<crate::ImaginationConsiderationLaunchBinding>()?;
|
||||
|
|
@ -882,7 +875,6 @@ fn runtime_spine_schema_cache() -> Result<CultCache> {
|
|||
cache.register_entry_type::<crate::EpiphanyReorientationLaunchBinding>()?;
|
||||
cache.register_entry_type::<crate::EpiphanyMindReorientationDecisionDocument>()?;
|
||||
cache.register_entry_type::<crate::EpiphanyMindReorientationPassFailureDocument>()?;
|
||||
cache.register_entry_type::<RepoFrontierPlanMindLaunchBinding>()?;
|
||||
cache.register_entry_type::<RepoFrontierVerificationRequest>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeReorientWorkerResult>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeJobResult>()?;
|
||||
|
|
@ -2497,6 +2489,12 @@ pub fn prepare_runtime_spine_heartbeat_job(
|
|||
options.frontier_planning_request_id.as_deref(),
|
||||
&options.launch_document,
|
||||
)?;
|
||||
validate_frontier_plan_mind_launch_carrier(
|
||||
&options.role,
|
||||
&options.binding_id,
|
||||
options.frontier_plan_mind_request_id.as_deref(),
|
||||
&options.launch_document,
|
||||
)?;
|
||||
validate_frontier_research_launch_carrier(
|
||||
&options.role,
|
||||
&options.binding_id,
|
||||
|
|
@ -2846,6 +2844,40 @@ fn validate_frontier_planning_launch_carrier(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_frontier_plan_mind_launch_carrier(
|
||||
role: &str,
|
||||
binding_id: &str,
|
||||
request_id: Option<&str>,
|
||||
launch_document: &EpiphanyWorkerLaunchDocument,
|
||||
) -> Result<()> {
|
||||
let projection = match launch_document {
|
||||
EpiphanyWorkerLaunchDocument::Role(document) => {
|
||||
document.frontier_plan_mind_context.as_ref()
|
||||
}
|
||||
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
|
||||
};
|
||||
let Some(request_id) = request_id else {
|
||||
if projection.is_some() {
|
||||
return Err(anyhow!(
|
||||
"frontier plan Mind context requires its typed request id"
|
||||
));
|
||||
}
|
||||
return Ok(());
|
||||
};
|
||||
validate_non_empty(request_id, "frontier plan Mind request id")?;
|
||||
if role != EPIPHANY_MIND_OWNER_ROLE || binding_id != EPIPHANY_MIND_ROLE_BINDING_ID {
|
||||
return Err(anyhow!(
|
||||
"frontier plan Mind request may only be transported by the Mind role launch"
|
||||
));
|
||||
}
|
||||
let projection = projection
|
||||
.ok_or_else(|| anyhow!("frontier plan Mind request requires its typed context"))?;
|
||||
if projection.request.request_id != request_id {
|
||||
return Err(anyhow!("frontier plan Mind context/request mismatch"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_imagination_consideration_launch_carrier(
|
||||
role: &str,
|
||||
binding_id: &str,
|
||||
|
|
@ -4265,19 +4297,6 @@ pub fn put_runtime_role_worker_result(
|
|||
.frontier_plan_candidate()?
|
||||
.ok_or_else(|| anyhow!("frontier planning candidate disappeared"))?;
|
||||
validate_repo_frontier_plan_candidate_against_request(&cache, &candidate, &request)?;
|
||||
let bindings = cache
|
||||
.get_all::<RepoFrontierPlanningLaunchBinding>()?
|
||||
.into_iter()
|
||||
.filter(|binding| {
|
||||
binding.planning_request_id == request.request_id && binding.job_id == result.job_id
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if bindings.len() != 1 {
|
||||
return Err(anyhow!(
|
||||
"frontier planning result requires exactly one coordinator launch binding"
|
||||
));
|
||||
}
|
||||
let binding = &bindings[0];
|
||||
let worker_launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(&result.job_id)?
|
||||
.ok_or_else(|| anyhow!("frontier planning result requires its worker launch"))?;
|
||||
|
|
@ -4290,36 +4309,22 @@ pub fn put_runtime_role_worker_result(
|
|||
};
|
||||
let expected_projection =
|
||||
crate::RepoFrontierPlanningContextProjection::from_request(&request);
|
||||
let launch_hash = format!(
|
||||
"{:x}",
|
||||
Sha256::digest(&worker_launch.launch_document_msgpack)
|
||||
);
|
||||
let expected_binding_record_id = if binding.attempt_ordinal == 0 {
|
||||
format!("repo-frontier-planning-launch-{}", request.request_id)
|
||||
} else {
|
||||
format!(
|
||||
"repo-frontier-planning-launch-{}-attempt-{}",
|
||||
request.request_id, binding.attempt_ordinal
|
||||
)
|
||||
};
|
||||
if binding.schema_version != REPO_FRONTIER_PLANNING_LAUNCH_BINDING_SCHEMA_VERSION
|
||||
|| binding.contract != REPO_FRONTIER_PLANNING_LAUNCH_BINDING_CONTRACT
|
||||
|| binding.binding_record_id != expected_binding_record_id
|
||||
|| binding.job_id != result.job_id
|
||||
|| binding.binding_id != EPIPHANY_IMAGINATION_ROLE_BINDING_ID
|
||||
|| binding.runtime_id != request.runtime_id
|
||||
|| binding.thread_id != launch_document.thread_id()
|
||||
|| binding.worker_launch_document_sha256 != launch_hash
|
||||
crate::current_work::frontier_planning_attempt_ordinal(
|
||||
&request.request_id,
|
||||
&result.job_id,
|
||||
)?;
|
||||
if worker_launch.schema_version != RUNTIME_WORKER_LAUNCH_REQUEST_SCHEMA_VERSION
|
||||
|| worker_launch.job_id != result.job_id
|
||||
|| worker_launch.role != EPIPHANY_IMAGINATION_OWNER_ROLE
|
||||
|| worker_launch.binding_id != EPIPHANY_IMAGINATION_ROLE_BINDING_ID
|
||||
|| worker_launch.frontier_planning_request_id.as_deref()
|
||||
!= Some(request.request_id.as_str())
|
||||
|| worker_launch.proposal_modeling_request_id.is_some()
|
||||
|| launch_document.thread_id() != result.job_id
|
||||
|| projection != Some(&expected_projection)
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"frontier planning result does not exactly bind request, launch, runtime, launch provenance, and candidate"
|
||||
"frontier planning result does not exactly bind request, immutable launch, and candidate"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -4529,19 +4534,6 @@ pub fn put_runtime_role_worker_result(
|
|||
"Mind decision substituted request echo or immutable candidate identity"
|
||||
));
|
||||
}
|
||||
let bindings = cache
|
||||
.get_all::<RepoFrontierPlanMindLaunchBinding>()?
|
||||
.into_iter()
|
||||
.filter(|binding| {
|
||||
binding.mind_request_id == request.request_id && binding.job_id == result.job_id
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if bindings.len() != 1 {
|
||||
return Err(anyhow!(
|
||||
"Mind result requires exactly one coordinator launch binding"
|
||||
));
|
||||
}
|
||||
let binding = &bindings[0];
|
||||
let launch = cache
|
||||
.get::<EpiphanyRuntimeWorkerLaunchRequest>(&result.job_id)?
|
||||
.ok_or_else(|| anyhow!("Mind result launch disappeared"))?;
|
||||
|
|
@ -4551,21 +4543,20 @@ pub fn put_runtime_role_worker_result(
|
|||
_ => None,
|
||||
};
|
||||
let expected = RepoFrontierPlanMindContextProjection::new(&request, &planning, &candidate);
|
||||
let hash = format!("{:x}", Sha256::digest(&launch.launch_document_msgpack));
|
||||
if binding.schema_version != REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_SCHEMA_VERSION
|
||||
|| binding.contract != REPO_FRONTIER_PLAN_MIND_LAUNCH_BINDING_CONTRACT
|
||||
|| binding.job_id != result.job_id
|
||||
|| binding.binding_id != EPIPHANY_MIND_ROLE_BINDING_ID
|
||||
|| binding.runtime_id != request.runtime_id
|
||||
|| binding.thread_id != document.thread_id()
|
||||
|| binding.worker_launch_document_sha256 != hash
|
||||
crate::current_work::frontier_plan_mind_attempt_ordinal(
|
||||
&request.request_id,
|
||||
&result.job_id,
|
||||
)?;
|
||||
if launch.schema_version != RUNTIME_WORKER_LAUNCH_REQUEST_SCHEMA_VERSION
|
||||
|| launch.job_id != result.job_id
|
||||
|| launch.role != EPIPHANY_MIND_OWNER_ROLE
|
||||
|| launch.binding_id != EPIPHANY_MIND_ROLE_BINDING_ID
|
||||
|| launch.frontier_plan_mind_request_id.as_deref() != Some(request.request_id.as_str())
|
||||
|| document.thread_id() != result.job_id
|
||||
|| projection != Some(&expected)
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Mind result does not exactly bind request, launch, runtime, launch provenance, and candidate"
|
||||
"Mind result does not exactly bind request, immutable launch, and candidate"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -6425,7 +6416,9 @@ fn frontier_item_is_actionable_for_organ(
|
|||
/// admitted exactly once and contains an item the route committer can hand to
|
||||
/// Hands. Status projection must use this instead of assuming that a clear
|
||||
/// CRRC lane implies implementation authority.
|
||||
pub(crate) fn runtime_has_actionable_hands_frontier(runtime_store: impl AsRef<Path>) -> Result<bool> {
|
||||
pub(crate) fn runtime_has_actionable_hands_frontier(
|
||||
runtime_store: impl AsRef<Path>,
|
||||
) -> Result<bool> {
|
||||
runtime_has_actionable_frontier_for_organ(runtime_store, "Hands")
|
||||
}
|
||||
|
||||
|
|
@ -7271,20 +7264,31 @@ pub fn runtime_repo_frontier_planning_lifecycle(
|
|||
decision_id: None,
|
||||
};
|
||||
let mut imagination_launches = cache
|
||||
.get_all::<RepoFrontierPlanningLaunchBinding>()?
|
||||
.get_all::<EpiphanyRuntimeWorkerLaunchRequest>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.planning_request_id == request.request_id)
|
||||
.collect::<Vec<_>>();
|
||||
imagination_launches.sort_by_key(|binding| binding.attempt_ordinal);
|
||||
for (expected, binding) in imagination_launches.iter().enumerate() {
|
||||
if binding.attempt_ordinal != expected as u64 {
|
||||
.filter(|launch| {
|
||||
launch.frontier_planning_request_id.as_deref() == Some(request.request_id.as_str())
|
||||
})
|
||||
.map(|launch| {
|
||||
Ok((
|
||||
crate::current_work::frontier_planning_attempt_ordinal(
|
||||
&request.request_id,
|
||||
&launch.job_id,
|
||||
)?,
|
||||
launch,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
imagination_launches.sort_by_key(|(ordinal, _)| *ordinal);
|
||||
for (expected, (ordinal, _)) in imagination_launches.iter().enumerate() {
|
||||
if *ordinal != expected {
|
||||
return Err(anyhow!(
|
||||
"Self found noncontiguous frontier planning attempt identity"
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Some(binding) = imagination_launches.last() {
|
||||
lifecycle.imagination_job_id = Some(binding.job_id.clone());
|
||||
if let Some((_, launch)) = imagination_launches.last() {
|
||||
lifecycle.imagination_job_id = Some(launch.job_id.clone());
|
||||
}
|
||||
let imagination_results = cache
|
||||
.get_all::<EpiphanyRuntimeRoleWorkerResult>()?
|
||||
|
|
@ -7351,18 +7355,30 @@ pub fn runtime_repo_frontier_planning_lifecycle(
|
|||
lifecycle.mind_request_id = Some(mind_request.request_id.clone());
|
||||
lifecycle.stage = RepoFrontierPlanningLifecycleStage::MindLaunchReady;
|
||||
let mut mind_launches = cache
|
||||
.get_all::<RepoFrontierPlanMindLaunchBinding>()?
|
||||
.get_all::<EpiphanyRuntimeWorkerLaunchRequest>()?
|
||||
.into_iter()
|
||||
.filter(|binding| binding.mind_request_id == mind_request.request_id)
|
||||
.collect::<Vec<_>>();
|
||||
mind_launches.sort_by_key(|binding| binding.attempt_ordinal);
|
||||
for (expected, binding) in mind_launches.iter().enumerate() {
|
||||
if binding.attempt_ordinal != expected as u64 {
|
||||
.filter(|launch| {
|
||||
launch.frontier_plan_mind_request_id.as_deref()
|
||||
== Some(mind_request.request_id.as_str())
|
||||
})
|
||||
.map(|launch| {
|
||||
Ok((
|
||||
crate::current_work::frontier_plan_mind_attempt_ordinal(
|
||||
&mind_request.request_id,
|
||||
&launch.job_id,
|
||||
)?,
|
||||
launch,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
mind_launches.sort_by_key(|(ordinal, _)| *ordinal);
|
||||
for (expected, (ordinal, _)) in mind_launches.iter().enumerate() {
|
||||
if *ordinal != expected {
|
||||
return Err(anyhow!("Self found noncontiguous Mind attempt identity"));
|
||||
}
|
||||
}
|
||||
if let Some(binding) = mind_launches.last() {
|
||||
lifecycle.mind_job_id = Some(binding.job_id.clone());
|
||||
if let Some((_, launch)) = mind_launches.last() {
|
||||
lifecycle.mind_job_id = Some(launch.job_id.clone());
|
||||
}
|
||||
let mind_results = cache
|
||||
.get_all::<EpiphanyRuntimeRoleWorkerResult>()?
|
||||
|
|
|
|||
Reference in a new issue