Add Epiphany scene projection

This commit is contained in:
Meta Vens 2026-04-25 16:07:41 +01:00
commit 8507b3c491
22 changed files with 1683 additions and 17 deletions

View file

@ -10,7 +10,7 @@ The important question for this file is not "what is Epiphany supposed to become
Current Epiphany is a forked Codex harness with a typed modeling spine.
The spine exists in eleven live paths:
The spine exists in twelve live paths:
- protocol state shape: `EpiphanyThreadState`, `RolloutItem::EpiphanyState`, retrieval summaries, and prompt tags live in [protocol.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/protocol/src/protocol.rs:103).
- in-memory session state: `SessionState` stores an optional `EpiphanyThreadState`, and `Session` exposes thin async accessors over it in [state/session.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/state/session.rs:36) and [session/mod.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/session/mod.rs:1240).
@ -22,6 +22,7 @@ The spine exists in eleven live paths:
- explicit promotion gates: app-server routes `thread/epiphany/promote` through a loaded-thread handler into `epiphany-core` policy evaluation, rejects failed verifier evidence without mutation, applies accepted candidates through the same durable update path, and now treats medium/high/expanded/broadening/semantic churn deltas as needing explicit rationale plus stronger verifier evidence whose kind is token-matched rather than substring-matched in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4316) and [promotion.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/promotion.rs:33).
- explicit state updates: app-server routes `thread/epiphany/update` through a loaded `CodexThread` update method that rejects malformed appended observation/evidence graph records and structurally invalid replacement fields, mutates live `SessionState` only after validation, bumps the revision, and persists an immediate `RolloutItem::EpiphanyState` snapshot in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4436), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:374), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:552), and [promotion.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/promotion.rs:44).
- live state notifications and write responses: app-server declares experimental `thread/epiphany/stateUpdated` and emits it with the updated typed state, typed `source`, event-level `revision`, and typed `changedFields` after successful direct updates and accepted promotions, but not after rejected promotions; direct `thread/epiphany/update` and accepted `thread/epiphany/promote` responses expose the same revision/change metadata, accepted promotions always report `Evidence` because verifier evidence is appended even when the patch evidence list is empty, and successful write response/notification states now use the same client-visible live projection as `thread/read`, including retrieval-summary backfill when durable state has no persisted retrieval metadata, in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:1097), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:3992), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4058), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4069), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4381), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4415), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4470), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4502), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10430), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10440), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10526), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10569).
- scene projection: app-server declares experimental read-only `thread/epiphany/scene`, reads the same live/stored Epiphany state view used by `thread/read`, and derives a compact client scene with objective, active subgoal, invariant status counts, graph focus/counts, retrieval status, observation/evidence summaries, churn, live/stored source, and available control-plane actions without mutating or persisting state in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:339), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:3921), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4067), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10500).
- retrieval/indexing: app-server routes `thread/epiphany/retrieve` and `thread/epiphany/index` through loaded `CodexThread` host methods into `epiphany-core` in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4046), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4122), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:438), and [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:456).
The thick Epiphany-owned implementation is mostly outside vendored Codex now:
@ -57,6 +58,8 @@ flowchart TD
O --> P["Backfill retrieval summary if missing"]
P --> N
N --> Q["Client can read typed state"]
N --> QS["thread/epiphany/scene derives compact client scene"]
QS --> Q
A --> R["thread/epiphany/retrieve requires loaded thread"]
A --> S["thread/epiphany/index requires loaded thread"]
A --> AA["thread/epiphany/distill requires loaded thread"]
@ -95,6 +98,7 @@ What this means in plain English:
- Epiphany state is a durable object, not prompt folklore.
- The prompt can read it every turn when it exists.
- The app-server can expose it as typed thread data.
- The app-server can also expose a compact read-only scene derived from that typed state for future clients.
- A loaded thread can ask for a typed observation/evidence proposal without mutating state.
- A loaded thread can ask a verifier-backed promotion gate to reject or apply that proposal.
- A loaded thread can now accept explicit typed state patches and persist them immediately.
@ -127,6 +131,7 @@ This is the same flow in the language Epiphany is supposed to make the model car
| Turn execution | Codex still runs the ordinary model/tool loop; Epiphany is context and discipline around that loop, not a replacement engine yet. | The same workshop machines run, but now there is a work order on the wall. |
| Persistence | After a real user turn, Epiphany snapshots the current model beside the normal turn context. | The field notebook gets dated and shelved after each real work session. |
| Thread read | Clients can ask for the current Epiphany model as typed data instead of scraping prompt text or transcript debris. | The dashboard reads the blueprint file directly, not a photo of the workbench. |
| Scene projection | Clients can ask for a compact reflection of the typed model: active goal, graph focus, retrieval status, evidence counts, churn, and available control actions. It is derived from state, not a second state store. | A foreman-facing wall board copied from the blueprint ledger; useful at a glance, legally not the blueprint. |
| Retrieval | A loaded thread can ask a structured question of the repo through one typed retrieval surface. | A librarian brings back marked pages instead of making the agent rummage through every shelf. |
| Indexing | Persistent semantic memory is built only through an explicit indexing path. | The librarian updates the card catalog only when asked, not while pretending to answer a question. |
| Distillation | One explicit observation can be normalized into a typed observation/evidence patch, but not promoted automatically. | The clerk drafts a ledger entry in pencil before anyone is allowed to ink it. |
@ -881,6 +886,79 @@ Rejected promotions return reasons and no state. Accepted promotions return the
Promotion is a gate, not independent persistence. It does not write rollout items directly, it does not mutate state on rejection, and rejected promotions emit no state update notification. Accepted promotions still go through `CodexThread.epiphany_update_state`, so the red pen remains one tool, not three tools in a coat.
## Flow 13: Scene Projection Control Flow
### Input
A client sends experimental `thread/epiphany/scene` with:
- `threadId`
### Plain-language role
Scene projection is the first Phase 6 reflection boundary. It is not another state object and not a GUI brain. It is the little wall board a client can read when the full ledger is too raw: state present or missing, live or stored source, revision, objective, active subgoal, invariant status counts, graph focus/counts, retrieval status, latest observations/evidence, churn, and which Epiphany control doors are available.
The important boundary is that it derives from the same Epiphany state view as `thread/read`. It never writes `SessionState`, never appends rollout items, never runs proposal or promotion, and never makes client-side layout the canonical model. The client gets a scene; the ledger remains the ledger.
Protocol shape:
- `threadId`
Response shape:
- `threadId`
- `scene`
- `stateStatus`
- `source`
- optional `revision`
- optional `objective`
- optional `activeSubgoal`
- `subgoals`
- `invariantStatusCounts`
- `graph`
- optional `retrieval`
- `observations`
- `evidence`
- optional `churn`
- `availableActions`
Code refs:
- [app-server-protocol/common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:339)
- [app-server-protocol/v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:3921)
- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4067)
- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10500)
### Mechanism
The app-server handler:
1. parses the thread id.
2. checks whether the thread is currently loaded so the scene can report live/stored source and available actions.
3. calls the existing `read_thread_view(..., include_turns: false)` path, which already applies live Epiphany state or stored rollout reconstruction.
4. passes the optional `thread.epiphany_state` into `map_epiphany_scene`.
5. returns a compact derived scene.
`map_epiphany_scene`:
1. returns a missing-state scene when no Epiphany state exists.
2. marks source as `live` when the thread is loaded, otherwise `stored`.
3. copies revision/objective/active subgoal without changing them.
4. summarizes invariant status counts with deterministic status ordering.
5. summarizes architecture/dataflow graph counts, active frontier ids, dirty paths, open question/gap counts, and checkpoint identity.
6. summarizes retrieval status, semantic availability, index revision, shard count, dirty-path count, and indexed file/chunk counts.
7. includes bounded latest observation/evidence summaries.
8. reflects churn pressure/warning fields.
9. reports available actions only when the thread is loaded, adding `propose` and `promote` only when state exists.
### Output
The response is a client-shaped reflection of the current Epiphany machine. It lets a GUI or other client render the state without scraping prompt text, diffing the full `EpiphanyThreadState`, or making up its own model of which doors exist.
### Invariant
Scene projection is read-only. It is allowed to compress and label the authoritative state for humans and clients, but it must not become the place where understanding is manufactured. A dashboard is allowed to exist. It is not allowed to grab the steering wheel and call itself destiny.
## Current Non-Flows
These are deliberately not shipped yet:
@ -891,7 +969,7 @@ These are deliberately not shipped yet:
- no watcher-driven graph or semantic invalidation.
- no code-intelligence graph.
- no specialist-agent scheduler.
- no GUI reflection layer.
- no GUI implementation beyond the read-only scene projection surface.
- no durable retrieval-summary write from `thread/epiphany/retrieve`.
The current system is therefore not "the model maintains a map automatically." More precisely:
@ -901,6 +979,7 @@ stored Epiphany state
-> rendered into model context
-> persisted across turns and resume
-> visible to clients
-> reflected as a compact read-only scene for clients
-> retrieval/indexing can inform future work
-> explicit distillation can draft observation/evidence patches
-> explicit proposal can draft map/churn patches from verified observations
@ -909,7 +988,7 @@ stored Epiphany state
-> successful writes emit thread/epiphany/stateUpdated
```
The current remaining missing organ is not the red pen, not the first chewing motion, and not the first state-change bell. Those exist. Proposal now has the first bits of map memory, focus, and selection hygiene: it can auto-select a bounded evidence-backed observation cluster when ids are omitted, requires accepting recent evidence behind selected observations, prioritizes stronger selected observations for proposal wording, reuses existing architecture nodes by concrete code-ref/path/id checks before creating new path nodes, can rescue unanchored graph nodes through strict unique semantic overlap, follows graph links and incident edges into the frontier, and reports match-kind-aware churn pressure from the actual proposal shape. Distillation now also has the first source-output-aware teeth for tool/model summaries. Promotion now notices risky deltas instead of just checking the shape of the envelope, treats graph expansion as risky even if the patch tries to mumble "low pressure" while dragging a new wall into the blueprint, and token-matches strong verifier kinds so `contest` cannot sneak past as `test`. Successful update/promote writes now emit `thread/epiphany/stateUpdated` with `source: "update"` or `source: "promote"`, event-level revision, and typed changed fields so clients no longer need to poll blindly, infer the cause from timing, or diff the whole state to know which top-level sections moved. Richer app-server smoke coverage now exists in `tools/epiphany_phase5_smoke.py`; the remaining missing organs are watcher/freshness inputs and eventually role-scoped specialist ownership without silently auto-promoting anything.
The current remaining missing organ is not the red pen, not the first chewing motion, not the first state-change bell, and no longer the first client-shaped scene. Those exist. Proposal now has the first bits of map memory, focus, and selection hygiene: it can auto-select a bounded evidence-backed observation cluster when ids are omitted, requires accepting recent evidence behind selected observations, prioritizes stronger selected observations for proposal wording, reuses existing architecture nodes by concrete code-ref/path/id checks before creating new path nodes, can rescue unanchored graph nodes through strict unique semantic overlap, follows graph links and incident edges into the frontier, and reports match-kind-aware churn pressure from the actual proposal shape. Distillation now also has the first source-output-aware teeth for tool/model summaries. Promotion now notices risky deltas instead of just checking the shape of the envelope, treats graph expansion as risky even if the patch tries to mumble "low pressure" while dragging a new wall into the blueprint, and token-matches strong verifier kinds so `contest` cannot sneak past as `test`. Successful update/promote writes now emit `thread/epiphany/stateUpdated` with `source: "update"` or `source: "promote"`, event-level revision, and typed changed fields so clients no longer need to poll blindly, infer the cause from timing, or diff the whole state to know which top-level sections moved. The scene surface gives clients a compact read-only view without making the GUI/client authoritative. Richer app-server smoke coverage now exists in `tools/epiphany_phase5_smoke.py`; the remaining missing organs are live scene smoke, job/progress reflection, watcher/freshness inputs, and eventually role-scoped specialist ownership without silently auto-promoting anything.
```text
model/tool observations
@ -923,7 +1002,7 @@ model/tool observations
The typed write path exists, the first deterministic observation/evidence distillation path exists, source-output-aware distillation now summarizes noisy tool/model output into typed evidence with final result/error/finished lines ahead of generic warnings, the first deterministic map/churn proposal path exists, proposal-quality hardening now auto-selects bounded observation clusters when ids are omitted, requires accepting recent evidence, reuses existing graph nodes by observed code refs, prioritizes stronger selected observations, rescues unanchored graph nodes by strict semantic overlap, focuses linked frontier context, reports match-kind-aware map-delta pressure, and the first verifier-backed promotion gate exists. The first map/churn safety layer also exists: promotion can reject state replacement patches that are not tied to explicit observations/evidence, that contain structurally broken subgoal, invariant, graph, frontier, checkpoint, or churn fields, that try to promote risky churn without a warning and stronger verifier evidence, that claim a graph expansion is low-pressure to dodge the warning gate, or that rely on substring verifier-kind accidents. The first live state notification layer also exists: accepted writes publish updated typed state plus event-level revision and typed changed fields; rejected promotions stay quiet.
In natural language: current Epiphany can preserve a map, show a map, retrieve evidence for the map, draft one explicit observation/evidence patch, derive a bounded graph/frontier/churn candidate from verified evidence-backed observations with code refs, choose a small coherent observation set when the caller does not provide one, favor the strongest selected observation when drafting that candidate, reject or accept a verified candidate, apply explicit map/evidence/churn edits, notify clients after successful writes, and sanity-check those edits before they hit the ledger. It still does not ingest fresh tool/model output into richer map deltas automatically, invalidate stale graph regions, or coordinate specialist ownership. Teeth are installed; chewing is supervised; the first bell rings; the next slices are about taste, not jawbones.
In natural language: current Epiphany can preserve a map, show a map, project a compact scene from the map, retrieve evidence for the map, draft one explicit observation/evidence patch, derive a bounded graph/frontier/churn candidate from verified evidence-backed observations with code refs, choose a small coherent observation set when the caller does not provide one, favor the strongest selected observation when drafting that candidate, reject or accept a verified candidate, apply explicit map/evidence/churn edits, notify clients after successful writes, and sanity-check those edits before they hit the ledger. It still does not ingest fresh tool/model output into richer map deltas automatically, invalidate stale graph regions, track long-running Epiphany jobs, or coordinate specialist ownership. Teeth are installed; chewing is supervised; the first bell rings; the first wall board exists; the next slices are about taste, not jawbones.
## Verification Hooks

View file

@ -2,7 +2,7 @@
## Status
Updated on 2026-04-25 after recognizing that Phase 5 is complete enough to stop feeding itself tiny safety slices. The update/distill/propose/promote/read/notification control plane is now the regression-guarded baseline, not an excuse to keep rearranging the furniture until everyone dies of responsible boredom.
Updated on 2026-04-25 after landing the first Phase 6 reflection-boundary slice. Phase 5 remains the regression-guarded update/distill/propose/promote/read/notification baseline, not an excuse to keep rearranging the furniture until everyone dies of responsible boredom.
This note tracks Epiphany as a fork of Codex with an opinionated modeling architecture. The point is not to offer Codex another collaboration preset. The point is to make the harness force the model to carry explicit structure about the codebase, the active subgoal, the evidence trail, and the machine it is modifying.
@ -33,11 +33,12 @@ This note tracks Epiphany as a fork of Codex with an opinionated modeling archit
- a rejected-promotion silence smoke hardening slice: the reusable Phase 5 app-server smoke now asserts rejected `thread/epiphany/promote` calls do not emit `thread/epiphany/stateUpdated`, preserving the "no mutation, no bell" contract
- a direct-update integrity hardening slice: `thread/epiphany/update` now validates appended observation/evidence graph records and structural replacement fields before mutation, rejects empty/duplicate/reused append ids, missing evidence references, and invalid graph/frontier/checkpoint/subgoal/churn replacement shapes, and the reusable smoke asserts invalid direct updates leave revision unchanged with no `thread/epiphany/stateUpdated` notification
- a write/read surface consistency hardening slice: successful direct update and accepted promote responses plus their `thread/epiphany/stateUpdated` notifications now reuse the same live Epiphany state projection as `thread/read`, so clients get retrieval-summary backfill consistently instead of receiving a raw just-written state in one surface and a richer read state in another
- a first Phase 6 reflection-boundary slice: experimental read-only `thread/epiphany/scene` returns a client-shaped projection derived from authoritative Epiphany state, including objective, active subgoal, invariant counts, graph focus, retrieval status, observation/evidence summaries, churn, live/stored source, and available control-plane actions without mutating or persisting anything
- current phase: Phase 6 reflection boundary / scene-surface precursor
The next job is no longer to prove the retriever exists, sketch the persistent follow-up in prose, invent the first red-pen path, build the first observation proposal surface, make promotion notice broken map/churn replacements, ship the first read-only map/churn proposal surface, teach proposal to avoid duplicating already-mapped code surfaces, make proposal frontier focus follow existing graph links, make selected observations evidence-backed with non-haunted churn pressure, rescue unanchored graph nodes with strict semantic matching, let proposal choose a bounded ready observation set when ids are omitted, make proposal pressure understand match kinds, make the distiller summarize noisy source output, make source-output salience prefer final results over generic warnings, make promotion notice risky deltas, make expansion freshness resistant to low-pressure underreporting, prevent substring verifier-kind accidents, prove that richer chain over app-server by hand, add the first live state notification after successful writes, make that notification say which revision and state sections changed, reject malformed direct updates, or make write responses match `thread/read` projection. Those parts are landed or live-smoked.
The next job is to move one layer outward: design and land a meaningful Phase 6 reflection/scene-surface or job-state precursor that lets a client inspect and steer the typed Epiphany machine without making the GUI/client the source of truth. Use `tools/epiphany_phase5_smoke.py` as a regression guardrail when touching the Phase 5 control plane, not as a ritual that justifies another tiny safety slice.
The next job is to continue from the read-only scene baseline: live-smoke `thread/epiphany/scene` through app-server or move toward a minimal job-state/progress surface for indexing/remap/verification work. Use `tools/epiphany_phase5_smoke.py` as a regression guardrail when touching the Phase 5 control plane, not as a ritual that justifies another tiny safety slice.
Workflow trap to avoid: do not leave handoff or plan notes that say only "continue the next smallest hardening slice" after a phase has reached a coherent baseline. Bounded slices are how work lands safely; they are not the project direction. A good handoff should name the next organ, not merely prescribe one more scrape of sandpaper on the same seam.
@ -319,7 +320,7 @@ Treat the current retrieval baseline and explicit indexing follow-up as landed P
5. declare Phase 5 complete enough unless a concrete bug, regression, or real-use gap appears
6. use the Phase 5 smoke as a guardrail before modifying the existing control plane, not as a reason to keep sanding that same control plane forever
7. choose the next meaningful Phase 6 precursor:
- a typed scene/read model for graph, invariants, evidence, intent, churn, and retrieval status, derived from existing Epiphany state
- extend the typed scene/read model for graph, invariants, evidence, intent, churn, and retrieval status, derived from existing Epiphany state
- or a minimal typed job-state/progress surface for indexing/remap/verification work that a future GUI can render
8. keep the source-of-truth rule intact: GUI/client surfaces reflect and steer typed state, but they do not manufacture canonical understanding

View file

@ -39,6 +39,7 @@ Recent anchor commits:
- current slice - hardened the reusable Phase 5 smoke so rejected promotions explicitly prove `thread/epiphany/stateUpdated` stays silent
- current slice - hardened direct `thread/epiphany/update` so malformed appended observations/evidence and structurally invalid replacement fields are rejected before mutation, and the reusable smoke proves invalid direct updates stay silent
- current slice - aligned successful update/promote response and notification state payloads with the same client-visible live-state projection used by `thread/read`, including retrieval-summary backfill
- current slice - added the first Phase 6 reflection surface as read-only `thread/epiphany/scene`, projecting objective, subgoals, invariant counts, graph focus, retrieval status, observations, evidence, churn, live/stored source, and available control actions from existing Epiphany state
Do not trust this note for the exact current HEAD; use `git log --oneline -1` if you need the live commit.
@ -64,10 +65,11 @@ Rehydrate:
Reorient:
- current HEAD before this packet was written: `0dcdfab Mark Phase 5 complete enough`
- branch is `main...origin/main [ahead 1]` after the Phase 5 completion docs commit unless a later slice pushes or commits more
- current active lane is Phase 6 reflection boundary / scene-surface precursor
- current HEAD before the Phase 6 scene slice was `e1e5c40 Persist compact reentry after Phase 5 exit`
- branch was `main...origin/main [ahead 2]` before the Phase 6 scene slice; check `git log --oneline -5` for the live commit after this lands
- current active lane is Phase 6 reflection boundary; the first read-only scene surface now exists
- latest landed implementation slice: successful `thread/epiphany/update` and accepted `thread/epiphany/promote` responses/notifications now publish the same client-visible live-state projection as `thread/read`, including retrieval-summary backfill
- latest landing slice: experimental `thread/epiphany/scene` derives a client-shaped reflection from `thread/read`-compatible Epiphany state without mutating or persisting anything
- latest docs/memory slice: Phase 5 is marked complete enough; the plan, map, handoff, algorithmic map, AGENTS discipline, and evidence now warn against self-reinforcing "one more tiny hardening slice" handoffs
- latest verification slice: richer Phase 5 smoke observed retrieval status `ready` on update/promote responses and notifications, with rejected promotions and invalid direct updates still silent/non-mutating; no new code changed after that smoke
- `thread/epiphany/retrieve`, `thread/epiphany/distill`, and `thread/epiphany/propose` remain read-only
@ -78,9 +80,9 @@ Continue:
- do not restart Phase 5 just because the handoff says to be careful; the update/distill/propose/promote/read/notification seam is complete enough unless a concrete regression appears
- use `tools/epiphany_phase5_smoke.py` as the app-server seam guardrail before changing proposal/promotion/write/read behavior, not as a ritual for generating more tiny safety work
- pick a meaningful Phase 6 reflection/scene-surface or job-state precursor that exposes the existing typed Epiphany machine without making GUI/client state authoritative
- continue from the first Phase 6 scene-surface baseline; either live-smoke `thread/epiphany/scene` through app-server or move toward a minimal job-state/progress surface
- avoid handoff notes that only say "next smallest hardening slice"; they can trap the next agent in furniture-rearrangement mode
- likely next move: source-ground the current app-server protocol/read surfaces and decide whether Phase 6 starts with a thin typed scene/read projection or a minimal job-state/progress surface; do not implement from vibes
- likely next move: use the new scene surface as the thin typed read projection and decide whether to live-smoke it or add a minimal job-state/progress surface; do not implement from vibes
- before natural-language algorithm-map edits, reread the exact source being described
- if a regression or benchmark fix attempt does not move the target, immediately revert that attempt before trying the next hypothesis
@ -132,6 +134,7 @@ Current verified typed state/promotion layer:
- experimental `thread/epiphany/stateUpdated` notifications after successful direct updates and accepted promotions, with typed `source` values of `update` or `promote`, event-level `revision`, and typed `changedFields`
- response-level `revision` and `changedFields` on successful `thread/epiphany/update` and accepted `thread/epiphany/promote`
- successful update/promote response and notification state payloads now include the same non-durable retrieval-summary backfill that live `thread/read` exposes when durable Epiphany state lacks persisted retrieval metadata
- experimental read-only `thread/epiphany/scene`, which turns existing authoritative Epiphany state into a compact client reflection without writing state or creating a GUI-owned brain
- typed patch shape for observations, evidence, objective, subgoals, invariants, graphs, graph frontier/checkpoint, scratch, churn, and mode
- direct `thread/epiphany/update` validation for appended observations/evidence and replacement fields: append records need nonempty identity fields, patch ids cannot duplicate or reuse durable ids, observations must cite existing or same-patch evidence ids, and graph/frontier/checkpoint/subgoal/churn replacement shapes must pass the shared `epiphany-core` structural validator before the durable writer mutates state
- deterministic observation/evidence proposal generation in `epiphany-core`
@ -520,7 +523,7 @@ Phase transition rule:
3. keep `thread/epiphany/retrieve`, `thread/epiphany/distill`, and `thread/epiphany/propose` read-only
4. run `tools/epiphany_phase5_smoke.py` before changing proposal, promotion, update, read, or notification behavior
5. do not keep adding tiny Phase 5 hardening rules merely because the harness can; if there is no concrete bug or real-use gap, move outward
6. start the next meaningful Phase 6 precursor: a typed reflection/scene surface or job-state/progress surface that lets clients inspect and steer existing Epiphany state without becoming the source of truth
6. continue the Phase 6 reflection boundary from the new read-only `thread/epiphany/scene` baseline, or add a minimal job-state/progress surface that lets clients inspect long-running work without becoming the source of truth
## What Not To Do Next
@ -560,4 +563,4 @@ cmd /c "\"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxi
The repo is in a good state.
Phase 1, Phase 2, the minimal Phase 3 typed read surface, Phase 4 retrieval/indexing/core-extraction, and the Phase 5 distill/propose/promote/update/read/notification control plane are landed and verified enough to move on. `vendor/codex` is first-class in the parent repo now, with the heavier Epiphany organs living in `epiphany-core`. Successful direct updates and accepted promotions now return response-level revision/changed-field metadata and emit experimental `thread/epiphany/stateUpdated` notifications carrying the updated client-visible typed state, source labels, event-level revision, and typed changed fields; accepted promotion responses/notifications include `evidence` whenever verifier evidence is appended, even when patch evidence was empty, and successful write response/notification states include the same retrieval-summary backfill exposed by live `thread/read`. Direct updates reject malformed appended observations/evidence and structurally invalid replacement fields before mutation. Read-only distillation summarizes noisy tool/model output into typed evidence, read-only proposal can auto-select a bounded evidence-backed observation cluster and report match-kind-aware map-delta pressure, and promotion rejects risky deltas without warning plus strong verifier evidence. The current Epiphany algorithmic map has been source-audited against the code flow it describes. The richer Phase 5 chain is live-smoked through app-server by `tools/epiphany_phase5_smoke.py`. The next clean move is no longer "one more tiny safety slice"; it is a meaningful Phase 6 reflection/scene-surface or job-state precursor over the existing typed machine. Pre-compaction persistence is now an explicit design rule, but persistence notes must name the next organ instead of trapping the agent in endless incremental hardening.
Phase 1, Phase 2, the minimal Phase 3 typed read surface, Phase 4 retrieval/indexing/core-extraction, and the Phase 5 distill/propose/promote/update/read/notification control plane are landed and verified enough to move on. The first Phase 6 reflection-boundary slice is now present as read-only `thread/epiphany/scene`, a compact client projection over authoritative Epiphany state. `vendor/codex` is first-class in the parent repo now, with the heavier Epiphany organs living in `epiphany-core`. Successful direct updates and accepted promotions now return response-level revision/changed-field metadata and emit experimental `thread/epiphany/stateUpdated` notifications carrying the updated client-visible typed state, source labels, event-level revision, and typed changed fields; accepted promotion responses/notifications include `evidence` whenever verifier evidence is appended, even when patch evidence was empty, and successful write response/notification states include the same retrieval-summary backfill exposed by live `thread/read`. Direct updates reject malformed appended observations/evidence and structurally invalid replacement fields before mutation. Read-only distillation summarizes noisy tool/model output into typed evidence, read-only proposal can auto-select a bounded evidence-backed observation cluster and report match-kind-aware map-delta pressure, and promotion rejects risky deltas without warning plus strong verifier evidence. The current Epiphany algorithmic map has been source-audited against the code flow it describes. The richer Phase 5 chain is live-smoked through app-server by `tools/epiphany_phase5_smoke.py`. The next clean move is to use or extend the Phase 6 scene boundary, not to restart Phase 5 sanding unless a concrete regression appears. Pre-compaction persistence is now an explicit design rule, but persistence notes must name the next organ instead of trapping the agent in endless incremental hardening.

View file

@ -157,3 +157,5 @@
{"ts": "2026-04-25T14:16:03+00:00", "type": "verification", "status": "ok", "note": "Corrected CRRC continuity planning for imminent compaction: persisted an explicit rehydrate/reorient/continue packet in fresh-workspace-handoff.md with current HEAD, required rehydrate reads/commands, active lane, latest landed write/read projection slice, read-only boundaries, forbidden detours, smoke guardrail, source-grounded map rule, and anti-cruft revert rule."}
{"ts": "2026-04-25T14:41:00+00:00", "type": "decision", "status": "ok", "note": "Corrected repo memory to mark Phase 5 complete enough and prevent self-reinforcing tiny-hardening loops. Updated canonical map, handoff, implementation plan, algorithmic map, and AGENTS operating discipline so future CRRC handoffs name the next larger organ instead of prescribing endless smallest safety slices."}
{"ts": "2026-04-25T14:45:45+00:00", "type": "verification", "status": "ok", "note": "Prepared imminent Compact-Rehydrate-Reorient-Continue packet after marking Phase 5 complete enough. Current HEAD before this packet is 0dcdfab on main, branch is ahead of origin/main by one commit, and next task should rehydrate from state/map.yaml plus fresh-workspace-handoff then choose a Phase 6 reflection/scene-surface or job-state precursor rather than resuming indefinite Phase 5 hardening."}
{"ts": "2026-04-25T15:06:57+00:00", "type": "implementation", "status": "ok", "note": "Landed first Phase 6 reflection-boundary slice as read-only thread/epiphany/scene. The method derives a compact client scene from existing thread/read-compatible Epiphany state, including objective, active subgoal, invariant counts, graph focus, retrieval status, observations, evidence, churn, source, and available actions without mutation or persistence."}
{"ts": "2026-04-25T15:07:22+00:00", "type": "verification", "status": "ok", "note": "Verified Phase 6 scene slice with cargo fmt -p codex-app-server-protocol -p codex-app-server, cargo test -p codex-app-server-protocol --lib thread_epiphany_, cargo test -p codex-app-server-protocol --test schema_fixtures after regenerating stable fixtures, cargo test -p codex-app-server --lib map_epiphany_, cargo build -p codex-app-server, and git diff --check."}

View file

@ -49,7 +49,7 @@ active_subgoals:
- Treat the Phase 5 distill/propose/promote/update control plane as complete enough unless a concrete regression appears.
- Keep vendored Codex as a thin typed host seam while Epiphany-owned prompt and retrieval/indexing logic live in the repo-owned `epiphany-core` crate.
- Preserve exact/path lookup and BM25 fallback while the Qdrant path stays explicit and bounded.
- Move toward the next meaningful architecture organ: a Phase 6 reflection/scene surface or job-state precursor that lets clients inspect the typed Epiphany machine without turning the GUI into the source of truth.
- Continue Phase 6 by growing the new read-only scene/reflection surface over authoritative Epiphany state without turning GUI/client state into the source of truth.
accepted_design:
- external typed state files
@ -115,6 +115,7 @@ accepted_design:
- harden direct update integrity: `thread/epiphany/update` now rejects malformed appended observations/evidence and structurally invalid replacement fields before durable persistence, including empty append record fields, duplicate append ids, durable id reuse, observations that cite missing evidence ids, and graph/frontier/checkpoint/subgoal/churn replacement shape errors; invalid direct updates leave revision unchanged and emit no state update notification
- harden write/read surface consistency: successful direct update and accepted promote responses plus `thread/epiphany/stateUpdated` notifications now publish the same client-visible live Epiphany state projection as `thread/read`, including the non-durable retrieval summary backfill when state exists without persisted retrieval metadata
- avoid self-reinforcing handoff notes that keep prescribing tiny safety-hardening slices after a phase has become complete enough; bounded slices are a way to land work safely, not a reason to orbit the same seam forever
- land the first Phase 6 reflection boundary slice as read-only `thread/epiphany/scene`: a derived client-shaped projection over existing Epiphany state that summarizes objective, active subgoal, invariants, graph focus, retrieval status, observations, evidence, churn, and available control-plane actions without persisting new state or making the GUI/client authoritative
rejected_paths:
- name: pinned_map_only
@ -131,5 +132,5 @@ rejected_paths:
reason: audited candidates were either terminal-only, stale/aspirational, or incoherent wrappers; the comparison clones were removed from vendor to avoid building on untrusted drift
current_status:
summary: Workspace initialized with protocol files, typed state, handoff notes, architecture maps, and a rolling implementation plan against vendored Codex. Phase 1 durable state, Phase 2 prompt integration, the minimal Phase 3 typed read surface, Phase 4 retrieval/indexing/core-extraction, and the Phase 5 update/distill/propose/promote/read/notification control plane are landed on `main` and complete enough to move on. The current baseline includes explicit Qdrant indexing with BM25 fallback, typed `thread/epiphany/update`, read-only `thread/epiphany/distill`, read-only `thread/epiphany/propose`, verifier-backed `thread/epiphany/promote`, response-level and notification-level revision/changed-field metadata, client-visible write/read projection consistency with retrieval-summary backfill, direct-update append/replacement validation, source-output-aware distillation, graph-aware proposal selection, risky-delta promotion policy, token-aware verifier-kind matching, and the reusable richer Phase 5 app-server smoke harness. Treat that smoke harness as a regression guardrail, not a prompt to invent another tiny safety slice. The next lane is Phase 6 reflection boundary work: expose the existing typed Epiphany machine through a thin scene/job-state surface without making GUI/client state authoritative.
next_action: Stop treating Phase 5 as an endless hardening lane. Treat the typed update/distill/propose/promote/read/notification control plane as complete enough, run the Phase 5 smoke only as a regression guardrail, and pick a meaningful Phase 6 reflection/scene-surface or job-state precursor that exposes the existing typed machine without making GUI/client state authoritative.
summary: Workspace initialized with protocol files, typed state, handoff notes, architecture maps, and a rolling implementation plan against vendored Codex. Phase 1 durable state, Phase 2 prompt integration, the minimal Phase 3 typed read surface, Phase 4 retrieval/indexing/core-extraction, and the Phase 5 update/distill/propose/promote/read/notification control plane are landed on `main` and complete enough. The first Phase 6 reflection-boundary slice is now implemented as read-only `thread/epiphany/scene`, a derived client-shaped scene over existing authoritative Epiphany state. The baseline includes explicit Qdrant indexing with BM25 fallback, typed `thread/epiphany/update`, read-only `thread/epiphany/distill`, read-only `thread/epiphany/propose`, verifier-backed `thread/epiphany/promote`, response-level and notification-level revision/changed-field metadata, client-visible write/read projection consistency with retrieval-summary backfill, direct-update append/replacement validation, source-output-aware distillation, graph-aware proposal selection, risky-delta promotion policy, token-aware verifier-kind matching, reusable richer Phase 5 smoke, and the new Phase 6 scene projection.
next_action: Treat `thread/epiphany/scene` as the first Phase 6 reflection baseline. Next, either live-smoke the scene method through app-server or extend the reflection boundary toward a minimal job-state/progress surface; do not restart Phase 5 hardening without a concrete regression.

View file

@ -14966,6 +14966,381 @@
],
"type": "object"
},
"ThreadEpiphanyScene": {
"properties": {
"activeSubgoal": {
"anyOf": [
{
"$ref": "#/definitions/v2/ThreadEpiphanySceneSubgoal"
},
{
"type": "null"
}
]
},
"availableActions": {
"items": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneAction"
},
"type": "array"
},
"churn": {
"anyOf": [
{
"$ref": "#/definitions/v2/ThreadEpiphanySceneChurn"
},
{
"type": "null"
}
]
},
"evidence": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneRecords"
},
"graph": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneGraph"
},
"invariantStatusCounts": {
"items": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneStatusCount"
},
"type": "array"
},
"objective": {
"type": [
"string",
"null"
]
},
"observations": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneRecords"
},
"retrieval": {
"anyOf": [
{
"$ref": "#/definitions/v2/ThreadEpiphanySceneRetrieval"
},
{
"type": "null"
}
]
},
"revision": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"source": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneSource"
},
"stateStatus": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneStateStatus"
},
"subgoals": {
"items": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneSubgoal"
},
"type": "array"
}
},
"required": [
"evidence",
"graph",
"observations",
"source",
"stateStatus"
],
"type": "object"
},
"ThreadEpiphanySceneAction": {
"enum": [
"index",
"retrieve",
"distill",
"propose",
"promote",
"update"
],
"type": "string"
},
"ThreadEpiphanySceneChurn": {
"properties": {
"diffPressure": {
"type": "string"
},
"graphFreshness": {
"type": [
"string",
"null"
]
},
"understandingStatus": {
"type": "string"
},
"unexplainedWrites": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"warning": {
"type": [
"string",
"null"
]
}
},
"required": [
"diffPressure",
"understandingStatus"
],
"type": "object"
},
"ThreadEpiphanySceneGraph": {
"properties": {
"activeEdgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"activeNodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"architectureEdgeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"architectureNodeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"checkpointId": {
"type": [
"string",
"null"
]
},
"checkpointSummary": {
"type": [
"string",
"null"
]
},
"dataflowEdgeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"dataflowNodeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"dirtyPaths": {
"items": {
"type": "string"
},
"type": "array"
},
"linkCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"openGapCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"openQuestionCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"architectureEdgeCount",
"architectureNodeCount",
"dataflowEdgeCount",
"dataflowNodeCount",
"linkCount",
"openGapCount",
"openQuestionCount"
],
"type": "object"
},
"ThreadEpiphanySceneRecord": {
"properties": {
"codeRefCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"id": {
"type": "string"
},
"kind": {
"type": "string"
},
"status": {
"type": "string"
},
"summary": {
"type": "string"
}
},
"required": [
"codeRefCount",
"id",
"kind",
"status",
"summary"
],
"type": "object"
},
"ThreadEpiphanySceneRecords": {
"properties": {
"latest": {
"items": {
"$ref": "#/definitions/v2/ThreadEpiphanySceneRecord"
},
"type": "array"
},
"totalCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"totalCount"
],
"type": "object"
},
"ThreadEpiphanySceneRetrieval": {
"properties": {
"dirtyPathCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"indexRevision": {
"type": [
"string",
"null"
]
},
"indexedChunkCount": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"indexedFileCount": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"semanticAvailable": {
"type": "boolean"
},
"shardCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"status": {
"$ref": "#/definitions/v2/EpiphanyRetrievalStatus"
},
"workspaceRoot": {
"type": "string"
}
},
"required": [
"dirtyPathCount",
"semanticAvailable",
"shardCount",
"status",
"workspaceRoot"
],
"type": "object"
},
"ThreadEpiphanySceneSource": {
"enum": [
"stored",
"live"
],
"type": "string"
},
"ThreadEpiphanySceneStateStatus": {
"enum": [
"missing",
"ready"
],
"type": "string"
},
"ThreadEpiphanySceneStatusCount": {
"properties": {
"count": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"status": {
"type": "string"
}
},
"required": [
"count",
"status"
],
"type": "object"
},
"ThreadEpiphanySceneSubgoal": {
"properties": {
"active": {
"type": "boolean"
},
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"summary": {
"type": [
"string",
"null"
]
},
"title": {
"type": "string"
}
},
"required": [
"active",
"id",
"status",
"title"
],
"type": "object"
},
"ThreadEpiphanyStateUpdatedField": {
"enum": [
"objective",

View file

@ -12853,6 +12853,381 @@
],
"type": "object"
},
"ThreadEpiphanyScene": {
"properties": {
"activeSubgoal": {
"anyOf": [
{
"$ref": "#/definitions/ThreadEpiphanySceneSubgoal"
},
{
"type": "null"
}
]
},
"availableActions": {
"items": {
"$ref": "#/definitions/ThreadEpiphanySceneAction"
},
"type": "array"
},
"churn": {
"anyOf": [
{
"$ref": "#/definitions/ThreadEpiphanySceneChurn"
},
{
"type": "null"
}
]
},
"evidence": {
"$ref": "#/definitions/ThreadEpiphanySceneRecords"
},
"graph": {
"$ref": "#/definitions/ThreadEpiphanySceneGraph"
},
"invariantStatusCounts": {
"items": {
"$ref": "#/definitions/ThreadEpiphanySceneStatusCount"
},
"type": "array"
},
"objective": {
"type": [
"string",
"null"
]
},
"observations": {
"$ref": "#/definitions/ThreadEpiphanySceneRecords"
},
"retrieval": {
"anyOf": [
{
"$ref": "#/definitions/ThreadEpiphanySceneRetrieval"
},
{
"type": "null"
}
]
},
"revision": {
"format": "uint64",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"source": {
"$ref": "#/definitions/ThreadEpiphanySceneSource"
},
"stateStatus": {
"$ref": "#/definitions/ThreadEpiphanySceneStateStatus"
},
"subgoals": {
"items": {
"$ref": "#/definitions/ThreadEpiphanySceneSubgoal"
},
"type": "array"
}
},
"required": [
"evidence",
"graph",
"observations",
"source",
"stateStatus"
],
"type": "object"
},
"ThreadEpiphanySceneAction": {
"enum": [
"index",
"retrieve",
"distill",
"propose",
"promote",
"update"
],
"type": "string"
},
"ThreadEpiphanySceneChurn": {
"properties": {
"diffPressure": {
"type": "string"
},
"graphFreshness": {
"type": [
"string",
"null"
]
},
"understandingStatus": {
"type": "string"
},
"unexplainedWrites": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"warning": {
"type": [
"string",
"null"
]
}
},
"required": [
"diffPressure",
"understandingStatus"
],
"type": "object"
},
"ThreadEpiphanySceneGraph": {
"properties": {
"activeEdgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"activeNodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"architectureEdgeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"architectureNodeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"checkpointId": {
"type": [
"string",
"null"
]
},
"checkpointSummary": {
"type": [
"string",
"null"
]
},
"dataflowEdgeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"dataflowNodeCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"dirtyPaths": {
"items": {
"type": "string"
},
"type": "array"
},
"linkCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"openGapCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"openQuestionCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"architectureEdgeCount",
"architectureNodeCount",
"dataflowEdgeCount",
"dataflowNodeCount",
"linkCount",
"openGapCount",
"openQuestionCount"
],
"type": "object"
},
"ThreadEpiphanySceneRecord": {
"properties": {
"codeRefCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"id": {
"type": "string"
},
"kind": {
"type": "string"
},
"status": {
"type": "string"
},
"summary": {
"type": "string"
}
},
"required": [
"codeRefCount",
"id",
"kind",
"status",
"summary"
],
"type": "object"
},
"ThreadEpiphanySceneRecords": {
"properties": {
"latest": {
"items": {
"$ref": "#/definitions/ThreadEpiphanySceneRecord"
},
"type": "array"
},
"totalCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
}
},
"required": [
"totalCount"
],
"type": "object"
},
"ThreadEpiphanySceneRetrieval": {
"properties": {
"dirtyPathCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"indexRevision": {
"type": [
"string",
"null"
]
},
"indexedChunkCount": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"indexedFileCount": {
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"semanticAvailable": {
"type": "boolean"
},
"shardCount": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"status": {
"$ref": "#/definitions/EpiphanyRetrievalStatus"
},
"workspaceRoot": {
"type": "string"
}
},
"required": [
"dirtyPathCount",
"semanticAvailable",
"shardCount",
"status",
"workspaceRoot"
],
"type": "object"
},
"ThreadEpiphanySceneSource": {
"enum": [
"stored",
"live"
],
"type": "string"
},
"ThreadEpiphanySceneStateStatus": {
"enum": [
"missing",
"ready"
],
"type": "string"
},
"ThreadEpiphanySceneStatusCount": {
"properties": {
"count": {
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"status": {
"type": "string"
}
},
"required": [
"count",
"status"
],
"type": "object"
},
"ThreadEpiphanySceneSubgoal": {
"properties": {
"active": {
"type": "boolean"
},
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"summary": {
"type": [
"string",
"null"
]
},
"title": {
"type": "string"
}
},
"required": [
"active",
"id",
"status",
"title"
],
"type": "object"
},
"ThreadEpiphanyStateUpdatedField": {
"enum": [
"objective",

View file

@ -0,0 +1,14 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ThreadEpiphanySceneAction } from "./ThreadEpiphanySceneAction";
import type { ThreadEpiphanySceneChurn } from "./ThreadEpiphanySceneChurn";
import type { ThreadEpiphanySceneGraph } from "./ThreadEpiphanySceneGraph";
import type { ThreadEpiphanySceneRecords } from "./ThreadEpiphanySceneRecords";
import type { ThreadEpiphanySceneRetrieval } from "./ThreadEpiphanySceneRetrieval";
import type { ThreadEpiphanySceneSource } from "./ThreadEpiphanySceneSource";
import type { ThreadEpiphanySceneStateStatus } from "./ThreadEpiphanySceneStateStatus";
import type { ThreadEpiphanySceneStatusCount } from "./ThreadEpiphanySceneStatusCount";
import type { ThreadEpiphanySceneSubgoal } from "./ThreadEpiphanySceneSubgoal";
export type ThreadEpiphanyScene = { stateStatus: ThreadEpiphanySceneStateStatus, source: ThreadEpiphanySceneSource, revision?: bigint | null, objective?: string | null, activeSubgoal?: ThreadEpiphanySceneSubgoal | null, subgoals?: Array<ThreadEpiphanySceneSubgoal>, invariantStatusCounts?: Array<ThreadEpiphanySceneStatusCount>, graph: ThreadEpiphanySceneGraph, retrieval?: ThreadEpiphanySceneRetrieval | null, observations: ThreadEpiphanySceneRecords, evidence: ThreadEpiphanySceneRecords, churn?: ThreadEpiphanySceneChurn | null, availableActions?: Array<ThreadEpiphanySceneAction>, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "propose" | "promote" | "update";

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneChurn = { understandingStatus: string, diffPressure: string, graphFreshness?: string | null, warning?: string | null, unexplainedWrites?: number | null, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneGraph = { architectureNodeCount: number, architectureEdgeCount: number, dataflowNodeCount: number, dataflowEdgeCount: number, linkCount: number, activeNodeIds?: Array<string>, activeEdgeIds?: Array<string>, openQuestionCount: number, openGapCount: number, dirtyPaths?: Array<string>, checkpointId?: string | null, checkpointSummary?: string | null, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneRecord = { id: string, kind: string, status: string, summary: string, codeRefCount: number, };

View file

@ -0,0 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ThreadEpiphanySceneRecord } from "./ThreadEpiphanySceneRecord";
export type ThreadEpiphanySceneRecords = { totalCount: number, latest?: Array<ThreadEpiphanySceneRecord>, };

View file

@ -0,0 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EpiphanyRetrievalStatus } from "../EpiphanyRetrievalStatus";
export type ThreadEpiphanySceneRetrieval = { workspaceRoot: string, status: EpiphanyRetrievalStatus, semanticAvailable: boolean, indexRevision?: string | null, indexedFileCount?: number | null, indexedChunkCount?: number | null, shardCount: number, dirtyPathCount: number, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneSource = "stored" | "live";

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneStateStatus = "missing" | "ready";

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneStatusCount = { status: string, count: number, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneSubgoal = { id: string, title: string, status: string, summary?: string | null, active: boolean, };

View file

@ -321,6 +321,17 @@ export type { ThreadEpiphanyRetrieveIndexSummary } from "./ThreadEpiphanyRetriev
export type { ThreadEpiphanyRetrieveResult } from "./ThreadEpiphanyRetrieveResult";
export type { ThreadEpiphanyRetrieveResultKind } from "./ThreadEpiphanyRetrieveResultKind";
export type { ThreadEpiphanyRetrieveShardSummary } from "./ThreadEpiphanyRetrieveShardSummary";
export type { ThreadEpiphanyScene } from "./ThreadEpiphanyScene";
export type { ThreadEpiphanySceneAction } from "./ThreadEpiphanySceneAction";
export type { ThreadEpiphanySceneChurn } from "./ThreadEpiphanySceneChurn";
export type { ThreadEpiphanySceneGraph } from "./ThreadEpiphanySceneGraph";
export type { ThreadEpiphanySceneRecord } from "./ThreadEpiphanySceneRecord";
export type { ThreadEpiphanySceneRecords } from "./ThreadEpiphanySceneRecords";
export type { ThreadEpiphanySceneRetrieval } from "./ThreadEpiphanySceneRetrieval";
export type { ThreadEpiphanySceneSource } from "./ThreadEpiphanySceneSource";
export type { ThreadEpiphanySceneStateStatus } from "./ThreadEpiphanySceneStateStatus";
export type { ThreadEpiphanySceneStatusCount } from "./ThreadEpiphanySceneStatusCount";
export type { ThreadEpiphanySceneSubgoal } from "./ThreadEpiphanySceneSubgoal";
export type { ThreadEpiphanyStateUpdatedField } from "./ThreadEpiphanyStateUpdatedField";
export type { ThreadEpiphanyStateUpdatedNotification } from "./ThreadEpiphanyStateUpdatedNotification";
export type { ThreadEpiphanyStateUpdatedSource } from "./ThreadEpiphanyStateUpdatedSource";

View file

@ -336,6 +336,11 @@ client_request_definitions! {
params: v2::ThreadReadParams,
response: v2::ThreadReadResponse,
},
#[experimental("thread/epiphany/scene")]
ThreadEpiphanyScene => "thread/epiphany/scene" {
params: v2::ThreadEpiphanySceneParams,
response: v2::ThreadEpiphanySceneResponse,
},
#[experimental("thread/epiphany/index")]
ThreadEpiphanyIndex => "thread/epiphany/index" {
params: v2::ThreadEpiphanyIndexParams,
@ -1579,6 +1584,167 @@ mod tests {
Ok(())
}
#[test]
fn serialize_thread_epiphany_scene_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyScene {
request_id: RequestId::Integer(8),
response: v2::ThreadEpiphanySceneResponse {
thread_id: "thr_123".to_string(),
scene: v2::ThreadEpiphanyScene {
state_status: v2::ThreadEpiphanySceneStateStatus::Ready,
source: v2::ThreadEpiphanySceneSource::Live,
revision: Some(3),
objective: Some("Keep the map visible".to_string()),
active_subgoal: Some(v2::ThreadEpiphanySceneSubgoal {
id: "phase-6".to_string(),
title: "Reflect typed state".to_string(),
status: "active".to_string(),
summary: None,
active: true,
}),
subgoals: Vec::new(),
invariant_status_counts: vec![v2::ThreadEpiphanySceneStatusCount {
status: "ok".to_string(),
count: 2,
}],
graph: v2::ThreadEpiphanySceneGraph {
architecture_node_count: 4,
architecture_edge_count: 3,
dataflow_node_count: 2,
dataflow_edge_count: 1,
link_count: 2,
active_node_ids: vec!["state-spine".to_string()],
active_edge_ids: Vec::new(),
open_question_count: 1,
open_gap_count: 0,
dirty_paths: vec![PathBuf::from("notes/scene.md")],
checkpoint_id: Some("ck-1".to_string()),
checkpoint_summary: None,
},
retrieval: Some(v2::ThreadEpiphanySceneRetrieval {
workspace_root: PathBuf::from("/workspace"),
status: codex_protocol::protocol::EpiphanyRetrievalStatus::Ready,
semantic_available: true,
index_revision: Some("qdrant-v1".to_string()),
indexed_file_count: Some(12),
indexed_chunk_count: Some(34),
shard_count: 1,
dirty_path_count: 0,
}),
observations: v2::ThreadEpiphanySceneRecords {
total_count: 1,
latest: vec![v2::ThreadEpiphanySceneRecord {
id: "obs-1".to_string(),
kind: "smoke".to_string(),
status: "ok".to_string(),
summary: "Scene projected".to_string(),
code_ref_count: 1,
}],
},
evidence: v2::ThreadEpiphanySceneRecords::default(),
churn: Some(v2::ThreadEpiphanySceneChurn {
understanding_status: "ready".to_string(),
diff_pressure: "low".to_string(),
graph_freshness: Some("fresh".to_string()),
warning: None,
unexplained_writes: Some(0),
}),
available_actions: vec![
v2::ThreadEpiphanySceneAction::Index,
v2::ThreadEpiphanySceneAction::Retrieve,
v2::ThreadEpiphanySceneAction::Distill,
v2::ThreadEpiphanySceneAction::Update,
v2::ThreadEpiphanySceneAction::Propose,
v2::ThreadEpiphanySceneAction::Promote,
],
},
},
};
assert_eq!(response.id(), &RequestId::Integer(8));
assert_eq!(response.method(), "thread/epiphany/scene");
assert_eq!(
json!({
"method": "thread/epiphany/scene",
"id": 8,
"response": {
"threadId": "thr_123",
"scene": {
"stateStatus": "ready",
"source": "live",
"revision": 3,
"objective": "Keep the map visible",
"activeSubgoal": {
"id": "phase-6",
"title": "Reflect typed state",
"status": "active",
"active": true
},
"invariantStatusCounts": [
{
"status": "ok",
"count": 2
}
],
"graph": {
"architectureNodeCount": 4,
"architectureEdgeCount": 3,
"dataflowNodeCount": 2,
"dataflowEdgeCount": 1,
"linkCount": 2,
"activeNodeIds": ["state-spine"],
"openQuestionCount": 1,
"openGapCount": 0,
"dirtyPaths": ["notes/scene.md"],
"checkpointId": "ck-1"
},
"retrieval": {
"workspaceRoot": "/workspace",
"status": "ready",
"semanticAvailable": true,
"indexRevision": "qdrant-v1",
"indexedFileCount": 12,
"indexedChunkCount": 34,
"shardCount": 1,
"dirtyPathCount": 0
},
"observations": {
"totalCount": 1,
"latest": [
{
"id": "obs-1",
"kind": "smoke",
"status": "ok",
"summary": "Scene projected",
"codeRefCount": 1
}
]
},
"evidence": {
"totalCount": 0
},
"churn": {
"understandingStatus": "ready",
"diffPressure": "low",
"graphFreshness": "fresh",
"unexplainedWrites": 0
},
"availableActions": [
"index",
"retrieve",
"distill",
"update",
"propose",
"promote"
]
}
}
}),
serde_json::to_value(&response)?,
);
Ok(())
}
#[test]
fn serialize_thread_epiphany_retrieve_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyRetrieve {
@ -2437,6 +2603,18 @@ mod tests {
assert_eq!(reason, Some("thread/epiphany/retrieve"));
}
#[test]
fn thread_epiphany_scene_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyScene {
request_id: RequestId::Integer(1),
params: v2::ThreadEpiphanySceneParams {
thread_id: "thr_123".to_string(),
},
};
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
assert_eq!(reason, Some("thread/epiphany/scene"));
}
#[test]
fn thread_epiphany_index_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyIndex {

View file

@ -3915,6 +3915,184 @@ pub struct ThreadReadResponse {
pub thread: Thread,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneParams {
pub thread_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneResponse {
pub thread_id: String,
pub scene: ThreadEpiphanyScene,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyScene {
pub state_status: ThreadEpiphanySceneStateStatus,
pub source: ThreadEpiphanySceneSource,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub revision: Option<u64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub objective: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub active_subgoal: Option<ThreadEpiphanySceneSubgoal>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub subgoals: Vec<ThreadEpiphanySceneSubgoal>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub invariant_status_counts: Vec<ThreadEpiphanySceneStatusCount>,
pub graph: ThreadEpiphanySceneGraph,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub retrieval: Option<ThreadEpiphanySceneRetrieval>,
pub observations: ThreadEpiphanySceneRecords,
pub evidence: ThreadEpiphanySceneRecords,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub churn: Option<ThreadEpiphanySceneChurn>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub available_actions: Vec<ThreadEpiphanySceneAction>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneStateStatus {
Missing,
Ready,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneSource {
Stored,
Live,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneAction {
Index,
Retrieve,
Distill,
Propose,
Promote,
Update,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneSubgoal {
pub id: String,
pub title: String,
pub status: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub summary: Option<String>,
pub active: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneStatusCount {
pub status: String,
pub count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneGraph {
pub architecture_node_count: u32,
pub architecture_edge_count: u32,
pub dataflow_node_count: u32,
pub dataflow_edge_count: u32,
pub link_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_edge_ids: Vec<String>,
pub open_question_count: u32,
pub open_gap_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub dirty_paths: Vec<PathBuf>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub checkpoint_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub checkpoint_summary: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRetrieval {
pub workspace_root: PathBuf,
pub status: CoreEpiphanyRetrievalStatus,
pub semantic_available: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub index_revision: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub indexed_file_count: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub indexed_chunk_count: Option<u32>,
pub shard_count: u32,
pub dirty_path_count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRecords {
pub total_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub latest: Vec<ThreadEpiphanySceneRecord>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRecord {
pub id: String,
pub kind: String,
pub status: String,
pub summary: String,
pub code_ref_count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneChurn {
pub understanding_status: String,
pub diff_pressure: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub graph_freshness: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub warning: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub unexplained_writes: Option<u32>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]

View file

@ -160,6 +160,19 @@ use codex_app_server_protocol::ThreadEpiphanyRetrieveResponse;
use codex_app_server_protocol::ThreadEpiphanyRetrieveResult;
use codex_app_server_protocol::ThreadEpiphanyRetrieveResultKind;
use codex_app_server_protocol::ThreadEpiphanyRetrieveShardSummary;
use codex_app_server_protocol::ThreadEpiphanyScene;
use codex_app_server_protocol::ThreadEpiphanySceneAction;
use codex_app_server_protocol::ThreadEpiphanySceneChurn;
use codex_app_server_protocol::ThreadEpiphanySceneGraph;
use codex_app_server_protocol::ThreadEpiphanySceneParams;
use codex_app_server_protocol::ThreadEpiphanySceneRecord;
use codex_app_server_protocol::ThreadEpiphanySceneRecords;
use codex_app_server_protocol::ThreadEpiphanySceneResponse;
use codex_app_server_protocol::ThreadEpiphanySceneRetrieval;
use codex_app_server_protocol::ThreadEpiphanySceneSource;
use codex_app_server_protocol::ThreadEpiphanySceneStateStatus;
use codex_app_server_protocol::ThreadEpiphanySceneStatusCount;
use codex_app_server_protocol::ThreadEpiphanySceneSubgoal;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource;
@ -390,6 +403,7 @@ use codex_thread_store::ThreadStoreError;
use codex_thread_store::UpdateThreadMetadataParams as StoreUpdateThreadMetadataParams;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_pty::DEFAULT_OUTPUT_BYTES_CAP;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Error as IoError;
@ -984,6 +998,10 @@ impl CodexMessageProcessor {
self.thread_read(to_connection_request_id(request_id), params)
.await;
}
ClientRequest::ThreadEpiphanyScene { request_id, params } => {
self.thread_epiphany_scene(to_connection_request_id(request_id), params)
.await;
}
ClientRequest::ThreadEpiphanyIndex { request_id, params } => {
self.thread_epiphany_index(to_connection_request_id(request_id), params)
.await;
@ -4046,6 +4064,41 @@ impl CodexMessageProcessor {
self.outgoing.send_response(request_id, response).await;
}
async fn thread_epiphany_scene(
&self,
request_id: ConnectionRequestId,
params: ThreadEpiphanySceneParams,
) {
let ThreadEpiphanySceneParams { thread_id } = params;
let thread_uuid = match ThreadId::from_string(&thread_id) {
Ok(id) => id,
Err(err) => {
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
.await;
return;
}
};
let loaded = self.thread_manager.get_thread(thread_uuid).await.is_ok();
let thread = match self.read_thread_view(thread_uuid, false).await {
Ok(thread) => thread,
Err(ThreadReadViewError::InvalidRequest(message)) => {
self.send_invalid_request_error(request_id, message).await;
return;
}
Err(ThreadReadViewError::Internal(message)) => {
self.send_internal_error(request_id, message).await;
return;
}
};
let response = ThreadEpiphanySceneResponse {
thread_id,
scene: map_epiphany_scene(thread.epiphany_state.as_ref(), loaded),
};
self.outgoing.send_response(request_id, response).await;
}
async fn thread_epiphany_retrieve(
&self,
request_id: ConnectionRequestId,
@ -10444,6 +10497,181 @@ async fn client_visible_live_thread_epiphany_state(
live_thread_epiphany_state(thread).await.unwrap_or(fallback)
}
fn map_epiphany_scene(state: Option<&EpiphanyThreadState>, loaded: bool) -> ThreadEpiphanyScene {
let source = if loaded {
ThreadEpiphanySceneSource::Live
} else {
ThreadEpiphanySceneSource::Stored
};
let available_actions = epiphany_scene_available_actions(loaded, state.is_some());
let Some(state) = state else {
return ThreadEpiphanyScene {
state_status: ThreadEpiphanySceneStateStatus::Missing,
source,
revision: None,
objective: None,
active_subgoal: None,
subgoals: Vec::new(),
invariant_status_counts: Vec::new(),
graph: ThreadEpiphanySceneGraph::default(),
retrieval: None,
observations: ThreadEpiphanySceneRecords::default(),
evidence: ThreadEpiphanySceneRecords::default(),
churn: None,
available_actions,
};
};
let subgoals = map_epiphany_scene_subgoals(state);
let active_subgoal = subgoals.iter().find(|subgoal| subgoal.active).cloned();
ThreadEpiphanyScene {
state_status: ThreadEpiphanySceneStateStatus::Ready,
source,
revision: Some(state.revision),
objective: state.objective.clone(),
active_subgoal,
subgoals,
invariant_status_counts: status_counts(
state.invariants.iter().map(|item| item.status.as_str()),
),
graph: map_epiphany_scene_graph(state),
retrieval: state
.retrieval
.as_ref()
.map(|retrieval| ThreadEpiphanySceneRetrieval {
workspace_root: retrieval.workspace_root.clone(),
status: retrieval.status,
semantic_available: retrieval.semantic_available,
index_revision: retrieval.index_revision.clone(),
indexed_file_count: retrieval.indexed_file_count,
indexed_chunk_count: retrieval.indexed_chunk_count,
shard_count: retrieval.shards.len() as u32,
dirty_path_count: retrieval.dirty_paths.len() as u32,
}),
observations: ThreadEpiphanySceneRecords {
total_count: state.observations.len() as u32,
latest: state
.observations
.iter()
.rev()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|observation| ThreadEpiphanySceneRecord {
id: observation.id.clone(),
kind: observation.source_kind.clone(),
status: observation.status.clone(),
summary: observation.summary.clone(),
code_ref_count: observation.code_refs.len() as u32,
})
.collect(),
},
evidence: ThreadEpiphanySceneRecords {
total_count: state.recent_evidence.len() as u32,
latest: state
.recent_evidence
.iter()
.rev()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|evidence| ThreadEpiphanySceneRecord {
id: evidence.id.clone(),
kind: evidence.kind.clone(),
status: evidence.status.clone(),
summary: evidence.summary.clone(),
code_ref_count: evidence.code_refs.len() as u32,
})
.collect(),
},
churn: state.churn.as_ref().map(|churn| ThreadEpiphanySceneChurn {
understanding_status: churn.understanding_status.clone(),
diff_pressure: churn.diff_pressure.clone(),
graph_freshness: churn.graph_freshness.clone(),
warning: churn.warning.clone(),
unexplained_writes: churn.unexplained_writes,
}),
available_actions,
}
}
const EPIPHANY_SCENE_RECORD_LIMIT: usize = 5;
fn epiphany_scene_available_actions(
loaded: bool,
state_present: bool,
) -> Vec<ThreadEpiphanySceneAction> {
if !loaded {
return Vec::new();
}
let mut actions = vec![
ThreadEpiphanySceneAction::Index,
ThreadEpiphanySceneAction::Retrieve,
ThreadEpiphanySceneAction::Distill,
ThreadEpiphanySceneAction::Update,
];
if state_present {
actions.push(ThreadEpiphanySceneAction::Propose);
actions.push(ThreadEpiphanySceneAction::Promote);
}
actions
}
fn map_epiphany_scene_subgoals(state: &EpiphanyThreadState) -> Vec<ThreadEpiphanySceneSubgoal> {
let active_id = state.active_subgoal_id.as_deref();
state
.subgoals
.iter()
.map(|subgoal| ThreadEpiphanySceneSubgoal {
id: subgoal.id.clone(),
title: subgoal.title.clone(),
status: subgoal.status.clone(),
summary: subgoal.summary.clone(),
active: active_id == Some(subgoal.id.as_str()),
})
.collect()
}
fn map_epiphany_scene_graph(state: &EpiphanyThreadState) -> ThreadEpiphanySceneGraph {
let frontier = state.graph_frontier.as_ref();
let checkpoint = state.graph_checkpoint.as_ref();
ThreadEpiphanySceneGraph {
architecture_node_count: state.graphs.architecture.nodes.len() as u32,
architecture_edge_count: state.graphs.architecture.edges.len() as u32,
dataflow_node_count: state.graphs.dataflow.nodes.len() as u32,
dataflow_edge_count: state.graphs.dataflow.edges.len() as u32,
link_count: state.graphs.links.len() as u32,
active_node_ids: frontier
.map(|frontier| frontier.active_node_ids.clone())
.unwrap_or_default(),
active_edge_ids: frontier
.map(|frontier| frontier.active_edge_ids.clone())
.unwrap_or_default(),
open_question_count: frontier
.map(|frontier| frontier.open_question_ids.len() as u32)
.unwrap_or_default(),
open_gap_count: frontier
.map(|frontier| frontier.open_gap_ids.len() as u32)
.unwrap_or_default(),
dirty_paths: frontier
.map(|frontier| frontier.dirty_paths.clone())
.unwrap_or_default(),
checkpoint_id: checkpoint.map(|checkpoint| checkpoint.checkpoint_id.clone()),
checkpoint_summary: checkpoint.and_then(|checkpoint| checkpoint.summary.clone()),
}
}
fn status_counts<'a>(
statuses: impl Iterator<Item = &'a str>,
) -> Vec<ThreadEpiphanySceneStatusCount> {
let mut counts = BTreeMap::<String, u32>::new();
for status in statuses {
*counts.entry(status.to_string()).or_default() += 1;
}
counts
.into_iter()
.map(|(status, count)| ThreadEpiphanySceneStatusCount { status, count })
.collect()
}
fn thread_epiphany_patch_has_state_replacements(patch: &ThreadEpiphanyUpdatePatch) -> bool {
patch.objective.is_some()
|| patch.active_subgoal_id.is_some()
@ -11831,6 +12059,175 @@ mod tests {
Ok(())
}
#[test]
fn map_epiphany_scene_projects_client_reflection_without_mutation_shape() {
let scene = map_epiphany_scene(
Some(&codex_protocol::protocol::EpiphanyThreadState {
revision: 5,
objective: Some("Expose typed state without making a second brain".to_string()),
active_subgoal_id: Some("phase-6".to_string()),
subgoals: vec![
codex_protocol::protocol::EpiphanySubgoal {
id: "phase-5".to_string(),
title: "Finish control plane".to_string(),
status: "done".to_string(),
summary: None,
},
codex_protocol::protocol::EpiphanySubgoal {
id: "phase-6".to_string(),
title: "Reflect typed state".to_string(),
status: "active".to_string(),
summary: Some("Thin client scene".to_string()),
},
],
invariants: vec![
codex_protocol::protocol::EpiphanyInvariant {
id: "inv-1".to_string(),
description: "No GUI source of truth".to_string(),
status: "ok".to_string(),
rationale: None,
},
codex_protocol::protocol::EpiphanyInvariant {
id: "inv-2".to_string(),
description: "No hidden mutation".to_string(),
status: "ok".to_string(),
rationale: None,
},
],
graphs: codex_protocol::protocol::EpiphanyGraphs {
architecture: codex_protocol::protocol::EpiphanyGraph {
nodes: vec![codex_protocol::protocol::EpiphanyGraphNode {
id: "scene".to_string(),
title: "Scene projection".to_string(),
purpose: "Reflect the typed state".to_string(),
..Default::default()
}],
edges: Vec::new(),
},
dataflow: codex_protocol::protocol::EpiphanyGraph {
nodes: vec![codex_protocol::protocol::EpiphanyGraphNode {
id: "state".to_string(),
title: "State".to_string(),
purpose: "Authoritative input".to_string(),
..Default::default()
}],
edges: Vec::new(),
},
links: vec![codex_protocol::protocol::EpiphanyGraphLink {
dataflow_node_id: "state".to_string(),
architecture_node_id: "scene".to_string(),
relationship: Some("derived".to_string()),
code_refs: Vec::new(),
}],
},
graph_frontier: Some(codex_protocol::protocol::EpiphanyGraphFrontier {
active_node_ids: vec!["scene".to_string()],
active_edge_ids: Vec::new(),
open_question_ids: vec!["q-1".to_string()],
open_gap_ids: Vec::new(),
dirty_paths: vec![PathBuf::from("app-server/src/codex_message_processor.rs")],
}),
graph_checkpoint: Some(codex_protocol::protocol::EpiphanyGraphCheckpoint {
checkpoint_id: "ck-5".to_string(),
graph_revision: 5,
summary: Some("Phase 6 start".to_string()),
frontier_node_ids: Vec::new(),
open_question_ids: Vec::new(),
open_gap_ids: Vec::new(),
}),
retrieval: Some(codex_protocol::protocol::EpiphanyRetrievalState {
workspace_root: test_path_buf("/repo"),
status: codex_protocol::protocol::EpiphanyRetrievalStatus::Ready,
semantic_available: true,
indexed_file_count: Some(2),
indexed_chunk_count: Some(8),
shards: vec![codex_protocol::protocol::EpiphanyRetrievalShardSummary {
shard_id: "workspace".to_string(),
path_prefix: PathBuf::from("."),
status: codex_protocol::protocol::EpiphanyRetrievalStatus::Ready,
exact_available: true,
semantic_available: true,
..Default::default()
}],
..Default::default()
}),
observations: vec![codex_protocol::protocol::EpiphanyObservation {
id: "obs-scene".to_string(),
summary: "Scene is derived".to_string(),
source_kind: "test".to_string(),
status: "ok".to_string(),
code_refs: Vec::new(),
evidence_ids: vec!["ev-scene".to_string()],
}],
recent_evidence: vec![codex_protocol::protocol::EpiphanyEvidenceRecord {
id: "ev-scene".to_string(),
kind: "test".to_string(),
status: "ok".to_string(),
summary: "Projection test".to_string(),
code_refs: Vec::new(),
}],
churn: Some(codex_protocol::protocol::EpiphanyChurnState {
understanding_status: "ready".to_string(),
diff_pressure: "low".to_string(),
graph_freshness: Some("fresh".to_string()),
warning: None,
unexplained_writes: Some(0),
}),
..Default::default()
}),
true,
);
assert_eq!(scene.state_status, ThreadEpiphanySceneStateStatus::Ready);
assert_eq!(scene.source, ThreadEpiphanySceneSource::Live);
assert_eq!(scene.revision, Some(5));
assert_eq!(
scene
.active_subgoal
.as_ref()
.map(|subgoal| subgoal.id.as_str()),
Some("phase-6")
);
assert_eq!(
scene.invariant_status_counts,
vec![ThreadEpiphanySceneStatusCount {
status: "ok".to_string(),
count: 2,
}]
);
assert_eq!(scene.graph.architecture_node_count, 1);
assert_eq!(scene.graph.dataflow_node_count, 1);
assert_eq!(scene.graph.link_count, 1);
assert_eq!(scene.graph.checkpoint_id.as_deref(), Some("ck-5"));
assert_eq!(
scene.retrieval.as_ref().and_then(|r| r.indexed_chunk_count),
Some(8)
);
assert_eq!(scene.observations.total_count, 1);
assert_eq!(scene.evidence.latest[0].id, "ev-scene");
assert_eq!(
scene.available_actions,
vec![
ThreadEpiphanySceneAction::Index,
ThreadEpiphanySceneAction::Retrieve,
ThreadEpiphanySceneAction::Distill,
ThreadEpiphanySceneAction::Update,
ThreadEpiphanySceneAction::Propose,
ThreadEpiphanySceneAction::Promote,
]
);
}
#[test]
fn map_epiphany_scene_handles_missing_state_without_write_actions() {
let scene = map_epiphany_scene(None, false);
assert_eq!(scene.state_status, ThreadEpiphanySceneStateStatus::Missing);
assert_eq!(scene.source, ThreadEpiphanySceneSource::Stored);
assert!(scene.available_actions.is_empty());
assert_eq!(scene.graph, ThreadEpiphanySceneGraph::default());
}
#[test]
fn epiphany_update_patch_changed_fields_reports_patch_surface() {
let fields = epiphany_update_patch_changed_fields(&ThreadEpiphanyUpdatePatch {