From a287ca39185b00cd3e5f427c0871f44f35694cc5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 9 Jun 2026 06:07:47 +0100 Subject: [PATCH] Move reorient result policy into bridge --- epiphany-codex-bridge/src/view_protocol.rs | 25 +++++++++++++++ notes/epiphany-current-algorithmic-map.md | 2 +- notes/fresh-workspace-handoff.md | 6 ++++ state/ledgers.cc | Bin 181461 -> 181887 bytes state/map.yaml | 2 +- .../epiphany_read_routes.rs | 30 ++++++------------ 6 files changed, 42 insertions(+), 23 deletions(-) diff --git a/epiphany-codex-bridge/src/view_protocol.rs b/epiphany-codex-bridge/src/view_protocol.rs index 5f61e5c8..d9ad5fb1 100644 --- a/epiphany-codex-bridge/src/view_protocol.rs +++ b/epiphany-codex-bridge/src/view_protocol.rs @@ -620,6 +620,31 @@ pub async fn map_epiphany_reorient_result_response( } } +pub async fn map_thread_epiphany_reorient_result_response( + params: ThreadEpiphanyReorientResultParams, + loaded: bool, + state: Option<&EpiphanyThreadState>, + runtime_store_path: Option<&Path>, +) -> ThreadEpiphanyReorientResultResponse { + let ThreadEpiphanyReorientResultParams { + thread_id, + binding_id, + } = params; + let binding_id = binding_id.unwrap_or_else(|| EPIPHANY_REORIENT_LAUNCH_BINDING_ID.into()); + map_epiphany_reorient_result_response(EpiphanyReorientResultResponseInput { + thread_id, + source: if loaded { + EpiphanySurfaceSource::Live + } else { + EpiphanySurfaceSource::Stored + }, + binding_id, + state, + runtime_store_path, + }) + .await +} + pub fn map_epiphany_distill_response( expected_revision: u64, input: EpiphanyDistillInput, diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 7dea0705..001b0db4 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -43,7 +43,7 @@ The spine exists in more than twenty-five live paths: - MVP dogfood runner: the old Python runner was cut with the `agent_jobs` path. The replacement must be native Rust/CultCache/CultNet and complete heartbeat-owned runtime-spine job results with operator-safe artifacts. - Agent function/API telemetry: native `epiphany-agent-telemetry` mechanically parses sealed AppServerClient JSONL transcripts into operator-safe telemetry with method counts, request shape, job/status/path fields, and visible function/tool names while sealing text, turn items, raw results, and direct agent messages. - reorientation launch: app-server now declares experimental `thread/epiphany/reorientLaunch`, requires a loaded thread plus durable investigation checkpoint, consumes the live reorientation verdict, and launches one fixed `reorient-worker` binding through the existing job-control seam with explicit resume-versus-regather scope, checkpoint-derived payload, and structured-output expectations instead of pretending CRRC suddenly grew a scheduler in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:370), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4575), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4519). -- reorientation result read-back: app-server now declares experimental read-only `thread/epiphany/reorientResult`, defaults to the fixed `reorient-worker` binding, resolves heartbeat bindings through typed runtime-spine job results, seals legacy `agent_jobs` bindings, and projects a reviewable finding with mode, summary, next safe move, checkpoint-validity flag, inspected files, frontier ids, evidence ids, raw result, and any errors without mutating state, promoting evidence, or scheduling follow-up work. +- reorientation result read-back: app-server now declares experimental read-only `thread/epiphany/reorientResult` and supplies loaded/stored thread state plus runtime-store host facts to `epiphany-codex-bridge::view_protocol::map_thread_epiphany_reorient_result_response`, which owns the fixed `reorient-worker` binding default, source projection, runtime-spine read-back, and response mapping. The surface resolves heartbeat bindings through typed runtime-spine job results, seals legacy `agent_jobs` bindings, and projects a reviewable finding with mode, summary, next safe move, checkpoint-validity flag, inspected files, frontier ids, evidence ids, raw result, and any errors without mutating state, promoting evidence, or scheduling follow-up work. - reorientation finding acceptance: app-server now declares experimental `thread/epiphany/reorientAccept`, requires a loaded thread and a completed `reorient-worker` result, accepts heartbeat-backed results from typed runtime-spine receipts before falling back to old bindings, uses core acceptance bundle policy to build accepted observation/evidence/receipt payloads plus optional scratch and durable investigation-checkpoint updates, persists through the normal typed update path, and emits `thread/epiphany/stateUpdated` with source `reorientAccept` without accepting pending work, auto-promoting arbitrary worker output, launching follow-up work, or silently continuing implementation in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:378), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4635), [role_result.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/role_result.rs:150), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4885). - retrieval/indexing: app-server routes `thread/epiphany/retrieve` and `thread/epiphany/index` through `epiphany-codex-bridge::retrieve`, which reads only host cwd/Codex-home facts from `CodexThread` and calls native `epiphany-core` retrieval/indexing in [retrieve.rs](E:/Projects/EpiphanyAgent/epiphany-codex-bridge/src/retrieve.rs:42), [retrieve.rs](E:/Projects/EpiphanyAgent/epiphany-codex-bridge/src/retrieve.rs:57), and [retrieve.rs](E:/Projects/EpiphanyAgent/epiphany-codex-bridge/src/retrieve.rs:69). diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 5fb4020f..beafd00a 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -869,6 +869,12 @@ role-id conversion, default binding selection, unsupported-role rejection, and response projection. `epiphany_read_routes.rs` is about 540 lines after this cut. +Reorient-result route policy followed too. App-server still parses the thread +id, loads the live/stored thread view, and looks up the runtime-store path, but +`map_thread_epiphany_reorient_result_response` now owns the fixed reorient +binding default, live/stored protocol source projection, and response mapping. +`epiphany_read_routes.rs` is about 528 lines after this cut. + Context and graph-query route-level conversion followed. App-server still parses thread ids, loads live/stored thread views, and emits JSON-RPC responses, but `map_thread_epiphany_context_response` and diff --git a/state/ledgers.cc b/state/ledgers.cc index 09fe61360ab828d6534c8cef7140f6e3ac316db6..486c92b71c23b23c93ddb52ede83a22acaa17192 100644 GIT binary patch delta 253 zcmccG$^E~FdxIn+m${XZS=2EGrlT>Nl^F{e8HJjsGPO@-V%$EJiOJ#6bom2Jd@QC` z2IkWhS20Oz-D0eAE-g_gO3g3IOwB6^N-ZwU0dn(8OHvh*GV@Y0^V0Q;^Gl18Qzyr~ zl$ib?fKgyN&mkuM=`#;A39>_VO<#MMNsYC*B(WrQ`j^8@swQcf6{#sO{R%0mX^B8n zbrfyD>D`{G72_NWon id, @@ -359,23 +352,18 @@ impl CodexMessageProcessor { } }; - let source = if loaded_thread.is_some() { - EpiphanySurfaceSource::Live - } else { - EpiphanySurfaceSource::Stored - }; + let loaded = loaded_thread.is_some(); let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() { Some(loaded_thread.epiphany_runtime_spine_store_path().await) } else { None }; - let response = map_epiphany_reorient_result_response(EpiphanyReorientResultResponseInput { - thread_id: thread_uuid.to_string(), - source, - binding_id, - state: thread.epiphany_state.as_ref(), - runtime_store_path: runtime_store_path.as_deref(), - }) + let response = map_thread_epiphany_reorient_result_response( + params, + loaded, + thread.epiphany_state.as_ref(), + runtime_store_path.as_deref(), + ) .await; self.outgoing.send_response(request_id, response).await;