Detach Epiphany jobs from Codex state runtime

This commit is contained in:
Meta Vens 2026-05-06 13:43:22 +01:00
commit fd0243f137
5 changed files with 49 additions and 197 deletions

View file

@ -31,13 +31,13 @@ remembers doctrine; the branch remembers the blade.
- Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`.
- Phase 1 through Phase 5 are complete enough.
- Phase 6 has read-only `thread/epiphany/scene`, `thread/epiphany/jobs`, `thread/epiphany/roles`, `thread/epiphany/freshness`, `thread/epiphany/context`, `thread/epiphany/graphQuery`, `thread/epiphany/planning`, `thread/epiphany/pressure`, `thread/epiphany/reorient`, `thread/epiphany/crrc`, `thread/epiphany/coordinator`, `thread/epiphany/reorientResult`, and `thread/epiphany/roleResult`; durable `jobBindings` now act as a thin Epiphany-owned launcher seam with launcher id, authority scope, and backend kind/job id. New `thread/epiphany/jobLaunch`, `thread/epiphany/jobInterrupt`, `thread/epiphany/roleLaunch`, and `thread/epiphany/reorientLaunch` writes are heartbeat-backed, open typed runtime-spine job receipts under `state/runtime-spine.msgpack`, and no longer create Codex `agent_jobs` rows or require the SQLite state runtime. Freshness carries watcher-backed invalidation inputs, graphQuery traverses authoritative typed graph neighborhoods and path/symbol matches without mutation, planning projects typed captures/backlog/roadmap/objective drafts without adopting work, roles project implementation/imagination/modeling/verification/reorientation ownership from existing signals without becoming a scheduler, `roleResult` and `reorientResult` read heartbeat-backed typed runtime-spine job results when present, `roleAccept` and `reorientAccept` accept completed heartbeat findings from typed runtime-spine results while remaining explicit review gates, `thread/epiphany/crrc` recommends the next explicit CRRC action without launching, accepting, compacting, scheduling, or mutating, and `thread/epiphany/coordinator` composes those signals into a fixed-lane MVP action recommendation without becoming a writer.
- Phase 6 has read-only `thread/epiphany/scene`, `thread/epiphany/jobs`, `thread/epiphany/roles`, `thread/epiphany/freshness`, `thread/epiphany/context`, `thread/epiphany/graphQuery`, `thread/epiphany/planning`, `thread/epiphany/pressure`, `thread/epiphany/reorient`, `thread/epiphany/crrc`, `thread/epiphany/coordinator`, `thread/epiphany/reorientResult`, and `thread/epiphany/roleResult`; durable `jobBindings` now act as a thin Epiphany-owned launcher seam with launcher id, authority scope, and heartbeat backend/job id. New `thread/epiphany/jobLaunch`, `thread/epiphany/jobInterrupt`, `thread/epiphany/roleLaunch`, and `thread/epiphany/reorientLaunch` writes open typed runtime-spine job receipts under `state/runtime-spine.msgpack` and do not require the Codex SQLite state runtime. Freshness carries watcher-backed invalidation inputs, graphQuery traverses authoritative typed graph neighborhoods and path/symbol matches without mutation, planning projects typed captures/backlog/roadmap/objective drafts without adopting work, roles project implementation/imagination/modeling/verification/reorientation ownership from existing signals without becoming a scheduler, `roleResult` and `reorientResult` read heartbeat-backed typed runtime-spine job results when present, `roleAccept` and `reorientAccept` accept completed heartbeat findings from typed runtime-spine results while remaining explicit review gates, `thread/epiphany/crrc` recommends the next explicit CRRC action without launching, accepting, compacting, scheduling, or mutating, and `thread/epiphany/coordinator` composes those signals into a fixed-lane MVP action recommendation without becoming a writer.
- Native `epiphany-mvp-status` is the first dogfood operator view. It starts or reads a thread through app-server and prints scene, planning, pressure, reorient, jobs, roles, Imagination/modeling/verification role result read-backs, reorient result, heartbeat, Face bubbles, and CRRC recommendation as text or machine output. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the smoked product path.
- Native `epiphany-mvp-coordinator` is the first auditable fixed-lane coordinator runner. It starts or reads a thread through app-server, opens a native runtime-spine session, follows the harness-native coordinator action, can auto-launch modeling, verification, or reorient-worker jobs, records native runtime job/result receipts for terminal launched work, keeps semantic findings review-gated by default, and writes summary, steps, rendered snapshots, transcript, stderr, runtime-spine status, and final next-action artifacts under `.epiphany-dogfood/coordinator` or a caller-provided artifact directory. It refuses direct backend-completion mutation; full completion smoke needs live workers while execution is being cauterized into CultNet.
- Native `epiphany-runtime-spine` is the first Codex-independent runtime vertebra. It owns typed CultCache documents for runtime identity, sessions, jobs, job results, and events; opens/completes native jobs; snapshots jobs/results by runtime job id; projects job-result counts; and can emit a framed CultNet hello message advertising the native document contract. Codex app-server launch/read-back/acceptance is now a typed heartbeat/runtime-spine bridge; the old `agent_jobs` SQLite path is sealed for Epiphany role/reorient results.
- Native `epiphany-runtime-spine` is the first Codex-independent runtime vertebra. It owns typed CultCache documents for runtime identity, sessions, jobs, job results, and events; opens/completes native jobs; snapshots jobs/results by runtime job id; projects job-result counts; and can emit a framed CultNet hello message advertising the native document contract. Codex app-server launch/read-back/acceptance is now a typed heartbeat/runtime-spine bridge with no Epiphany job-result dependency on the Codex SQLite runtime.
- Native CRRC automation is now landed only at turn-complete safe boundaries. It may submit `Op::Compact` for coordinator-approved `compactRehydrateReorient` or for a successful pre-compaction checkpoint intervention's pending compact handoff, and it may launch the fixed `reorient-worker` for coordinator-approved `launchReorientWorker`. It does not auto-launch Imagination/modeling/verification, accept findings, promote evidence, edit implementation code, or keep going after reviewable semantic output.
- Pre-compaction checkpoint intervention is now landed. On token-count events for loaded Epiphany threads, when current context usage reaches 80% of the active auto-compact/context limit, the harness steers the active turn once with a CRRC checkpoint directive so the agent banks working context before compaction/reorientation. Pressure ignores cumulative token spend; cumulative-only telemetry reports unknown instead of yelling. A successful steer now latches a turn-scoped compact handoff that is consumed at clean turn completion, preventing the brake from decaying into another implementation turn. This is still bounded steering plus compaction handoff, not automatic semantic acceptance, a broad scheduler, or implementation continuation.
- The old Python dogfood/live-specialist runners were cut because they encoded the `agent_jobs` completion path. The replacement must be native Rust/CultCache/CultNet and complete heartbeat-owned runtime-spine job results with auditable artifacts.
- The old Python dogfood/live-specialist runners were cut because they encoded the obsolete completion path. The replacement must be native Rust/CultCache/CultNet and complete heartbeat-owned runtime-spine job results with auditable artifacts.
- The Aquarium operator UI now lives in sibling repo `E:\Projects\EpiphanyAquarium`, not under `apps/epiphany-gui`. It is a Tauri v2 + React/WebGL interface organism over the existing status bridge, dogfood artifacts, and GUI action artifacts, not a new throne of truth. It has its own `AGENTS.md`, persistent `state/map.yaml`, `state/memory.json`, scratch/evidence files, and interface doctrine. EpiphanyAgent remains the authoritative harness/backend forge.
- Durable in-flight investigation checkpointing is now landed in authoritative typed state, writable through `thread/epiphany/update` or accepted `thread/epiphany/promote`, rendered into the prompt, and reflected through scene/context.
- The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline. Rendered state intro/doctrine text lives in `epiphany-core/src/prompts/`, and lane/control prompt text lives in `vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml`: modeling is the Body, implementation is the Hands and GUI-launched main coding lane, verification is the Soul, reorientation is Life, coordinator remains the read-only Self, and CRRC owns the pre-compaction intervention template.
@ -119,7 +119,7 @@ The current spine, blessed but not yet finished:
- thin launcher metadata in durable `jobBindings`
- `thread/epiphany/jobsUpdated` remains protocol shape only for sealed legacy evacuation telemetry; app-server no longer emits Epiphany updates from old runtime `agent_job_progress` events
- read-only compact reflection through `thread/epiphany/scene`
- read-only job/progress reflection through `thread/epiphany/jobs`, with durable launcher metadata, heartbeat pending projection, and sealed stale `agent_jobs` bindings
- read-only job/progress reflection through `thread/epiphany/jobs`, with durable launcher metadata and heartbeat pending projection
- read-only role ownership reflection through `thread/epiphany/roles`
- read-only retrieval/graph freshness reflection plus watcher-backed invalidation inputs through `thread/epiphany/freshness`
- read-only targeted state-shard reflection through `thread/epiphany/context`
@ -374,10 +374,9 @@ honest: they record skipped, failed, or completed vanilla-reference state
instead of pretending the receipt drawer is full.
The first live-specialist pass has also run. It produced
`.epiphany-dogfood/live-specialist` artifacts and proved the real worker path:
Historical scar: an earlier role smoke used a bound `agent_jobs` row and
`report_agent_job_result`; that path is now cut and must not be used as current
proof.
`.epiphany-dogfood/live-specialist` artifacts and proved the real worker path.
Historical scar: an earlier role smoke used the obsolete Codex job-result path;
that path is now cut and must not be used as current proof.
The role smoke now also proves modeling can return a reviewable graph/checkpoint
`statePatch` and `thread/epiphany/roleAccept` can apply it so the durable graph
actually grows after review.

Binary file not shown.

View file

@ -94,8 +94,8 @@ accepted_design:
- GUI/client work must reflect or steer typed state rather than manufacture a second throne of truth.
- The Aquarium operator UI now lives in sibling repo `E:\Projects\EpiphanyAquarium`, with its own `AGENTS.md`, `state/map.yaml`, `state/memory.json`, and interface doctrine. It remains a local Tauri v2 + React/WebGL client over EpiphanyAgent's app-server/tooling surfaces; app-server and typed Epiphany state remain authoritative.
- EpiphanyAgent no longer carries the embedded `apps/epiphany-gui` source tree. Backend artifact directories and action tools still use the historical `.epiphany-gui` contract until that backend naming seam is deliberately renamed.
- Durable `job_bindings` now form a thin Epiphany-owned launcher seam: new specialist/reorient launches write heartbeat-backed bindings with launcher identity, authority scope, backend kind, and backend job id, and open matching typed runtime-spine job receipts under `state/runtime-spine.msgpack`. Interrupt clears typed binding authority without inspecting or cancelling old Codex `agent_jobs` rows. The older runtime-agent-job pointer remains schema compatibility only; new Epiphany launches do not create Codex `agent_jobs` rows.
- `thread/epiphany/jobs` is a read-only job/progress reflection: it derives indexing, remap, verification, and specialist slots from authoritative state and retrieval summaries, projects heartbeat-backed bindings as pending heartbeat turns, and seals old `agent_jobs` bindings instead of crawling SQLite. It is not the scheduler, notification stream, or durable runtime job table.
- Durable `job_bindings` now form a thin Epiphany-owned launcher seam: new specialist/reorient launches write heartbeat-backed bindings with launcher identity, authority scope, backend kind, and backend job id, and open matching typed runtime-spine job receipts under `state/runtime-spine.msgpack`. Interrupt clears typed binding authority without querying the Codex SQLite runtime.
- `thread/epiphany/jobs` is a read-only job/progress reflection: it derives indexing, remap, verification, and specialist slots from authoritative state and retrieval summaries, then projects heartbeat-backed bindings as pending heartbeat turns. It is not the scheduler, notification stream, durable runtime job table, or SQLite reader.
- `thread/epiphany/jobsUpdated` is sealed legacy Codex evacuation telemetry. The handler no longer emits Epiphany updates from old runtime `agent_job_progress:{json}` background events; heartbeat/runtime-spine is the live activation and result path.
- `thread/epiphany/freshness` is the first read-only freshness surface: it derives retrieval and graph staleness from live retrieval summaries plus frontier/churn state, and for loaded threads reflects watcher-backed invalidation inputs with changed paths plus mapped graph/frontier hits, without mutating, scheduling, or performing automatic semantic invalidation.
- `thread/epiphany/context` is the first targeted read-only state-shard surface: it selects graph nodes/edges, active frontier, checkpoint, observations, and evidence from authoritative typed state without mutating or notifying.
@ -108,7 +108,7 @@ accepted_design:
- Coordinator implementation clearance is stricter than review acceptance: an accepted verification/review finding only opens the implementation gate when its verdict is `pass`; accepted `needs-evidence`, `needs-review`, or `fail` findings send the loop back toward modeling/checkpoint strengthening or reorientation instead of blessing a sick machine.
- Coordinator regather handling is now fixed-lane first, not supervisor improvisation: `regatherManually` is a fallback only after reorient/modeling/verification review and launch lanes cannot advance the state, completed modeling findings must be reviewed before verification, and the CLI coordinator's explicit test-only `--auto-review` mode may accept modeling state patches before launching verification while production semantics remain review-gated.
- Native `epiphany-mvp-coordinator` is the first auditable coordinator runner: it drives the fixed single-user lanes through app-server APIs, opens a native runtime-spine session, records native runtime job/result receipts for launched specialists and reorient workers when terminal results arrive, keeps semantic findings review-gated by default, and writes coordinator summaries, JSONL steps, rendered snapshots, transcript, stderr, runtime-spine status, and final next-action artifacts. It refuses direct backend-completion mutation; full specialist completion smoke must use live workers while the execution path is cauterized into CultNet.
- Native `epiphany-runtime-spine` is the first Codex-independent runtime vertebra: it initializes and inspects typed CultCache `epiphany.runtime.identity`, `epiphany.runtime.session`, `epiphany.runtime.job`, `epiphany.runtime.job_result`, and `epiphany.runtime.event` documents, opens/completes native jobs with result records, snapshots jobs by id, and can emit a framed CultNet hello message advertising the native document contract. App-server launch now opens typed runtime jobs; `roleResult` / `reorientResult` read heartbeat-backed typed job results only; and `roleAccept` / `reorientAccept` accept completed heartbeat findings from the typed runtime-spine path without requiring SQLite.
- Native `epiphany-runtime-spine` is the first Codex-independent runtime vertebra: it initializes and inspects typed CultCache `epiphany.runtime.identity`, `epiphany.runtime.session`, `epiphany.runtime.job`, `epiphany.runtime.job_result`, and `epiphany.runtime.event` documents, opens/completes native jobs with result records, snapshots jobs by id, and can emit a framed CultNet hello message advertising the native document contract. App-server launch now opens typed runtime jobs; `roleResult` / `reorientResult` read heartbeat-backed typed job results only; and `roleAccept` / `reorientAccept` accept completed heartbeat findings from the typed runtime-spine path without opening the Codex SQLite state runtime.
- Limited native CRRC automation is now wired only at turn-complete safe boundaries: it can submit a compact operation when the read-only coordinator recommends `compactRehydrateReorient` or when a successful pre-compaction checkpoint intervention left a pending compact handoff for the completed turn, and it can launch the fixed `reorient-worker` when the coordinator recommends `launchReorientWorker`. It does not auto-launch modeling or verification, auto-accept findings, promote evidence, edit implementation code, or continue after reviewable semantic results; the rite may carry the stretcher, not declare the patient healed.
- Pre-compaction checkpoint intervention is now wired at token-count boundaries: when a loaded Epiphany thread crosses the existing `shouldPrepareCompaction` pressure threshold during an active turn, the harness steers the active agent once for that turn with a bounded CRRC directive to bank scratch/checkpoint/map/evidence before compaction/reorientation. A successful steer marks a turn-scoped pending compact handoff consumed at clean turn completion; this is banking the fire before the dark, not semantic acceptance, broad scheduling, or automatic implementation continuation.
- Native `epiphany-mvp-status` is the first dogfood operator view: it starts or reads a thread through app-server and renders scene, planning, pressure, reorient, jobs, role result read-backs, reorient result, CRRC recommendation, heartbeat, Face bubbles, and MVP role lanes as text or machine output without becoming a state store. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the product path.
@ -116,7 +116,7 @@ accepted_design:
- `thread/epiphany/roleLaunch` and `thread/epiphany/roleResult` are the first explicit role-scoped specialist templates: Imagination/planning, modeling/checkpoint, and verification/review launch through fixed heartbeat-backed bindings with typed runtime-spine receipts and can be read back as reviewable findings from typed runtime-spine job results, while implementation stays owned by the main coding agent and reorientation stays on the CRRC-specific launch/result path.
- `thread/epiphany/roleAccept` is the first review-gated role finding acceptance path: it accepts completed heartbeat-backed findings from typed runtime-spine results, accepts Imagination/planning findings only when they return a valid planning-only `statePatch` with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, appends audit observation/evidence, and rejects verification, implementation, reorientation, job binding, objective adoption, or broad authority fields.
- `thread/epiphany/reorientLaunch` is the first bounded runtime consumer over the reorientation verdict: it launches one fixed `reorient-worker` heartbeat binding with explicit resume-versus-regather scope, authority, and checkpoint-derived payload, without making `thread/epiphany/reorient` a writer or turning CRRC into an ambient scheduler.
- `thread/epiphany/reorientResult` is the first bounded read-back surface for that worker: heartbeat-backed bindings read typed runtime-spine job results when present and otherwise report pending; old `agent_jobs` result read-back is sealed.
- `thread/epiphany/reorientResult` is the first bounded read-back surface for that worker: heartbeat-backed bindings read typed runtime-spine job results when present and otherwise report pending.
- `thread/epiphany/reorientAccept` is the first explicit acceptance write for completed reorient-worker findings: it accepts completed heartbeat-backed findings from typed runtime-spine results, appends accepted observation/evidence records, can optionally update scratch and investigation checkpoint state, and emits `stateUpdated` with source `reorientAccept` without accepting pending work or launching follow-up work.
- After `thread/epiphany/reorientAccept`, CRRC recognizes the accepted reorientation finding and does not recommend accepting the same completed result again.
- The old Python MVP dogfood runner has been cut. Auditable dogfood must use native coordinator/status/runtime-spine tools or a new typed Rust runner that completes heartbeat-owned runtime-spine job results.

View file

@ -4327,16 +4327,6 @@ impl CodexMessageProcessor {
} else {
None
};
let mut state_db_ctx = loaded_thread.as_ref().and_then(|thread| thread.state_db());
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution = load_epiphany_job_launcher_snapshots(
state_db_ctx.as_ref(),
thread.epiphany_state.as_ref(),
)
.await;
let response = ThreadEpiphanyJobsResponse {
thread_id,
source: if loaded {
@ -4348,11 +4338,7 @@ impl CodexMessageProcessor {
.epiphany_state
.as_ref()
.map(|epiphany_state| epiphany_state.revision),
jobs: map_epiphany_jobs(
thread.epiphany_state.as_ref(),
retrieval_override.as_ref(),
&job_resolution,
),
jobs: map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref()),
};
self.outgoing.send_response(request_id, response).await;
}
@ -4432,35 +4418,18 @@ impl CodexMessageProcessor {
&watcher,
);
let (mut state_db_ctx, runtime_store_path) =
if let Some(loaded_thread) = loaded_thread.as_ref() {
(
loaded_thread.epiphany_state_runtime().await,
Some(loaded_thread.epiphany_runtime_spine_store_path().await),
)
} else {
(None, None)
};
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution = load_epiphany_job_launcher_snapshots(
state_db_ctx.as_ref(),
thread.epiphany_state.as_ref(),
)
.await;
let jobs = map_epiphany_jobs(
thread.epiphany_state.as_ref(),
retrieval_override.as_ref(),
&job_resolution,
);
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 jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
let reorient_job = jobs
.iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.cloned();
let (result_status, finding, _) = load_epiphany_reorient_result_snapshot(
thread.epiphany_state.as_ref(),
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
)
@ -4583,35 +4552,18 @@ impl CodexMessageProcessor {
&watcher,
);
let (mut state_db_ctx, runtime_store_path) =
if let Some(loaded_thread) = loaded_thread.as_ref() {
(
loaded_thread.epiphany_state_runtime().await,
Some(loaded_thread.epiphany_runtime_spine_store_path().await),
)
} else {
(None, None)
};
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution = load_epiphany_job_launcher_snapshots(
state_db_ctx.as_ref(),
thread.epiphany_state.as_ref(),
)
.await;
let jobs = map_epiphany_jobs(
thread.epiphany_state.as_ref(),
retrieval_override.as_ref(),
&job_resolution,
);
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 jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
let reorient_job = jobs
.iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.cloned();
let (reorient_result_status, reorient_finding, _) = load_epiphany_reorient_result_snapshot(
thread.epiphany_state.as_ref(),
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
)
@ -4651,7 +4603,6 @@ impl CodexMessageProcessor {
if let Some(state) = thread.epiphany_state.as_ref() {
load_epiphany_role_result_snapshot(
state,
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
ThreadEpiphanyRoleId::Modeling,
EPIPHANY_MODELING_ROLE_BINDING_ID,
@ -4677,7 +4628,6 @@ impl CodexMessageProcessor {
if let Some(state) = thread.epiphany_state.as_ref() {
load_epiphany_role_result_snapshot(
state,
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
ThreadEpiphanyRoleId::Verification,
EPIPHANY_VERIFICATION_ROLE_BINDING_ID,
@ -4868,11 +4818,7 @@ impl CodexMessageProcessor {
launched.epiphany_state,
)
.await;
let state_db_ctx = loaded_thread.epiphany_state_runtime().await;
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(&epiphany_state))
.await;
let job = map_epiphany_jobs(Some(&epiphany_state), None, &job_resolution)
let job = map_epiphany_jobs(Some(&epiphany_state), None)
.into_iter()
.find(|job| job.id == binding_id)
.unwrap_or_else(|| ThreadEpiphanyJob {
@ -4995,26 +4941,16 @@ impl CodexMessageProcessor {
return;
}
let (mut state_db_ctx, runtime_store_path) =
if let Some(loaded_thread) = loaded_thread.as_ref() {
(
loaded_thread.epiphany_state_runtime().await,
Some(loaded_thread.epiphany_runtime_spine_store_path().await),
)
} else {
(None, None)
};
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(state)).await;
let job = map_epiphany_jobs(Some(state), None, &job_resolution)
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 job = map_epiphany_jobs(Some(state), None)
.into_iter()
.find(|job| job.id == binding_id);
let (status, finding, note) = load_epiphany_role_result_snapshot(
state,
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
role_id,
&binding_id,
@ -5695,35 +5631,18 @@ impl CodexMessageProcessor {
&watcher,
);
let (mut state_db_ctx, runtime_store_path) =
if let Some(loaded_thread) = loaded_thread.as_ref() {
(
loaded_thread.epiphany_state_runtime().await,
Some(loaded_thread.epiphany_runtime_spine_store_path().await),
)
} else {
(None, None)
};
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution = load_epiphany_job_launcher_snapshots(
state_db_ctx.as_ref(),
thread.epiphany_state.as_ref(),
)
.await;
let jobs = map_epiphany_jobs(
thread.epiphany_state.as_ref(),
retrieval_override.as_ref(),
&job_resolution,
);
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 jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
let reorient_job = jobs
.iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.cloned();
let (result_status, finding, result_note) = load_epiphany_reorient_result_snapshot(
thread.epiphany_state.as_ref(),
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
)
@ -5902,11 +5821,7 @@ impl CodexMessageProcessor {
launched.epiphany_state,
)
.await;
let state_db_ctx = loaded_thread.epiphany_state_runtime().await;
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(&epiphany_state))
.await;
let job = map_epiphany_jobs(Some(&epiphany_state), None, &job_resolution)
let job = map_epiphany_jobs(Some(&epiphany_state), None)
.into_iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.unwrap_or_else(map_epiphany_specialist_job);
@ -5999,24 +5914,17 @@ impl CodexMessageProcessor {
};
let state_revision = Some(state.revision);
let (state_db_ctx, runtime_store_path) = if let Some(loaded_thread) = loaded_thread.as_ref()
{
(
loaded_thread.epiphany_state_runtime().await,
Some(loaded_thread.epiphany_runtime_spine_store_path().await),
)
let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() {
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
} else {
(None, None)
None
};
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(state)).await;
let job = map_epiphany_jobs(Some(state), None, &job_resolution)
let job = map_epiphany_jobs(Some(state), None)
.into_iter()
.find(|job| job.id == binding_id);
let (status, finding, note) = load_epiphany_reorient_result_snapshot(
Some(state),
state_db_ctx.as_ref(),
runtime_store_path.as_deref(),
binding_id.as_str(),
)
@ -6786,11 +6694,7 @@ impl CodexMessageProcessor {
let epiphany_state =
client_visible_live_thread_epiphany_state(thread.as_ref(), launched.epiphany_state)
.await;
let state_db_ctx = thread.epiphany_state_runtime().await;
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(&epiphany_state))
.await;
let job = map_epiphany_jobs(Some(&epiphany_state), None, &job_resolution)
let job = map_epiphany_jobs(Some(&epiphany_state), None)
.into_iter()
.find(|job| job.id == binding_id)
.unwrap_or_else(|| ThreadEpiphanyJob {
@ -6896,11 +6800,7 @@ impl CodexMessageProcessor {
let epiphany_state =
client_visible_live_thread_epiphany_state(thread.as_ref(), interrupted.epiphany_state)
.await;
let state_db_ctx = thread.epiphany_state_runtime().await;
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(&epiphany_state))
.await;
let job = map_epiphany_jobs(Some(&epiphany_state), None, &job_resolution)
let job = map_epiphany_jobs(Some(&epiphany_state), None)
.into_iter()
.find(|job| job.id == binding_id)
.unwrap_or_else(|| map_epiphany_specialist_job());
@ -14456,7 +14356,6 @@ fn runtime_job_result_to_reorient_json(result: &EpiphanyRuntimeJobResult) -> ser
async fn load_epiphany_role_result_snapshot(
state: &EpiphanyThreadState,
_state_db_ctx: Option<&StateDbHandle>,
runtime_store_path: Option<&Path>,
role_id: ThreadEpiphanyRoleId,
binding_id: &str,
@ -14488,7 +14387,6 @@ async fn load_epiphany_role_result_snapshot(
async fn load_epiphany_reorient_result_snapshot(
state: Option<&EpiphanyThreadState>,
_state_db_ctx: Option<&StateDbHandle>,
runtime_store_path: Option<&Path>,
binding_id: &str,
) -> (
@ -17305,9 +17203,6 @@ fn extend_unique_strings(target: &mut Vec<String>, values: impl IntoIterator<Ite
}
}
#[derive(Debug, Default, Clone)]
struct EpiphanyJobLauncherResolution;
fn binding_launcher_job_id(binding: &EpiphanyJobBinding) -> Option<&str> {
binding.launcher_job_id.as_deref()
}
@ -17341,7 +17236,6 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary(
.snapshot(&thread_id_text)
.await;
let token_usage_info = thread.token_usage_info().await;
let state_db_ctx = thread.epiphany_state_runtime().await;
let runtime_store_path = thread.epiphany_runtime_spine_store_path().await;
let (_state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
@ -17356,16 +17250,13 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary(
return;
}
let job_resolution =
load_epiphany_job_launcher_snapshots(state_db_ctx.as_ref(), Some(&state)).await;
let jobs = map_epiphany_jobs(Some(&state), Some(&retrieval_override), &job_resolution);
let jobs = map_epiphany_jobs(Some(&state), Some(&retrieval_override));
let reorient_job = jobs
.iter()
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
.cloned();
let (reorient_result_status, reorient_finding, _) = load_epiphany_reorient_result_snapshot(
Some(&state),
state_db_ctx.as_ref(),
Some(runtime_store_path.as_path()),
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
)
@ -17394,7 +17285,6 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary(
);
let (modeling_result_status, modeling_finding, _) = load_epiphany_role_result_snapshot(
&state,
state_db_ctx.as_ref(),
Some(runtime_store_path.as_path()),
ThreadEpiphanyRoleId::Modeling,
EPIPHANY_MODELING_ROLE_BINDING_ID,
@ -17408,7 +17298,6 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary(
.is_some_and(epiphany_modeling_finding_has_reviewable_state_patch);
let (verification_result_status, verification_finding, _) = load_epiphany_role_result_snapshot(
&state,
state_db_ctx.as_ref(),
Some(runtime_store_path.as_path()),
ThreadEpiphanyRoleId::Verification,
EPIPHANY_VERIFICATION_ROLE_BINDING_ID,
@ -17570,17 +17459,9 @@ pub(crate) async fn maybe_run_epiphany_pre_compaction_checkpoint_intervention_fo
}
}
async fn load_epiphany_job_launcher_snapshots(
_state_db_ctx: Option<&StateDbHandle>,
_state: Option<&EpiphanyThreadState>,
) -> EpiphanyJobLauncherResolution {
EpiphanyJobLauncherResolution::default()
}
fn map_epiphany_jobs(
state: Option<&EpiphanyThreadState>,
retrieval_override: Option<&EpiphanyRetrievalState>,
_job_resolution: &EpiphanyJobLauncherResolution,
) -> Vec<ThreadEpiphanyJob> {
let mut jobs = vec![
map_epiphany_index_job(state, retrieval_override),
@ -22651,11 +22532,7 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(
Some(&state),
None,
&EpiphanyJobLauncherResolution::default(),
);
let jobs = map_epiphany_jobs(Some(&state), None);
assert_eq!(jobs.len(), 4);
assert_eq!(jobs[0].id, "retrieval-index");
@ -22692,11 +22569,7 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(
None,
Some(&retrieval),
&EpiphanyJobLauncherResolution::default(),
);
let jobs = map_epiphany_jobs(None, Some(&retrieval));
assert_eq!(jobs[0].status, ThreadEpiphanyJobStatus::Idle);
assert_eq!(jobs[0].items_processed, Some(7));
@ -22727,11 +22600,7 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(
Some(&state),
None,
&EpiphanyJobLauncherResolution::default(),
);
let jobs = map_epiphany_jobs(Some(&state), None);
let specialist = jobs
.iter()
.find(|job| job.id == "modeling-checkpoint-worker")
@ -22856,11 +22725,7 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(
Some(&state),
None,
&EpiphanyJobLauncherResolution::default(),
);
let jobs = map_epiphany_jobs(Some(&state), None);
let specialist = jobs
.iter()
.find(|job| job.id == "specialist-work")

View file

@ -423,18 +423,6 @@ impl CodexThread {
self.codex.state_db()
}
pub async fn epiphany_state_runtime(&self) -> Option<StateDbHandle> {
if let Some(state_db) = self.state_db() {
return Some(state_db);
}
let codex_home = self.codex.session.codex_home().await;
let config = self.codex.thread_config_snapshot().await;
codex_state::StateRuntime::init(codex_home.to_path_buf(), config.model_provider_id)
.await
.ok()
}
pub async fn config_snapshot(&self) -> ThreadConfigSnapshot {
self.codex.thread_config_snapshot().await
}