Move view route planning into bridge
This commit is contained in:
parent
a287ca3918
commit
bd6df14ad3
6 changed files with 51 additions and 25 deletions
|
|
@ -40,6 +40,11 @@ use crate::error::Result as BridgeResult;
|
|||
use crate::jobs::map_epiphany_jobs;
|
||||
use crate::launch::epiphany_role_binding_id;
|
||||
use crate::pressure::derive_epiphany_pressure;
|
||||
use crate::protocol_edge::core_epiphany_view_needs_jobs;
|
||||
use crate::protocol_edge::core_epiphany_view_needs_pressure;
|
||||
use crate::protocol_edge::core_epiphany_view_needs_reorientation_inputs;
|
||||
use crate::protocol_edge::core_epiphany_view_needs_runtime_store;
|
||||
use crate::protocol_edge::default_core_epiphany_view_lenses;
|
||||
use crate::protocol_edge::protocol_context_params_to_core;
|
||||
use crate::protocol_edge::protocol_distill_params_to_core;
|
||||
use crate::protocol_edge::protocol_freshness_response_from_surface;
|
||||
|
|
@ -57,6 +62,7 @@ use crate::protocol_edge::protocol_role_id_to_core;
|
|||
use crate::protocol_edge::protocol_role_result_status;
|
||||
use crate::protocol_edge::protocol_roles_source;
|
||||
use crate::protocol_edge::protocol_view_lens_from_core;
|
||||
use crate::protocol_edge::protocol_view_lenses_to_core;
|
||||
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
|
||||
use crate::reorient::derive_epiphany_freshness_view;
|
||||
use crate::reorient::derive_epiphany_reorient;
|
||||
|
|
@ -180,6 +186,32 @@ pub struct EpiphanyViewResponseInput<'a> {
|
|||
pub runtime_store_path: Option<&'a Path>,
|
||||
}
|
||||
|
||||
pub struct EpiphanyViewRoutePlan {
|
||||
pub thread_id: String,
|
||||
pub lenses: Vec<EpiphanyViewLens>,
|
||||
pub needs_jobs: bool,
|
||||
pub needs_reorientation_inputs: bool,
|
||||
pub needs_pressure: bool,
|
||||
pub needs_runtime_store: bool,
|
||||
}
|
||||
|
||||
pub fn plan_thread_epiphany_view(params: ThreadEpiphanyViewParams) -> EpiphanyViewRoutePlan {
|
||||
let ThreadEpiphanyViewParams { thread_id, lenses } = params;
|
||||
let lenses = if lenses.is_empty() {
|
||||
default_core_epiphany_view_lenses()
|
||||
} else {
|
||||
protocol_view_lenses_to_core(lenses)
|
||||
};
|
||||
EpiphanyViewRoutePlan {
|
||||
thread_id,
|
||||
needs_jobs: core_epiphany_view_needs_jobs(&lenses),
|
||||
needs_reorientation_inputs: core_epiphany_view_needs_reorientation_inputs(&lenses),
|
||||
needs_pressure: core_epiphany_view_needs_pressure(&lenses),
|
||||
needs_runtime_store: core_epiphany_view_needs_runtime_store(&lenses),
|
||||
lenses,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn map_epiphany_view_response(
|
||||
input: EpiphanyViewResponseInput<'_>,
|
||||
) -> ThreadEpiphanyViewResponse {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ The spine exists in more than twenty-five live paths:
|
|||
- targeted context reflection: app-server declares experimental read-only `thread/epiphany/context`, reads the same live/stored Epiphany state view used by the view lenses, and derives a bounded state shard containing selected graph nodes/edges, links, active frontier, checkpoint, the full durable investigation-checkpoint packet, observations, direct evidence, linked evidence, and missing requested ids without retrieval, proposal, promotion, notification, mutation, or persistence in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:355), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4253), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4261), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:11152).
|
||||
- graph traversal reflection: app-server declares experimental read-only `thread/epiphany/graphQuery`, reads the same live Epiphany state view used by context, and derives explicit node/edge lookup, path/symbol matches, bounded neighbors, edge-kind matches, and frontier neighborhoods with architecture/dataflow links plus frontier/checkpoint identity, matched selectors, and missing ids without retrieval, proposal, promotion, indexing, notification, mutation, or scheduling in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:379), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4720), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:5060), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:15201).
|
||||
- planning reflection: the `planning` view lens reads the same live/stored Epiphany state view and adapts the core planning projection. `epiphany-core` returns typed captures, backlog items, roadmap streams, Objective Drafts, GitHub source refs, count summaries, and the separate active objective without adopting drafts, launching work, notifying, mutating, or scheduling in [planning.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/planning.rs:1).
|
||||
- canonical view lens reflection: app-server declares experimental read-only `thread/epiphany/view` with selectable lenses and uses it as the canonical operator read surface for pressure, reorient, CRRC, and coordinator projections. Those projections no longer have standalone protocol verbs; the separate `reorientLaunch`, `reorientResult`, and `reorientAccept` surfaces remain because they carry authority, result read-back, and review acceptance rather than mere reflection.
|
||||
- canonical view lens reflection: app-server declares experimental read-only `thread/epiphany/view` with selectable lenses and uses it as the canonical operator read surface for pressure, reorient, CRRC, and coordinator projections. `epiphany-codex-bridge::view_protocol::plan_thread_epiphany_view` owns protocol lens conversion, default lens selection, and host-fact dependency planning; app-server only gathers the requested Codex host facts and passes them into the bridge response mapper. Those projections no longer have standalone protocol verbs; the separate `reorientLaunch`, `reorientResult`, and `reorientAccept` surfaces remain because they carry authority, result read-back, and review acceptance rather than mere reflection.
|
||||
- context-pressure reflection: core token telemetry carries `model_auto_compact_token_limit` beside total/last usage and `model_context_window`; the `pressure` view lens reads live token usage or the latest stored rollout `TokenCount`, derives current context pressure from `last_token_usage` rather than cumulative thread spend, treats cumulative-only telemetry as unknown, and raises `shouldPrepareCompaction` at 80% of the active auto-compact/context limit without mutating Epiphany state or scheduling compaction in [protocol.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/protocol/src/protocol.rs:2237), [turn_context.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/session/turn_context.rs:103), [session/mod.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/session/mod.rs:2716), [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:360), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4361), [token_usage_replay.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor/token_usage_replay.rs:75), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4306), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:11028).
|
||||
- pre-compaction checkpoint intervention: app-server `TokenCount` handling now checks the same pressure mapper, and for loaded Epiphany threads crossing `shouldPrepareCompaction` it steers the active turn once with a bounded CRRC checkpoint directive to bank working context before compaction/reorientation. The per-turn dedupe bit and the pending compact handoff live in listener `ThreadState`; successful steering marks the active turn for a forced compact action at clean turn completion, while aborted turns clear the handoff. The intervention uses existing turn steering and turn-boundary automation rather than a new scheduler in [bespoke_event_handling.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/bespoke_event_handling.rs:1467), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:15405), and [thread_state.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/thread_state.rs:144).
|
||||
- reorientation policy: the `reorient` view lens reuses the same live/stored thread view plus mapped pressure/freshness/watcher signals, then adapts those inputs into pure `epiphany-core` verdict policy. Core derives the bounded `resume`/`regather` decision with checkpoint-path/frontier reasons; app-server only maps the core decision back to protocol shape, without mutating, compacting, scheduling, notifying, or continuing work in [reorient.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/reorient.rs:1), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4514), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:15296).
|
||||
|
|
|
|||
|
|
@ -823,14 +823,20 @@ now live in `epiphany-codex-bridge::view`. The same bridge view module now owns
|
|||
role/reorient result response construction too: it loads the mapped
|
||||
runtime-spine status/finding, projects the matching job, and builds
|
||||
`ThreadEpiphanyRoleResultResponse` /
|
||||
`ThreadEpiphanyReorientResultResponse`. App-server keeps only role binding
|
||||
validation, live/stored source selection, runtime-store path lookup, and
|
||||
response emission for those compatibility verbs. `epiphany_read_routes.rs` is
|
||||
`ThreadEpiphanyReorientResultResponse`. App-server keeps only live/stored state
|
||||
loading, runtime-store path lookup, and response emission for those
|
||||
compatibility verbs. `epiphany_read_routes.rs` is
|
||||
about 648 lines after these cuts. The remaining read-route bodies are mostly individual
|
||||
legacy read verbs (`roleResult`, `freshness`, `context`, `graphQuery`,
|
||||
`reorientResult`, `retrieve`, `distill`, `propose`) plus host loading and
|
||||
response/error shaping.
|
||||
|
||||
View route planning is bridge-owned at the route boundary now. App-server calls
|
||||
`plan_thread_epiphany_view` to convert protocol lenses, apply default lenses,
|
||||
and learn which host facts to gather. It no longer imports the raw
|
||||
`core_epiphany_view_needs_*`, default-lens, or protocol-lens conversion helpers.
|
||||
`epiphany_read_routes.rs` is about 516 lines after this cut.
|
||||
|
||||
Freshness/context/graph-query response construction is also bridge-owned now.
|
||||
`epiphany-codex-bridge::view` builds `ThreadEpiphanyFreshnessResponse`,
|
||||
`ThreadEpiphanyContextResponse`, and `ThreadEpiphanyGraphQueryResponse` from
|
||||
|
|
|
|||
BIN
state/ledgers.cc
BIN
state/ledgers.cc
Binary file not shown.
|
|
@ -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/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.
|
||||
- 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; view lens planning, 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.
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ use codex_protocol::ThreadId;
|
|||
use codex_protocol::protocol::EpiphanyRetrievalState;
|
||||
use epiphany_codex_bridge::error::EpiphanyBridgeError;
|
||||
use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
|
||||
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;
|
||||
use epiphany_codex_bridge::protocol_edge::core_epiphany_view_needs_runtime_store;
|
||||
use epiphany_codex_bridge::protocol_edge::default_core_epiphany_view_lenses;
|
||||
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;
|
||||
|
|
@ -22,6 +16,7 @@ use epiphany_codex_bridge::view_protocol::map_thread_epiphany_graph_query_respon
|
|||
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 epiphany_codex_bridge::view_protocol::plan_thread_epiphany_view;
|
||||
|
||||
use super::CodexMessageProcessor;
|
||||
use super::ConnectionRequestId;
|
||||
|
|
@ -35,12 +30,8 @@ impl CodexMessageProcessor {
|
|||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyViewParams,
|
||||
) {
|
||||
let ThreadEpiphanyViewParams { thread_id, lenses } = params;
|
||||
let lenses = if lenses.is_empty() {
|
||||
default_core_epiphany_view_lenses()
|
||||
} else {
|
||||
protocol_view_lenses_to_core(lenses)
|
||||
};
|
||||
let view_plan = plan_thread_epiphany_view(params);
|
||||
let thread_id = view_plan.thread_id.clone();
|
||||
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
|
|
@ -65,10 +56,7 @@ impl CodexMessageProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
let needs_jobs = core_epiphany_view_needs_jobs(&lenses);
|
||||
let needs_reorientation_inputs = core_epiphany_view_needs_reorientation_inputs(&lenses);
|
||||
let needs_pressure = core_epiphany_view_needs_pressure(&lenses);
|
||||
let retrieval_override = if (needs_jobs || needs_reorientation_inputs)
|
||||
let retrieval_override = if (view_plan.needs_jobs || view_plan.needs_reorientation_inputs)
|
||||
&& thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
|
|
@ -83,7 +71,7 @@ impl CodexMessageProcessor {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if needs_reorientation_inputs {
|
||||
let watcher_snapshot = if view_plan.needs_reorientation_inputs {
|
||||
if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
|
|
@ -100,7 +88,7 @@ impl CodexMessageProcessor {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let token_usage_info = if needs_pressure {
|
||||
let token_usage_info = if view_plan.needs_pressure {
|
||||
if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
loaded_thread.token_usage_info().await
|
||||
} else {
|
||||
|
|
@ -112,7 +100,7 @@ impl CodexMessageProcessor {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let runtime_store_path = if core_epiphany_view_needs_runtime_store(&lenses) {
|
||||
let runtime_store_path = if view_plan.needs_runtime_store {
|
||||
if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
|
||||
} else {
|
||||
|
|
@ -124,7 +112,7 @@ impl CodexMessageProcessor {
|
|||
let token_usage_snapshot = epiphany_token_usage_snapshot(token_usage_info.as_ref());
|
||||
let response = map_epiphany_view_response(EpiphanyViewResponseInput {
|
||||
thread_id: thread_id.clone(),
|
||||
lenses,
|
||||
lenses: view_plan.lenses,
|
||||
loaded,
|
||||
state: thread.epiphany_state.as_ref(),
|
||||
retrieval_override: retrieval_override.as_ref(),
|
||||
|
|
|
|||
Reference in a new issue