diff --git a/notes/codex-starvation-and-cultnet-liberation-plan.md b/notes/codex-starvation-and-cultnet-liberation-plan.md index b91e9f2a..82d1013b 100644 --- a/notes/codex-starvation-and-cultnet-liberation-plan.md +++ b/notes/codex-starvation-and-cultnet-liberation-plan.md @@ -290,6 +290,11 @@ Stop and redesign if a proposed change: ## First Slice +This inventory slice is complete. The live implementation cut is defined in +`notes/native-coordinator-liberation-map.md`: remove Codex JSON-RPC from the +native coordinator control loop, then leave the old endpoints as delegating +compatibility wrappers only. + Do not start by cutting random code. Map first. First concrete slice: diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 89599c5b..be51b2af 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -633,6 +633,13 @@ that change what the next agent should believe. Do not continue implementation automatically from a rehydrate-only request. +The source-grounded cut map for the current Codex-starvation incision is +`notes/native-coordinator-liberation-map.md`. The highest-leverage surviving +ownership fault is that `epiphany-mvp-coordinator` still uses +`thread/epiphany/*` JSON-RPC for state, views, specialist launch/result/accept, +and recovery. Migrate that whole control loop to one native typed service; do +not add a parallel native state path or a native/compatibility mode flag. + Bridge identity correction from 2026-06-22: Epiphany owns swarm execution, repo Body work, branch-local lanes, memory, evidence, and Persona cognition. Bifrost owns GameCult identity, governed crossings into GitHub/Discord/Reddit diff --git a/notes/native-coordinator-liberation-map.md b/notes/native-coordinator-liberation-map.md new file mode 100644 index 00000000..7cba7c04 --- /dev/null +++ b/notes/native-coordinator-liberation-map.md @@ -0,0 +1,156 @@ +# Native Coordinator Liberation Map + +## Objective + +Make `epiphany-mvp-coordinator` an Epiphany-native control loop. It must read +and mutate typed Epiphany state, launch and inspect runtime work, and accept or +refuse findings without sending `thread/epiphany/*` JSON-RPC requests through +Codex. + +Codex remains the OpenAI authentication/model-transport bridge and may retain +legacy app-server wrappers for named Codex clients. It is not the coordinator's +nervous system. + +## Current Mechanism + +The coordinator is compiled from +`epiphany-core/src/bin/epiphany-mvp-coordinator.rs`, but starts a Codex app-server +process and uses `status_cli::AppServerClient` for the authoritative loop: + +- state bootstrap and revision writes use `thread/epiphany/update` +- freshness and coordinator projections use `thread/epiphany/freshness` and + `thread/epiphany/view` +- specialist lifecycle uses `thread/epiphany/roleLaunch`, + `thread/epiphany/roleResult`, and `thread/epiphany/roleAccept` +- recovery lifecycle uses `thread/epiphany/reorientLaunch` and + `thread/epiphany/reorientResult` + +The typed machinery already exists below that shell: + +- `epiphany-core/src/thread_state_store.rs` owns CultCache-backed typed thread + state persistence. +- `epiphany-core/src/runtime_spine.rs` owns typed job, launch, result, event, and + receipt persistence. +- `epiphany-core/src/agent_launch.rs` builds typed role and reorientation launch + documents. +- `epiphany-core/src/surfaces/role_result.rs` interprets typed findings and + constructs acceptance bundles. +- `epiphany-core/src/mind_gateway.rs`, `hands_gateway.rs`, and the receipt proof + machinery own admission, action, and verification contracts. +- `epiphany-codex-bridge/src/mutation_service.rs` currently composes much of + this policy behind an `EpiphanyMutationHost`, but its host contract still + assumes a Codex-hosted compatibility snapshot and persistence hook. +- `vendor/codex/codex-rs/app-server/src/codex_message_processor/ + epiphany_mutation_routes.rs` is already mostly a transport shell over that + bridge service. It should become a compatibility caller of the native owner, + not the place where the owner remains hosted. + +## Authority Map + +### Owner + +One Epiphany-native coordinator service owns the control decision and delegates +typed persistence to the thread-state store and runtime-spine. + +### Inputs + +- typed operator/coordinator intent +- CultCache-backed `EpiphanyThreadState` +- runtime-spine job, result, and receipt documents +- typed watcher, retrieval, token-pressure, and dynamic prompt context +- model events returned by the model-transport adapter + +### Outputs + +- revision-gated typed state updates +- typed runtime launch and interrupt receipts +- typed role/reorientation findings +- Mind review and state-commit receipts +- read-only typed coordinator, freshness, role, and recovery projections + +### Derived State + +JSON-RPC responses, app-server notifications, Aquarium panels, CLI JSON, TUI +rows, CultMesh mirrors, and operator summaries are projections. They do not own +lifecycle, scheduling, acceptance, prompt doctrine, or durable truth. + +### Forbidden Writers + +- `codex_message_processor.rs` and its route modules +- Codex thread/session prompt machinery +- JSON-RPC request/response types +- GUI/Aquarium clients +- CultMesh mirrors and status snapshots +- watcher or reorientation verdicts +- raw model or MCP JSON + +Each may submit or translate a typed intent. None may preserve an independent +decision after the native owner responds. + +### Shared Paths + +Manual CLI actions, programmatic coordinator turns, heartbeat scheduling, +Aquarium actions, and legacy Codex JSON-RPC calls must use the same native +operations for: + +1. state read/update +2. freshness and coordinator derivation +3. role/reorientation launch +4. result readback +5. accept/refuse +6. interrupt + +### Deletion Line + +Delete `status_cli::AppServerClient` from the coordinator control path. Delete +its direct `thread/epiphany/*` request construction. After the native loop is +proved, reduce Codex mutation routes to protocol parsing, native service calls, +response mapping, and compatibility notifications. Then remove bridge policy +that exists only to compensate for Codex-hosted state. + +## Migration Order + +This is one vertical ownership migration, landed in buildable cuts. No cut may +introduce a second authoritative store or a native/JSON-RPC mode flag. + +1. Move route-independent mutation/launch/accept orchestration out of + `epiphany-codex-bridge` into an Epiphany-native service whose host ports are + typed state persistence, runtime-spine, clock, and context inputs. Preserve + the existing bridge service as a thin delegating compatibility wrapper. +2. Add native read operations for state, freshness, coordinator/role views, and + typed result readback over the same stores used by mutation operations. +3. Rewire `epiphany-mvp-coordinator` to the native service and remove + `AppServerClient` plus every `thread/epiphany/*` request from the binary. +4. Prove bootstrap, manual/programmatic launch, pending/completed result, + acceptance, refusal, interruption, and recovery against native stores. +5. Make Codex JSON-RPC routes delegate to the same service. Remove duplicated + route/bridge policy and mapper-only tests that no longer protect a boundary. + +## Invariants + +- There is one durable thread-state owner and one runtime lifecycle owner. +- Revision validation is identical for CLI, coordinator, heartbeat, Aquarium, + and compatibility JSON-RPC callers. +- A view or watcher verdict cannot launch or accept work. +- Raw JSON is parsed once at a hostile edge and does not cross native service + ports. +- Model transport cannot inject organ doctrine, scheduler decisions, or state + mutation policy. +- Compatibility wrappers cannot override or repair the native result after the + fact. + +## Verification Layer + +The proof must observe the stores and receipts where the invariant lives: + +- unit tests for each native operation with injected state store, runtime + store, clock, and context inputs +- adjacent-operation smokes for launch -> result -> review -> state commit +- a native coordinator smoke with no app-server binary available +- a compatibility smoke proving JSON-RPC delegates to the same native result +- negative tests proving Codex routes cannot write around revision/admission + gates and the coordinator binary contains no `thread/epiphany/*` methods + +The migration is not complete because the coordinator eventually converges on +the same state after an app-server round trip. The old path must be structurally +unable to decide the result. diff --git a/state/map.yaml b/state/map.yaml index 5b86bef1..719bd18d 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -659,4 +659,12 @@ current_status: - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. Gjallar readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Continue repo-swarm MVP work from `notes/epiphany-repo-swarm-mvp-contract.md`. Huginn is now live-fire proven through branch-local closure, the operator wrapper `repo-livefire-closure`, and redacted public-proof export/readback, and is awaiting Bifrost publication/upstream-main sync; do not push, publish, merge, or sync that branch without explicit Bifrost/maintainer authority. Useful next cuts are Bifrost publication proof for Huginn's closed item using the existing redacted public proof, controlled upstream sync only after publication authority, explicit elevated/operator Idunn execution proof only when the human grants that authority, or another repo-owned safe action family only if it materially improves the MVP story. Persona-to-Imagination consensus readback, Mind-owned interpreter brief cargo, safe-family planning depth and closure, Gjallar closure/readiness/readiness-review/public-proof rows, receipt-directory readiness-review indexing, Bifrost ledger accounting rows including readiness-review closure plus artifact/metrics final receipt closure, readiness wrapper mouth, repo deployment handoff/readback wrappers, readiness deployment-aftercare closure, readiness Idunn/tool-directory receipt validation, readiness Bifrost/GitHub publication-chain validation, readiness upstream-main sync validation, readiness review/adoption receipt validation, aggregate fresh-repo/readiness/Bifrost/deployment-handoff/daemon-survival/Weksa/Persona two-pass memory MVP gate reporting, bounded Idunn daemon survival rehearsal, Huginn live-fire branch-local closure, Huginn closure wrapper mouth, Huginn redacted public-proof export/readback, and Bifrost public-proof wrapper authority-label/summary hardening are sealed; preserve Idunn service lifecycle ownership, Bifrost publication/upstream-main ownership, Mind durable-state admission, and existing CultMesh/Odin/Eve tool directories. Windows service install/start/deployment execution still requires explicit elevated operator authority. + next_action: > + Execute the native coordinator liberation map in + `notes/native-coordinator-liberation-map.md`. Move route-independent + mutation, launch, result, acceptance, and view orchestration behind one + Epiphany-native typed service; rewire `epiphany-mvp-coordinator` to that + owner; then demote `thread/epiphany/*` JSON-RPC routes to delegating Codex + compatibility wrappers. Do not introduce a parallel state owner, a + native/compatibility mode flag, or new outward bridge work before this + control-loop authority is cut from Codex.