Bind Research routing to current Eyes frontier

This commit is contained in:
Meta Vens 2026-08-11 23:11:08 +02:00
commit 18966e55cd
17 changed files with 446 additions and 14 deletions

View file

@ -1265,6 +1265,7 @@ pub fn build_epiphany_frontier_plan_mind_launch_request(
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -1316,6 +1317,7 @@ pub fn build_epiphany_frontier_plan_mind_launch_request(
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
})
}
@ -1367,6 +1369,7 @@ pub fn build_epiphany_role_launch_request_with_dynamic_context(
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -1417,6 +1420,7 @@ pub fn build_epiphany_role_launch_request_with_dynamic_context(
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
})
}
@ -1582,6 +1586,7 @@ pub fn build_epiphany_job_launch_request(
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
}
}

View file

@ -1524,6 +1524,17 @@ fn launch_role(
let state_loaded_ms = started.elapsed().as_millis();
let role = parse_role_id(role_id)?;
let mut repo_frontier_modeling_request_id = None;
let repo_frontier_research_request = if role
== epiphany_core::EpiphanyRoleResultRoleId::Research
&& epiphany_core::runtime_has_actionable_eyes_frontier(runtime_store)?
{
Some(epiphany_core::select_and_commit_repo_frontier_research_request(
runtime_store,
&now(),
)?)
} else {
None
};
let mut repo_frontier_verdict_modeling_authority = None;
let expected_revision = expected_revision.and_then(|value| u64::try_from(value).ok());
let focus =
@ -1578,6 +1589,18 @@ fn launch_role(
.map_err(anyhow::Error::msg)?;
request.proposal_modeling_request_id = proposal_modeling_request_id.map(str::to_string);
request.repo_frontier_modeling_request_id = repo_frontier_modeling_request_id;
request.repo_frontier_research_request_id = repo_frontier_research_request
.as_ref()
.map(|selected| selected.request_id.clone());
if let (
Some(selected),
epiphany_core::EpiphanyWorkerLaunchDocument::Role(document),
) = (
repo_frontier_research_request.as_ref(),
&mut request.launch_document,
) {
document.frontier_research_context = Some(selected.into());
}
request.repo_frontier_verdict_modeling_authority = repo_frontier_verdict_modeling_authority;
let request_built_ms = started.elapsed().as_millis();
let launched = service.launch_job(

View file

@ -38,7 +38,7 @@ use epiphany_core::derive_scene;
use epiphany_core::read_accepted_coordinator_state;
use epiphany_core::recommend_crrc_action;
use epiphany_core::recommend_reorientation;
use epiphany_core::runtime_has_actionable_eyes_frontier;
use epiphany_core::runtime_has_uncovered_actionable_eyes_frontier;
use epiphany_core::runtime_has_actionable_hands_frontier;
use epiphany_core::runtime_job_snapshot;
use epiphany_self_policy::crrc_scene_action_to_coordinator_scene_action;
@ -478,7 +478,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
};
let hands_frontier_ready = runtime_has_actionable_hands_frontier(&runtime_store_path)
.context("failed to derive actionable Hands frontier from runtime-spine state")?;
let eyes_frontier_ready = runtime_has_actionable_eyes_frontier(&runtime_store_path)
let eyes_frontier_ready = runtime_has_uncovered_actionable_eyes_frontier(&runtime_store_path)
.context("failed to derive actionable Eyes frontier from runtime-spine state")?;
let frontier_planning_eligibility = epiphany_core::runtime_repo_frontier_planning_eligibility(
&runtime_store_path,

View file

@ -341,6 +341,9 @@ fn commit_coordinator_job_launch_in_cache(
.admitted_model_direction_consideration_request_id
.clone(),
repo_frontier_modeling_request_id: request.repo_frontier_modeling_request_id.clone(),
repo_frontier_research_request_id: request
.repo_frontier_research_request_id
.clone(),
repo_frontier_verdict_modeling_authority: request
.repo_frontier_verdict_modeling_authority
.clone(),
@ -3182,6 +3185,7 @@ pub(crate) mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
created_at: "2026-07-15T09:00:17Z".into(),
},

View file

@ -1734,6 +1734,7 @@ mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
created_at: "2026-06-02T00:00:00Z".to_string(),
},
@ -2127,6 +2128,7 @@ mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
created_at: "2026-06-12T00:00:06Z".to_string(),
},

View file

@ -1137,6 +1137,7 @@ pub use runtime_spine::runtime_hands_pr_receipt;
pub use runtime_spine::runtime_hands_receipt_chain_after;
pub use runtime_spine::runtime_hands_receipt_chain_matches_current_model;
pub use runtime_spine::runtime_has_actionable_eyes_frontier;
pub use runtime_spine::runtime_has_uncovered_actionable_eyes_frontier;
pub use runtime_spine::runtime_has_actionable_hands_frontier;
pub use runtime_spine::runtime_has_actionable_imagination_frontier;
pub use runtime_spine::runtime_hello_frame;
@ -1173,6 +1174,7 @@ pub use runtime_spine::runtime_worker_launch_body_basis;
pub use runtime_spine::runtime_worker_launch_request;
pub use runtime_spine::runtime_worker_process_claim;
pub use runtime_spine::select_and_commit_repo_frontier_planning_request;
pub use runtime_spine::select_and_commit_repo_frontier_research_request;
pub use runtime_spine::select_and_commit_repo_frontier_route;
pub use runtime_spine::select_repo_frontier_work_proposal_for_modeling;
pub use runtime_spine::validate_hands_action_authority;
@ -1320,6 +1322,8 @@ pub use surfaces::REPO_FRONTIER_PLAN_MIND_CONTEXT_CONTRACT;
pub use surfaces::REPO_FRONTIER_PLAN_MIND_CONTEXT_SCHEMA_VERSION;
pub use surfaces::REPO_FRONTIER_PLANNING_CONTEXT_CONTRACT;
pub use surfaces::REPO_FRONTIER_PLANNING_CONTEXT_SCHEMA_VERSION;
pub use surfaces::REPO_FRONTIER_RESEARCH_CONTEXT_CONTRACT;
pub use surfaces::REPO_FRONTIER_RESEARCH_CONTEXT_SCHEMA_VERSION;
pub use surfaces::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT;
pub use surfaces::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION;
pub use surfaces::REPO_MODEL_CLAIM_REPAIR_CONTEXT_CONTRACT;
@ -1327,6 +1331,7 @@ pub use surfaces::REPO_MODEL_CLAIM_REPAIR_CONTEXT_SCHEMA_VERSION;
pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::RepoFrontierPlanMindContextProjection;
pub use surfaces::RepoFrontierPlanningContextProjection;
pub use surfaces::RepoFrontierResearchContextProjection;
pub use surfaces::RepoFrontierProposalModelingContextProjection;
pub use surfaces::RepoModelClaimRepairContextProjection;
pub use surfaces::build_reorient_acceptance_bundle;

View file

@ -100,6 +100,10 @@ pub const LEGACY_REPO_FRONTIER_PLAN_DECISION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.repo_frontier_plan_decision_receipt.v0";
pub const REPO_FRONTIER_PLAN_DECISION_CONTRACT: &str = "epiphany.repo_frontier_plan_decision.v0";
pub const REPO_FRONTIER_PLANNING_CONTRACT: &str = "epiphany.repo_frontier_planning.v1";
pub const REPO_FRONTIER_RESEARCH_REQUEST_SCHEMA_VERSION: &str =
"epiphany.self.repo_frontier_research_request.v0";
pub const REPO_FRONTIER_RESEARCH_REQUEST_CONTRACT: &str =
"epiphany.repo_frontier_research_request.v0";
pub const REPO_FRONTIER_WORK_PROPOSAL_CONTRACT: &str =
"epiphany.repo_frontier_work_proposal.inert.v0";
pub const REPO_FRONTIER_AUTONOMOUS_PROPOSAL_BINDING_SCHEMA_VERSION: &str =
@ -556,6 +560,38 @@ pub struct RepoFrontierPlanningLaunchBinding {
pub superseded_failure_result_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.self.repo_frontier_research_request",
schema = "RepoFrontierResearchRequest"
)]
pub struct RepoFrontierResearchRequest {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub request_id: String,
#[cultcache(key = 2)]
pub model_revision: u64,
#[cultcache(key = 3)]
pub model_hash: String,
#[cultcache(key = 4)]
pub admission_receipt_id: String,
#[cultcache(key = 5)]
pub frontier_item_id: String,
#[cultcache(key = 6)]
pub frontier_item_hash: String,
#[cultcache(key = 7)]
pub source_scope: Vec<String>,
#[cultcache(key = 8)]
pub requested_at: String,
#[cultcache(key = 9)]
pub runtime_id: String,
#[cultcache(key = 10)]
pub thread_id: String,
#[cultcache(key = 11)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.imagination.repo_frontier_plan_candidate",

View file

@ -3710,6 +3710,7 @@ mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: Some(
@ -3755,6 +3756,7 @@ mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: Some(request.request_id.clone()),
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority_msgpack: None,
};
let mut cache = crate::runtime_spine_cache(store)?;
@ -3784,6 +3786,7 @@ mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: Some(
crate::ImaginationConsiderationContextProjection::new(request, model),
@ -3827,6 +3830,7 @@ mod tests {
imagination_consideration_request_id: Some(request.request_id.clone()),
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority_msgpack: None,
};
let binding = crate::ImaginationConsiderationLaunchBinding {
@ -6016,6 +6020,7 @@ mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -6057,6 +6062,7 @@ mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority_msgpack: None,
};
let mut runtime = crate::runtime_spine_cache(&runtime_store)?;
@ -6165,6 +6171,7 @@ mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -6208,6 +6215,7 @@ mod tests {
"request-worker-death-settlement".into(),
),
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority_msgpack: None,
};
crate::runtime_spine_cache(&policy.runtime_store)?.put(&launch.job_id, &launch)?;

View file

@ -65,6 +65,7 @@ use crate::repo_model_gateway::{
REPO_FRONTIER_PLANNING_CONTRACT, REPO_FRONTIER_PLANNING_LAUNCH_BINDING_CONTRACT,
REPO_FRONTIER_PLANNING_LAUNCH_BINDING_SCHEMA_VERSION,
REPO_FRONTIER_PLANNING_REQUEST_SCHEMA_VERSION,
REPO_FRONTIER_RESEARCH_REQUEST_CONTRACT, REPO_FRONTIER_RESEARCH_REQUEST_SCHEMA_VERSION,
REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_CONTRACT,
REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_SCHEMA_VERSION,
REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT,
@ -85,6 +86,7 @@ use crate::repo_model_gateway::{
RepoFrontierPlanningCandidateEligibility, RepoFrontierPlanningEligibility,
RepoFrontierPlanningLaunchBinding, RepoFrontierPlanningLifecycle,
RepoFrontierPlanningLifecycleStage, RepoFrontierPlanningRequest,
RepoFrontierResearchRequest,
RepoFrontierProposalModelingLaunchBinding, RepoFrontierProposalModelingRequest,
RepoFrontierRelinquishmentReceipt, RepoFrontierRoute, RepoFrontierVerdictDisposition,
RepoFrontierWorkProposal, RepoModelAdmissionReceipt, RepoModelAdmissionReview,
@ -461,6 +463,8 @@ pub struct EpiphanyRuntimeWorkerLaunchRequest {
pub repo_frontier_modeling_request_id: Option<String>,
#[cultcache(key = 18, default)]
pub repo_frontier_verdict_modeling_authority_msgpack: Option<Vec<u8>>,
#[cultcache(key = 19, default)]
pub repo_frontier_research_request_id: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
@ -999,6 +1003,7 @@ pub struct RuntimeSpineHeartbeatJobOptions {
pub imagination_consideration_request_id: Option<String>,
pub admitted_model_direction_consideration_request_id: Option<String>,
pub repo_frontier_modeling_request_id: Option<String>,
pub repo_frontier_research_request_id: Option<String>,
pub repo_frontier_verdict_modeling_authority:
Option<RepoFrontierVerdictModelingLaunchAuthority>,
pub created_at: String,
@ -1055,6 +1060,7 @@ pub struct EpiphanyJobLaunchRequest {
pub imagination_consideration_request_id: Option<String>,
pub admitted_model_direction_consideration_request_id: Option<String>,
pub repo_frontier_modeling_request_id: Option<String>,
pub repo_frontier_research_request_id: Option<String>,
pub repo_frontier_verdict_modeling_authority:
Option<RepoFrontierVerdictModelingLaunchAuthority>,
}
@ -1136,6 +1142,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
cache.register_entry_type::<RepoFrontierProposalModelingRequest>()?;
cache.register_entry_type::<RepoFrontierProposalModelingLaunchBinding>()?;
cache.register_entry_type::<RepoFrontierPlanningRequest>()?;
cache.register_entry_type::<RepoFrontierResearchRequest>()?;
cache.register_entry_type::<RepoFrontierPlanningLaunchBinding>()?;
cache.register_entry_type::<crate::ImaginationConsiderationRequest>()?;
cache.register_entry_type::<crate::ImaginationConsiderationLaunchBinding>()?;
@ -3048,6 +3055,12 @@ pub fn open_runtime_spine_heartbeat_job(
options.frontier_planning_request_id.as_deref(),
&options.launch_document,
)?;
validate_frontier_research_launch_carrier(
&options.role,
&options.binding_id,
options.repo_frontier_research_request_id.as_deref(),
&options.launch_document,
)?;
validate_imagination_consideration_launch_carrier(
&options.role,
&options.binding_id,
@ -3150,6 +3163,7 @@ pub fn open_runtime_spine_heartbeat_job(
admitted_model_direction_consideration_request_id: options
.admitted_model_direction_consideration_request_id,
repo_frontier_modeling_request_id: options.repo_frontier_modeling_request_id,
repo_frontier_research_request_id: options.repo_frontier_research_request_id,
repo_frontier_verdict_modeling_authority_msgpack: options
.repo_frontier_verdict_modeling_authority
.as_ref()
@ -3189,6 +3203,12 @@ pub fn prepare_runtime_spine_heartbeat_job(
options.frontier_planning_request_id.as_deref(),
&options.launch_document,
)?;
validate_frontier_research_launch_carrier(
&options.role,
&options.binding_id,
options.repo_frontier_research_request_id.as_deref(),
&options.launch_document,
)?;
validate_imagination_consideration_launch_carrier(
&options.role,
&options.binding_id,
@ -3317,6 +3337,7 @@ pub fn prepare_runtime_spine_heartbeat_job(
admitted_model_direction_consideration_request_id: options
.admitted_model_direction_consideration_request_id,
repo_frontier_modeling_request_id: options.repo_frontier_modeling_request_id,
repo_frontier_research_request_id: options.repo_frontier_research_request_id,
repo_frontier_verdict_modeling_authority_msgpack: options
.repo_frontier_verdict_modeling_authority
.as_ref()
@ -3589,6 +3610,44 @@ pub fn runtime_worker_process_claim(
cache.get::<EpiphanyRuntimeWorkerProcessClaim>(&worker_process_claim_id(job_id))
}
fn validate_frontier_research_launch_carrier(
role: &str,
binding_id: &str,
research_request_id: Option<&str>,
launch_document: &EpiphanyWorkerLaunchDocument,
) -> Result<()> {
let projection = match launch_document {
EpiphanyWorkerLaunchDocument::Role(document) => document.frontier_research_context.as_ref(),
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
};
let Some(request_id) = research_request_id else {
if projection.is_some() {
return Err(anyhow!(
"frontier Research context requires its typed request id"
));
}
return Ok(());
};
validate_non_empty(request_id, "frontier Research request id")?;
if role != crate::EPIPHANY_RESEARCH_OWNER_ROLE
|| binding_id != crate::EPIPHANY_RESEARCH_ROLE_BINDING_ID
{
return Err(anyhow!(
"frontier Research request may only be transported by the Research role launch"
));
}
let projection = projection
.ok_or_else(|| anyhow!("frontier Research request requires its typed context"))?;
if projection.request_id != request_id
|| projection.schema_version
!= crate::REPO_FRONTIER_RESEARCH_CONTEXT_SCHEMA_VERSION
|| projection.contract != crate::REPO_FRONTIER_RESEARCH_CONTEXT_CONTRACT
{
return Err(anyhow!("frontier Research context/request mismatch"));
}
Ok(())
}
pub fn runtime_authenticated_public_source_lookups_for_worker(
store_path: impl AsRef<Path>,
worker_job_id: &str,
@ -8632,6 +8691,206 @@ pub fn runtime_has_actionable_eyes_frontier(runtime_store: impl AsRef<Path>) ->
runtime_has_actionable_frontier_for_organ(runtime_store, "Eyes")
}
pub fn select_and_commit_repo_frontier_research_request(
runtime_store: impl AsRef<Path>,
at: &str,
) -> Result<RepoFrontierResearchRequest> {
chrono::DateTime::parse_from_rfc3339(at)
.map_err(|_| anyhow!("research request timestamp must be RFC3339"))?;
let runtime_store = runtime_store.as_ref();
let backing = SingleFileMessagePackBackingStore::new(runtime_store);
let opening = backing.pull_all()?;
let model_envelope = opening
.iter()
.find(|entry| {
entry.r#type == crate::MEMORY_GRAPH_TYPE && entry.key == crate::MEMORY_GRAPH_KEY
})
.cloned()
.ok_or_else(|| anyhow!("frontier Research requires the canonical runtime model"))?;
let mut cache = runtime_spine_cache(runtime_store)?;
cache.pull_all_backing_stores()?;
let identity = require_identity(&cache)?;
let thread = cache
.get::<crate::EpiphanyThreadStateEntry>(crate::THREAD_STATE_KEY)?
.ok_or_else(|| anyhow!("frontier Research requires authoritative thread state"))?;
thread.state()?;
let entry: crate::EpiphanyMemoryGraphEntry = rmp_serde::from_slice(&model_envelope.payload)?;
crate::validate_memory_graph_entry(&entry)?;
let model = entry.snapshot()?;
let model_hash = crate::memory_graph_model_hash(&model)?;
let receipts = cache
.get_all::<RepoModelAdmissionReceipt>()?
.into_iter()
.filter(|receipt| {
crate::repo_model_admission_receipt_schema_supported(
&receipt.schema_version,
&receipt.contract,
) && receipt.admitted_revision == model.model_revision
&& receipt.admitted_hash == model_hash
})
.collect::<Vec<_>>();
if receipts.len() != 1 {
return Err(anyhow!(
"frontier Research requires exactly one current model admission"
));
}
let challenges = current_repo_model_claim_challenges(&cache, &model, &model_hash)?;
let item = actionable_frontier_item_for_organ(&model, &challenges, "Eyes", false)
.ok_or_else(|| anyhow!("current model has no actionable Eyes frontier"))?;
let item_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(item)?));
let request_id = format!(
"repo-frontier-research-{:x}",
Sha256::digest(
format!("{}:{}:{}:{item_hash}", identity.runtime_id, thread.thread_id, model_hash)
.as_bytes()
)
);
let request = RepoFrontierResearchRequest {
schema_version: REPO_FRONTIER_RESEARCH_REQUEST_SCHEMA_VERSION.to_string(),
request_id: request_id.clone(),
model_revision: model.model_revision,
model_hash,
admission_receipt_id: receipts[0].receipt_id.clone(),
frontier_item_id: item.id.clone(),
frontier_item_hash: item_hash,
source_scope: item.source_scope.clone(),
requested_at: at.to_string(),
runtime_id: identity.runtime_id,
thread_id: thread.thread_id,
contract: REPO_FRONTIER_RESEARCH_REQUEST_CONTRACT.to_string(),
};
if let Some(existing) = cache.get::<RepoFrontierResearchRequest>(&request_id)? {
let mut replay = request.clone();
replay.requested_at = existing.requested_at.clone();
return if existing == replay {
Ok(existing)
} else {
Err(anyhow!("frontier Research request identity collision"))
};
}
let (request_envelope, _) = cache.prepare_entry(&request_id, &request)?;
if !backing.compare_and_swap_batch(&[model_envelope.clone()], vec![model_envelope, request_envelope])? {
return Err(anyhow!("frontier Research request lost current-model CAS"));
}
Ok(request)
}
/// True only when the exact current Eyes frontier has not yet been covered by
/// an accepted Eyes packet from a worker launch bound to its typed request.
/// Historical Research acceptance is deliberately irrelevant.
pub fn runtime_has_uncovered_actionable_eyes_frontier(
runtime_store: impl AsRef<Path>,
) -> Result<bool> {
let runtime_store = runtime_store.as_ref();
let mut cache = runtime_spine_cache(runtime_store)?;
cache.pull_all_backing_stores()?;
require_identity(&cache)?;
let requests = cache.get_all::<RepoFrontierResearchRequest>()?;
let launches = cache.get_all::<EpiphanyRuntimeWorkerLaunchRequest>()?;
let packets = cache.get_all::<EyesEvidencePacket>()?;
let mut current = Vec::new();
for request in requests {
if repo_frontier_research_request_is_current(&cache, &request)? {
current.push(request);
}
}
if current.len() > 1 {
return Err(anyhow!("Self found multiple current frontier Research requests"));
}
let Some(request) = current.pop() else {
return runtime_has_actionable_eyes_frontier(runtime_store);
};
let expected_projection = crate::RepoFrontierResearchContextProjection::from(&request);
let mut matching_jobs = BTreeSet::new();
for launch in &launches {
if launch.repo_frontier_research_request_id.as_deref() != Some(&request.request_id) {
continue;
}
let document: EpiphanyWorkerLaunchDocument =
rmp_serde::from_slice(&launch.launch_document_msgpack)?;
validate_frontier_research_launch_carrier(
&launch.role,
&launch.binding_id,
launch.repo_frontier_research_request_id.as_deref(),
&document,
)?;
let carried = match document {
EpiphanyWorkerLaunchDocument::Role(document) => document.frontier_research_context,
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
};
if carried.as_ref() != Some(&expected_projection) {
return Err(anyhow!("frontier Research launch carries substituted context"));
}
matching_jobs.insert(launch.job_id.as_str());
}
Ok(!packets
.iter()
.any(|packet| matching_jobs.contains(packet.source_job_id.as_str())))
}
fn repo_frontier_research_request_is_current(
cache: &CultCache,
request: &RepoFrontierResearchRequest,
) -> Result<bool> {
if request.schema_version != REPO_FRONTIER_RESEARCH_REQUEST_SCHEMA_VERSION
|| request.contract != REPO_FRONTIER_RESEARCH_REQUEST_CONTRACT
|| request.source_scope.is_empty()
|| !safe_sorted_unique_paths(&request.source_scope)
{
return Err(anyhow!("invalid frontier Research request"));
}
let identity = require_identity(cache)?;
let thread = cache
.get::<crate::EpiphanyThreadStateEntry>(crate::THREAD_STATE_KEY)?
.ok_or_else(|| anyhow!("frontier Research request lost thread state"))?;
let entry = cache
.get::<crate::EpiphanyMemoryGraphEntry>(crate::MEMORY_GRAPH_KEY)?
.ok_or_else(|| anyhow!("frontier Research request lost current model"))?;
crate::validate_memory_graph_entry(&entry)?;
let model = entry.snapshot()?;
let model_hash = crate::memory_graph_model_hash(&model)?;
if request.runtime_id != identity.runtime_id
|| request.thread_id != thread.thread_id
|| request.model_revision != model.model_revision
|| request.model_hash != model_hash
{
return Ok(false);
}
let challenges = current_repo_model_claim_challenges(cache, &model, &model_hash)?;
let Some(item) = actionable_frontier_item_for_organ(&model, &challenges, "Eyes", false) else {
return Ok(false);
};
let item_hash = format!("{:x}", Sha256::digest(rmp_serde::to_vec_named(item)?));
let expected_request_id = format!(
"repo-frontier-research-{:x}",
Sha256::digest(
format!(
"{}:{}:{}:{item_hash}",
identity.runtime_id, thread.thread_id, model_hash
)
.as_bytes()
)
);
let admission_count = cache
.get_all::<RepoModelAdmissionReceipt>()?
.into_iter()
.filter(|receipt| {
receipt.receipt_id == request.admission_receipt_id
&& crate::repo_model_admission_receipt_schema_supported(
&receipt.schema_version,
&receipt.contract,
)
&& receipt.admitted_revision == model.model_revision
&& receipt.admitted_hash == model_hash
})
.count();
Ok(admission_count == 1
&& request.request_id == expected_request_id
&& request.frontier_item_id == item.id
&& request.frontier_item_hash == item_hash
&& request.source_scope == item.source_scope)
}
/// Read-only Self signal for proposal planning. It uses the same eligibility
/// predicate as the planning-request committer, including unchallenged target
/// claims, so status cannot advertise authority that the commit path rejects.
@ -13863,6 +14122,7 @@ pub(crate) mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -13903,6 +14163,7 @@ pub(crate) mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority_msgpack: None,
};
let mut cache = runtime_spine_cache(store)?;
@ -16458,6 +16719,20 @@ pub(crate) mod tests {
claim_challenge_fixture(root.path(), "eyes-regather", "Eyes")?;
commit_repo_model_claim_challenge(&eyes_store, &eyes_challenge)?;
assert!(runtime_has_actionable_eyes_frontier(&eyes_store)?);
assert!(runtime_has_uncovered_actionable_eyes_frontier(&eyes_store)?);
let research_request = select_and_commit_repo_frontier_research_request(
&eyes_store,
"2026-07-13T04:02:00Z",
)?;
assert_eq!(research_request.model_revision, eyes_challenge.model_revision);
assert_eq!(
select_and_commit_repo_frontier_research_request(
&eyes_store,
"2026-07-13T04:03:00Z",
)?,
research_request
);
assert!(runtime_has_uncovered_actionable_eyes_frontier(&eyes_store)?);
let (planning_store, planning_challenge) =
claim_challenge_fixture(root.path(), "planning-gate", "Imagination")?;
@ -20622,6 +20897,7 @@ pub(crate) mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -20653,6 +20929,7 @@ pub(crate) mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
created_at: "2026-05-06T00:02:00Z".to_string(),
},
@ -20715,6 +20992,7 @@ pub(crate) mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -20806,6 +21084,7 @@ pub(crate) mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,

View file

@ -281,6 +281,7 @@ mod tests {
proposal_modeling_context: None,
claim_repair_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: None,
admitted_model_direction_consideration_context: None,
@ -313,6 +314,7 @@ mod tests {
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
};
let grant = substrate_gate_repo_access_grant_for_launch(

View file

@ -1139,7 +1139,6 @@ pub fn recommend_coordinator_action(
}
if input.eyes_frontier_ready
&& !input.research_result_accepted
&& matches!(
input.signals.research_result_status,
EpiphanyCoordinatorRoleResultStatus::MissingBinding
@ -2344,6 +2343,7 @@ mod tests {
let eyes_frontier = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: modeling_done,
research_result_accepted: true,
modeling_result_accepted: true,
modeling_result_reviewable: true,
hands_frontier_ready: false,

View file

@ -158,7 +158,8 @@ pub struct EpiphanyCoordinatorInput {
/// admission and an Active, dependency-ready Hands frontier item.
pub hands_frontier_ready: bool,
/// True only when the canonical runtime RepoModel has exactly one current
/// admission and an Active, dependency-ready Eyes frontier item.
/// admission and an Active, dependency-ready Eyes frontier item not yet
/// covered by an accepted packet from its typed Research request.
pub eyes_frontier_ready: bool,
/// Read-only projection of the single typed Imagination -> Mind planning
/// lifecycle. Self may advance it, but only Mind's result can decide adoption.

View file

@ -129,6 +129,8 @@ pub use worker_launch::REPO_FRONTIER_PLAN_MIND_CONTEXT_CONTRACT;
pub use worker_launch::REPO_FRONTIER_PLAN_MIND_CONTEXT_SCHEMA_VERSION;
pub use worker_launch::REPO_FRONTIER_PLANNING_CONTEXT_CONTRACT;
pub use worker_launch::REPO_FRONTIER_PLANNING_CONTEXT_SCHEMA_VERSION;
pub use worker_launch::REPO_FRONTIER_RESEARCH_CONTEXT_CONTRACT;
pub use worker_launch::REPO_FRONTIER_RESEARCH_CONTEXT_SCHEMA_VERSION;
pub use worker_launch::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT;
pub use worker_launch::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION;
pub use worker_launch::REPO_MODEL_CLAIM_REPAIR_CONTEXT_CONTRACT;
@ -136,6 +138,7 @@ pub use worker_launch::REPO_MODEL_CLAIM_REPAIR_CONTEXT_SCHEMA_VERSION;
pub use worker_launch::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use worker_launch::RepoFrontierPlanMindContextProjection;
pub use worker_launch::RepoFrontierPlanningContextProjection;
pub use worker_launch::RepoFrontierResearchContextProjection;
pub use worker_launch::RepoFrontierProposalModelingContextProjection;
pub use worker_launch::RepoModelClaimRepairContextProjection;
pub use worker_launch::build_reorient_job_launch_request;

View file

@ -38,6 +38,10 @@ pub const REPO_FRONTIER_PLANNING_CONTEXT_SCHEMA_VERSION: &str =
"epiphany.worker.repo_frontier_planning_context.v0";
pub const REPO_FRONTIER_PLANNING_CONTEXT_CONTRACT: &str =
"epiphany.repo_frontier_planning_context.v0";
pub const REPO_FRONTIER_RESEARCH_CONTEXT_SCHEMA_VERSION: &str =
"epiphany.worker.repo_frontier_research_context.v0";
pub const REPO_FRONTIER_RESEARCH_CONTEXT_CONTRACT: &str =
"epiphany.repo_frontier_research_context.v0";
pub const REPO_FRONTIER_PLAN_MIND_CONTEXT_SCHEMA_VERSION: &str =
"epiphany.worker.repo_frontier_plan_mind_context.v0";
pub const REPO_FRONTIER_PLAN_MIND_CONTEXT_CONTRACT: &str =
@ -109,6 +113,8 @@ pub struct EpiphanyRoleWorkerLaunchDocument {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub frontier_planning_context: Option<RepoFrontierPlanningContextProjection>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub frontier_research_context: Option<RepoFrontierResearchContextProjection>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub frontier_plan_mind_context: Option<RepoFrontierPlanMindContextProjection>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub imagination_consideration_context: Option<ImaginationConsiderationContextProjection>,
@ -143,6 +149,36 @@ pub struct EpiphanyRoleWorkerLaunchDocument {
pub churn: Option<EpiphanyChurnState>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RepoFrontierResearchContextProjection {
pub schema_version: String,
pub request_id: String,
pub model_revision: u64,
pub model_hash: String,
pub admission_receipt_id: String,
pub frontier_item_id: String,
pub frontier_item_hash: String,
pub source_scope: Vec<String>,
pub contract: String,
}
impl From<&crate::RepoFrontierResearchRequest> for RepoFrontierResearchContextProjection {
fn from(request: &crate::RepoFrontierResearchRequest) -> Self {
Self {
schema_version: REPO_FRONTIER_RESEARCH_CONTEXT_SCHEMA_VERSION.to_string(),
request_id: request.request_id.clone(),
model_revision: request.model_revision,
model_hash: request.model_hash.clone(),
admission_receipt_id: request.admission_receipt_id.clone(),
frontier_item_id: request.frontier_item_id.clone(),
frontier_item_hash: request.frontier_item_hash.clone(),
source_scope: request.source_scope.clone(),
contract: REPO_FRONTIER_RESEARCH_CONTEXT_CONTRACT.to_string(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyReorientWorkerLaunchDocument {
@ -441,6 +477,7 @@ pub fn build_reorient_job_launch_request(
imagination_consideration_request_id: None,
admitted_model_direction_consideration_request_id: None,
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verdict_modeling_authority: None,
}
}