Move reorient accept planning into bridge
This commit is contained in:
parent
4b9863b0fe
commit
881e9c4e5e
6 changed files with 52 additions and 21 deletions
|
|
@ -31,6 +31,7 @@ use codex_app_server_protocol::ThreadEpiphanyPressure;
|
|||
use codex_app_server_protocol::ThreadEpiphanyPressureBasis;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureLevel;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientAcceptParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientCheckpointStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
|
||||
|
|
@ -56,6 +57,7 @@ use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource;
|
|||
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
|
||||
use codex_app_server_protocol::ThreadEpiphanyViewLens;
|
||||
use codex_app_server_protocol::ThreadEpiphanyWorkerLaunchDocument;
|
||||
use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use epiphany_core::EpiphanyContextParams;
|
||||
use epiphany_core::EpiphanyCoordinatorRoleResultStatus;
|
||||
use epiphany_core::EpiphanyCrrcResultStatus;
|
||||
|
|
@ -354,6 +356,33 @@ pub fn plan_thread_epiphany_role_accept(
|
|||
})
|
||||
}
|
||||
|
||||
pub struct ThreadEpiphanyReorientAcceptPlan {
|
||||
pub thread_id: String,
|
||||
pub expected_revision: Option<u64>,
|
||||
pub binding_id: String,
|
||||
pub update_scratch: bool,
|
||||
pub update_investigation_checkpoint: bool,
|
||||
}
|
||||
|
||||
pub fn plan_thread_epiphany_reorient_accept(
|
||||
params: ThreadEpiphanyReorientAcceptParams,
|
||||
) -> ThreadEpiphanyReorientAcceptPlan {
|
||||
let ThreadEpiphanyReorientAcceptParams {
|
||||
thread_id,
|
||||
expected_revision,
|
||||
binding_id,
|
||||
update_scratch,
|
||||
update_investigation_checkpoint,
|
||||
} = params;
|
||||
ThreadEpiphanyReorientAcceptPlan {
|
||||
thread_id,
|
||||
expected_revision,
|
||||
binding_id: binding_id.unwrap_or_else(|| EPIPHANY_REORIENT_LAUNCH_BINDING_ID.to_string()),
|
||||
update_scratch,
|
||||
update_investigation_checkpoint,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_state_updated_fields(
|
||||
fields: Vec<EpiphanyStateUpdatedField>,
|
||||
) -> Vec<ThreadEpiphanyStateUpdatedField> {
|
||||
|
|
|
|||
|
|
@ -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` 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 result/read-back/acceptance: app-server now declares experimental read-only `thread/epiphany/reorientResult` and write-gated `thread/epiphany/reorientAccept`. Result read-back 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. Accept planning supplies `ThreadEpiphanyReorientAcceptParams` to `epiphany-codex-bridge::protocol_edge::plan_thread_epiphany_reorient_accept`, which owns the same fixed binding default before the mutation service banks accepted findings. 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`; for retrieve, app-server reads only host cwd/Codex-home facts from `CodexThread`, while `retrieve_protocol::retrieve_thread_epiphany` accepts the protocol params and owns query/limit/path-prefix normalization, native `epiphany-core` retrieval, and Codex response projection in [retrieve_protocol.rs](E:/Projects/EpiphanyAgent/epiphany-codex-bridge/src/retrieve_protocol.rs:19), [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).
|
||||
|
||||
|
|
|
|||
|
|
@ -895,6 +895,13 @@ accepts the finding. App-server still loads the thread, calls the mutation
|
|||
service, builds the legacy accept response DTO, and emits the state-updated
|
||||
notification. `epiphany_mutation_routes.rs` is about 749 lines after this cut.
|
||||
|
||||
Reorient-accept write-route planning has moved to the bridge protocol edge too.
|
||||
`plan_thread_epiphany_reorient_accept` owns the fixed reorient binding default
|
||||
and carries the explicit scratch/checkpoint flags forward. App-server still
|
||||
loads the thread, calls the mutation service, builds the legacy accept response
|
||||
DTO, and emits the state-updated notification. `epiphany_mutation_routes.rs` is
|
||||
about 744 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
|
||||
|
|
|
|||
BIN
state/ledgers.cc
BIN
state/ledgers.cc
Binary file not shown.
|
|
@ -139,7 +139,7 @@ accepted_design:
|
|||
- `epiphany-core` and `epiphany-codex-bridge` must not depend directly on vendored `codex-core`. Host-specific Codex concepts belong in vendored app-server host adapters or the thin OpenAI subscription auth/model-transport spine, while native retrieval/state/runtime/mutation policy stays in Epiphany crates.
|
||||
- The prompt reads typed state through a bounded `<epiphany_state>` developer fragment.
|
||||
- Clients read typed state through `Thread.epiphanyState`, read-only `thread/epiphany/view` lenses for scene/jobs/roles/planning/pressure/reorient/CRRC/coordinator, freshness through `thread/epiphany/freshness`, targeted state shards through `thread/epiphany/context`, bounded graph traversal through `thread/epiphany/graphQuery`, and reviewable role output through `thread/epiphany/roleResult`. The scene, jobs, roles, planning, pressure, reorient, CRRC, and coordinator read projections now live only as view lenses, not standalone protocol verbs.
|
||||
- Durable typed state writes route through `thread/epiphany/update`, accepted `thread/epiphany/promote`, `thread/epiphany/reorientAccept`, `thread/epiphany/roleAccept`, or the bounded `thread/epiphany/jobLaunch`, `thread/epiphany/jobInterrupt`, `thread/epiphany/reorientLaunch`, and `thread/epiphany/roleLaunch` authority surfaces when they mutate state or `job_bindings`; roleAccept protocol role/default-binding planning now lives in the bridge protocol edge rather than app-server mutation routes.
|
||||
- Durable typed state writes route through `thread/epiphany/update`, accepted `thread/epiphany/promote`, `thread/epiphany/reorientAccept`, `thread/epiphany/roleAccept`, or the bounded `thread/epiphany/jobLaunch`, `thread/epiphany/jobInterrupt`, `thread/epiphany/reorientLaunch`, and `thread/epiphany/roleLaunch` authority surfaces when they mutate state or `job_bindings`; roleAccept and reorientAccept protocol/default-binding planning now lives in the bridge protocol edge rather than app-server mutation routes.
|
||||
- `thread/epiphany/retrieve`, `thread/epiphany/distill`, `thread/epiphany/propose`, `thread/epiphany/freshness`, `thread/epiphany/context`, `thread/epiphany/graphQuery`, and `thread/epiphany/view` stay read-only.
|
||||
- `thread/epiphany/index` writes the retrieval catalog, not durable Epiphany understanding; catalog is auspex output, not doctrine.
|
||||
- Qdrant is the preferred persistent semantic backend; BM25 remains the bootstrap/fallback/control path. Qdrant's HTTP API and acknowledgements remain JSON wire edges, but Epiphany-owned retrieval point payloads are typed at the adapter boundary before serialization/deserialization.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use codex_protocol::protocol::EpiphanyThreadState;
|
|||
use epiphany_codex_bridge::cultnet::EpiphanyStateUpdatedField;
|
||||
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::launch::build_epiphany_job_launch_request;
|
||||
use epiphany_codex_bridge::mutation_service::EpiphanyThreadPromoteApplied;
|
||||
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_promote;
|
||||
|
|
@ -17,6 +16,7 @@ use epiphany_codex_bridge::mutation_service::interrupt_thread_epiphany_job;
|
|||
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_job;
|
||||
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_reorient;
|
||||
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_role;
|
||||
use epiphany_codex_bridge::protocol_edge::plan_thread_epiphany_reorient_accept;
|
||||
use epiphany_codex_bridge::protocol_edge::plan_thread_epiphany_role_accept;
|
||||
use epiphany_codex_bridge::protocol_edge::protocol_job_from_surface;
|
||||
use epiphany_codex_bridge::protocol_edge::protocol_patch_from_core;
|
||||
|
|
@ -345,27 +345,22 @@ impl CodexMessageProcessor {
|
|||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyReorientAcceptParams,
|
||||
) {
|
||||
let ThreadEpiphanyReorientAcceptParams {
|
||||
thread_id,
|
||||
expected_revision,
|
||||
binding_id,
|
||||
update_scratch,
|
||||
update_investigation_checkpoint,
|
||||
} = params;
|
||||
let binding_id = binding_id.unwrap_or_else(|| EPIPHANY_REORIENT_LAUNCH_BINDING_ID.into());
|
||||
let accept_plan = plan_thread_epiphany_reorient_accept(params);
|
||||
|
||||
let (thread_uuid, loaded_thread) =
|
||||
match self.load_epiphany_thread(&request_id, &thread_id).await {
|
||||
Some(thread) => thread,
|
||||
None => return,
|
||||
};
|
||||
let (thread_uuid, loaded_thread) = match self
|
||||
.load_epiphany_thread(&request_id, &accept_plan.thread_id)
|
||||
.await
|
||||
{
|
||||
Some(thread) => thread,
|
||||
None => return,
|
||||
};
|
||||
let host = EpiphanyCodexThreadHost::new(loaded_thread.as_ref());
|
||||
let applied = match apply_thread_epiphany_reorient_accept(
|
||||
&host,
|
||||
expected_revision,
|
||||
binding_id.as_str(),
|
||||
update_scratch,
|
||||
update_investigation_checkpoint,
|
||||
accept_plan.expected_revision,
|
||||
accept_plan.binding_id.as_str(),
|
||||
accept_plan.update_scratch,
|
||||
accept_plan.update_investigation_checkpoint,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
|
@ -394,7 +389,7 @@ impl CodexMessageProcessor {
|
|||
revision: applied.revision,
|
||||
changed_fields: protocol_changed_fields,
|
||||
epiphany_state: epiphany_state.clone(),
|
||||
binding_id: binding_id.clone(),
|
||||
binding_id: accept_plan.binding_id.clone(),
|
||||
accepted_receipt_id: applied.accepted_receipt_id,
|
||||
accepted_observation_id: applied.accepted_observation_id,
|
||||
accepted_evidence_id: applied.accepted_evidence_id,
|
||||
|
|
|
|||
Reference in a new issue