Extract Epiphany graph context into core

This commit is contained in:
Meta Vens 2026-05-12 21:58:52 +01:00
commit 954103ec4d
9 changed files with 959 additions and 520 deletions

View file

@ -1177,6 +1177,7 @@ Code refs:
- [app-server-protocol/common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:350)
- [app-server-protocol/v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4182)
- [epiphany-core/src/surfaces/graph_context.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/graph_context.rs:104)
- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4186)
- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10791)
@ -1187,10 +1188,12 @@ The app-server handler:
1. parses the thread id.
2. checks whether the thread is loaded so the response can report live/stored source.
3. calls `read_thread_view(..., include_turns: false)` to reuse the live/stored Epiphany projection path.
4. passes the optional `thread.epiphany_state` and selectors into `map_epiphany_context`.
5. returns the derived context shard and missing-id lists.
4. maps protocol selectors into `epiphany-core::EpiphanyContextParams`.
5. calls `epiphany-core::derive_context`.
6. maps the core context view back into the protocol response.
7. returns the derived context shard and missing-id lists.
`map_epiphany_context`:
`epiphany-core::derive_context`:
1. returns missing state with an empty context and echoes requested ids when no Epiphany state exists.
2. defaults `includeActiveFrontier` to true, so a client can ask for the current working slice with only a thread id.
@ -1261,10 +1264,12 @@ The app-server handler:
1. parses the thread id.
2. requires a loaded thread.
3. calls `read_thread_view(..., include_turns: false)` to reuse the live Epiphany projection path.
4. passes the optional `thread.epiphany_state` and query into `map_epiphany_graph_query`.
5. returns the selected graph records, current frontier/checkpoint, matched selectors, and missing explicit ids.
4. maps the protocol query into `epiphany-core::EpiphanyGraphQuery`.
5. calls `epiphany-core::derive_graph_query`.
6. maps the core graph query view back into the protocol response.
7. returns the selected graph records, current frontier/checkpoint, matched selectors, and missing explicit ids.
`map_epiphany_graph_query`:
`epiphany-core::derive_graph_query`:
1. returns missing state with an empty graph and echoes requested node/edge ids when no Epiphany state exists.
2. starts from explicit node/edge ids.

View file

@ -337,15 +337,16 @@ Commit shape:
Purpose: stop fresh surface sprawl while the foundation is being rebuilt.
### 2. Introduce Core View Types
### 2. Introduce Core Surface Modules
Add `epiphany-core/src/surfaces/` with domain-level view input/output structs:
Add `epiphany-core/src/surfaces/` with domain-level surface contracts for the
live lenses and read models:
- `EpiphanyViewInput`
- `EpiphanyViewLens`
- `EpiphanyViewOutput`
- shared source snapshots for durable state, runtime state, retrieval summary,
watcher snapshot, and token pressure
- pressure, freshness, jobs, planning, scene, role board, reorient, CRRC, and
coordinator view derivation
- targeted graph/evidence context and bounded graph query derivation
- role and reorient result acceptance bundle policy
- typed inputs that carry only the source snapshots each surface actually needs
Do not move behavior yet.

View file

@ -32,7 +32,7 @@ remembers doctrine; the branch remembers the blade.
## Current Orientation
- Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`.
- Top priority is still foundation cleanup, not outward feature work. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code. The May 2026 suspicion pass found that the app-server Epiphany control plane had become architectural Jenga: too much policy, projection, lifecycle glue, prompt packet assembly, coordinator sequencing, and test authority lives in `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`. The rebuild has begun: scene projection, freshness derivation, pressure policy, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy moved into `epiphany-core`, typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links.
- Top priority is still foundation cleanup until the documented rebuild audit is closed. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code. The May 2026 suspicion pass found that the app-server Epiphany control plane had become architectural Jenga: too much policy, projection, lifecycle glue, prompt packet assembly, coordinator sequencing, and test authority lives in `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`. The rebuild has moved scene projection, freshness derivation, pressure policy, targeted context shards, bounded graph traversal, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`; typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links.
- Read `notes/epiphany-ideal-architecture-rebuild-plan.md` immediately after the teardown. It defines the smallest coherent replacement architecture: durable `EpiphanyState`, runtime-spine-owned `RuntimeState`, separate role memory/heartbeat state, `epiphany-core` as policy owner, app-server as adapter, Aquarium as reflector, typed acceptance receipts, and derived view lenses instead of a protocol verb zoo.
- Do not continue Aquarium UI, bridge, Face, or dogfood expansion until the teardown has a source-grounded cleanup slice plan. Epiphany is the foundation; patches on patches are not a purification rite, they are how the altar becomes load-bearing garbage.
- Phase 1 through Phase 5 are complete enough.
@ -362,22 +362,23 @@ that change what the next agent should believe.
Do not continue implementation automatically from a rehydrate-only request.
The next real move is still foundation cleanup. Start from
The next real move is still the final foundation cleanup audit. Start from
`notes/epiphany-architectural-teardown.md` and
`notes/epiphany-ideal-architecture-rebuild-plan.md`, not from the older outward
Phase 6 bridge/UI trail. Landed rebuild cuts: `epiphany-core/src/surfaces/`
exists, pressure view derivation/tests, pure CRRC recommendation policy/tests,
fixed-lane coordinator decision policy/tests, role-board projection policy/tests,
role-result interpretation/self-persistence review policy/tests, and role/reorient
acceptance bundle policy/tests, scene projection/tests, freshness derivation/tests, planning view derivation/tests, reorientation resume/regather verdict policy/tests, and job/progress view derivation/tests live in core, live acceptance writes typed receipts keyed by runtime result id,
acceptance bundle policy/tests, scene projection/tests, freshness derivation/tests, targeted context and graph traversal derivation/tests, planning view derivation/tests, reorientation resume/regather verdict policy/tests, and job/progress view derivation/tests live in core, live acceptance writes typed receipts keyed by runtime result id,
summary-string acceptance identity is gone for live paths, launches dual-write
runtime links, result read-back prefers those runtime links, normal public
`raw_result` is sealed, MVP consumers use `thread/epiphany/view`, heartbeat
cognition is quarantined, and the old scene/jobs/roles/planning/pressure/reorient/
CRRC/coordinator read wrappers are deleted, and durable `jobBindings` no longer
carry launcher/backend/progress lifecycle fields. The next pass is to audit the
plan's remaining success criteria and cut whatever still makes app-server more
than routing/adaptation. No Agile confetti. No new balcony on the swaying tower.
plan's remaining success criteria and, if no remaining policy cluster is found,
mark the rebuild migration complete enough to defend. No Agile confetti. No new
balcony on the swaying tower.
The Phase 6 freshness slice is landed. It exposes read-only
`thread/epiphany/freshness` from live retrieval summaries plus graph