Move reorient result policy into bridge

This commit is contained in:
Meta Vens 2026-06-09 06:07:47 +01:00
commit a287ca3918
6 changed files with 42 additions and 23 deletions

View file

@ -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,

View file

@ -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).

View file

@ -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

Binary file not shown.

View file

@ -82,7 +82,7 @@ active_subgoals:
- Use `notes/epiphany-investor-readiness-roadmap.md` as this Codex operator's investor-scale todo rail and as the optional Epiphany Imagination sub-agent planning rail. Angel capital is fuel for compute, review capacity, legal diligence, infrastructure, and public proof, not a governance throne. The operator roadmap is now: make the local Mom MVP a repeatable proof bundle; build the Bifrost-first external-work bridge; add model-spend/review-load/accepted-artifact accounting; prove fresh-repo operation without supervisor contamination; and keep public/operator-safe exports sealed against private worker/operator/agent context. Imagination should translate world-scale Colossus pressure into Bifrost-first Objective Drafts with consent, maintainer review, receipts/ledger evidence, compute/output metrics, public/private export safety, and bounded proof artifacts.
- The May 2026 teardown/rebuild migration is archived under `notes/archive/epiphany-ideal-architecture-rebuild-plan.md` unless a concrete regression reopens it. Preserve the new foundation: Epiphany view/coordinator policy lives in `epiphany-core`, runtime-spine owns job/result lifecycle identity through `runtime_links`, duplicate acceptance is receipt-keyed, public findings stay typed/sealed, view expansion requires a core contract, and app-server remains routing/adaptation rather than a second policy throne.
- Treat Phase 5 update/distill/propose/promote/read/notification as complete enough unless a concrete regression appears; distill/propose route-level response construction now lives in the bridge, with app-server supplying loaded-thread state as host fact and mapping bridge errors to JSON-RPC.
- Preserve read-only boundaries for retrieve, distill, propose, freshness, context, graphQuery, roleResult, reorientResult, and the canonical view lenses for scene, jobs, roles, planning, pressure, reorient, crrc, and coordinator; freshness response construction, roleResult route role/binding policy, and context/graphQuery route-level DTO-to-core conversion now live in bridge view protocol mappers rather than app-server read routes.
- Preserve read-only boundaries for retrieve, distill, propose, freshness, context, graphQuery, roleResult, reorientResult, and the canonical view lenses for scene, jobs, roles, planning, pressure, reorient, crrc, and coordinator; freshness response construction, roleResult/reorientResult route binding/source policy, and context/graphQuery route-level DTO-to-core conversion now live in bridge view protocol mappers rather than app-server read routes.
- Use `notes/epiphany-memory-graph-unified-plan.md` as the source-grounded memory architecture direction. The repo fractal dataflow graph and agent memory are one `EpiphanyMemoryGraph` substrate with repo, role, short-term, incubation, agency, candidate-intervention, and evidence profiles. Qdrant stores rebuildable semantic embeddings for typed graph documents; it is never canonical memory. The first live skeleton now exists in `epiphany-state-model` plus `epiphany-core::memory_graph`: typed graph documents, stable ids, profile/lifecycle validation, freshness propagation, context cuts, a CultCache store seam, and the native `epiphany-memory-graph` status/validate/context/smoke CLI. Do not add repo scanners, sleep runners, Qdrant cache plumbing, CultNet advertisement, or prompt integration before routing them through this shared substrate.
- Keep the landed Phase 6 coordinator, limited safe-boundary CRRC automation, and pre-compaction checkpoint intervention ready for the next bridge-equipped dogfood run.
- Preserve the Ghostlight-derived heartbeat initiative seam: every lane, including coordinator/Self and Persona, has a organ-state record and competes for heartbeat slots through readiness/reaction timing; initiative heat can raise or cool global, group, arena, role, and agent tempo through typed heartbeat policy; active thinking freezes initiative until completion, so heat never queues a lane already mid-turn; idle winners ruminate instead of inventing project work, and sleep windows distill the accumulated thought pressure into reviewed self-memory or doctrine.

View file

@ -2,10 +2,8 @@ use codex_app_server_protocol::*;
use codex_core::CodexThread;
use codex_protocol::ThreadId;
use codex_protocol::protocol::EpiphanyRetrievalState;
use epiphany_codex_bridge::cultnet::EpiphanySurfaceSource;
use epiphany_codex_bridge::error::EpiphanyBridgeError;
use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use epiphany_codex_bridge::protocol_edge::core_epiphany_view_needs_jobs;
use epiphany_codex_bridge::protocol_edge::core_epiphany_view_needs_pressure;
use epiphany_codex_bridge::protocol_edge::core_epiphany_view_needs_reorientation_inputs;
@ -15,15 +13,14 @@ use epiphany_codex_bridge::protocol_edge::protocol_view_lenses_to_core;
use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths;
use epiphany_codex_bridge::retrieve_protocol::retrieve_thread_epiphany_for_paths;
use epiphany_codex_bridge::view_protocol::EpiphanyFreshnessResponseInput;
use epiphany_codex_bridge::view_protocol::EpiphanyReorientResultResponseInput;
use epiphany_codex_bridge::view_protocol::EpiphanyViewResponseInput;
use epiphany_codex_bridge::view_protocol::map_epiphany_freshness_response;
use epiphany_codex_bridge::view_protocol::map_epiphany_reorient_result_response;
use epiphany_codex_bridge::view_protocol::map_epiphany_view_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_context_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_distill_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_graph_query_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_propose_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_reorient_result_response;
use epiphany_codex_bridge::view_protocol::map_thread_epiphany_role_result_response;
use super::CodexMessageProcessor;
@ -331,11 +328,7 @@ impl CodexMessageProcessor {
request_id: ConnectionRequestId,
params: ThreadEpiphanyReorientResultParams,
) {
let ThreadEpiphanyReorientResultParams {
thread_id,
binding_id,
} = params;
let binding_id = binding_id.unwrap_or_else(|| EPIPHANY_REORIENT_LAUNCH_BINDING_ID.into());
let thread_id = params.thread_id.clone();
let thread_uuid = match ThreadId::from_string(&thread_id) {
Ok(id) => 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;