Migrate Planning to keyed Mind authority
This commit is contained in:
parent
7501564f0a
commit
c9329ed6ec
10 changed files with 1566 additions and 1044 deletions
|
|
@ -1066,83 +1066,6 @@ pub fn build_epiphany_role_launch_request(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_frontier_plan_mind_launch_request(
|
||||
thread_id: &str,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
mind_request_id: String,
|
||||
) -> Result<EpiphanyJobLaunchRequest, String> {
|
||||
let linked_subgoal_ids = epiphany_active_subgoal_ids(Some(state));
|
||||
let linked_graph_node_ids = epiphany_active_graph_node_ids(Some(state));
|
||||
let authority_scope = "epiphany.procedure.mind_admission_review";
|
||||
let launch_document = EpiphanyWorkerLaunchDocument::Role(EpiphanyRoleWorkerLaunchDocument {
|
||||
thread_id: thread_id.to_string(),
|
||||
role_id: "mindAdmissionReview".to_string(),
|
||||
state_revision: state.revision,
|
||||
objective: state.objective.clone(),
|
||||
dynamic_prompt_context: None,
|
||||
repository_body_observation_basis: None,
|
||||
proposal_modeling_context: None,
|
||||
frontier_verdict_modeling_context: None,
|
||||
frontier_planning_context: None,
|
||||
frontier_research_context: None,
|
||||
frontier_verification_context: None,
|
||||
frontier_plan_mind_context: None,
|
||||
imagination_consideration_context: None,
|
||||
admitted_model_direction_consideration_context: None,
|
||||
active_subgoal_id: state.active_subgoal_id.clone(),
|
||||
active_subgoals: state
|
||||
.subgoals
|
||||
.iter()
|
||||
.filter(|subgoal| Some(subgoal.id.as_str()) == state.active_subgoal_id.as_deref())
|
||||
.cloned()
|
||||
.collect(),
|
||||
active_graph_node_ids: linked_graph_node_ids.clone(),
|
||||
investigation_checkpoint: state.investigation_checkpoint.clone(),
|
||||
scratch: state.scratch.clone(),
|
||||
invariants: state.invariants.clone(),
|
||||
graphs: Some(state.graphs.clone()),
|
||||
recent_evidence: state.recent_evidence.iter().take(8).cloned().collect(),
|
||||
recent_observations: state.observations.iter().take(8).cloned().collect(),
|
||||
graph_frontier: state.graph_frontier.clone(),
|
||||
graph_checkpoint: state.graph_checkpoint.clone(),
|
||||
planning: Some(state.planning.clone()),
|
||||
churn: state.churn.clone(),
|
||||
});
|
||||
let output_contract_id = launch_document.output_contract_id().to_string();
|
||||
let organ_launch_contract = default_launch_organ_contract(
|
||||
authority_scope,
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
Ok(EpiphanyJobLaunchRequest {
|
||||
expected_revision,
|
||||
binding_id: EPIPHANY_MIND_ROLE_BINDING_ID.to_string(),
|
||||
kind: CoreEpiphanyJobKind::Specialist,
|
||||
scope: "role-scoped frontier plan judgment".to_string(),
|
||||
owner_role: EPIPHANY_MIND_OWNER_ROLE.to_string(),
|
||||
authority_scope: authority_scope.to_string(),
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids,
|
||||
instruction: epiphany_worker_prompt(
|
||||
epiphany_specialist_prompt_config().roles.mind.as_str(),
|
||||
),
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds,
|
||||
proposal_modeling_request_id: None,
|
||||
frontier_planning_request_id: None,
|
||||
frontier_plan_mind_request_id: Some(mind_request_id),
|
||||
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_verification_request_id: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_epiphany_role_launch_request_with_dynamic_context(
|
||||
thread_id: &str,
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
|
|
@ -1514,7 +1437,6 @@ fn epiphany_active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec<St
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sha2::Digest;
|
||||
|
||||
#[test]
|
||||
fn admitted_direction_schema_bounds_autonomous_proposal_fanout() {
|
||||
|
|
@ -1595,234 +1517,6 @@ mod tests {
|
|||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn frontier_plan_mind_launch_is_a_real_prompted_role_with_strict_schema() {
|
||||
let request = build_epiphany_frontier_plan_mind_launch_request(
|
||||
"thread-mind",
|
||||
Some(0),
|
||||
Some(60),
|
||||
&EpiphanyThreadState::default(),
|
||||
"mind-request-1".into(),
|
||||
)
|
||||
.expect("Mind launch request");
|
||||
assert_eq!(request.owner_role, EPIPHANY_MIND_OWNER_ROLE);
|
||||
assert_eq!(request.binding_id, EPIPHANY_MIND_ROLE_BINDING_ID);
|
||||
assert!(
|
||||
request
|
||||
.instruction
|
||||
.contains("admission-review procedure serving Epiphany Mind")
|
||||
);
|
||||
assert_eq!(
|
||||
request.frontier_plan_mind_request_id.as_deref(),
|
||||
Some("mind-request-1")
|
||||
);
|
||||
let EpiphanyWorkerLaunchDocument::Role(document) = request.launch_document else {
|
||||
panic!("Mind must use a role launch document")
|
||||
};
|
||||
assert_eq!(document.role_id, "mindAdmissionReview");
|
||||
let schema = epiphany_frontier_plan_mind_output_schema();
|
||||
assert_eq!(
|
||||
schema["properties"]["roleId"]["const"],
|
||||
"mindAdmissionReview"
|
||||
);
|
||||
assert_eq!(
|
||||
schema["properties"]["frontierPlanMindDecision"]["properties"]["decision"]["enum"],
|
||||
serde_json::json!(["adopt", "refuse", "hold"])
|
||||
);
|
||||
assert!(
|
||||
schema["properties"]
|
||||
.get("frontierPlanMindRequestId")
|
||||
.is_none()
|
||||
);
|
||||
for runtime_owned in [
|
||||
"mindRequestId",
|
||||
"planningRequestId",
|
||||
"imaginationResultId",
|
||||
"candidateId",
|
||||
"candidateSha256",
|
||||
"decidedAt",
|
||||
] {
|
||||
assert!(
|
||||
schema["properties"]["frontierPlanMindDecision"]["properties"]
|
||||
.get(runtime_owned)
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modeling_schema_exposes_semantic_operations_without_runtime_authority() {
|
||||
let schema = epiphany_role_launch_output_schema(EpiphanyRoleResultRoleId::Modeling);
|
||||
let required = schema["required"].as_array().expect("required fields");
|
||||
assert!(required.iter().any(|value| value == "repoModelOperations"));
|
||||
for runtime_owned in [
|
||||
"repoModelPatch",
|
||||
"repositoryBodyObservationBasis",
|
||||
"repoFrontierModelingRequestId",
|
||||
"proposalModelingRequestId",
|
||||
] {
|
||||
assert!(schema["properties"].get(runtime_owned).is_none());
|
||||
}
|
||||
let operations = schema["properties"]["repoModelOperations"]["items"]["anyOf"]
|
||||
.as_array()
|
||||
.expect("typed Modeling operations");
|
||||
let operation_names = operations
|
||||
.iter()
|
||||
.map(|operation| {
|
||||
operation["properties"]["operation"]["const"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
operation_names,
|
||||
vec![
|
||||
"put_node",
|
||||
"retire_node",
|
||||
"put_edge",
|
||||
"retire_edge",
|
||||
"put_frontier",
|
||||
"create_surface_offer",
|
||||
"deprecate_surface_offer",
|
||||
"withdraw_surface_offer",
|
||||
"create_dependency_claim",
|
||||
"retire_dependency_claim"
|
||||
]
|
||||
);
|
||||
let node_kinds = operations[0]["properties"]["node"]["properties"]["kind"]["enum"]
|
||||
.as_array()
|
||||
.expect("typed RepoModel node kinds");
|
||||
assert!(node_kinds.iter().any(|kind| kind == "runtime_contract"));
|
||||
assert!(!node_kinds.iter().any(|kind| kind == "claim"));
|
||||
assert!(
|
||||
operations[0]["properties"]["node"]["properties"]
|
||||
.get("created_at")
|
||||
.is_none()
|
||||
);
|
||||
assert!(operations[5]["properties"].get("surface_id").is_none());
|
||||
assert!(operations[8]["properties"].get("claim_id").is_none());
|
||||
assert_eq!(
|
||||
operations[5]["required"],
|
||||
serde_json::json!(["operation", "label", "contract", "source_refs"])
|
||||
);
|
||||
assert_eq!(
|
||||
operations[8]["required"],
|
||||
serde_json::json!([
|
||||
"operation",
|
||||
"label",
|
||||
"target",
|
||||
"entanglement_kind",
|
||||
"failure_semantics",
|
||||
"impact_scope",
|
||||
"source_refs"
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
schema["allOf"][0]["then"]["properties"]["repoModelOperations"]["maxContains"],
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
schema["allOf"][1]["then"]["properties"]["repoModelOperations"]["maxItems"],
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verdict_bound_modeling_schema_exposes_only_exact_frontier_revision_authority() {
|
||||
let authority = crate::RepoFrontierVerdictModelingLaunchAuthority {
|
||||
request: crate::RepoFrontierModelingRequest {
|
||||
schema_version: crate::REPO_FRONTIER_MODELING_REQUEST_SCHEMA_VERSION.to_string(),
|
||||
request_id: "modeling-request-exact".into(),
|
||||
model_projection_digest: format!("sha256:{}", "a".repeat(64)),
|
||||
model_source_documents: vec![crate::EpiphanyMindDocumentVersion {
|
||||
store_id: "epiphany-mind".into(),
|
||||
document_type: "epiphany.mind.repo_model.identity.v1".into(),
|
||||
document_key: crate::REPO_MODEL_IDENTITY_KEY.into(),
|
||||
schema_id: Some("EpiphanyRepoModelIdentityDocument".into()),
|
||||
payload_msgpack: vec![1],
|
||||
payload_sha256: format!("sha256:{:x}", sha2::Sha256::digest([1])),
|
||||
}],
|
||||
route_id: "route-exact".into(),
|
||||
frontier_item_id: "frontier-exact".into(),
|
||||
frontier_item_hash: "frontier-hash".into(),
|
||||
verification_request_id: "verification-exact".into(),
|
||||
soul_verdict_receipt_id: "soul-exact".into(),
|
||||
verification_result_id: "verification-result".into(),
|
||||
verification_job_id: "verification-job".into(),
|
||||
allowed_disposition: crate::RepoFrontierVerdictDisposition::Resolved,
|
||||
requested_at: "2026-08-08T00:00:00Z".into(),
|
||||
contract: crate::REPO_FRONTIER_MODELING_REQUEST_CONTRACT.into(),
|
||||
},
|
||||
frontier_item: crate::RepoFrontierItem {
|
||||
id: "frontier-exact".into(),
|
||||
migration_body: "runtime".into(),
|
||||
question: "Did the consequence hold?".into(),
|
||||
gap: "Awaiting verdict incorporation.".into(),
|
||||
target_claim_ids: vec!["claim-exact".into()],
|
||||
source_scope: vec!["epiphany-core".into()],
|
||||
recommended_next_organ: "Hands".into(),
|
||||
adopted_plan: Some(crate::RepoFrontierAdoptedPlan {
|
||||
command: "cargo test".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
dependency_item_ids: Vec::new(),
|
||||
status: crate::RepoFrontierStatus::Active,
|
||||
evidence_refs: vec!["prior-evidence".into()],
|
||||
public_source_refs: Vec::new(),
|
||||
created_at: Some("2026-08-07T00:00:00Z".into()),
|
||||
updated_at: Some("2026-08-07T00:00:00Z".into()),
|
||||
retired_at: None,
|
||||
superseded_by: None,
|
||||
},
|
||||
soul_verdict: crate::SoulVerdictReceipt {
|
||||
schema_version: crate::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION.into(),
|
||||
receipt_id: "soul-exact".into(),
|
||||
source_result_id: "verification-result".into(),
|
||||
source_job_id: "verification-job".into(),
|
||||
verdict: "pass".into(),
|
||||
summary: "verified".into(),
|
||||
evidence_ids: Vec::new(),
|
||||
risks: Vec::new(),
|
||||
emitted_at: "2026-08-08T00:00:00Z".into(),
|
||||
contract: "test".into(),
|
||||
verification_request_id: "verification-exact".into(),
|
||||
frontier_route_id: "route-exact".into(),
|
||||
},
|
||||
};
|
||||
let schema = epiphany_frontier_verdict_modeling_output_schema(&authority);
|
||||
assert!(
|
||||
schema["properties"]
|
||||
.get("repoFrontierModelingRequestId")
|
||||
.is_none()
|
||||
);
|
||||
assert!(schema["properties"].get("repoModelOperations").is_none());
|
||||
assert_eq!(schema["properties"]["frontierVerdictGap"]["type"], "string");
|
||||
assert!(
|
||||
schema["required"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.any(|value| value == "frontierVerdictGap")
|
||||
);
|
||||
assert_eq!(schema["properties"]["evidenceIds"]["minItems"], 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modeling_node_schema_matches_mind_nonempty_invariants() {
|
||||
let schema = repo_model_node_output_schema();
|
||||
|
||||
assert_eq!(schema["properties"]["title"]["minLength"], 1);
|
||||
assert_eq!(schema["properties"]["claim"]["minLength"], 1);
|
||||
assert_eq!(schema["properties"]["action_implication"]["minLength"], 1);
|
||||
assert_eq!(
|
||||
schema["anyOf"],
|
||||
serde_json::json!([
|
||||
{"properties": {"question": {"minLength": 1}}},
|
||||
{"properties": {"tension": {"minLength": 1}}}
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn role_self_patch_schema_matches_canonical_numeric_memory_contract() {
|
||||
let schema = epiphany_role_launch_output_schema(EpiphanyRoleResultRoleId::Verification);
|
||||
|
|
|
|||
Reference in a new issue