From 78965396de5b693a9b5114b7dee28b9a61d8297c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 26 Apr 2026 02:24:56 +0100 Subject: [PATCH] Add Phase 6 jobs reflection --- notes/epiphany-core-harness-surfaces.md | 21 +- notes/epiphany-current-algorithmic-map.md | 101 ++++- notes/epiphany-fork-implementation-plan.md | 20 +- notes/fresh-workspace-handoff.md | 20 +- state/evidence.jsonl | 1 + state/map.yaml | 20 +- state/scratch.md | 17 +- tools/epiphany_phase6_jobs_smoke.py | 247 +++++++++++ tools/epiphany_phase6_scene_smoke.py | 8 +- .../codex_app_server_protocol.schemas.json | 101 +++++ .../codex_app_server_protocol.v2.schemas.json | 101 +++++ .../schema/typescript/v2/ThreadEpiphanyJob.ts | 7 + .../typescript/v2/ThreadEpiphanyJobKind.ts | 5 + .../typescript/v2/ThreadEpiphanyJobStatus.ts | 5 + .../typescript/v2/ThreadEpiphanyJobsSource.ts | 5 + .../v2/ThreadEpiphanySceneAction.ts | 2 +- .../schema/typescript/v2/index.ts | 4 + .../src/protocol/common.rs | 75 ++++ .../app-server-protocol/src/protocol/v2.rs | 79 ++++ .../app-server/src/codex_message_processor.rs | 404 ++++++++++++++++++ 20 files changed, 1196 insertions(+), 47 deletions(-) create mode 100644 tools/epiphany_phase6_jobs_smoke.py create mode 100644 vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJob.ts create mode 100644 vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobKind.ts create mode 100644 vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobStatus.ts create mode 100644 vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobsSource.ts diff --git a/notes/epiphany-core-harness-surfaces.md b/notes/epiphany-core-harness-surfaces.md index e6907741..1918ea1d 100644 --- a/notes/epiphany-core-harness-surfaces.md +++ b/notes/epiphany-core-harness-surfaces.md @@ -47,6 +47,7 @@ The rule is: | `thread/epiphany/promote` | verifier gate | landed | Rejects or applies candidates through the durable update path. | | `thread/epiphany/stateUpdated` | notification | landed | Emits updated projected state, source, revision, and changed fields after successful update/promote writes. | | `thread/epiphany/scene` | read-only reflection | landed, live-smoked | Compact client scene derived from authoritative Epiphany state. | +| `thread/epiphany/jobs` | read-only reflection | landed, live-smoked | Derived indexing, remap, verification, and specialist-progress slots from typed state and retrieval summaries. | ## Write Authority @@ -64,14 +65,15 @@ The following must stay read-only: - `thread/epiphany/distill` - `thread/epiphany/propose` - `thread/epiphany/scene` +- `thread/epiphany/jobs` `thread/epiphany/index` is a write to the retrieval catalog. It is not a license to mutate map/evidence/churn state as a side effect. ## Reflection Authority -Scene and GUI surfaces may compress state for humans and clients. They may not -invent canonical understanding. +Scene, jobs, and GUI surfaces may compress state for humans and clients. They +may not invent canonical understanding. Reflection surfaces should: @@ -118,7 +120,7 @@ Metaphor is compression after source context. It is not decoration for guesses. These are not landed yet: -- typed job/progress state for indexing, remap, verification, and specialist work +- live typed job/progress state for running indexing, remap, verification, and specialist work - `thread/epiphany/jobsUpdated` or equivalent progress notifications - evidence-range and graph-shard targeted reads - watcher-driven graph/retrieval/invariant invalidation @@ -133,9 +135,14 @@ and a verification story. ## Job And Progress Surface Direction -The next likely missing organ is observable long-running work. +The first read-only job/progress reflection is landed as `thread/epiphany/jobs`. +It reports derived slots for retrieval indexing, graph remap, invariant +verification, and future specialist work. It does not start, schedule, persist, +or notify jobs. -Future job state should describe work like: +The next missing organ is live observable long-running work. + +Future live job state should describe work like: - retrieval refresh - graph remap @@ -157,8 +164,8 @@ Minimum useful fields: - `blockingReason` - linked subgoal or graph node ids -This should be read/reflection first. Do not make job state a hidden second -planner. +The landed reflection surface keeps this read-only. Future live job state must +keep the same rule: do not make job state a hidden second planner. ## Compaction And CRRC diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 652bd0f3..cef0d513 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -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 twelve live paths: +The spine exists in thirteen 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,7 +22,8 @@ The spine exists in twelve 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). +- 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:340), [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:4079), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10573). +- job/progress reflection: app-server declares experimental read-only `thread/epiphany/jobs`, reads the same thread view as scene, optionally fills retrieval state for loaded threads with no Epiphany state, and derives four non-authoritative progress slots for retrieval indexing, graph remap, invariant verification, and future specialist work without scheduling, notifying, mutating, or persisting jobs in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:344), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4100), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4114), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10734). - 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: @@ -60,6 +61,8 @@ flowchart TD N --> Q["Client can read typed state"] N --> QS["thread/epiphany/scene derives compact client scene"] QS --> Q + N --> QJ["thread/epiphany/jobs derives progress slots"] + QJ --> 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"] @@ -99,6 +102,7 @@ What this means in plain English: - 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. +- The app-server can expose read-only job/progress slots derived from typed state and retrieval summaries without creating a scheduler. - 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. @@ -116,7 +120,7 @@ The current landed machine is still coherent. The core shape is not ornamental: Nothing in the current typed spine obviously deserves deletion right now. The parts that would turn this into Jenga are still correctly listed as non-flows: automatic tool-output ingestion, watcher invalidation, specialist scheduling, broad event streaming, and an automatic Compact-Rehydrate-Reorient-Continue coordinator. Thin GUI/client reflection is no longer forbidden as a category, provided it reflects and steers typed state rather than inventing a second source of truth. -The next Perfect Machine move is not adding another writer, and it is no longer another generic scrape of notification/read/proposal/promotion hardening. That wording turned into a loop hazard: after a phase is coherent, "one more smallest safety slice" can become a polite way to rearrange the furniture forever. The Phase 5 smoke harness should guard the existing control plane against regressions. The next organ should move outward toward a Phase 6 reflection/scene-surface or job-state precursor that lets clients inspect the machine Epiphany already built. +The next Perfect Machine move is not adding another writer, not re-hardening Phase 5, and no longer the first scene or job reflection. Those surfaces now let clients inspect the machine Epiphany already built. The next outward work should add a missing observation source only when there is a concrete consumer: targeted graph/evidence reads, watcher/freshness inputs, or live progress notifications once real long-running job owners exist. ## Natural Language Spine @@ -132,6 +136,7 @@ This is the same flow in the language Epiphany is supposed to make the model car | 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. | +| Job projection | Clients can ask which Epiphany work slots are idle, needed, blocked, running, or unavailable for indexing, remap, verification, and future specialists. The slots are derived from state and retrieval summaries; they do not start work. | A shift board listing which crews would be needed if work begins, not a foreman secretly hiring people in the back room. | | 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. | @@ -949,7 +954,7 @@ The app-server handler: 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 in newest-first order, matching the durable state's recent-record ordering. 8. reflects churn pressure/warning fields. -9. reports available actions only when the thread is loaded, adding `propose` and `promote` only when state exists. +9. reports available actions only when the thread is loaded, including the read-only `jobs` door and adding `propose`/`promote` only when state exists. ### Output @@ -959,6 +964,84 @@ The response is a client-shaped reflection of the current Epiphany machine. It l 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. +## Flow 14: Job/Progress Reflection Control Flow + +### Input + +A client sends experimental `thread/epiphany/jobs` with: + +- `threadId` + +### Plain-language role + +Job projection is the second Phase 6 reflection boundary. It gives clients a typed answer to "what Epiphany work is visible from here?" without creating a background scheduler, durable job table, or GUI-owned progress model. + +The surface currently reports four derived slots: + +- retrieval indexing +- graph remap +- invariant/evidence verification +- future specialist work + +The important boundary is that these are reflections over existing state. Retrieval status comes from the same retrieval summary machinery used by scene/thread reads. Remap pressure comes from graph frontier dirty paths, open questions/gaps, and churn freshness. Verification pressure comes from invariant status counts. Specialist work is explicitly `unavailable` until a scheduler exists, which is intentionally better than making clients invent one in the upholstery. + +Protocol shape: + +- `threadId` + +Response shape: + +- `threadId` +- `source` +- optional `stateRevision` +- `jobs` + - `id` + - `kind` + - `scope` + - `ownerRole` + - `status` + - optional `itemsProcessed` + - optional `itemsTotal` + - optional `progressNote` + - optional `lastCheckpointAtUnixSeconds` + - optional `blockingReason` + - `linkedSubgoalIds` + - `linkedGraphNodeIds` + +Code refs: + +- [app-server-protocol/common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:344) +- [app-server-protocol/v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4100) +- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4114) +- [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:10734) + +### Mechanism + +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. if the thread is loaded and no Epiphany retrieval summary is present, asks the loaded thread for retrieval state so the index slot can still be honest before typed Epiphany state exists. +5. returns `stateRevision` only when authoritative Epiphany state exists. +6. passes the optional state and optional retrieval override into `map_epiphany_jobs`. + +`map_epiphany_jobs`: + +1. returns a `retrieval-index` slot from retrieval status: ready becomes idle, stale becomes needed, indexing becomes running, unavailable stays unavailable. +2. returns a `graph-remap` slot that is blocked without Epiphany state and needed when frontier dirty paths, open questions/gaps, or stale graph freshness are visible. +3. returns a `verification` slot that is blocked without Epiphany state and needed when any invariant status is not accepting. +4. returns a `specialist-work` slot as unavailable with an explicit blocking reason because specialist scheduling is not landed. +5. copies active subgoal and graph-node ids into relevant slots so clients can link progress pressure back to the visible model. + +### Output + +The response is a typed progress board derived from the current Epiphany machine. The Phase 6 jobs smoke proved that missing-state jobs can still reflect retrieval while graph/remap and verification stay blocked, ready-state jobs expose revision identity and needed remap/verification pressure, no `thread/epiphany/stateUpdated` notification is emitted by the read, and final thread state revision does not change. + +### Invariant + +Job projection is read-only. It does not start indexing, remap graphs, verify invariants, schedule specialists, mutate `SessionState`, append rollout items, or emit progress notifications. It is a board on the wall, not a payroll department with a fake mustache. + ## Current Non-Flows These are deliberately not shipped yet: @@ -969,7 +1052,8 @@ These are deliberately not shipped yet: - no watcher-driven graph or semantic invalidation. - no code-intelligence graph. - no specialist-agent scheduler. -- no GUI implementation beyond the read-only scene projection surface. +- no live long-running job execution or `thread/epiphany/jobsUpdated` progress notification. +- no GUI implementation beyond the read-only scene and jobs projection surfaces. - no durable retrieval-summary write from `thread/epiphany/retrieve`. The current system is therefore not "the model maintains a map automatically." More precisely: @@ -980,6 +1064,7 @@ stored Epiphany state -> persisted across turns and resume -> visible to clients -> reflected as a compact read-only scene for clients +-> reflected as read-only job/progress slots 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 @@ -988,7 +1073,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, 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, and live app-server smoke now guards that boundary. The remaining missing organs are job/progress reflection, 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, not the first client-shaped scene, and no longer the first job/progress reflection. 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 and jobs surfaces give clients compact read-only views without making the GUI/client authoritative, and live app-server smoke now guards those boundaries. The remaining missing organs are watcher/freshness inputs, targeted graph/evidence reads, live job progress notifications once real job owners exist, and eventually role-scoped specialist ownership without silently auto-promoting anything. ```text model/tool observations @@ -1002,7 +1087,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, 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. +In natural language: current Epiphany can preserve a map, show a map, project a compact scene from the map, project derived job/progress slots from the map and retrieval summary, 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, execute long-running Epiphany jobs as tracked background work, emit job progress notifications, or coordinate specialist ownership. Teeth are installed; chewing is supervised; the first bell rings; the first wall board exists; the first shift board exists; the next slices are about senses, not jawbones. ## Verification Hooks @@ -1021,6 +1106,7 @@ Current tests cover the landed flows at useful seams: - app-server mapping of core retrieval/index summaries into protocol responses. - reusable app-server smoke for the richer Phase 5 chain in `tools/epiphany_phase5_smoke.py`, including update/promote response metadata, `thread/epiphany/stateUpdated` notifications with source, revision, changed-field checks, retrieval-summary presence in successful write response/notification states, the verifier-only promotion edge where `Evidence` changes because verifier evidence is appended, invalid direct observation/evidence and replacement update rejection without mutation or notification, and explicit zero-notification assertions for rejected promotions. - live app-server smoke for the first Phase 6 scene boundary in `tools/epiphany_phase6_scene_smoke.py`. +- live app-server smoke for the first Phase 6 jobs boundary in `tools/epiphany_phase6_jobs_smoke.py`. Useful commands: @@ -1031,4 +1117,5 @@ $env:CARGO_TARGET_DIR='C:\Users\Meta\.cargo-target-codex'; cargo test -p codex-a $env:CARGO_TARGET_DIR='C:\Users\Meta\.cargo-target-codex'; cargo test -p codex-app-server --lib map_epiphany_ & 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase5_smoke.py' & 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_scene_smoke.py' +& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_jobs_smoke.py' ``` diff --git a/notes/epiphany-fork-implementation-plan.md b/notes/epiphany-fork-implementation-plan.md index 40d3d99f..a2f6cee2 100644 --- a/notes/epiphany-fork-implementation-plan.md +++ b/notes/epiphany-fork-implementation-plan.md @@ -57,6 +57,8 @@ The landed machine now has: - reusable Phase 5 app-server smoke coverage in `tools/epiphany_phase5_smoke.py` - a first Phase 6 read-only reflection surface through `thread/epiphany/scene` - live Phase 6 scene app-server smoke coverage in `tools/epiphany_phase6_scene_smoke.py` +- read-only Phase 6 job/progress reflection through `thread/epiphany/jobs` +- live Phase 6 jobs app-server smoke coverage in `tools/epiphany_phase6_jobs_smoke.py` The current phase is Phase 6: reflection boundary and observable harness state. @@ -70,6 +72,7 @@ These boundaries are more important than the individual method names: - Durable typed state writes go through `thread/epiphany/update` or accepted `thread/epiphany/promote`. - `thread/epiphany/index` may update the semantic retrieval catalog, but it is not a hidden Epiphany-state writer. - `thread/epiphany/scene` is a client reflection, not a second source of truth. +- `thread/epiphany/jobs` is a derived reflection, not a scheduler or durable job store. - The GUI may render and steer typed state, but it must not manufacture canonical understanding. - The app-server remains a host seam; Epiphany-owned machinery should live in `epiphany-core` where practical. - Qdrant is the preferred persistent semantic backend; BM25 remains the bootstrap/fallback/control path. @@ -105,8 +108,7 @@ and notify typed state. It can. The next unknowns are: -- what minimal job/progress surface is needed for indexing, remap, verification, and future specialist work -- how to expose long-running work without making the GUI authoritative +- how to expose live long-running job progress without making the GUI authoritative - when watcher-driven invalidation becomes necessary instead of merely tempting - how much automatic CRRC coordination belongs in runtime before it becomes ceremony machinery - what Phase 6 should prove before specialist scheduling begins @@ -117,10 +119,10 @@ Phase 6 should grow observable harness state outward from the typed spine. Useful candidates: -1. Add a minimal read-only job/progress surface for indexing, remap, and verification work. -2. Add targeted scene fields only when a client or smoke exposes a real gap. -3. Keep the scene derived from authoritative Epiphany state. -4. Keep long-running work observable through typed state or notifications, not transcript inference. +1. Add targeted graph/evidence shard reads when the full `EpiphanyThreadState` is too raw. +2. Add watcher/freshness inputs when stale graph or retrieval state needs earlier warning. +3. Add live job progress notifications only after there is a real long-running owner to report. +4. Add targeted scene/jobs fields only when a client or smoke exposes a real gap. Do not spend Phase 6 polishing Phase 5 out of anxiety. The Phase 5 smoke harness is a regression guardrail, not a ritual drum circle for summoning more tiny @@ -157,6 +159,12 @@ Before modifying scene projection behavior, run: & 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_scene_smoke.py' ``` +Before modifying jobs reflection behavior, run: + +```powershell +& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_jobs_smoke.py' +``` + For app-server protocol changes, expect to run the relevant protocol tests, regenerate stable schema fixtures when needed, and verify the generated tree is intentional. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index d6fd3867..9c841c80 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -28,7 +28,7 @@ Do not trust this file for the exact live HEAD. Always check git. - Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`. - Phase 1 through Phase 5 are complete enough. -- Phase 6 has begun with read-only `thread/epiphany/scene`, and that scene surface now has live app-server smoke coverage. +- Phase 6 has read-only `thread/epiphany/scene` and `thread/epiphany/jobs`; both have live app-server smoke coverage. - The repo is an Epiphany fork of Codex, not a Codex preset. - `vendor/codex` is tracked directly, not a submodule. - `epiphany-core` owns the heavy Epiphany organs where practical. @@ -60,7 +60,9 @@ The current spine: - verifier-backed promotion through `thread/epiphany/promote` - successful-write notification through `thread/epiphany/stateUpdated` - read-only compact reflection through `thread/epiphany/scene` +- read-only job/progress reflection through `thread/epiphany/jobs` - live scene app-server smoke through `tools/epiphany_phase6_scene_smoke.py` +- live jobs app-server smoke through `tools/epiphany_phase6_jobs_smoke.py` The exact current control flow is documented in `notes/epiphany-current-algorithmic-map.md`. @@ -71,6 +73,7 @@ The exact current control flow is documented in - `thread/epiphany/distill` is read-only. - `thread/epiphany/propose` is read-only. - `thread/epiphany/scene` is read-only. +- `thread/epiphany/jobs` is read-only. - Durable typed state writes go through `thread/epiphany/update` or accepted `thread/epiphany/promote`. - `thread/epiphany/index` writes the retrieval catalog, not durable Epiphany understanding. - GUI/client surfaces reflect and steer typed state; they do not become the source of truth. @@ -90,6 +93,12 @@ For scene projection behavior changes, run: & 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_scene_smoke.py' ``` +For jobs reflection behavior changes, run: + +```powershell +& 'C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' '.\tools\epiphany_phase6_jobs_smoke.py' +``` + For Codex Rust work on this Windows machine: ```powershell @@ -128,10 +137,12 @@ that change what the next agent should believe. Do not continue implementation automatically from a rehydrate-only request. -When the user asks to continue, design and land a minimal read-only job/progress -reflection surface for indexing, remap, and verification work. +When the user asks to continue, choose the next Phase 6 outward slice. Good +candidates are targeted graph/evidence shard reads, watcher/freshness inputs, +or live job progress notifications. Do not build a scheduler from vibes. -Live `thread/epiphany/scene` smoke is now a guardrail, not the next organ. +Live `thread/epiphany/scene` and `thread/epiphany/jobs` smokes are now +guardrails, not the next organs. ## Not Yet @@ -140,6 +151,7 @@ Live `thread/epiphany/scene` smoke is now a guardrail, not the next organ. - specialist-agent scheduling - GUI-as-source-of-truth - automatic runtime CRRC coordinator +- live long-running job execution or `thread/epiphany/jobsUpdated` - broad event stream beyond the landed state update notification The machine is good enough to move outward. Do not sand the same edge until the diff --git a/state/evidence.jsonl b/state/evidence.jsonl index b4c7dfad..04587ef7 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -30,3 +30,4 @@ {"ts": "2026-04-26T00:17:24+00:00", "type": "decision", "status": "ok", "note": "Persistent-state sawdust audit cut stale README, architecture rationale, controller-action, handoff, branch-note, and scratch guidance. Future rehydrate should treat map/handoff/plan/algo-map as current truth; README/rationale are orientation, not phase ledger; exact HEAD belongs to git commands, not handoff prose."} {"ts": "2026-04-26T00:20:30+00:00", "type": "decision", "status": "ok", "note": "Added tools/epiphany_prepare_compaction.py and local AGENTS guidance so imminent-compaction passes run a concrete persistence audit before and after state edits. The helper checks required state files, map summary/next action, scratch staleness, evidence/branch parsing, stale handoff git snapshots, AGENTS trigger wording, and dirty git state."} {"ts": "2026-04-26T00:33:31+00:00", "type": "verification", "status": "ok", "note": "Phase 6 scene live-smoked through app-server with tools/epiphany_phase6_scene_smoke.py. The smoke proves missing and ready scene shapes, live source, retrieval-summary backfill, available actions, newest-first bounded observation/evidence records, no scene-triggered stateUpdated notification, and unchanged final read revision; it also caught and fixed reversed latest-record ordering in map_epiphany_scene."} +{"ts": "2026-04-26T01:08:00+00:00", "type": "verification", "status": "ok", "note": "Phase 6 jobs reflection landed as read-only thread/epiphany/jobs and live-smoked through app-server with tools/epiphany_phase6_jobs_smoke.py. The surface derives retrieval-index, graph-remap, verification, and specialist slots from thread state/retrieval summaries, preserves revision identity, emits no stateUpdated notification, and leaves live scheduling/progress notifications as future work."} diff --git a/state/map.yaml b/state/map.yaml index 2a81ad21..cb920d2d 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -51,17 +51,17 @@ data_flow: active_subgoals: - Treat Phase 5 update/distill/propose/promote/read/notification as complete enough unless a concrete regression appears. - - Preserve read-only boundaries for retrieve, distill, propose, and scene. - - Design the minimal read-only job/progress reflection surface for indexing, remap, verification, and future specialist work. + - Preserve read-only boundaries for retrieve, distill, propose, scene, and jobs. + - Extend Phase 6 observability only where it reflects authoritative state or retrieval summaries without becoming a scheduler. - Keep persistent project state ruthlessly distilled so rehydration strengthens the next turn instead of bloating it. accepted_design: - Epiphany is a fork-level modeling architecture, not merely a Codex collaboration mode. - Authoritative Epiphany state lives in Codex protocol/core session and rollout state. - The prompt reads typed state through a bounded `` developer fragment. - - Clients read typed state through `Thread.epiphanyState` and compact reflections such as `thread/epiphany/scene`. + - Clients read typed state through `Thread.epiphanyState` and compact reflections such as `thread/epiphany/scene` and `thread/epiphany/jobs`. - Durable typed state writes route through `thread/epiphany/update` or accepted `thread/epiphany/promote`. - - `thread/epiphany/retrieve`, `thread/epiphany/distill`, `thread/epiphany/propose`, and `thread/epiphany/scene` stay read-only. + - `thread/epiphany/retrieve`, `thread/epiphany/distill`, `thread/epiphany/propose`, `thread/epiphany/scene`, and `thread/epiphany/jobs` stay read-only. - `thread/epiphany/index` writes the retrieval catalog, not durable Epiphany understanding. - Qdrant is the preferred persistent semantic backend; BM25 remains the bootstrap/fallback/control path. - `epiphany-core` owns prompt rendering, rollout replay helpers, retrieval/indexing, distillation, proposal, and promotion policy where possible. @@ -69,7 +69,8 @@ accepted_design: - The current algorithmic map is the source-grounded description of live control flow. - Compact-Rehydrate-Reorient-Continue is an architecture primitive; automatic runtime coordination is not landed yet. - GUI/client work must reflect or steer typed state rather than manufacture a second source of truth. - - Long-running indexing, remap, verification, and specialist work should eventually surface as typed jobs/progress. + - `thread/epiphany/jobs` is the first read-only job/progress reflection: it derives indexing, remap, verification, and specialist slots from existing state; it is not a scheduler or durable job store. + - Live long-running job execution, progress notifications, and specialist scheduling are still future work. - Handoff, plan, harness-surface, and scratch files must have distinct jobs and must not become duplicate brains. - A machine is perfect when every remaining part visibly deserves to exist; this applies to persistent memory too. - Evidence is not an activity feed; repeated "I just did this" entries should be cut or distilled when git already proves the work. @@ -84,11 +85,12 @@ landed_baseline: - Phase 3: typed client read surface through `Thread.epiphanyState`. - Phase 4: hybrid retrieval plus explicit Qdrant indexing with BM25 fallback. - Phase 5: typed update/distill/propose/promote/read/notification control plane. - - Phase 6: first read-only scene/reflection surface. + - Phase 6: read-only scene and job/progress reflection surfaces. guardrails: - Use `tools/epiphany_phase5_smoke.py` before modifying update, distill, propose, promote, read-projection, or notification behavior. - Use `tools/epiphany_phase6_scene_smoke.py` before modifying scene projection behavior. - - Use focused scene/protocol/schema checks for scene-only changes. + - Use `tools/epiphany_phase6_jobs_smoke.py` before modifying job/progress reflection behavior. + - Use focused scene/jobs/protocol/schema checks for reflection-only changes. - Use `tools/epiphany_prepare_compaction.py` before and after imminent-compaction persistence passes. - Use `CARGO_TARGET_DIR=C:\Users\Meta\.cargo-target-codex` for Codex Rust work on this Windows machine. - Do not parallelize cargo builds/tests against the same target directory. @@ -106,5 +108,5 @@ rejected_paths: reason: persistent state that accumulates every local truth becomes memory cruft and weakens rehydration current_status: - summary: Phase 1 durable state, Phase 2 prompt integration, Phase 3 typed read, Phase 4 retrieval/indexing, Phase 5 update/distill/propose/promote/read/notification, and the first Phase 6 scene surface are landed. Scene behavior has a live app-server smoke guardrail. Persistent state was cut down so map, handoff, plan, harness surfaces, scratch, and evidence each carry one job instead of becoming a Jenga tower; evidence is now a distilled ledger rather than an activity feed. The global AGENTS Epiphany core command says persistent state is the agent's mind and explicitly permits the agent to ask for self-modification when memory or workflow makes it worse. The continuity goal is to bank the fire before the dark so compaction becomes less like death and more like sleep. - next_action: After compaction, rehydrate and reorient. Do not continue implementation from the rehydrate step alone. When work resumes, design the minimal read-only job/progress reflection surface for indexing, remap, verification, and future specialist work. + summary: Phase 1 durable state, Phase 2 prompt integration, Phase 3 typed read, Phase 4 retrieval/indexing, Phase 5 update/distill/propose/promote/read/notification, and Phase 6 read-only scene plus jobs reflection are landed. Scene and jobs behavior have live app-server smoke guardrails. Persistent state was cut down so map, handoff, plan, harness surfaces, scratch, and evidence each carry one job instead of becoming a Jenga tower; evidence is now a distilled ledger rather than an activity feed. The global AGENTS Epiphany core command says persistent state is the agent's mind and explicitly permits the agent to ask for self-modification when memory or workflow makes it worse. The continuity goal is to bank the fire before the dark so compaction becomes less like death and more like sleep. + next_action: After compaction, rehydrate and reorient. Do not continue implementation from the rehydrate step alone. When work resumes, choose the next Phase 6 outward slice: likely targeted graph/evidence shard reads, watcher-driven freshness inputs, or live job progress notifications; do not rebuild a scheduler from vibes. diff --git a/state/scratch.md b/state/scratch.md index 8aeb9933..14ef9cb9 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -8,19 +8,18 @@ No active scratch subgoal. ## Last Completed Audit -- `thread/epiphany/scene` had protocol and mapper coverage but no live app-server smoke. -- Scene latest-record mapping reversed the durable newest-first record order. -- Async update notifications had to be drained before asserting that scene emits no state update notification. +- `thread/epiphany/jobs` now provides the first read-only job/progress reflection. +- The surface derives retrieval-index, graph-remap, verification, and specialist slots from live/stored thread state and retrieval summaries. +- It does not schedule, persist, notify, or mutate jobs. ## Decision -Add `tools/epiphany_phase6_scene_smoke.py`, fix scene latest records to preserve -newest-first order, and make the smoke prove missing/ready state, live source, -retrieval backfill, action availability, bounded latest records, and no -scene-triggered `thread/epiphany/stateUpdated`. +Keep jobs as a reflection board, not a scheduler. The next outward Phase 6 move +should add a missing sense only when there is a real consumer: targeted +graph/evidence reads, watcher/freshness inputs, or live job progress +notifications once actual long-running owners exist. -Next implementation move is Phase 6 job/progress reflection: design the minimal -read-only surface for indexing, remap, verification, and future specialist work. +Scene and jobs smokes are guardrails now, not the next organs. Do not promote anything from this scratch into the map unless it survives verification or repeated reuse without contradiction. diff --git a/tools/epiphany_phase6_jobs_smoke.py b/tools/epiphany_phase6_jobs_smoke.py new file mode 100644 index 00000000..672b740a --- /dev/null +++ b/tools/epiphany_phase6_jobs_smoke.py @@ -0,0 +1,247 @@ +from __future__ import annotations + +import argparse +import json +from pathlib import Path +from typing import Any + +from epiphany_phase5_smoke import AppServerClient +from epiphany_phase5_smoke import DEFAULT_APP_SERVER +from epiphany_phase5_smoke import ROOT +from epiphany_phase5_smoke import require +from epiphany_phase5_smoke import reset_smoke_paths + + +DEFAULT_CODEX_HOME = ROOT / ".epiphany-smoke" / "phase6-jobs-codex-home" +DEFAULT_RESULT = ROOT / ".epiphany-smoke" / "phase6-jobs-smoke-result.json" +DEFAULT_TRANSCRIPT = ROOT / ".epiphany-smoke" / "phase6-jobs-smoke-transcript.jsonl" +DEFAULT_STDERR = ROOT / ".epiphany-smoke" / "phase6-jobs-smoke-server.stderr.log" + +JOBS_CODE_REF = { + "path": "app-server/src/codex_message_processor.rs", + "start_line": 10734, + "end_line": 10982, + "symbol": "map_epiphany_jobs", +} + + +def job_surface_patch() -> dict[str, Any]: + return { + "objective": "Expose read-only Epiphany job/progress reflection without creating a scheduler.", + "activeSubgoalId": "phase6-jobs-smoke", + "subgoals": [ + { + "id": "phase6-jobs-smoke", + "title": "Live-smoke job reflection", + "status": "active", + "summary": "The app-server jobs surface should reflect typed state and retrieval progress.", + } + ], + "invariants": [ + { + "id": "inv-jobs-read-only", + "description": "thread/epiphany/jobs must not mutate Epiphany state.", + "status": "ok", + }, + { + "id": "inv-jobs-needs-review", + "description": "The first job surface should stay reflection-only until live scheduling lands.", + "status": "needs_review", + }, + ], + "graphs": { + "architecture": { + "nodes": [ + { + "id": "job-surface", + "title": "Job reflection surface", + "purpose": "Expose derived progress slots without becoming canonical job state.", + "code_refs": [JOBS_CODE_REF], + } + ] + }, + "dataflow": {"nodes": []}, + "links": [], + }, + "graphFrontier": { + "active_node_ids": ["job-surface"], + "dirty_paths": ["app-server/src/codex_message_processor.rs"], + "open_question_ids": ["q-live-progress"], + }, + "churn": { + "understanding_status": "ready", + "diff_pressure": "low", + "graph_freshness": "stale", + "unexplained_writes": 0, + }, + } + + +def job_by_id(jobs: list[dict[str, Any]], job_id: str) -> dict[str, Any]: + for job in jobs: + if job["id"] == job_id: + return job + raise AssertionError(f"missing job {job_id!r}: {jobs!r}") + + +def assert_missing_state_jobs(response: dict[str, Any]) -> None: + require(response["source"] == "live", "jobs should report live source for loaded thread") + require("stateRevision" not in response, "missing-state jobs should not invent a revision") + require(len(response["jobs"]) == 4, "jobs surface should expose the four known slots") + + index = job_by_id(response["jobs"], "retrieval-index") + require(index["kind"] == "indexing", "retrieval slot should be indexing kind") + require(index["status"] in {"idle", "needed", "running", "unavailable"}, "index status should be typed") + + remap = job_by_id(response["jobs"], "graph-remap") + require(remap["status"] == "blocked", "missing state should block graph remap") + + verification = job_by_id(response["jobs"], "verification") + require(verification["status"] == "blocked", "missing state should block verification") + + specialist = job_by_id(response["jobs"], "specialist-work") + require(specialist["status"] == "unavailable", "specialist slot should report not landed") + + +def assert_ready_jobs(response: dict[str, Any]) -> None: + require(response["source"] == "live", "ready jobs should report live source") + require(response["stateRevision"] == 1, "jobs should preserve state revision identity") + require(len(response["jobs"]) == 4, "ready jobs should still expose the four known slots") + + index = job_by_id(response["jobs"], "retrieval-index") + require(index["kind"] == "indexing", "retrieval slot should remain indexing kind") + require(index["ownerRole"] == "epiphany-core", "retrieval job should name epiphany-core owner") + require(index["linkedSubgoalIds"] == ["phase6-jobs-smoke"], "index job should link active subgoal") + require(index["linkedGraphNodeIds"] == ["job-surface"], "index job should link active graph node") + + remap = job_by_id(response["jobs"], "graph-remap") + require(remap["kind"] == "remap", "graph job should be remap kind") + require(remap["status"] == "needed", "dirty/stale graph frontier should need remap") + require(remap["linkedGraphNodeIds"] == ["job-surface"], "remap should expose active graph node") + + verification = job_by_id(response["jobs"], "verification") + require(verification["kind"] == "verification", "verification slot should be typed") + require(verification["status"] == "needed", "non-accepting invariant should need verification") + require(verification["itemsProcessed"] == 1, "verification should count accepting invariants") + require(verification["itemsTotal"] == 2, "verification should count total invariants") + + specialist = job_by_id(response["jobs"], "specialist-work") + require(specialist["status"] == "unavailable", "specialist scheduler should remain explicit non-flow") + require("blockingReason" in specialist, "specialist non-flow should explain itself") + + +def run_smoke(args: argparse.Namespace) -> dict[str, Any]: + app_server = args.app_server.resolve() + if not app_server.exists(): + raise FileNotFoundError(f"codex app-server binary not found: {app_server}") + + codex_home = args.codex_home.resolve() + result_path = args.result.resolve() + transcript_path = args.transcript.resolve() + stderr_path = args.stderr.resolve() + reset_smoke_paths(codex_home, result_path, transcript_path, stderr_path) + + with AppServerClient(app_server, codex_home, transcript_path, stderr_path) as client: + client.send( + "initialize", + { + "clientInfo": { + "name": "epiphany-phase6-jobs-smoke", + "title": "Epiphany Phase 6 Jobs Smoke", + "version": "0.1.0", + }, + "capabilities": {"experimentalApi": True}, + }, + ) + client.send("initialized", expect_response=False) + started = client.send( + "thread/start", + {"cwd": str(ROOT / "epiphany-core"), "ephemeral": True}, + ) + assert started is not None + thread_id = started["thread"]["id"] + + missing_notification_start = len(client.notifications) + missing_response = client.send("thread/epiphany/jobs", {"threadId": thread_id}) + assert missing_response is not None + require(missing_response["threadId"] == thread_id, "jobs response should echo thread id") + assert_missing_state_jobs(missing_response) + client.require_no_notification( + "thread/epiphany/stateUpdated", + start_index=missing_notification_start, + ) + + update_notification_start = len(client.notifications) + update = client.send( + "thread/epiphany/update", + {"threadId": thread_id, "expectedRevision": 0, "patch": job_surface_patch()}, + ) + assert update is not None + require(update["revision"] == 1, "job smoke patch should advance revision to 1") + client.wait_for_notification( + "thread/epiphany/stateUpdated", + start_index=update_notification_start, + ) + + jobs_notification_start = len(client.notifications) + ready_response = client.send("thread/epiphany/jobs", {"threadId": thread_id}) + assert ready_response is not None + assert_ready_jobs(ready_response) + client.require_no_notification( + "thread/epiphany/stateUpdated", + start_index=jobs_notification_start, + ) + + final_read = client.send("thread/read", {"threadId": thread_id, "includeTurns": False}) + assert final_read is not None + require( + final_read["thread"]["epiphanyState"]["revision"] == 1, + "jobs reflection should not mutate state revision", + ) + + result = { + "threadId": thread_id, + "codexHome": str(codex_home), + "missingJobStatuses": { + job["id"]: job["status"] for job in missing_response["jobs"] + }, + "readyRevision": ready_response["stateRevision"], + "readyJobStatuses": {job["id"]: job["status"] for job in ready_response["jobs"]}, + "verificationItemsProcessed": job_by_id( + ready_response["jobs"], "verification" + )["itemsProcessed"], + "verificationItemsTotal": job_by_id( + ready_response["jobs"], "verification" + )["itemsTotal"], + "jobsNotificationCount": client.count_notifications( + "thread/epiphany/stateUpdated", + start_index=jobs_notification_start, + ), + "finalReadRevision": final_read["thread"]["epiphanyState"]["revision"], + } + + result_path.parent.mkdir(parents=True, exist_ok=True) + result_path.write_text( + json.dumps(result, indent=2, ensure_ascii=False) + "\n", + encoding="utf-8", + ) + return result + + +def main() -> int: + parser = argparse.ArgumentParser( + description="Live-smoke the Phase 6 Epiphany job/progress reflection surface." + ) + parser.add_argument("--app-server", type=Path, default=DEFAULT_APP_SERVER) + parser.add_argument("--codex-home", type=Path, default=DEFAULT_CODEX_HOME) + parser.add_argument("--result", type=Path, default=DEFAULT_RESULT) + parser.add_argument("--transcript", type=Path, default=DEFAULT_TRANSCRIPT) + parser.add_argument("--stderr", type=Path, default=DEFAULT_STDERR) + args = parser.parse_args() + result = run_smoke(args) + print(json.dumps(result, indent=2, ensure_ascii=False)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tools/epiphany_phase6_scene_smoke.py b/tools/epiphany_phase6_scene_smoke.py index aa355add..7074fe20 100644 --- a/tools/epiphany_phase6_scene_smoke.py +++ b/tools/epiphany_phase6_scene_smoke.py @@ -19,8 +19,8 @@ DEFAULT_STDERR = ROOT / ".epiphany-smoke" / "phase6-scene-smoke-server.stderr.lo MAPPER_CODE_REF = { "path": "app-server/src/codex_message_processor.rs", - "start_line": 10500, - "end_line": 10680, + "start_line": 10573, + "end_line": 10689, "symbol": "map_epiphany_scene", } @@ -129,7 +129,7 @@ def assert_missing_scene(scene: dict[str, Any]) -> None: require(scene["stateStatus"] == "missing", "initial scene should report missing state") require(scene["source"] == "live", "loaded missing scene should report live source") require( - scene["availableActions"] == ["index", "retrieve", "distill", "update"], + scene["availableActions"] == ["index", "retrieve", "distill", "jobs", "update"], "missing live scene should expose only bootstrap actions", ) require( @@ -200,7 +200,7 @@ def assert_ready_scene(scene: dict[str, Any], expected_revision: int) -> None: ) require( scene["availableActions"] - == ["index", "retrieve", "distill", "update", "propose", "promote"], + == ["index", "retrieve", "distill", "jobs", "update", "propose", "promote"], "ready live scene should expose full loaded-state actions", ) diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index 67122277..cd7e2660 100644 --- a/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -14811,6 +14811,106 @@ "title": "ThreadCompactStartResponse", "type": "object" }, + "ThreadEpiphanyJob": { + "properties": { + "blockingReason": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "string" + }, + "itemsProcessed": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "itemsTotal": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "kind": { + "$ref": "#/definitions/v2/ThreadEpiphanyJobKind" + }, + "lastCheckpointAtUnixSeconds": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "linkedGraphNodeIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "linkedSubgoalIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ownerRole": { + "type": "string" + }, + "progressNote": { + "type": [ + "string", + "null" + ] + }, + "scope": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/v2/ThreadEpiphanyJobStatus" + } + }, + "required": [ + "id", + "kind", + "ownerRole", + "scope", + "status" + ], + "type": "object" + }, + "ThreadEpiphanyJobKind": { + "enum": [ + "indexing", + "remap", + "verification", + "specialist" + ], + "type": "string" + }, + "ThreadEpiphanyJobStatus": { + "enum": [ + "idle", + "needed", + "running", + "blocked", + "unavailable" + ], + "type": "string" + }, + "ThreadEpiphanyJobsSource": { + "enum": [ + "stored", + "live" + ], + "type": "string" + }, "ThreadEpiphanyRetrieveIndexSummary": { "properties": { "dirtyPaths": { @@ -15060,6 +15160,7 @@ "index", "retrieve", "distill", + "jobs", "propose", "promote", "update" diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index 85015cbc..8ca4fd70 100644 --- a/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -12698,6 +12698,106 @@ "title": "ThreadCompactStartResponse", "type": "object" }, + "ThreadEpiphanyJob": { + "properties": { + "blockingReason": { + "type": [ + "string", + "null" + ] + }, + "id": { + "type": "string" + }, + "itemsProcessed": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "itemsTotal": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "kind": { + "$ref": "#/definitions/ThreadEpiphanyJobKind" + }, + "lastCheckpointAtUnixSeconds": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "linkedGraphNodeIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "linkedSubgoalIds": { + "items": { + "type": "string" + }, + "type": "array" + }, + "ownerRole": { + "type": "string" + }, + "progressNote": { + "type": [ + "string", + "null" + ] + }, + "scope": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/ThreadEpiphanyJobStatus" + } + }, + "required": [ + "id", + "kind", + "ownerRole", + "scope", + "status" + ], + "type": "object" + }, + "ThreadEpiphanyJobKind": { + "enum": [ + "indexing", + "remap", + "verification", + "specialist" + ], + "type": "string" + }, + "ThreadEpiphanyJobStatus": { + "enum": [ + "idle", + "needed", + "running", + "blocked", + "unavailable" + ], + "type": "string" + }, + "ThreadEpiphanyJobsSource": { + "enum": [ + "stored", + "live" + ], + "type": "string" + }, "ThreadEpiphanyRetrieveIndexSummary": { "properties": { "dirtyPaths": { @@ -12947,6 +13047,7 @@ "index", "retrieve", "distill", + "jobs", "propose", "promote", "update" diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJob.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJob.ts new file mode 100644 index 00000000..1efee0f3 --- /dev/null +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJob.ts @@ -0,0 +1,7 @@ +// 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 { ThreadEpiphanyJobKind } from "./ThreadEpiphanyJobKind"; +import type { ThreadEpiphanyJobStatus } from "./ThreadEpiphanyJobStatus"; + +export type ThreadEpiphanyJob = { id: string, kind: ThreadEpiphanyJobKind, scope: string, ownerRole: string, status: ThreadEpiphanyJobStatus, itemsProcessed?: number | null, itemsTotal?: number | null, progressNote?: string | null, lastCheckpointAtUnixSeconds?: bigint | null, blockingReason?: string | null, linkedSubgoalIds?: Array, linkedGraphNodeIds?: Array, }; diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobKind.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobKind.ts new file mode 100644 index 00000000..8248f423 --- /dev/null +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobKind.ts @@ -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 ThreadEpiphanyJobKind = "indexing" | "remap" | "verification" | "specialist"; diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobStatus.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobStatus.ts new file mode 100644 index 00000000..6c582a9d --- /dev/null +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobStatus.ts @@ -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 ThreadEpiphanyJobStatus = "idle" | "needed" | "running" | "blocked" | "unavailable"; diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobsSource.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobsSource.ts new file mode 100644 index 00000000..11b53e6b --- /dev/null +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyJobsSource.ts @@ -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 ThreadEpiphanyJobsSource = "stored" | "live"; diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanySceneAction.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanySceneAction.ts index 19e33a19..0f16f01d 100644 --- a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanySceneAction.ts +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanySceneAction.ts @@ -2,4 +2,4 @@ // 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"; +export type ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "jobs" | "propose" | "promote" | "update"; diff --git a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts index 20795b64..29827fb5 100644 --- a/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -317,6 +317,10 @@ export type { ThreadArchivedNotification } from "./ThreadArchivedNotification"; export type { ThreadClosedNotification } from "./ThreadClosedNotification"; export type { ThreadCompactStartParams } from "./ThreadCompactStartParams"; export type { ThreadCompactStartResponse } from "./ThreadCompactStartResponse"; +export type { ThreadEpiphanyJob } from "./ThreadEpiphanyJob"; +export type { ThreadEpiphanyJobKind } from "./ThreadEpiphanyJobKind"; +export type { ThreadEpiphanyJobStatus } from "./ThreadEpiphanyJobStatus"; +export type { ThreadEpiphanyJobsSource } from "./ThreadEpiphanyJobsSource"; export type { ThreadEpiphanyRetrieveIndexSummary } from "./ThreadEpiphanyRetrieveIndexSummary"; export type { ThreadEpiphanyRetrieveResult } from "./ThreadEpiphanyRetrieveResult"; export type { ThreadEpiphanyRetrieveResultKind } from "./ThreadEpiphanyRetrieveResultKind"; diff --git a/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs b/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs index 841afad8..6637cb26 100644 --- a/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs @@ -341,6 +341,11 @@ client_request_definitions! { params: v2::ThreadEpiphanySceneParams, response: v2::ThreadEpiphanySceneResponse, }, + #[experimental("thread/epiphany/jobs")] + ThreadEpiphanyJobs => "thread/epiphany/jobs" { + params: v2::ThreadEpiphanyJobsParams, + response: v2::ThreadEpiphanyJobsResponse, + }, #[experimental("thread/epiphany/index")] ThreadEpiphanyIndex => "thread/epiphany/index" { params: v2::ThreadEpiphanyIndexParams, @@ -1745,6 +1750,64 @@ mod tests { Ok(()) } + #[test] + fn serialize_thread_epiphany_jobs_response() -> Result<()> { + let response = ClientResponse::ThreadEpiphanyJobs { + request_id: RequestId::Integer(8), + response: v2::ThreadEpiphanyJobsResponse { + thread_id: "thr_123".to_string(), + source: v2::ThreadEpiphanyJobsSource::Live, + state_revision: Some(3), + jobs: vec![v2::ThreadEpiphanyJob { + id: "retrieval-index".to_string(), + kind: v2::ThreadEpiphanyJobKind::Indexing, + scope: "/workspace".to_string(), + owner_role: "epiphany-core".to_string(), + status: v2::ThreadEpiphanyJobStatus::Needed, + items_processed: Some(12), + items_total: None, + progress_note: Some( + "Retrieval catalog is stale; refresh is available.".to_string(), + ), + last_checkpoint_at_unix_seconds: Some(1_744_500_000), + blocking_reason: None, + linked_subgoal_ids: vec!["phase-6".to_string()], + linked_graph_node_ids: vec!["retrieval".to_string()], + }], + }, + }; + + assert_eq!(response.id(), &RequestId::Integer(8)); + assert_eq!(response.method(), "thread/epiphany/jobs"); + assert_eq!( + json!({ + "method": "thread/epiphany/jobs", + "id": 8, + "response": { + "threadId": "thr_123", + "source": "live", + "stateRevision": 3, + "jobs": [ + { + "id": "retrieval-index", + "kind": "indexing", + "scope": "/workspace", + "ownerRole": "epiphany-core", + "status": "needed", + "itemsProcessed": 12, + "progressNote": "Retrieval catalog is stale; refresh is available.", + "lastCheckpointAtUnixSeconds": 1744500000, + "linkedSubgoalIds": ["phase-6"], + "linkedGraphNodeIds": ["retrieval"] + } + ] + } + }), + serde_json::to_value(&response)?, + ); + Ok(()) + } + #[test] fn serialize_thread_epiphany_retrieve_response() -> Result<()> { let response = ClientResponse::ThreadEpiphanyRetrieve { @@ -2615,6 +2678,18 @@ mod tests { assert_eq!(reason, Some("thread/epiphany/scene")); } + #[test] + fn thread_epiphany_jobs_is_marked_experimental() { + let request = ClientRequest::ThreadEpiphanyJobs { + request_id: RequestId::Integer(1), + params: v2::ThreadEpiphanyJobsParams { + thread_id: "thr_123".to_string(), + }, + }; + let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request); + assert_eq!(reason, Some("thread/epiphany/jobs")); + } + #[test] fn thread_epiphany_index_is_marked_experimental() { let request = ClientRequest::ThreadEpiphanyIndex { diff --git a/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs b/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs index e88ef6ed..370465e1 100644 --- a/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -3985,6 +3985,7 @@ pub enum ThreadEpiphanySceneAction { Index, Retrieve, Distill, + Jobs, Propose, Promote, Update, @@ -4093,6 +4094,84 @@ pub struct ThreadEpiphanySceneChurn { pub unexplained_writes: Option, } +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ThreadEpiphanyJobsParams { + pub thread_id: String, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ThreadEpiphanyJobsResponse { + pub thread_id: String, + pub source: ThreadEpiphanyJobsSource, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub state_revision: Option, + pub jobs: Vec, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ThreadEpiphanyJobsSource { + Stored, + Live, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ThreadEpiphanyJobKind { + Indexing, + Remap, + Verification, + Specialist, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum ThreadEpiphanyJobStatus { + Idle, + Needed, + Running, + Blocked, + Unavailable, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct ThreadEpiphanyJob { + pub id: String, + pub kind: ThreadEpiphanyJobKind, + pub scope: String, + pub owner_role: String, + pub status: ThreadEpiphanyJobStatus, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub items_processed: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub items_total: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub progress_note: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub last_checkpoint_at_unix_seconds: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional = nullable)] + pub blocking_reason: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub linked_subgoal_ids: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub linked_graph_node_ids: Vec, +} + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] diff --git a/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs b/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs index 466cee68..05666273 100644 --- a/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs +++ b/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs @@ -150,6 +150,12 @@ use codex_app_server_protocol::ThreadEpiphanyDistillParams; use codex_app_server_protocol::ThreadEpiphanyDistillResponse; use codex_app_server_protocol::ThreadEpiphanyIndexParams; use codex_app_server_protocol::ThreadEpiphanyIndexResponse; +use codex_app_server_protocol::ThreadEpiphanyJob; +use codex_app_server_protocol::ThreadEpiphanyJobKind; +use codex_app_server_protocol::ThreadEpiphanyJobStatus; +use codex_app_server_protocol::ThreadEpiphanyJobsParams; +use codex_app_server_protocol::ThreadEpiphanyJobsResponse; +use codex_app_server_protocol::ThreadEpiphanyJobsSource; use codex_app_server_protocol::ThreadEpiphanyPromoteParams; use codex_app_server_protocol::ThreadEpiphanyPromoteResponse; use codex_app_server_protocol::ThreadEpiphanyProposeParams; @@ -361,6 +367,8 @@ use codex_protocol::protocol::ConversationAudioParams; use codex_protocol::protocol::ConversationStartParams; use codex_protocol::protocol::ConversationStartTransport; use codex_protocol::protocol::ConversationTextParams; +use codex_protocol::protocol::EpiphanyRetrievalState; +use codex_protocol::protocol::EpiphanyRetrievalStatus; use codex_protocol::protocol::EpiphanyThreadState; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::GitInfo as CoreGitInfo; @@ -1002,6 +1010,10 @@ impl CodexMessageProcessor { self.thread_epiphany_scene(to_connection_request_id(request_id), params) .await; } + ClientRequest::ThreadEpiphanyJobs { request_id, params } => { + self.thread_epiphany_jobs(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; @@ -4099,6 +4111,67 @@ impl CodexMessageProcessor { self.outgoing.send_response(request_id, response).await; } + async fn thread_epiphany_jobs( + &self, + request_id: ConnectionRequestId, + params: ThreadEpiphanyJobsParams, + ) { + let ThreadEpiphanyJobsParams { 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_thread = self.thread_manager.get_thread(thread_uuid).await.ok(); + let loaded = loaded_thread.is_some(); + 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 retrieval_override = if thread + .epiphany_state + .as_ref() + .and_then(|state| state.retrieval.as_ref()) + .is_none() + { + if let Some(loaded_thread) = loaded_thread.as_ref() { + Some(loaded_thread.epiphany_retrieval_state().await) + } else { + None + } + } else { + None + }; + + let response = ThreadEpiphanyJobsResponse { + thread_id, + source: if loaded { + ThreadEpiphanyJobsSource::Live + } else { + ThreadEpiphanyJobsSource::Stored + }, + state_revision: thread + .epiphany_state + .as_ref() + .map(|epiphany_state| epiphany_state.revision), + jobs: map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref()), + }; + self.outgoing.send_response(request_id, response).await; + } + async fn thread_epiphany_retrieve( &self, request_id: ConnectionRequestId, @@ -10604,6 +10677,7 @@ fn epiphany_scene_available_actions( ThreadEpiphanySceneAction::Index, ThreadEpiphanySceneAction::Retrieve, ThreadEpiphanySceneAction::Distill, + ThreadEpiphanySceneAction::Jobs, ThreadEpiphanySceneAction::Update, ]; if state_present { @@ -10657,6 +10731,249 @@ fn map_epiphany_scene_graph(state: &EpiphanyThreadState) -> ThreadEpiphanySceneG } } +fn map_epiphany_jobs( + state: Option<&EpiphanyThreadState>, + retrieval_override: Option<&EpiphanyRetrievalState>, +) -> Vec { + vec![ + map_epiphany_index_job(state, retrieval_override), + map_epiphany_remap_job(state), + map_epiphany_verification_job(state), + map_epiphany_specialist_job(), + ] +} + +fn map_epiphany_index_job( + state: Option<&EpiphanyThreadState>, + retrieval_override: Option<&EpiphanyRetrievalState>, +) -> ThreadEpiphanyJob { + let retrieval = state + .and_then(|state| state.retrieval.as_ref()) + .or(retrieval_override); + let linked_subgoal_ids = epiphany_active_subgoal_ids(state); + let linked_graph_node_ids = epiphany_active_graph_node_ids(state); + + let Some(retrieval) = retrieval else { + return ThreadEpiphanyJob { + id: "retrieval-index".to_string(), + kind: ThreadEpiphanyJobKind::Indexing, + scope: "workspace".to_string(), + owner_role: "epiphany-core".to_string(), + status: ThreadEpiphanyJobStatus::Unavailable, + items_processed: None, + items_total: None, + progress_note: None, + last_checkpoint_at_unix_seconds: None, + blocking_reason: Some("Retrieval state is unavailable for this thread.".to_string()), + linked_subgoal_ids, + linked_graph_node_ids, + }; + }; + + let dirty_path_count = retrieval.dirty_paths.len(); + let progress_note = match retrieval.status { + EpiphanyRetrievalStatus::Ready if dirty_path_count == 0 => { + "Retrieval catalog is ready.".to_string() + } + EpiphanyRetrievalStatus::Ready => { + format!("Retrieval catalog is ready with {dirty_path_count} dirty path(s) noted.") + } + EpiphanyRetrievalStatus::Stale => { + format!("Retrieval catalog is stale; {dirty_path_count} dirty path(s) need refresh.") + } + EpiphanyRetrievalStatus::Indexing => "Retrieval catalog is indexing.".to_string(), + EpiphanyRetrievalStatus::Unavailable => "Retrieval catalog is unavailable.".to_string(), + }; + + ThreadEpiphanyJob { + id: "retrieval-index".to_string(), + kind: ThreadEpiphanyJobKind::Indexing, + scope: retrieval.workspace_root.display().to_string(), + owner_role: "epiphany-core".to_string(), + status: epiphany_job_status_from_retrieval_status(retrieval.status), + items_processed: retrieval.indexed_file_count, + items_total: None, + progress_note: Some(progress_note), + last_checkpoint_at_unix_seconds: retrieval.last_indexed_at_unix_seconds, + blocking_reason: (retrieval.status == EpiphanyRetrievalStatus::Unavailable).then(|| { + "Indexing requires a readable workspace and configured retrieval backend.".to_string() + }), + linked_subgoal_ids, + linked_graph_node_ids, + } +} + +fn epiphany_job_status_from_retrieval_status( + status: EpiphanyRetrievalStatus, +) -> ThreadEpiphanyJobStatus { + match status { + EpiphanyRetrievalStatus::Ready => ThreadEpiphanyJobStatus::Idle, + EpiphanyRetrievalStatus::Stale => ThreadEpiphanyJobStatus::Needed, + EpiphanyRetrievalStatus::Indexing => ThreadEpiphanyJobStatus::Running, + EpiphanyRetrievalStatus::Unavailable => ThreadEpiphanyJobStatus::Unavailable, + } +} + +fn map_epiphany_remap_job(state: Option<&EpiphanyThreadState>) -> ThreadEpiphanyJob { + let Some(state) = state else { + return epiphany_blocked_state_job( + "graph-remap", + ThreadEpiphanyJobKind::Remap, + "architecture/dataflow graphs", + "Epiphany state is missing, so there is no graph to remap.", + ); + }; + + let frontier = state.graph_frontier.as_ref(); + let dirty_path_count = frontier + .map(|frontier| frontier.dirty_paths.len()) + .unwrap_or_default(); + let open_count = frontier + .map(|frontier| frontier.open_question_ids.len() + frontier.open_gap_ids.len()) + .unwrap_or_default(); + let graph_freshness = state + .churn + .as_ref() + .and_then(|churn| churn.graph_freshness.as_deref()); + let freshness_needs_work = graph_freshness + .is_some_and(|freshness| !matches!(freshness, "fresh" | "ready" | "current" | "ok")); + let needs_work = dirty_path_count > 0 || open_count > 0 || freshness_needs_work; + let progress_note = if needs_work { + format!( + "Graph frontier has {dirty_path_count} dirty path(s) and {open_count} open question/gap id(s)." + ) + } else { + "Graph frontier has no reflected remap pressure.".to_string() + }; + + ThreadEpiphanyJob { + id: "graph-remap".to_string(), + kind: ThreadEpiphanyJobKind::Remap, + scope: "architecture/dataflow graphs".to_string(), + owner_role: "epiphany-core".to_string(), + status: if needs_work { + ThreadEpiphanyJobStatus::Needed + } else { + ThreadEpiphanyJobStatus::Idle + }, + items_processed: None, + items_total: None, + progress_note: Some(progress_note), + last_checkpoint_at_unix_seconds: None, + blocking_reason: None, + linked_subgoal_ids: epiphany_active_subgoal_ids(Some(state)), + linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)), + } +} + +fn map_epiphany_verification_job(state: Option<&EpiphanyThreadState>) -> ThreadEpiphanyJob { + let Some(state) = state else { + return epiphany_blocked_state_job( + "verification", + ThreadEpiphanyJobKind::Verification, + "invariants/evidence", + "Epiphany state is missing, so there are no invariants to verify.", + ); + }; + + let total = state.invariants.len() as u32; + let verified = state + .invariants + .iter() + .filter(|invariant| epiphany_invariant_status_is_accepting(&invariant.status)) + .count() as u32; + let status = if total > 0 && verified < total { + ThreadEpiphanyJobStatus::Needed + } else { + ThreadEpiphanyJobStatus::Idle + }; + let progress_note = if total == 0 { + "No invariants are recorded yet.".to_string() + } else if verified == total { + format!("All {total} invariant(s) are currently accepting.") + } else { + format!("{verified} of {total} invariant(s) are currently accepting.") + }; + + ThreadEpiphanyJob { + id: "verification".to_string(), + kind: ThreadEpiphanyJobKind::Verification, + scope: "invariants/evidence".to_string(), + owner_role: "epiphany-harness".to_string(), + status, + items_processed: Some(verified), + items_total: Some(total), + progress_note: Some(progress_note), + last_checkpoint_at_unix_seconds: None, + blocking_reason: None, + linked_subgoal_ids: epiphany_active_subgoal_ids(Some(state)), + linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)), + } +} + +fn map_epiphany_specialist_job() -> ThreadEpiphanyJob { + ThreadEpiphanyJob { + id: "specialist-work".to_string(), + kind: ThreadEpiphanyJobKind::Specialist, + scope: "role-scoped specialist work".to_string(), + owner_role: "epiphany-harness".to_string(), + status: ThreadEpiphanyJobStatus::Unavailable, + items_processed: None, + items_total: None, + progress_note: None, + last_checkpoint_at_unix_seconds: None, + blocking_reason: Some( + "Specialist scheduling is not landed; this slot prevents clients from inventing private scheduler state." + .to_string(), + ), + linked_subgoal_ids: Vec::new(), + linked_graph_node_ids: Vec::new(), + } +} + +fn epiphany_blocked_state_job( + id: &str, + kind: ThreadEpiphanyJobKind, + scope: &str, + blocking_reason: &str, +) -> ThreadEpiphanyJob { + ThreadEpiphanyJob { + id: id.to_string(), + kind, + scope: scope.to_string(), + owner_role: "epiphany-harness".to_string(), + status: ThreadEpiphanyJobStatus::Blocked, + items_processed: None, + items_total: None, + progress_note: None, + last_checkpoint_at_unix_seconds: None, + blocking_reason: Some(blocking_reason.to_string()), + linked_subgoal_ids: Vec::new(), + linked_graph_node_ids: Vec::new(), + } +} + +fn epiphany_active_subgoal_ids(state: Option<&EpiphanyThreadState>) -> Vec { + state + .and_then(|state| state.active_subgoal_id.clone()) + .map(|id| vec![id]) + .unwrap_or_default() +} + +fn epiphany_active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec { + state + .and_then(|state| state.graph_frontier.as_ref()) + .map(|frontier| frontier.active_node_ids.clone()) + .unwrap_or_default() +} + +fn epiphany_invariant_status_is_accepting(status: &str) -> bool { + matches!( + status, + "ok" | "ready" | "accepted" | "verified" | "pass" | "passed" + ) +} + fn status_counts<'a>( statuses: impl Iterator, ) -> Vec { @@ -12209,6 +12526,7 @@ mod tests { ThreadEpiphanySceneAction::Index, ThreadEpiphanySceneAction::Retrieve, ThreadEpiphanySceneAction::Distill, + ThreadEpiphanySceneAction::Jobs, ThreadEpiphanySceneAction::Update, ThreadEpiphanySceneAction::Propose, ThreadEpiphanySceneAction::Promote, @@ -12274,6 +12592,92 @@ mod tests { assert_eq!(evidence_ids, vec!["ev-6", "ev-5", "ev-4", "ev-3", "ev-2"]); } + #[test] + fn map_epiphany_jobs_reflects_current_progress_without_scheduling_work() { + let state = codex_protocol::protocol::EpiphanyThreadState { + active_subgoal_id: Some("phase-6".to_string()), + invariants: vec![ + codex_protocol::protocol::EpiphanyInvariant { + id: "inv-ready".to_string(), + description: "State reads are read-only".to_string(), + status: "ok".to_string(), + rationale: None, + }, + codex_protocol::protocol::EpiphanyInvariant { + id: "inv-review".to_string(), + description: "Job state needs review".to_string(), + status: "needs_review".to_string(), + rationale: None, + }, + ], + graph_frontier: Some(codex_protocol::protocol::EpiphanyGraphFrontier { + active_node_ids: vec!["retrieval".to_string()], + active_edge_ids: Vec::new(), + open_question_ids: vec!["q-jobs".to_string()], + open_gap_ids: Vec::new(), + dirty_paths: vec![PathBuf::from("notes/jobs.md")], + }), + retrieval: Some(codex_protocol::protocol::EpiphanyRetrievalState { + workspace_root: test_path_buf("/repo"), + status: codex_protocol::protocol::EpiphanyRetrievalStatus::Stale, + indexed_file_count: Some(12), + indexed_chunk_count: Some(34), + last_indexed_at_unix_seconds: Some(1_744_500_100), + dirty_paths: vec![PathBuf::from("src/lib.rs")], + ..Default::default() + }), + churn: Some(codex_protocol::protocol::EpiphanyChurnState { + graph_freshness: Some("stale".to_string()), + ..Default::default() + }), + ..Default::default() + }; + + let jobs = map_epiphany_jobs(Some(&state), None); + + assert_eq!(jobs.len(), 4); + assert_eq!(jobs[0].id, "retrieval-index"); + assert_eq!(jobs[0].kind, ThreadEpiphanyJobKind::Indexing); + assert_eq!(jobs[0].status, ThreadEpiphanyJobStatus::Needed); + assert_eq!(jobs[0].items_processed, Some(12)); + assert_eq!(jobs[0].last_checkpoint_at_unix_seconds, Some(1_744_500_100)); + assert_eq!(jobs[0].linked_subgoal_ids, vec!["phase-6".to_string()]); + assert_eq!(jobs[0].linked_graph_node_ids, vec!["retrieval".to_string()]); + + assert_eq!(jobs[1].id, "graph-remap"); + assert_eq!(jobs[1].kind, ThreadEpiphanyJobKind::Remap); + assert_eq!(jobs[1].status, ThreadEpiphanyJobStatus::Needed); + assert_eq!(jobs[1].linked_graph_node_ids, vec!["retrieval".to_string()]); + + assert_eq!(jobs[2].id, "verification"); + assert_eq!(jobs[2].kind, ThreadEpiphanyJobKind::Verification); + assert_eq!(jobs[2].status, ThreadEpiphanyJobStatus::Needed); + assert_eq!(jobs[2].items_processed, Some(1)); + assert_eq!(jobs[2].items_total, Some(2)); + + assert_eq!(jobs[3].id, "specialist-work"); + assert_eq!(jobs[3].kind, ThreadEpiphanyJobKind::Specialist); + assert_eq!(jobs[3].status, ThreadEpiphanyJobStatus::Unavailable); + assert!(jobs[3].blocking_reason.is_some()); + } + + #[test] + fn map_epiphany_jobs_can_reflect_retrieval_without_epiphany_state() { + let retrieval = codex_protocol::protocol::EpiphanyRetrievalState { + workspace_root: test_path_buf("/repo"), + status: codex_protocol::protocol::EpiphanyRetrievalStatus::Ready, + indexed_file_count: Some(7), + ..Default::default() + }; + + let jobs = map_epiphany_jobs(None, Some(&retrieval)); + + assert_eq!(jobs[0].status, ThreadEpiphanyJobStatus::Idle); + assert_eq!(jobs[0].items_processed, Some(7)); + assert_eq!(jobs[1].status, ThreadEpiphanyJobStatus::Blocked); + assert_eq!(jobs[2].status, ThreadEpiphanyJobStatus::Blocked); + } + #[test] fn epiphany_update_patch_changed_fields_reports_patch_surface() { let fields = epiphany_update_patch_changed_fields(&ThreadEpiphanyUpdatePatch {