diff --git a/epiphany-core/src/agent_launch.rs b/epiphany-core/src/agent_launch.rs index 9d8504ca..adea6869 100644 --- a/epiphany-core/src/agent_launch.rs +++ b/epiphany-core/src/agent_launch.rs @@ -621,6 +621,33 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) -> "required": ["repoModelPatch"] }, "then": {"required": ["claimRepairRequestId"]} + }, + { + "if": {"required": ["proposalModelingRequestId"]}, + "then": { + "properties": { + "evidenceIds": {"type": "array", "minItems": 1}, + "repoModelPatch": { + "properties": { + "purpose": { + "properties": {"kind": {"const": "evolution"}}, + "required": ["kind"] + }, + "operations": { + "contains": { + "type": "object", + "properties": {"operation": {"const": "upsert_frontier"}}, + "required": ["operation"] + }, + "minContains": 1, + "maxContains": 1 + } + }, + "required": ["purpose", "operations"] + } + }, + "required": ["evidenceIds", "repoModelPatch"] + } } ]); } @@ -1531,6 +1558,11 @@ mod tests { schema["allOf"][1]["then"]["required"][0], "claimRepairRequestId" ); + assert_eq!( + schema["allOf"][2]["then"]["properties"]["repoModelPatch"]["properties"]["operations"] + ["maxContains"], + 1 + ); let operations = schema["properties"]["repoModelPatch"]["properties"]["operations"]["items"]["anyOf"] .as_array() diff --git a/epiphany-core/src/bin/epiphany-mvp-status.rs b/epiphany-core/src/bin/epiphany-mvp-status.rs index af036b91..f5d183fc 100644 --- a/epiphany-core/src/bin/epiphany-mvp-status.rs +++ b/epiphany-core/src/bin/epiphany-mvp-status.rs @@ -436,6 +436,7 @@ fn run_native_status(args: &Args) -> Result { modeling_result_accepted: finding_signals.modeling_result_accepted, modeling_result_reviewable: finding_signals.modeling_result_reviewable, modeling_result_failure_reviewed: finding_signals.modeling_result_failure_reviewed, + modeling_result_proposal_bound: finding_signals.modeling_result_proposal_bound, modeling_result_accepted_after_verification: finding_signals .modeling_result_accepted_after_verification, implementation_evidence_after_verification: finding_signals diff --git a/epiphany-core/src/coordinator_acceptance.rs b/epiphany-core/src/coordinator_acceptance.rs index 12a29955..da1abe20 100644 --- a/epiphany-core/src/coordinator_acceptance.rs +++ b/epiphany-core/src/coordinator_acceptance.rs @@ -902,6 +902,7 @@ mod tests { item_error: None, verification_request_id: Some(request.request_id.clone()), frontier_route_id: Some(request.route_id.clone()), + proposal_modeling_request_id: None, }; validate_verification_finding_binding(&finding, &request).expect("exact binding"); diff --git a/epiphany-core/src/coordinator_results.rs b/epiphany-core/src/coordinator_results.rs index 84e01bd5..ebabaad6 100644 --- a/epiphany-core/src/coordinator_results.rs +++ b/epiphany-core/src/coordinator_results.rs @@ -307,6 +307,7 @@ fn interpret_role_lifecycle_failure( item_error: None, verification_request_id: None, frontier_route_id: None, + proposal_modeling_request_id: None, } } diff --git a/epiphany-core/src/eyes_gateway.rs b/epiphany-core/src/eyes_gateway.rs index 0b9b6403..210ef64f 100644 --- a/epiphany-core/src/eyes_gateway.rs +++ b/epiphany-core/src/eyes_gateway.rs @@ -253,6 +253,7 @@ mod tests { item_error: None, verification_request_id: None, frontier_route_id: None, + proposal_modeling_request_id: None, }; let mut patch = EpiphanyRoleStatePatchDocument::default(); patch diff --git a/epiphany-core/src/mind_gateway.rs b/epiphany-core/src/mind_gateway.rs index ecf314e6..2d91e4a2 100644 --- a/epiphany-core/src/mind_gateway.rs +++ b/epiphany-core/src/mind_gateway.rs @@ -498,6 +498,7 @@ mod tests { item_error: None, verification_request_id: None, frontier_route_id: None, + proposal_modeling_request_id: None, } } diff --git a/epiphany-core/src/prompts/epiphany_specialists.toml b/epiphany-core/src/prompts/epiphany_specialists.toml index afaa56b5..0e224cc0 100644 --- a/epiphany-core/src/prompts/epiphany_specialists.toml +++ b/epiphany-core/src/prompts/epiphany_specialists.toml @@ -100,8 +100,8 @@ Every upserted or revised node must include all canonical identity and judgment If you emit an `anchor`, it must include its own stable `id`, `kind`, and `target`; a nested `code_ref` must include `path`. Do not use a bare path-shaped object as an anchor. Omitting anchors is safer than inventing malformed provenance. The launch context includes ``. Every new node must use one exact `existingDomains` id from that packet, and repo architecture/dataflow nodes and edges must use one of the listed legal lifecycles. Never derive a domain id from the workspace path; patches cannot create domains. When `` 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. -An ordinary `purpose.kind=evolution` patch may mutate nodes and edges only. It must not upsert, revise, retire, or adopt frontier items. Frontier mutation requires an explicit typed frontier request and its corresponding non-evolution purpose; describe an observed frontier wound in `summary`, `evidenceGaps`, or `nextSafeMove` when no such request exists. -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. +An ordinary `purpose.kind=evolution` patch without `proposalModelingContext` may mutate nodes and edges only. It must not upsert, revise, retire, or adopt frontier items. Describe an observed frontier wound in `summary`, `evidenceGaps`, or `nextSafeMove` when no typed frontier authority exists. +When the typed launch document contains `proposalModelingContext`, echo its exact `requestId` as `proposalModelingRequestId` and use `purpose.kind=evolution`. This is the one evolution frontier exception: emit exactly one `upsert_frontier` operation grounded in the proposal, cite the exact `proposalId` in both top-level `evidenceIds` and the frontier item's `evidence_refs`, preserve the proposal's exact `scopeHints` as `source_scope`, and route a user proposal to `Hands` as an `active` item. You may also update source-grounded anatomy, but must not emit any other frontier operation. Read only that immutable typed projection against its exact canonical `modelRevision` and `modelHash`. The proposal is evidence, not campaign truth: Mind still owns admission, and Hands still owns execution. Do not substitute adjacent proposals, infer service intake, parse proposal authority from prose, 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. ''' diff --git a/epiphany-core/src/soul_gateway.rs b/epiphany-core/src/soul_gateway.rs index e7088cd8..23d237bc 100644 --- a/epiphany-core/src/soul_gateway.rs +++ b/epiphany-core/src/soul_gateway.rs @@ -257,6 +257,7 @@ mod tests { item_error: None, verification_request_id: Some("verification-request-1".to_string()), frontier_route_id: Some("frontier-route-1".to_string()), + proposal_modeling_request_id: None, }; let receipt = soul_verdict_receipt_from_verification_finding( "soul-verdict-1".to_string(), diff --git a/epiphany-core/src/surfaces/coordinator.rs b/epiphany-core/src/surfaces/coordinator.rs index 0d273f7e..170934dc 100644 --- a/epiphany-core/src/surfaces/coordinator.rs +++ b/epiphany-core/src/surfaces/coordinator.rs @@ -139,6 +139,7 @@ pub struct EpiphanyCoordinatorInput { pub modeling_result_accepted: bool, pub modeling_result_reviewable: bool, pub modeling_result_failure_reviewed: bool, + pub modeling_result_proposal_bound: bool, pub modeling_result_accepted_after_verification: bool, pub implementation_evidence_after_verification: bool, pub verification_result_cites_implementation_evidence: bool, @@ -183,6 +184,7 @@ pub struct EpiphanyCoordinatorStatusInput { pub modeling_result_accepted: bool, pub modeling_result_reviewable: bool, pub modeling_result_failure_reviewed: bool, + pub modeling_result_proposal_bound: bool, pub modeling_result_accepted_after_verification: bool, pub implementation_evidence_after_verification: bool, pub verification_result_cites_implementation_evidence: bool, @@ -212,6 +214,7 @@ pub struct EpiphanyCoordinatorFindingSignals { pub modeling_result_accepted: bool, pub modeling_result_reviewable: bool, pub modeling_result_failure_reviewed: bool, + pub modeling_result_proposal_bound: bool, pub modeling_result_accepted_after_verification: bool, pub implementation_evidence_after_verification: bool, pub verification_result_cites_implementation_evidence: bool, @@ -277,6 +280,7 @@ pub fn derive_coordinator_status( modeling_result_accepted: input.modeling_result_accepted, modeling_result_reviewable: input.modeling_result_reviewable, modeling_result_failure_reviewed: input.modeling_result_failure_reviewed, + modeling_result_proposal_bound: input.modeling_result_proposal_bound, modeling_result_accepted_after_verification: input .modeling_result_accepted_after_verification, implementation_evidence_after_verification: input @@ -332,6 +336,8 @@ pub fn derive_coordinator_finding_signals( role_finding_failure_reviewed(state, EpiphanyCoordinatorRoleId::Modeling, finding) }) }); + let modeling_result_proposal_bound = + modeling_finding.is_some_and(|finding| finding.proposal_modeling_request_id.is_some()); let verification_result_accepted = verification_finding.as_ref().is_some_and(|finding| { state.is_some_and(|state| { role_finding_already_accepted(state, EpiphanyCoordinatorRoleId::Verification, finding) @@ -390,6 +396,7 @@ pub fn derive_coordinator_finding_signals( modeling_result_accepted, modeling_result_reviewable, modeling_result_failure_reviewed, + modeling_result_proposal_bound, modeling_result_accepted_after_verification, implementation_evidence_after_verification, verification_result_cites_implementation_evidence, @@ -824,6 +831,16 @@ pub fn recommend_coordinator_action( && !input.modeling_result_accepted { if input.modeling_result_failure_reviewed { + if input.modeling_result_proposal_bound { + return build( + EpiphanyCoordinatorAction::AwaitFrontierProposal, + Some(EpiphanyCoordinatorRoleId::Imagination), + None, + true, + false, + "The proposal-bound Modeling result was rejected and its immutable selection request is consumed; await a fresh typed proposal instead of replaying old authority.", + ); + } return build( EpiphanyCoordinatorAction::LaunchModeling, Some(EpiphanyCoordinatorRoleId::Modeling), @@ -1318,6 +1335,7 @@ mod tests { modeling_result_accepted: false, modeling_result_reviewable: false, modeling_result_failure_reviewed: false, + modeling_result_proposal_bound: false, modeling_result_accepted_after_verification: false, implementation_evidence_after_verification: false, verification_result_cites_implementation_evidence: false, @@ -1359,9 +1377,26 @@ mod tests { item_error: None, verification_request_id: None, frontier_route_id: None, + proposal_modeling_request_id: None, } } + #[test] + fn finding_signals_preserve_proposal_modeling_authority() { + let mut modeling = finding("result-modeling", "job-modeling", Vec::new()); + modeling.proposal_modeling_request_id = Some("proposal-request-1".to_string()); + + let signals = derive_coordinator_finding_signals( + Some(&EpiphanyThreadState::default()), + None, + Some(&modeling), + None, + None, + ); + + assert!(signals.modeling_result_proposal_bound); + } + #[test] fn implementation_evidence_lets_verification_cover_post_modeling_work() { let mut state = EpiphanyThreadState::default(); @@ -1782,6 +1817,29 @@ mod tests { .contains("rejected by admission") ); + let await_fresh_proposal_after_rejected_selection = + recommend_coordinator_action(EpiphanyCoordinatorInput { + signals: EpiphanyCoordinatorSignals { + research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding, + modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed, + verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding, + }, + modeling_result_failure_reviewed: true, + modeling_result_reviewable: true, + modeling_result_proposal_bound: true, + ..input() + }); + assert_eq!( + await_fresh_proposal_after_rejected_selection.action, + EpiphanyCoordinatorAction::AwaitFrontierProposal + ); + assert!(!await_fresh_proposal_after_rejected_selection.can_auto_run); + assert!( + await_fresh_proposal_after_rejected_selection + .reason + .contains("selection request is consumed") + ); + let await_proposal_without_hands_frontier = recommend_coordinator_action(EpiphanyCoordinatorInput { signals: EpiphanyCoordinatorSignals { diff --git a/epiphany-core/src/surfaces/role_result.rs b/epiphany-core/src/surfaces/role_result.rs index 5ebda028..161d1cf5 100644 --- a/epiphany-core/src/surfaces/role_result.rs +++ b/epiphany-core/src/surfaces/role_result.rs @@ -53,6 +53,7 @@ pub struct EpiphanyRoleFindingInterpretation { pub item_error: Option, pub verification_request_id: Option, pub frontier_route_id: Option, + pub proposal_modeling_request_id: Option, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -208,6 +209,7 @@ fn interpret_role_finding( item_error, verification_request_id: json_string_field(raw_result, "verificationRequestId"), frontier_route_id: json_string_field(raw_result, "frontierRouteId"), + proposal_modeling_request_id: json_string_field(raw_result, "proposalModelingRequestId"), } } @@ -322,6 +324,7 @@ pub fn interpret_runtime_role_worker_result( }, verification_request_id: result.verification_request_id.clone(), frontier_route_id: result.frontier_route_id.clone(), + proposal_modeling_request_id: result.proposal_modeling_request_id.clone(), } }