diff --git a/epiphany-openai-runtime/src/lib.rs b/epiphany-openai-runtime/src/lib.rs index 2ff919a2..611e5add 100644 --- a/epiphany-openai-runtime/src/lib.rs +++ b/epiphany-openai-runtime/src/lib.rs @@ -1997,7 +1997,7 @@ mod tests { } #[test] - fn repo_work_modeling_worker_emits_the_typed_finding() -> Result<()> { + fn repo_work_modeling_generation_retry_admits_only_current_runtime_finding() -> Result<()> { let temp = tempdir()?; let store = temp.path().join("runtime.msgpack"); initialize_runtime_spine( @@ -2036,7 +2036,20 @@ mod tests { private_state_exposed: false, contract: "test".to_string(), }; - epiphany_core::put_repo_work_modeling_request(&store, &request)?; + let route0 = epiphany_core::RepoWorkModelingRoute { + schema_version: epiphany_core::REPO_WORK_MODELING_ROUTE_SCHEMA_VERSION.to_string(), + route_id: "repo-route-1".to_string(), + item: request.item.clone(), + generation: 0, + request_id: request.request_id.clone(), + previous_finding_receipt_id: String::new(), + authority_owner: "soul".to_string(), + authority_witness_id: request.soul_verdict_receipt_id.clone(), + updated_at: now(), + private_state_exposed: false, + contract: "test initial route".to_string(), + }; + epiphany_core::commit_initial_repo_work_modeling_route(&store, &request, &route0)?; open_runtime_spine_heartbeat_job( &store, RuntimeSpineHeartbeatJobOptions { @@ -2101,15 +2114,168 @@ mod tests { &launch, &model_request.request_id, &openai_summary, - r#"{"verdict":"passed","finding":"The verified README change updates the repo map.","summary":"README consequence mapped.","nextSafeMove":"Let Mind review the finding.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#, + r#"{"verdict":"needs-work","finding":"The verified README consequence needs reviewed context.","summary":"Context incomplete.","nextSafeMove":"Ask Mind to review a retry.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#, )?; - let finding = + let finding0 = epiphany_core::runtime_repo_work_modeling_finding(&store, "repo-request-1-finding")? .expect("typed repo-work Modeling finding"); - assert_eq!(finding.request_id, request.request_id); - assert_eq!(finding.verdict, "passed"); - assert_eq!(finding.commit_sha, "abc123"); - assert!(!finding.private_state_exposed); + assert_eq!(finding0.request_id, request.request_id); + assert_eq!(finding0.verdict, "needs-work"); + assert_eq!(finding0.commit_sha, "abc123"); + assert!(!finding0.private_state_exposed); + + let review = epiphany_core::MindGatewayReview { + schema_version: epiphany_core::MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), + gateway_id: "repo-route-1-g1-review".to_string(), + source_kind: "repo_work_modeling_revision".to_string(), + source_role_id: "mind".to_string(), + decision: epiphany_core::MindGatewayDecision::Accept, + allowed_effects: vec!["repoWork.modelingRoute".to_string()], + refused_effects: vec!["repoWork.map".to_string()], + reasons: vec!["Reviewed the missing context.".to_string()], + contract: "test route review".to_string(), + }; + let request1 = epiphany_core::RepoWorkModelingRequest { + request_id: "repo-request-2".to_string(), + requester: "mind".to_string(), + instruction: "Re-model with reviewed context.".to_string(), + requested_at: now(), + ..request.clone() + }; + let route1 = epiphany_core::RepoWorkModelingRoute { + generation: 1, + request_id: request1.request_id.clone(), + previous_finding_receipt_id: finding0.receipt_id.clone(), + authority_owner: "mind".to_string(), + authority_witness_id: review.gateway_id.clone(), + updated_at: now(), + ..route0.clone() + }; + epiphany_core::advance_repo_work_modeling_route(&store, &request1, &route1, &review)?; + open_runtime_spine_heartbeat_job( + &store, + RuntimeSpineHeartbeatJobOptions { + runtime_id: "repo-work-test".to_string(), + display_name: "Repo Work Test".to_string(), + session_id: "repo-session-1".to_string(), + objective: "Map reviewed repo work.".to_string(), + coordinator_note: "Mind selected generation one; Modeling authors.".to_string(), + job_id: "repo-modeling-job-2".to_string(), + role: "modeling".to_string(), + binding_id: "repo-work-modeling-worker".to_string(), + authority_scope: "epiphany.role.modeling.repo-work".to_string(), + instruction: "Return the reviewed repo-work Modeling result.".to_string(), + launch_document: EpiphanyWorkerLaunchDocument::RepoWorkModeling( + epiphany_core::EpiphanyRepoWorkModelingLaunchDocument { + thread_id: "repo-thread-1".to_string(), + request_id: request1.request_id.clone(), + item: request1.item.clone(), + soul_verdict_receipt_id: request1.soul_verdict_receipt_id.clone(), + commit_sha: request1.commit_sha.clone(), + changed_paths: request1.changed_paths.clone(), + instruction: request1.instruction.clone(), + dynamic_prompt_context: Some("Mind-reviewed generation one.".to_string()), + }, + ), + output_contract_id: epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID + .to_string(), + organ_launch_contract: epiphany_core::default_launch_organ_contract( + "epiphany.role.modeling.repo-work", + "repo-work-modeling", + epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID, + ), + created_at: now(), + }, + )?; + let launch1 = load_worker_launch_request(&store, "repo-modeling-job-2")?; + let model_request1 = + build_worker_model_request(&launch1, DEFAULT_MODEL_PROVIDER, "gpt-5.4")?; + let openai_summary1 = EpiphanyOpenAiRuntimeRunSummary { + request_id: model_request1.request_id.clone(), + job_id: "openai-repo-job-2".to_string(), + result_id: "openai-repo-result-2".to_string(), + ..openai_summary + }; + complete_worker_job_from_assistant_text( + &store, + &launch1, + &model_request1.request_id, + &openai_summary1, + r#"{"verdict":"passed","finding":"The reviewed README consequence updates the repo map.","summary":"README consequence mapped.","nextSafeMove":"Let Mind admit generation one.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#, + )?; + let finding1 = epiphany_core::runtime_repo_work_modeling_finding( + &store, + "repo-request-2-finding", + )? + .expect("generation-one typed finding"); + assert_eq!(finding1.verdict, "passed"); + + let map_review = epiphany_core::MindGatewayReview { + gateway_id: "repo-map-review".to_string(), + source_kind: "repo_work_closure".to_string(), + allowed_effects: vec!["repoWork.map".to_string()], + refused_effects: Vec::new(), + reasons: vec!["Admit current passing finding.".to_string()], + contract: "test map review".to_string(), + ..review.clone() + }; + let map_commit = epiphany_core::mind_state_commit_receipt( + "repo-map-commit".to_string(), + &map_review, + 1, + vec!["repoWork.map".to_string()], + now(), + ); + let map = epiphany_core::RepoWorkMapEntry { + schema_version: epiphany_core::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(), + map_entry_id: "repo-map-entry".to_string(), + admitted_at: now(), + item: request1.item.clone(), + branch: "test".to_string(), + changed_paths: request1.changed_paths.clone(), + commit_sha: request1.commit_sha.clone(), + safe_action_family: "repo.status_section".to_string(), + modeling_summary: finding1.summary.clone(), + modeling_finding_receipt_id: finding1.receipt_id.clone(), + soul_verdict_receipt_id: request1.soul_verdict_receipt_id.clone(), + mind_gateway_review_id: map_review.gateway_id.clone(), + mind_state_commit_receipt_id: map_commit.receipt_id.clone(), + execute_receipt_path: "execute.json".to_string(), + closure_review_path: "review.json".to_string(), + closure_receipt_path: "close.json".to_string(), + publication_gate: "Bifrost".to_string(), + durable_state_admitted: true, + private_state_exposed: false, + modeling_route_id: route1.route_id.clone(), + modeling_generation: 1, + }; + epiphany_core::commit_repo_work_map_admission( + &store, + &map, + &map_review, + &map_commit, + )?; + let mut stale = map.clone(); + stale.map_entry_id = "stale-generation-zero-map".to_string(); + stale.modeling_finding_receipt_id = finding0.receipt_id.clone(); + stale.modeling_summary = finding0.summary.clone(); + stale.modeling_generation = 0; + assert!( + epiphany_core::commit_repo_work_map_admission( + &store, + &stale, + &map_review, + &map_commit, + ) + .is_err() + ); + let current_route = epiphany_core::runtime_repo_work_modeling_route( + &store, + &route1.route_id, + )? + .expect("current route"); + assert_eq!(current_route.generation, 1); + assert_eq!(current_route.request_id, request1.request_id); Ok(()) } diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 6611d9e5..5b8a729a 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -296,6 +296,15 @@ current request. CLI closure is a caller of this invariant, not its owner. Non-passing findings and stale generations therefore cannot become durable Mind state even through a forged-looking admission call. +The model runtime has a deterministic generation-retry proof at +`epiphany-openai-runtime/src/lib.rs`: both findings pass through the production +assistant-result parser and runtime-owned finding writer. Generation zero is +non-passing, Mind alone advances the route, generation one is passing and +admitted, and a stale generation-zero admission is refused. This proves typed +handoff and ownership without provider/network variance. The remaining smoke +boundary is process composition through `epiphany-work revise-modeling`, the +scheduler's consumer preflight, and Idunn's child lifecycle receipt. + ## Current Cut Line Keep: diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 0c587dd3..aff2c41a 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2139,6 +2139,17 @@ finding from entering durable Mind state. The authority suite includes the negative non-passing admission path and remains 4/4 green. The next move is still the native generation-one workflow smoke; it must exercise these gates, not recreate them in orchestration code. +The deterministic model-runtime seam now crosses the complete typed authority +chain without network inference: runtime-authored generation zero returns +`needs-work`; Mind advances the immutable route to generation one; the runtime +parses and persists a passing generation-one finding; canonical Mind/map +admission accepts generation one and rejects an attempted generation-zero map; +the route remains on generation one. The focused runtime test is +`repo_work_modeling_generation_retry_admits_only_current_runtime_finding`. +What remains is process composition, not another state abstraction: drive this +same chain through the public `revise-modeling` command and scheduler so the +generation-one launch carries a passing consumer preflight into an Idunn-owned +lifecycle receipt. ## Immediate Re-entry Instruction diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 4a4e2dfd..ba875291 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index f7588d4b..645ec374 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -659,4 +659,4 @@ current_status: - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. Gjallar readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Add a native end-to-end generation-one repo-work Modeling smoke. Begin with a non-passing runtime-authored generation-zero finding, exercise the explicit Mind-reviewed revise-modeling mouth, launch generation one through Idunn plus runtime-schema preflight, admit only generation one through the canonical generation-bound map transaction, and prove generation zero cannot close or regain current authority. + next_action: Add the process-composition half of the native generation-one repo-work Modeling smoke. Reuse the now-proven deterministic runtime generation chain, but exercise the public Mind-reviewed revise-modeling mouth and scheduler launch so generation one carries a passing consumer schema preflight into an Idunn-owned lifecycle receipt; verify the receipt selects the generation-one request and preserve the existing canonical proof that generation zero cannot close or regain authority.