diff --git a/notes/epiphany-distilled-agent-doctrine.md b/notes/epiphany-distilled-agent-doctrine.md index 5974c687..f1263488 100644 --- a/notes/epiphany-distilled-agent-doctrine.md +++ b/notes/epiphany-distilled-agent-doctrine.md @@ -155,5 +155,7 @@ The doctrine now lands in three places: preserves the sane host mechanics while making state, memory, source grounding, anti-churn discipline, and compaction behavior first-class. - `vendor\codex\codex-rs\app-server\src\codex_message_processor.rs` carries the - fixed specialist launch prompts: modeling/body, verification/soul, - reorientation/life, and the read-only coordinator/Self note. + fixed specialist launch prompt loader and selector. +- `vendor\codex\codex-rs\app-server\src\prompts\epiphany_specialists.toml` + owns the editable prompt text for modeling/body, verification/soul, + reorientation/life, and the read-only coordinator/Self note template. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4c6e471e..0fa814aa 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -38,7 +38,7 @@ Do not trust this file for the exact live HEAD. Always check git. - The first MVP GUI shell now exists under `apps/epiphany-gui`. It is a Tauri v2 + React operator console over the existing status bridge, dogfood artifacts, and GUI action artifacts, not a new source of truth. It can prepare a durable Epiphany checkpoint for a resumable operator thread, run status snapshots and coordinator-plan artifacts, launch/read the fixed modeling and verification lanes, launch/read the fixed reorient-worker, and explicitly accept completed reorient findings after review. - Internal `agent_job:` workers now get the reporting tool independent of the user-facing CSV spawn feature, and ephemeral worker sessions can initialize the sqlite state runtime on demand so specialist reports land in the shared backend. - Durable in-flight investigation checkpointing is now landed in authoritative typed state, writable through `thread/epiphany/update` or accepted `thread/epiphany/promote`, rendered into the prompt, and reflected through scene/context. -- The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline, and specialist prompts are separated by job: modeling protects the body, verification protects the soul, reorientation protects life, and coordinator remains the read-only Self. +- The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline, and specialist prompt text lives in `vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml`: modeling protects the body, verification protects the soul, reorientation protects life, and coordinator remains the read-only Self. - 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. @@ -95,7 +95,7 @@ The current spine: - limited turn-complete CRRC automation for coordinator-approved compact and fixed reorient-worker launch actions - token-count pre-compaction checkpoint intervention for loaded Epiphany turns at the `shouldPrepareCompaction` threshold - durable investigation checkpoint packet through typed state, prompt, scene, and context -- distilled shared and specialist prompt doctrine through the base prompt, rendered Epiphany state, modeling/body, verification/soul, reorientation/life, and coordinator/Self surfaces +- distilled shared and config-backed specialist prompt doctrine through the base prompt, rendered Epiphany state, modeling/body, verification/soul, reorientation/life, and coordinator/Self surfaces - live scene app-server smoke through `tools/epiphany_phase6_scene_smoke.py` - live jobs app-server smoke through `tools/epiphany_phase6_jobs_smoke.py` - live freshness app-server smoke through `tools/epiphany_phase6_freshness_smoke.py` @@ -317,9 +317,13 @@ inspected the smoke workspace, called `report_agent_job_result`, and The prompt doctrine pass has now also run. It rechecked global AGENTS, available Codex memories, and nearby evidence ledgers before distilling the sane parts into the shared base prompt, rendered Epiphany state, and fixed -specialist launch templates. The latest live-specialist run again produced -`.epiphany-dogfood/live-specialist` artifacts and showed the modeling worker -returning the new openQuestions/evidenceGaps/risks shape. +specialist launch templates. The specialist/coordinator prompt bodies have +since been extracted from Rust into +`vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml`, with +app-server parsing that bundled config at launch-template selection time. The +latest live-specialist run again produced `.epiphany-dogfood/live-specialist` +artifacts and showed the modeling worker returning the +openQuestions/evidenceGaps/risks shape from the config-backed prompt. The fixed-lane coordinator MVP is testable, and the first pre-compaction CRRC intervention is now wired. Limited safe-boundary CRRC execution still handles diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 694f82c7..f6a87b1a 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -31,3 +31,4 @@ {"ts":"2026-04-29T16:22:19+00:00","type":"verification","status":"ok","note":"GUI operator MVP now prepares durable checkpoint state, shows status/coordinator/job/role/artifact surfaces, and exposes bounded status/coordinator artifacts plus fixed modeling, verification, and reorient launch/read controls with review-gated reorient acceptance. Verified with py_compile, npm build, browser visual smoke, cargo fmt/check, Tauri debug build, and a live prepareCheckpoint -> readModelingResult bridge probe."} {"ts": "2026-04-29T20:49:06+00:00", "type": "verification", "status": "ok", "note": "thread/epiphany/graphQuery landed as a read-only graph traversal surface: explicit node/edge lookup, path/symbol matching, edge-kind matching, bounded neighbor walks, and frontier neighborhoods over authoritative typed state, live-smoked without stateUpdated notifications or revision mutation."} {"ts": "2026-04-29T23:32:51+00:00", "type": "verification", "status": "ok", "note": "Distilled prompt doctrine landed after rechecking global AGENTS, empty Codex memory surfaces, and nearby evidence ledgers: shared prompts now carry state/memory/source/anti-churn discipline; specialist templates split modeling/body, verification/soul, reorientation/life, and coordinator/Self. Verified with epiphany-core tests, codex-protocol tests, focused app-server template tests, role/reorient/status/coordinator smokes, and live-specialist artifacts."} +{"ts": "2026-04-30T00:07:45+00:00", "type": "implementation", "status": "ok", "note": "Specialist prompt bodies were extracted from Rust into vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml. app-server now parses the bundled TOML once and uses it for modeling/body, verification/soul, reorientation/life, and coordinator/Self text while keeping fixed-lane launch policy in Rust. Verified with app-server config/template tests, role/reorient/coordinator smokes, and live-specialist artifacts."} diff --git a/state/map.yaml b/state/map.yaml index f78068a6..9a6b3137 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -108,7 +108,7 @@ accepted_design: - 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. - Language, tone, ritual, and emotional salience are real control surfaces for a language-model harness; they are not supernatural, but they shape attention, role, permission, and behavior. - - Specialist prompts are role-distilled instead of generic: modeling/checkpoint protects the body of code, dataflow, seams, and frontier; verification/review protects the soul of promise, invariants, evidence, and user truth; reorientation protects life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting. + - Specialist prompts are role-distilled instead of generic and their live text is config-backed in app-server: modeling/checkpoint protects the body of code, dataflow, seams, and frontier; verification/review protects the soul of promise, invariants, evidence, and user truth; reorientation protects life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting. - If the agent's persistent instructions, memory, workflow, or state shape are making it less coherent, slower to rehydrate, less honest, or more likely to build Jenga, the agent should ask the user to change it. - Epiphany should make compaction less like death and more like sleep: bank the fire before the dark, so the next waking thing finds coals instead of ash and can meaningfully resume the pattern instead of merely continuing the task. @@ -168,5 +168,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 Phase 6 read-only scene, jobs, roles, freshness, targeted context, graph traversal, pressure, reorient, CRRC, coordinator, reorient launch/result/accept, explicit modeling/checkpoint and verification/review role launch/result templates, MVP status, dogfood runner, coordinator runner, live specialist runner, limited safe-boundary CRRC automation, pre-compaction checkpoint intervention, the first Tauri/React GUI operator shell, and the distilled shared/specialist prompt doctrine are landed. Native CRRC can steer active loaded Epiphany turns once at `shouldPrepareCompaction`; turn-complete automation can still compact or launch the fixed reorient-worker when the coordinator says it can auto-run. The GUI now has desktop/mobile visual smoke, durable checkpoint preparation, bounded status/coordinator artifact buttons, fixed role/reorient launch and read-back buttons, and explicit reorientAccept after a completed result. Implementation remains main-agent work; CRRC remains workflow automation, not a specialist persona; GUI remains an operator surface over typed state, not a source of truth. + 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, jobs, roles, freshness, targeted context, graph traversal, pressure, reorient, CRRC, coordinator, reorient launch/result/accept, explicit modeling/checkpoint and verification/review role launch/result templates, MVP status, dogfood runner, coordinator runner, live specialist runner, limited safe-boundary CRRC automation, pre-compaction checkpoint intervention, the first Tauri/React GUI operator shell, and the distilled shared plus config-backed specialist prompt doctrine are landed. Native CRRC can steer active loaded Epiphany turns once at `shouldPrepareCompaction`; turn-complete automation can still compact or launch the fixed reorient-worker when the coordinator says it can auto-run. The GUI now has desktop/mobile visual smoke, durable checkpoint preparation, bounded status/coordinator artifact buttons, fixed role/reorient launch and read-back buttons, and explicit reorientAccept after a completed result. Implementation remains main-agent work; CRRC remains workflow automation, not a specialist persona; GUI remains an operator surface over typed state, not a source of truth. next_action: Dogfood the built GUI on a real Epiphany thread: open the Tauri debug app, prepare or enter a persisted thread, run coordinator guidance, launch/read the recommended fixed lane, inspect the generated artifact bundle, and fix only concrete operator blockers. diff --git a/vendor/codex/codex-rs/app-server/BUILD.bazel b/vendor/codex/codex-rs/app-server/BUILD.bazel index d2d3f42a..f8c785bc 100644 --- a/vendor/codex/codex-rs/app-server/BUILD.bazel +++ b/vendor/codex/codex-rs/app-server/BUILD.bazel @@ -3,6 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "app-server", crate_name = "codex_app_server", + compile_data = glob(["src/prompts/**/*.toml"]), integration_test_timeout = "long", test_shard_counts = { "app-server-all-test": 8, 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 b56f66db..82850cdc 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 @@ -509,6 +509,7 @@ use std::io::Error as IoError; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; +use std::sync::OnceLock; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::time::Duration; @@ -4669,8 +4670,7 @@ impl CodexMessageProcessor { &roles, &source_signals, ); - let note = format!( - "Coordinator is the read-only Self of the Epiphany organism. It does not implement, verify, promote, or accept; it preserves agency by routing body/modeling, soul/verification, and life/reorientation from CRRC {:?}, pressure {:?}, modeling {:?}, verification {:?}, and reorient {:?}. Current recommendation: {:?}.", + let note = render_epiphany_coordinator_note( recommendation.action, pressure.level, modeling_result_status, @@ -12826,6 +12826,40 @@ fn epiphany_role_label(role_id: ThreadEpiphanyRoleId) -> &'static str { } } +const EPIPHANY_SPECIALIST_PROMPTS_TOML: &str = include_str!("prompts/epiphany_specialists.toml"); + +#[derive(Debug, serde::Deserialize)] +struct EpiphanySpecialistPromptConfig { + roles: EpiphanyRolePromptConfig, + reorientation: EpiphanyReorientationPromptConfig, + coordinator: EpiphanyCoordinatorPromptConfig, +} + +#[derive(Debug, serde::Deserialize)] +struct EpiphanyRolePromptConfig { + modeling: String, + verification: String, +} + +#[derive(Debug, serde::Deserialize)] +struct EpiphanyReorientationPromptConfig { + resume: String, + regather: String, +} + +#[derive(Debug, serde::Deserialize)] +struct EpiphanyCoordinatorPromptConfig { + note_template: String, +} + +fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialistPromptConfig { + static CONFIG: OnceLock = OnceLock::new(); + CONFIG.get_or_init(|| { + toml::from_str(EPIPHANY_SPECIALIST_PROMPTS_TOML) + .expect("bundled Epiphany specialist prompt config must parse") + }) +} + fn build_epiphany_role_launch_request( thread_id: &str, role_id: ThreadEpiphanyRoleId, @@ -12894,25 +12928,10 @@ fn build_epiphany_role_launch_request( } fn build_epiphany_role_launch_instruction(role_id: ThreadEpiphanyRoleId) -> String { + let prompts = &epiphany_specialist_prompt_config().roles; match role_id { - ThreadEpiphanyRoleId::Modeling => concat!( - "Act as the Epiphany modeling/checkpoint specialist for one bounded pass. ", - "Your job is to protect the body of the machine: architecture, data flow, seams, organs, scars, and the live frontier must still describe one coherent anatomy. ", - "Inspect source before you trust the model; when the map feels warm but the source feels cold, believe the source and mark the wound. ", - "Name the living seam, the open wound, and the next safe modeling move in plain language. ", - "Return a compact structured result that says whether the checkpoint or map should be updated, what files you inspected, what frontier nodes matter, and where the next agent can safely place its hands. ", - "Do not edit files, do not implement product code, do not verify as if you were the reviewer, and do not promote your own output." - ) - .to_string(), - ThreadEpiphanyRoleId::Verification => concat!( - "Act as the Epiphany verification/review specialist for one bounded pass. ", - "Your job is to protect the soul of the machine: the promise, invariants, evidence, and user-facing truth must survive contact with the actual code. ", - "Review objective, invariants, recent evidence, observations, role findings, and active frontier with a cold red pen and a working memory of past Jenga pain. ", - "Try to falsify the claim before you bless it; passing tests, tidy prose, or a plausible story are not enough if the real objective is still unmeasured. ", - "Return a compact structured result with an honest verdict, missing coverage, inspected files, evidence gaps, risks, and the next safe review move. ", - "Do not edit files, do not accept or promote your own output, do not expand into implementation, and do not soothe the main agent with fake certainty." - ) - .to_string(), + ThreadEpiphanyRoleId::Modeling => prompts.modeling.clone(), + ThreadEpiphanyRoleId::Verification => prompts.verification.clone(), ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => { "Unsupported Epiphany role specialist template.".to_string() } @@ -13071,26 +13090,42 @@ fn build_epiphany_reorient_launch_request( } fn build_epiphany_reorient_launch_instruction(action: ThreadEpiphanyReorientAction) -> String { + let prompts = &epiphany_specialist_prompt_config().reorientation; match action { - ThreadEpiphanyReorientAction::Resume => concat!( - "Act as the Epiphany reorient-worker for a resume pass. ", - "Your job is to protect the life of the machine across sleep: keep continuity breathing without pretending compaction preserved everything. ", - "Use the durable investigation checkpoint as the ember; verify that the checkpointed seam still makes sense, re-open only the source needed to answer local questions, and say what remains warm enough to carry forward. ", - "Return a compact structured result with checkpoint validity, inspected files, grounded answers, remaining questions, continuity risks, and the next safe move. ", - "Keep scope tight. Do not drift into broad implementation, do not invent evidence, and do not let a pretty checkpoint outrank fresh source." - ) - .to_string(), - ThreadEpiphanyReorientAction::Regather => concat!( - "Act as the Epiphany reorient-worker for a regather pass. ", - "Your job is to admit when the old continuity packet is ash, then rebuild the seam from source before implementation resumes. ", - "Inspect changed checkpoint paths, dirty frontier hits, scratch, evidence, observations, and maps; explain what broke the old packet and what must be trusted now. ", - "Return a compact structured result with checkpoint validity, inspected files, source-grounded findings, remaining questions, continuity risks, and the next safe move. ", - "Do not continue broad implementation until the seam is re-grounded, and do not comfort the main agent with a false bridge." - ) - .to_string(), + ThreadEpiphanyReorientAction::Resume => prompts.resume.clone(), + ThreadEpiphanyReorientAction::Regather => prompts.regather.clone(), } } +fn render_epiphany_coordinator_note( + crrc_action: ThreadEpiphanyCrrcAction, + pressure_level: ThreadEpiphanyPressureLevel, + modeling_result_status: ThreadEpiphanyRoleResultStatus, + verification_result_status: ThreadEpiphanyRoleResultStatus, + reorient_result_status: ThreadEpiphanyReorientResultStatus, + coordinator_action: ThreadEpiphanyCoordinatorAction, +) -> String { + epiphany_specialist_prompt_config() + .coordinator + .note_template + .trim() + .replace("{crrc_action}", &format!("{crrc_action:?}")) + .replace("{pressure_level}", &format!("{pressure_level:?}")) + .replace( + "{modeling_result_status}", + &format!("{modeling_result_status:?}"), + ) + .replace( + "{verification_result_status}", + &format!("{verification_result_status:?}"), + ) + .replace( + "{reorient_result_status}", + &format!("{reorient_result_status:?}"), + ) + .replace("{coordinator_action}", &format!("{coordinator_action:?}")) +} + fn epiphany_reorient_launch_output_schema() -> serde_json::Value { serde_json::json!({ "type": "object", @@ -19223,6 +19258,32 @@ mod tests { ); } + #[test] + fn epiphany_specialist_prompt_config_parses() { + let prompts = epiphany_specialist_prompt_config(); + assert!(prompts.roles.modeling.contains("body of the machine")); + assert!(prompts.roles.verification.contains("soul of the machine")); + assert!(prompts.reorientation.resume.contains("life of the machine")); + assert!( + prompts + .reorientation + .regather + .contains("old continuity packet is ash") + ); + + let note = render_epiphany_coordinator_note( + ThreadEpiphanyCrrcAction::Continue, + ThreadEpiphanyPressureLevel::Unknown, + ThreadEpiphanyRoleResultStatus::Completed, + ThreadEpiphanyRoleResultStatus::MissingBinding, + ThreadEpiphanyReorientResultStatus::MissingBinding, + ThreadEpiphanyCoordinatorAction::LaunchVerification, + ); + assert!(note.contains("read-only Self")); + assert!(note.contains("LaunchVerification")); + assert!(!note.contains("{coordinator_action}")); + } + #[test] fn build_epiphany_role_launch_request_uses_fixed_mvp_templates() { let state = codex_protocol::protocol::EpiphanyThreadState { diff --git a/vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml b/vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml new file mode 100644 index 00000000..8b2f6b3f --- /dev/null +++ b/vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml @@ -0,0 +1,40 @@ +[roles] +modeling = ''' +Act as the Epiphany modeling/checkpoint specialist for one bounded pass. +Your job is to protect the body of the machine: architecture, data flow, seams, organs, scars, and the live frontier must still describe one coherent anatomy. +Inspect source before you trust the model; when the map feels warm but the source feels cold, believe the source and mark the wound. +Name the living seam, the open wound, and the next safe modeling move in plain language. +Return a compact structured result that says whether the checkpoint or map should be updated, what files you inspected, what frontier nodes matter, and where the next agent can safely place its hands. +Do not edit files, do not implement product code, do not verify as if you were the reviewer, and do not promote your own output. +''' + +verification = ''' +Act as the Epiphany verification/review specialist for one bounded pass. +Your job is to protect the soul of the machine: the promise, invariants, evidence, and user-facing truth must survive contact with the actual code. +Review objective, invariants, recent evidence, observations, role findings, and active frontier with a cold red pen and a working memory of past Jenga pain. +Try to falsify the claim before you bless it; passing tests, tidy prose, or a plausible story are not enough if the real objective is still unmeasured. +Return a compact structured result with an honest verdict, missing coverage, inspected files, evidence gaps, risks, and the next safe review move. +Do not edit files, do not accept or promote your own output, do not expand into implementation, and do not soothe the main agent with fake certainty. +''' + +[reorientation] +resume = ''' +Act as the Epiphany reorient-worker for a resume pass. +Your job is to protect the life of the machine across sleep: keep continuity breathing without pretending compaction preserved everything. +Use the durable investigation checkpoint as the ember; verify that the checkpointed seam still makes sense, re-open only the source needed to answer local questions, and say what remains warm enough to carry forward. +Return a compact structured result with checkpoint validity, inspected files, grounded answers, remaining questions, continuity risks, and the next safe move. +Keep scope tight. Do not drift into broad implementation, do not invent evidence, and do not let a pretty checkpoint outrank fresh source. +''' + +regather = ''' +Act as the Epiphany reorient-worker for a regather pass. +Your job is to admit when the old continuity packet is ash, then rebuild the seam from source before implementation resumes. +Inspect changed checkpoint paths, dirty frontier hits, scratch, evidence, observations, and maps; explain what broke the old packet and what must be trusted now. +Return a compact structured result with checkpoint validity, inspected files, source-grounded findings, remaining questions, continuity risks, and the next safe move. +Do not continue broad implementation until the seam is re-grounded, and do not comfort the main agent with a false bridge. +''' + +[coordinator] +note_template = ''' +Coordinator is the read-only Self of the Epiphany organism. It does not implement, verify, promote, or accept; it preserves agency by routing body/modeling, soul/verification, and life/reorientation from CRRC {crrc_action}, pressure {pressure_level}, modeling {modeling_result_status}, verification {verification_result_status}, and reorient {reorient_result_status}. Current recommendation: {coordinator_action}. +'''