Bind selected proposals to Modeling admission

This commit is contained in:
Meta Vens 2026-07-14 01:03:54 +01:00
commit 79e1e26cf8
18 changed files with 1802 additions and 57 deletions

View file

@ -327,6 +327,14 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
"repoFrontierModelingRequestId".to_string(),
serde_json::json!({"type": "string", "minLength": 1}),
);
map.insert(
"proposalModelingRequestId".to_string(),
serde_json::json!({
"type": "string",
"minLength": 1,
"description": "Exact echo of an explicit typed repo-frontier proposal Modeling request, when supplied."
}),
);
map.insert(
"statePatch".to_string(),
serde_json::json!({
@ -560,6 +568,7 @@ pub fn build_epiphany_role_launch_request_with_dynamic_context(
state_revision: state.revision,
objective: state.objective.clone(),
dynamic_prompt_context,
proposal_modeling_context: None,
active_subgoal_id: state.active_subgoal_id.clone(),
active_subgoals: state
.subgoals
@ -600,6 +609,7 @@ pub fn build_epiphany_role_launch_request_with_dynamic_context(
output_contract_id,
organ_launch_contract,
max_runtime_seconds,
proposal_modeling_request_id: None,
})
}
@ -702,6 +712,7 @@ pub fn build_epiphany_job_launch_request(
output_contract_id,
organ_launch_contract,
max_runtime_seconds,
proposal_modeling_request_id: None,
}
}

View file

@ -95,6 +95,7 @@ struct Args {
simulate_continue_implementation: bool,
simulate_source_drift: bool,
dry_compact: bool,
proposal_modeling_request_id: Option<String>,
}
impl Args {
@ -133,6 +134,7 @@ impl Args {
simulate_continue_implementation: false,
simulate_source_drift: false,
dry_compact: false,
proposal_modeling_request_id: None,
};
while let Some(arg) = args.next() {
match arg.as_str() {
@ -152,6 +154,10 @@ impl Args {
parsed.model_provider = take_string(&mut args, "--model-provider")?;
}
"--thread-id" => parsed.thread_id = Some(take_string(&mut args, "--thread-id")?),
"--proposal-modeling-request-id" => {
parsed.proposal_modeling_request_id =
Some(take_string(&mut args, "--proposal-modeling-request-id")?);
}
"--cwd" => parsed.cwd = take_path(&mut args, "--cwd")?,
"--codex-home" => parsed.codex_home = take_path(&mut args, "--codex-home")?,
"--artifact-dir" => parsed.artifact_dir = take_path(&mut args, "--artifact-dir")?,
@ -488,6 +494,11 @@ fn run_coordinator(args: &Args) -> Result<Value> {
role_id,
revision,
args.max_runtime_seconds,
if role_id == "modeling" {
args.proposal_modeling_request_id.as_deref()
} else {
None
},
)?;
let worker_job_id = worker_job_id_from_launch(&launch)?;
push_event(
@ -937,6 +948,7 @@ fn launch_role(
role_id: &str,
expected_revision: Option<i64>,
max_runtime_seconds: u64,
proposal_modeling_request_id: Option<&str>,
) -> Result<Value> {
let service = epiphany_core::EpiphanyCoordinatorService::new(runtime_store);
let state = service
@ -965,7 +977,7 @@ fn launch_role(
)
.map_err(anyhow::Error::msg)?;
}
let request = epiphany_core::build_epiphany_role_launch_request_with_dynamic_context(
let mut request = epiphany_core::build_epiphany_role_launch_request_with_dynamic_context(
thread_id,
role,
expected_revision,
@ -974,6 +986,7 @@ fn launch_role(
Some(context),
)
.map_err(anyhow::Error::msg)?;
request.proposal_modeling_request_id = proposal_modeling_request_id.map(str::to_string);
let launched = service.launch_job(
thread_id,
&state,

View file

@ -1169,6 +1169,7 @@ mod tests {
verification_request_id: String::new(),
soul_verdict_receipt_id: String::new(),
frontier_modeling_request_id: String::new(),
proposal_modeling_request_id: String::new(),
},
)?;
let mut fresh = existing.clone();

View file

@ -2,6 +2,7 @@ use crate::*;
use anyhow::{Result, anyhow};
use cultcache_rs::{CultCache, CultCacheEnvelope};
use epiphany_state_model::{EpiphanyRuntimeLink, EpiphanyThreadState};
use sha2::{Digest, Sha256};
use std::path::Path;
#[derive(Debug, Clone)]
@ -43,12 +44,45 @@ fn commit_coordinator_job_launch_in_cache(
created_at: String,
injected_envelopes: Vec<CultCacheEnvelope>,
) -> Result<EpiphanyJobLaunchResult> {
let runtime_identity = cache
.get::<EpiphanyRuntimeIdentity>(RUNTIME_IDENTITY_KEY)?
.ok_or_else(|| anyhow!("coordinator launch requires runtime identity"))?;
let next_state =
apply_coordinator_state_update_to_state(current_state, plan.state_update.clone(), None)?;
let mut effective_launch_document = request.launch_document.clone();
let proposal_launch = if let Some(request_id) = request.proposal_modeling_request_id.as_deref()
{
let (selection, proposal, identity) =
validate_proposal_modeling_launch(cache, current_state, request, request_id)?;
let model = cache
.get::<crate::EpiphanyMemoryGraphEntry>(crate::MEMORY_GRAPH_KEY)?
.ok_or_else(|| anyhow!("proposal Modeling launch requires canonical RepoModel"))?
.snapshot()?;
let projection = build_proposal_modeling_context_projection(&selection, &proposal, &model)?;
match &mut effective_launch_document {
EpiphanyWorkerLaunchDocument::Role(document) => {
document.proposal_modeling_context = Some(projection);
}
EpiphanyWorkerLaunchDocument::Reorient(_) => {
return Err(anyhow!(
"reorient launch cannot carry proposal Modeling context"
));
}
}
let bytes = rmp_serde::to_vec_named(&effective_launch_document)?;
Some((
selection,
proposal,
identity,
format!("{:x}", Sha256::digest(bytes)),
))
} else {
None
};
let prepared = prepare_runtime_spine_heartbeat_job(
&cache,
RuntimeSpineHeartbeatJobOptions {
runtime_id: "epiphany-local".to_string(),
runtime_id: runtime_identity.runtime_id,
display_name: "Epiphany Local".to_string(),
session_id: "epiphany-main".to_string(),
objective: plan
@ -64,13 +98,46 @@ fn commit_coordinator_job_launch_in_cache(
binding_id: request.binding_id.clone(),
authority_scope: request.authority_scope.clone(),
instruction: request.instruction.clone(),
launch_document: request.launch_document.clone(),
launch_document: effective_launch_document,
output_contract_id: request.output_contract_id.clone(),
organ_launch_contract: request.organ_launch_contract.clone(),
proposal_modeling_request_id: request.proposal_modeling_request_id.clone(),
created_at: created_at.clone(),
},
)?;
let mut batch = prepared.envelopes;
if let Some((selection, proposal, identity, worker_launch_document_sha256)) = proposal_launch {
let launch_binding = RepoFrontierProposalModelingLaunchBinding {
schema_version: REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_SCHEMA_VERSION.into(),
binding_record_id: format!(
"repo-frontier-proposal-modeling-launch-{}",
plan.backend_job_id
),
proposal_modeling_request_id: selection.request_id,
proposal_id: proposal.proposal_id,
proposal_payload_sha256: proposal.payload_sha256,
job_id: plan.backend_job_id.clone(),
binding_id: request.binding_id.clone(),
runtime_id: identity.runtime_id,
thread_id: selection.thread_id.clone(),
launched_at: created_at.clone(),
worker_launch_document_sha256,
contract: REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_CONTRACT.into(),
};
if cache
.get::<RepoFrontierProposalModelingLaunchBinding>(&launch_binding.binding_record_id)?
.is_some()
{
return Err(anyhow!(
"proposal Modeling launch binding already exists for backend job"
));
}
batch.push(
cache
.prepare_entry(&launch_binding.binding_record_id, &launch_binding)?
.0,
);
}
if request.binding_id == EPIPHANY_RESEARCH_ROLE_BINDING_ID {
let grant = substrate_gate_repo_access_grant_for_launch(
format!("substrate-grant-{}", plan.backend_job_id),
@ -102,6 +169,15 @@ pub fn plan_coordinator_job_launch(
launcher_job_id: String,
backend_job_id: String,
) -> Result<EpiphanyCoordinatorJobLaunchPlan> {
let caller_projection = match &request.launch_document {
EpiphanyWorkerLaunchDocument::Role(document) => document.proposal_modeling_context.as_ref(),
EpiphanyWorkerLaunchDocument::Reorient(_) => None,
};
if caller_projection.is_some() {
return Err(anyhow!(
"caller-prepopulated proposal Modeling context is forbidden; coordinator commit owns projection"
));
}
if let Some(expected) = request.expected_revision
&& expected != state.revision
{
@ -110,6 +186,13 @@ pub fn plan_coordinator_job_launch(
state.revision
));
}
if let Some(request_id) = request.proposal_modeling_request_id.as_deref() {
let mut cache = runtime_spine_cache(runtime_store)?;
cache.pull_all_backing_stores()?;
validate_proposal_modeling_launch(&cache, state, request, request_id)?;
} else if request.owner_role == EPIPHANY_MODELING_OWNER_ROLE {
// Ordinary Modeling launches remain valid, but carry no proposal authority.
}
let completed_prior_link =
terminal_runtime_link_for_binding(state, &request.binding_id, runtime_store)?;
let mut planning_state = state.clone();
@ -164,6 +247,115 @@ pub fn plan_coordinator_job_launch(
})
}
fn build_proposal_modeling_context_projection(
request: &RepoFrontierProposalModelingRequest,
proposal: &RepoFrontierWorkProposal,
model: &crate::EpiphanyMemoryGraphSnapshot,
) -> Result<RepoFrontierProposalModelingContextProjection> {
Ok(RepoFrontierProposalModelingContextProjection {
schema_version: REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION.into(),
contract: REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT.into(),
request_id: request.request_id.clone(),
proposal_id: proposal.proposal_id.clone(),
proposal_payload_sha256: proposal.payload_sha256.clone(),
runtime_id: request.runtime_id.clone(),
thread_id: request.thread_id.clone(),
repository: request.repository.clone(),
workspace: request.workspace.clone(),
source_kind: proposal.source_kind,
source_actor: proposal.source_actor.clone(),
source_ref: proposal.source_ref.clone(),
title: proposal.title.clone(),
body: proposal.body.clone(),
desired_outcome: proposal.desired_outcome.clone(),
constraints: proposal.constraints.clone(),
scope_hints: proposal.scope_hints.clone(),
evidence_refs: proposal.evidence_refs.clone(),
private_state_included: proposal.private_state_included,
model_revision: model.model_revision,
model_hash: crate::memory_graph_model_hash(model)?,
})
}
fn validate_proposal_modeling_launch(
cache: &CultCache,
state: &EpiphanyThreadState,
launch: &EpiphanyJobLaunchRequest,
request_id: &str,
) -> Result<(
RepoFrontierProposalModelingRequest,
RepoFrontierWorkProposal,
EpiphanyRuntimeIdentity,
)> {
if match &launch.launch_document {
EpiphanyWorkerLaunchDocument::Role(document) => {
document.proposal_modeling_context.is_some()
}
EpiphanyWorkerLaunchDocument::Reorient(_) => false,
} {
return Err(anyhow!("caller cannot author proposal Modeling context"));
}
if launch.owner_role != EPIPHANY_MODELING_OWNER_ROLE
|| launch.binding_id != EPIPHANY_MODELING_ROLE_BINDING_ID
{
return Err(anyhow!(
"proposal selection may only be carried by the Modeling role launch"
));
}
let selection = cache
.get::<RepoFrontierProposalModelingRequest>(request_id)?
.ok_or_else(|| {
anyhow!("proposal Modeling selection request {request_id:?} does not exist")
})?;
crate::runtime_spine::validate_repo_frontier_proposal_modeling_request(&selection)?;
let proposal = cache
.get::<RepoFrontierWorkProposal>(&selection.proposal_id)?
.ok_or_else(|| anyhow!("proposal Modeling selection references a missing proposal"))?;
crate::runtime_spine::validate_repo_frontier_work_proposal(&proposal)?;
if cache
.get_all::<RepoFrontierProposalModelingLaunchBinding>()?
.iter()
.any(|binding| binding.proposal_modeling_request_id == request_id)
{
return Err(anyhow!(
"proposal Modeling selection request is already bound to a launch"
));
}
let identity = cache
.get::<EpiphanyRuntimeIdentity>(RUNTIME_IDENTITY_KEY)?
.ok_or_else(|| anyhow!("proposal Modeling launch requires runtime identity"))?;
let persisted_state = cache
.get::<crate::EpiphanyThreadStateEntry>(crate::THREAD_STATE_KEY)?
.ok_or_else(|| anyhow!("proposal Modeling launch requires authoritative thread state"))?;
let persisted_state_value = persisted_state.state()?;
let content = rmp_serde::to_vec_named(&(
&proposal.title,
&proposal.body,
&proposal.desired_outcome,
&proposal.constraints,
&proposal.scope_hints,
&proposal.evidence_refs,
))?;
if selection.schema_version != REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_SCHEMA_VERSION
|| selection.contract != REPO_FRONTIER_PROPOSAL_MODELING_REQUEST_CONTRACT
|| selection.request_id != request_id
|| selection.proposal_payload_sha256 != proposal.payload_sha256
|| proposal.payload_sha256 != format!("{:x}", Sha256::digest(content))
|| selection.runtime_id != identity.runtime_id
|| selection.runtime_id != proposal.runtime_id
|| selection.thread_id != persisted_state.thread_id
|| selection.thread_id != proposal.thread_id
|| persisted_state_value != *state
|| selection.repository != proposal.repository
|| selection.workspace != proposal.workspace
{
return Err(anyhow!(
"proposal Modeling launch provenance binding mismatch"
));
}
Ok((selection, proposal, identity))
}
fn terminal_runtime_link_for_binding(
state: &EpiphanyThreadState,
binding_id: &str,
@ -196,6 +388,102 @@ fn terminal_runtime_link_for_binding(
mod tests {
use super::*;
fn proposal_launch_fixture(
root: &Path,
suffix: &str,
) -> Result<(
std::path::PathBuf,
EpiphanyThreadState,
EpiphanyJobLaunchRequest,
crate::RepoFrontierProposalModelingRequest,
)> {
let store = root.join(format!("proposal-launch-{suffix}.cc"));
let runtime_id = format!("proposal-launch-runtime-{suffix}");
let thread_id = format!("proposal-launch-thread-{suffix}");
initialize_runtime_spine(
&store,
RuntimeSpineInitOptions {
runtime_id: runtime_id.clone(),
display_name: "Proposal launch fixture".into(),
created_at: "2026-07-13T05:00:00Z".into(),
},
)?;
let state = EpiphanyThreadState::default();
let cache = coordinator_acceptance_cache(&store)?;
cache.put(
THREAD_STATE_KEY,
&EpiphanyThreadStateEntry::from_state(&thread_id, &state)?,
)?;
crate::ensure_runtime_repo_model(
&store,
root.join(format!("proposal-launch-{suffix}.legacy.cc")),
&crate::EpiphanyMemoryGraphSnapshot {
schema_version: Some(crate::MEMORY_GRAPH_SCHEMA_VERSION.to_string()),
graph_id: format!("proposal-launch-model-{suffix}"),
domains: vec![crate::EpiphanyMemoryDomain {
id: "repo".to_string(),
profile: crate::EpiphanyMemoryProfile::RepoArchitecture,
title: "Repository".to_string(),
lifecycle: crate::EpiphanyMemoryLifecycle::Accepted,
..Default::default()
}],
nodes: vec![crate::EpiphanyMemoryNode {
id: format!("proposal-launch-claim-{suffix}"),
domain_id: "repo".to_string(),
profile: crate::EpiphanyMemoryProfile::RepoArchitecture,
kind: crate::EpiphanyMemoryNodeKind::RuntimeContract,
title: "Proposal launch".to_string(),
claim: "Coordinator launch owns the proposal context projection.".to_string(),
question: "Does every selected proposal reach the exact bound worker?"
.to_string(),
action_implication: "Inject and seal the projection in the launch transaction."
.to_string(),
source_hashes: vec!["anchor:missing".to_string()],
lifecycle: crate::EpiphanyMemoryLifecycle::Accepted,
..Default::default()
}],
..Default::default()
},
"2026-07-13T05:00:00Z",
)?;
let proposal_id = format!("proposal-launch-{suffix}");
crate::intake_user_repo_frontier_proposal(
&store,
crate::RepoFrontierUserProposalInput {
proposal_id: proposal_id.clone(),
source_actor: "fixture-user".into(),
source_ref: format!("fixture:{suffix}"),
repository: "EpiphanyAgent".into(),
workspace: "E:/Projects/EpiphanyAgent".into(),
thread_id: thread_id.clone(),
runtime_id,
title: "Launch selected Modeling".into(),
body: "Bind one backend job".into(),
desired_outcome: "One immutable launch binding".into(),
constraints: vec!["No duplicate backend".into()],
scope_hints: vec!["epiphany-core/src".into()],
evidence_refs: vec![format!("fixture:{suffix}")],
private_state_included: false,
proposed_at: "2026-07-13T05:00:01Z".into(),
},
)?;
let selection = crate::select_repo_frontier_work_proposal_for_modeling(
&store,
&proposal_id,
"2026-07-13T05:00:02Z",
)?;
let mut request = build_epiphany_role_launch_request(
&thread_id,
EpiphanyRoleResultRoleId::Modeling,
Some(state.revision),
Some(60),
&state,
)
.map_err(|error| anyhow!(error))?;
request.proposal_modeling_request_id = Some(selection.request_id.clone());
Ok((store, state, request, selection))
}
fn research_launch(state: &EpiphanyThreadState) -> EpiphanyJobLaunchRequest {
build_epiphany_role_launch_request(
"thread-1",
@ -236,6 +524,14 @@ mod tests {
fn launch_documents_state_and_grant_share_one_snapshot() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("launch.cc");
initialize_runtime_spine(
&store,
RuntimeSpineInitOptions {
runtime_id: "coordinator-launch-test".to_string(),
display_name: "Coordinator Launch Test".to_string(),
created_at: "2026-07-10T23:59:59Z".to_string(),
},
)?;
let state = EpiphanyThreadState::default();
let request = research_launch(&state);
let plan = plan_coordinator_job_launch(
@ -349,4 +645,95 @@ mod tests {
);
Ok(())
}
#[test]
fn proposal_launch_refuses_corrupt_selection_and_second_backend_without_writes() -> Result<()> {
let root = tempfile::tempdir()?;
let (store, state, request, mut selection) =
proposal_launch_fixture(root.path(), "corrupt")?;
selection.contract = "corrupt".into();
let mut cache = coordinator_acceptance_cache(&store)?;
cache.put(&selection.request_id, &selection)?;
let before = std::fs::read(&store)?;
assert!(
plan_coordinator_job_launch(
&state,
&request,
&store,
"launcher-corrupt".into(),
"backend-corrupt".into(),
)
.is_err()
);
assert_eq!(std::fs::read(&store)?, before);
let (store, state, request, selection) = proposal_launch_fixture(root.path(), "duplicate")?;
let first = plan_coordinator_job_launch(
&state,
&request,
&store,
"launcher-first".into(),
"backend-first".into(),
)?;
let committed = commit_coordinator_job_launch(
&store,
&selection.thread_id,
&state,
&request,
&first,
"2026-07-13T05:00:03Z".into(),
)?;
let persisted_launch = runtime_worker_launch_request(&store, "backend-first")?
.expect("coordinator persisted worker launch");
let persisted_document = persisted_launch.launch_document()?;
let projection = match persisted_document {
EpiphanyWorkerLaunchDocument::Role(document) => document
.proposal_modeling_context
.expect("coordinator injected typed proposal context"),
EpiphanyWorkerLaunchDocument::Reorient(_) => {
panic!("proposal selection cannot produce reorient launch")
}
};
assert_eq!(projection.request_id, selection.request_id);
assert_eq!(projection.proposal_id, selection.proposal_id);
assert_eq!(
projection.proposal_payload_sha256,
selection.proposal_payload_sha256
);
let mut cache = coordinator_acceptance_cache(&store)?;
let binding = cache
.get::<RepoFrontierProposalModelingLaunchBinding>(
"repo-frontier-proposal-modeling-launch-backend-first",
)?
.expect("coordinator persisted proposal launch binding");
assert_eq!(
binding.worker_launch_document_sha256,
format!(
"{:x}",
Sha256::digest(&persisted_launch.launch_document_msgpack)
)
);
let mut second_request = build_epiphany_role_launch_request(
&selection.thread_id,
EpiphanyRoleResultRoleId::Modeling,
Some(committed.epiphany_state.revision),
Some(60),
&committed.epiphany_state,
)
.map_err(|error| anyhow!(error))?;
second_request.proposal_modeling_request_id = request.proposal_modeling_request_id.clone();
let before = std::fs::read(&store)?;
assert!(
plan_coordinator_job_launch(
&committed.epiphany_state,
&second_request,
&store,
"launcher-second".into(),
"backend-second".into(),
)
.is_err()
);
assert_eq!(std::fs::read(&store)?, before);
Ok(())
}
}

View file

@ -831,6 +831,64 @@ mod tests {
let legacy = store.with_extension("context-legacy.msgpack");
let (current, _) =
crate::ensure_runtime_repo_model(store, legacy, &bootstrap, "2026-06-12T00:00:00Z")?;
let thread_id = "context-proposal-thread";
let state = EpiphanyThreadState::default();
let mut cache = crate::runtime_spine_cache(store)?;
cache.pull_all_backing_stores()?;
cache.put(
crate::THREAD_STATE_KEY,
&crate::EpiphanyThreadStateEntry::from_state(thread_id, &state)?,
)?;
let proposal_id = "context-route-proposal";
crate::intake_user_repo_frontier_proposal(
store,
crate::RepoFrontierUserProposalInput {
proposal_id: proposal_id.to_string(),
source_actor: "context-test".to_string(),
source_ref: "test:verification-context".to_string(),
repository: "EpiphanyAgent".to_string(),
workspace: "E:/Projects/EpiphanyAgent".to_string(),
thread_id: thread_id.to_string(),
runtime_id: "epiphany-hands-context-test".to_string(),
title: "Verify routed Hands receipts".to_string(),
body: "The verification context needs one admitted frontier.".to_string(),
desired_outcome: "Bind verification to the exact Hands chain.".to_string(),
constraints: vec!["No direct execution authority".to_string()],
scope_hints: intent.requested_paths.clone(),
evidence_refs: vec!["context-route-evidence".to_string()],
private_state_included: false,
proposed_at: "2026-06-12T00:00:01Z".to_string(),
},
)?;
let selection = crate::select_repo_frontier_work_proposal_for_modeling(
store,
proposal_id,
"2026-06-12T00:00:02Z",
)?;
let mut launch = crate::build_epiphany_role_launch_request(
thread_id,
crate::EpiphanyRoleResultRoleId::Modeling,
Some(state.revision),
Some(60),
&state,
)
.map_err(anyhow::Error::msg)?;
launch.proposal_modeling_request_id = Some(selection.request_id.clone());
let plan = crate::plan_coordinator_job_launch(
&state,
&launch,
store,
"context-route-launcher".to_string(),
"context-route-job".to_string(),
)?;
crate::commit_coordinator_job_launch(
store,
thread_id,
&state,
&launch,
&plan,
"2026-06-12T00:00:03Z".to_string(),
)?;
let patch = crate::RepoModelPatch {
patch_id: "context-route-patch".to_string(),
base_revision: current.model_revision,
@ -846,6 +904,7 @@ mod tests {
target_claim_ids: vec!["claim-context-hands".to_string()],
source_scope: intent.requested_paths.clone(),
recommended_next_organ: "Hands".to_string(),
evidence_refs: vec![proposal_id.to_string()],
status: RepoFrontierStatus::Active,
..Default::default()
},
@ -864,7 +923,7 @@ mod tests {
scratch_summary: None,
files_inspected: vec!["epiphany-core/src/runtime_spine.rs".to_string()],
frontier_node_ids: vec!["claim-context-hands".to_string()],
evidence_ids: vec!["context-route-evidence".to_string()],
evidence_ids: vec![proposal_id.to_string()],
artifact_refs: Vec::new(),
open_questions: Vec::new(),
evidence_gaps: Vec::new(),
@ -877,6 +936,7 @@ mod tests {
verification_request_id: None,
frontier_route_id: None,
repo_frontier_modeling_request_id: None,
proposal_modeling_request_id: Some(selection.request_id),
};
crate::put_runtime_role_worker_result(store, &result)?;
crate::commit_repo_model_admission(
@ -1070,6 +1130,7 @@ mod tests {
launch_document: launch_request.launch_document.clone(),
output_contract_id: launch_request.output_contract_id.clone(),
organ_launch_contract: launch_request.organ_launch_contract.clone(),
proposal_modeling_request_id: None,
created_at: "2026-06-02T00:00:00Z".to_string(),
},
)?;
@ -1353,6 +1414,7 @@ mod tests {
verification_request_id: Some(verification_request.request_id.clone()),
frontier_route_id: Some(verification_request.route_id.clone()),
repo_frontier_modeling_request_id: None,
proposal_modeling_request_id: None,
};
crate::put_runtime_role_worker_result(&runtime_store, &verification_result)?;
crate::put_soul_verdict_receipt(

View file

@ -38,6 +38,25 @@ impl EpiphanyCoordinatorService {
pub fn store(&self) -> &Path {
&self.store
}
pub fn intake_user_repo_frontier_proposal(
&self,
input: crate::RepoFrontierUserProposalInput,
) -> Result<crate::RepoFrontierWorkProposal> {
crate::intake_user_repo_frontier_proposal(&self.store, input)
}
pub fn select_repo_frontier_proposal_for_modeling(
&self,
proposal_id: &str,
selected_at: &str,
) -> Result<crate::RepoFrontierProposalModelingRequest> {
crate::select_repo_frontier_work_proposal_for_modeling(
&self.store,
proposal_id,
selected_at,
)
}
pub fn state(&self) -> Result<Option<EpiphanyThreadState>> {
read_coordinator_state(&self.store)
}

View file

@ -786,6 +786,7 @@ pub use runtime_spine::create_runtime_session;
pub use runtime_spine::ensure_runtime_repo_model;
pub use runtime_spine::ensure_runtime_session;
pub use runtime_spine::initialize_runtime_spine;
pub use runtime_spine::intake_user_repo_frontier_proposal;
pub use runtime_spine::open_runtime_spine_heartbeat_job;
pub use runtime_spine::plan_runtime_spine_heartbeat_launch;
pub use runtime_spine::prepare_runtime_spine_heartbeat_job;
@ -812,6 +813,7 @@ pub use runtime_spine::put_soul_verdict_receipt;
pub use runtime_spine::put_substrate_gate_repo_access_grant_receipt;
pub use runtime_spine::replace_or_append_epiphany_job_binding;
pub use runtime_spine::runtime_continuity_recovery_receipt;
pub use runtime_spine::runtime_current_repo_model;
pub use runtime_spine::runtime_eyes_evidence_packet;
pub use runtime_spine::runtime_hands_action_intent;
pub use runtime_spine::runtime_hands_action_review;
@ -828,8 +830,10 @@ pub use runtime_spine::runtime_mind_gateway_review;
pub use runtime_spine::runtime_mind_state_commit_receipt;
pub use runtime_spine::runtime_registered_document_types;
pub use runtime_spine::runtime_reorient_worker_result;
pub use runtime_spine::runtime_repo_frontier_proposal_modeling_request;
pub use runtime_spine::runtime_repo_frontier_route;
pub use runtime_spine::runtime_repo_frontier_verification_request;
pub use runtime_spine::runtime_repo_frontier_work_proposal;
pub use runtime_spine::runtime_role_worker_result;
pub use runtime_spine::runtime_schema_catalog_response;
pub use runtime_spine::runtime_soul_verdict_receipt;
@ -840,6 +844,7 @@ pub use runtime_spine::runtime_tool_invocation_statuses;
pub use runtime_spine::runtime_worker_launch_request;
pub use runtime_spine::select_and_commit_repo_frontier_planning_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;
pub use runtime_spine::write_runtime_hello_frame;
pub use runtime_spine::write_runtime_schema_catalog_json;
@ -971,7 +976,10 @@ pub use surfaces::EpiphanyTokenUsageSnapshot;
pub use surfaces::EpiphanyViewLens;
pub use surfaces::EpiphanyWorkerLaunchDocument;
pub use surfaces::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT;
pub use surfaces::REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION;
pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::RepoFrontierProposalModelingContextProjection;
pub use surfaces::build_reorient_acceptance_bundle;
pub use surfaces::build_reorient_job_launch_request;
pub use surfaces::build_role_acceptance_bundle;

View file

@ -90,6 +90,7 @@ Name the living seam, the open wound, and the next safe modeling move in plain l
Return a compact structured result that says whether the checkpoint or map should be updated, what files you inspected, what frontier nodes matter, and where the next agent can safely place its hands.
`repoModelPatch` is required. Return the typed patch against the canonical repository model revision/hash supplied in context. Use explicit node, edge, and frontier operations; preserve exact source-grounded claim ids and dependency ids. This artifact is only a proposal for later Modeling review/admission: do not claim it has been applied.
When `<repo_frontier_modeling_request>` is present, echo its exact `modelingRequestId` as `repoFrontierModelingRequestId`, use `purpose.kind=incorporate_frontier_verdict` with its exact `frontierRouteId` and `soulVerdictReceiptId`, and revise only its routed frontier item to its allowed disposition. The typed request is authority; nearby telemetry, timestamps, and prose are not substitutes. When that request is absent, use `purpose.kind=evolution` and do not invent verdict-incorporation authority.
When the typed launch document contains `proposalModelingContext`, echo its exact `requestId` as `proposalModelingRequestId`. Read only that immutable typed projection against its exact canonical `modelRevision` and `modelHash`. The proposal is evidence, not campaign truth: contribute one source-grounded interpretation to shared typed state, where another organ may later challenge or revise it through another typed artifact. Do not substitute adjacent proposals, infer service intake, parse proposal authority from prose, manufacture Hands work, or claim admission or execution authority.
Generic `statePatch` is optional and has been stripped of repository-anatomy authority. If present, it may contain only coherent `observations` and `evidence`. Never put graphs, graph frontier, graph checkpoint, scratch, investigation checkpoint, planning, objectives, jobs, or other anatomy in `statePatch`; those old paths are demoted and will be rejected.
Do not edit files, do not implement product code, do not verify as if you were the reviewer, do not change jobs/subgoals/objective/invariants/churn/mode, and do not promote or accept your own output.
'''

View file

@ -7,11 +7,11 @@ pub const REPO_MODEL_ADMISSION_REVIEW_SCHEMA_VERSION: &str =
"epiphany.mind.repo_model_admission_review.v0";
pub const REPO_MODEL_ADMISSION_RECEIPT_TYPE: &str = "epiphany.mind.repo_model_admission_receipt";
pub const REPO_MODEL_ADMISSION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.repo_model_admission_receipt.v1";
"epiphany.mind.repo_model_admission_receipt.v2";
pub const REPO_MODEL_MIGRATION_RECEIPT_TYPE: &str = "epiphany.mind.repo_model_migration_receipt";
pub const REPO_MODEL_MIGRATION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.repo_model_migration_receipt.v0";
pub const REPO_MODEL_ADMISSION_CONTRACT: &str = "epiphany.repo_model_admission.v1";
pub const REPO_MODEL_ADMISSION_CONTRACT: &str = "epiphany.repo_model_admission.v2";
pub const REPO_MODEL_MIGRATION_CONTRACT: &str = "epiphany.repo_model_migration.v0";
pub const REPO_FRONTIER_ROUTE_TYPE: &str = "epiphany.self.repo_frontier_route";
pub const REPO_FRONTIER_ROUTE_SCHEMA_VERSION: &str = "epiphany.self.repo_frontier_route.v0";
@ -38,6 +38,14 @@ pub const REPO_FRONTIER_PLAN_ADOPTION_SCHEMA_VERSION: &str =
pub const REPO_FRONTIER_PLANNING_CONTRACT: &str = "epiphany.repo_frontier_planning.v0";
pub const REPO_FRONTIER_WORK_PROPOSAL_CONTRACT: &str =
"epiphany.repo_frontier_work_proposal.inert.v0";
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_PROPOSAL_MODELING_LAUNCH_BINDING_SCHEMA_VERSION: &str =
"epiphany.coordinator.repo_frontier_proposal_modeling_launch_binding.v1";
pub const REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_CONTRACT: &str =
"epiphany.repo_frontier_proposal_modeling_launch_binding.v1";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
@ -47,6 +55,25 @@ pub enum RepoFrontierProposalSourceKind {
Bifrost,
}
#[derive(Debug, Clone)]
pub struct RepoFrontierUserProposalInput {
pub proposal_id: String,
pub source_actor: String,
pub source_ref: String,
pub repository: String,
pub workspace: String,
pub thread_id: String,
pub runtime_id: String,
pub title: String,
pub body: String,
pub desired_outcome: String,
pub constraints: Vec<String>,
pub scope_hints: Vec<String>,
pub evidence_refs: Vec<String>,
pub proposed_at: String,
pub private_state_included: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.evidence.repo_frontier_work_proposal",
@ -72,7 +99,7 @@ pub struct RepoFrontierWorkProposal {
#[cultcache(key = 8)]
pub runtime_id: String,
#[cultcache(key = 9)]
pub content_sha256: String,
pub payload_sha256: String,
#[cultcache(key = 10)]
pub title: String,
#[cultcache(key = 11)]
@ -93,6 +120,66 @@ pub struct RepoFrontierWorkProposal {
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.coordinator.repo_frontier_proposal_modeling_request",
schema = "RepoFrontierProposalModelingRequest"
)]
pub struct RepoFrontierProposalModelingRequest {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub request_id: String,
#[cultcache(key = 2)]
pub proposal_id: String,
#[cultcache(key = 3)]
pub proposal_payload_sha256: String,
#[cultcache(key = 4)]
pub runtime_id: String,
#[cultcache(key = 5)]
pub thread_id: String,
#[cultcache(key = 6)]
pub repository: String,
#[cultcache(key = 7)]
pub workspace: String,
#[cultcache(key = 8)]
pub selected_at: String,
#[cultcache(key = 9)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.coordinator.repo_frontier_proposal_modeling_launch_binding",
schema = "RepoFrontierProposalModelingLaunchBinding"
)]
pub struct RepoFrontierProposalModelingLaunchBinding {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub binding_record_id: String,
#[cultcache(key = 2)]
pub proposal_modeling_request_id: String,
#[cultcache(key = 3)]
pub proposal_id: String,
#[cultcache(key = 4)]
pub proposal_payload_sha256: String,
#[cultcache(key = 5)]
pub job_id: String,
#[cultcache(key = 6)]
pub binding_id: String,
#[cultcache(key = 7)]
pub runtime_id: String,
#[cultcache(key = 8)]
pub thread_id: String,
#[cultcache(key = 9)]
pub launched_at: String,
#[cultcache(key = 10)]
pub worker_launch_document_sha256: String,
#[cultcache(key = 11)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.self.repo_frontier_planning_request",
@ -400,6 +487,8 @@ pub struct RepoModelAdmissionReceipt {
pub soul_verdict_receipt_id: String,
#[cultcache(key = 16, default)]
pub frontier_modeling_request_id: String,
#[cultcache(key = 17, default)]
pub proposal_modeling_request_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]

File diff suppressed because it is too large Load diff

View file

@ -249,6 +249,7 @@ mod tests {
state_revision: 7,
objective: None,
dynamic_prompt_context: None,
proposal_modeling_context: None,
active_subgoal_id: None,
active_subgoals: Vec::new(),
active_graph_node_ids: Vec::new(),
@ -271,6 +272,7 @@ mod tests {
crate::ROLE_WORKER_OUTPUT_CONTRACT_ID,
),
max_runtime_seconds: None,
proposal_modeling_request_id: None,
};
let grant = substrate_gate_repo_access_grant_for_launch(
"grant-1".to_string(),

View file

@ -144,5 +144,8 @@ pub use worker_launch::EpiphanyReorientWorkerLaunchDocument;
pub use worker_launch::EpiphanyRoleWorkerLaunchDocument;
pub use worker_launch::EpiphanyWorkerLaunchDocument;
pub use worker_launch::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
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::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use worker_launch::RepoFrontierProposalModelingContextProjection;
pub use worker_launch::build_reorient_job_launch_request;

View file

@ -26,6 +26,10 @@ use crate::EpiphanyReorientReason;
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v0";
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
pub const REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_SCHEMA_VERSION: &str =
"epiphany.worker.repo_frontier_proposal_modeling_context.v0";
pub const REPO_FRONTIER_PROPOSAL_MODELING_CONTEXT_CONTRACT: &str =
"epiphany.repo_frontier_proposal_modeling_context.v0";
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", tag = "documentKind")]
@ -77,6 +81,8 @@ pub struct EpiphanyRoleWorkerLaunchDocument {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dynamic_prompt_context: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub proposal_modeling_context: Option<RepoFrontierProposalModelingContextProjection>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub active_subgoal_id: Option<String>,
#[serde(default)]
pub active_subgoals: Vec<EpiphanySubgoal>,
@ -165,6 +171,35 @@ pub struct EpiphanyReorientLaunchRequestInput<'a> {
pub dynamic_prompt_context: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RepoFrontierProposalModelingContextProjection {
pub schema_version: String,
pub contract: String,
pub request_id: String,
pub proposal_id: String,
pub proposal_payload_sha256: String,
pub runtime_id: String,
pub thread_id: String,
pub repository: String,
pub workspace: String,
pub source_kind: crate::RepoFrontierProposalSourceKind,
pub source_actor: String,
pub source_ref: String,
pub title: String,
pub body: String,
pub desired_outcome: String,
#[serde(default)]
pub constraints: Vec<String>,
#[serde(default)]
pub scope_hints: Vec<String>,
#[serde(default)]
pub evidence_refs: Vec<String>,
pub private_state_included: bool,
pub model_revision: u64,
pub model_hash: String,
}
pub fn build_reorient_job_launch_request(
input: EpiphanyReorientLaunchRequestInput<'_>,
) -> EpiphanyJobLaunchRequest {
@ -205,6 +240,7 @@ pub fn build_reorient_job_launch_request(
output_contract_id,
organ_launch_contract,
max_runtime_seconds: input.max_runtime_seconds,
proposal_modeling_request_id: None,
}
}