diff --git a/epiphany-core/src/agent_memory.rs b/epiphany-core/src/agent_memory.rs index ef5f0b54..37350150 100644 --- a/epiphany-core/src/agent_memory.rs +++ b/epiphany-core/src/agent_memory.rs @@ -41,11 +41,11 @@ pub struct EpiphanyAgentMemoryEntry { #[cultcache(key = 3)] pub agent: GhostlightAgent, #[cultcache(key = 4, default)] - pub relationships: Vec, + pub relationships: Vec, #[cultcache(key = 5, default)] - pub events: Vec, + pub events: Vec, #[cultcache(key = 6, default)] - pub scenes: Vec, + pub scenes: Vec, #[cultcache(key = 7, default)] pub extra: BTreeMap, } @@ -74,7 +74,7 @@ pub struct GhostlightAgent { pub canonical_state: GhostlightCanonicalState, pub goals: Vec, pub memories: GhostlightMemories, - pub perceived_state_overlays: Vec, + pub perceived_state_overlays: Vec, #[serde(flatten)] pub extra: BTreeMap, } @@ -160,17 +160,83 @@ pub struct GhostlightMemory { pub extra: BTreeMap, } +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct GhostlightRelationship { + #[serde(default)] + pub relationship_id: String, + #[serde(default)] + pub summary: String, + #[serde(default)] + pub stance: String, + #[serde(default)] + pub salience: f64, + #[serde(default)] + pub confidence: f64, + #[serde(flatten)] + pub extra: BTreeMap, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct GhostlightEvent { + #[serde(default)] + pub event_id: String, + #[serde(default)] + pub summary: String, + #[serde(default)] + pub occurred_at: String, + #[serde(default)] + pub salience: f64, + #[serde(default)] + pub confidence: f64, + #[serde(flatten)] + pub extra: BTreeMap, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct GhostlightScene { + #[serde(default)] + pub scene_id: String, + #[serde(default)] + pub summary: String, + #[serde(default)] + pub status: String, + #[serde(default)] + pub salience: f64, + #[serde(default)] + pub confidence: f64, + #[serde(flatten)] + pub extra: BTreeMap, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct GhostlightPerceivedStateOverlay { + #[serde(default)] + pub overlay_id: String, + #[serde(default)] + pub label: String, + #[serde(default)] + pub summary: String, + #[serde(default)] + pub source: String, + #[serde(default)] + pub salience: f64, + #[serde(default)] + pub confidence: f64, + #[serde(flatten)] + pub extra: BTreeMap, +} + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] struct AgentMemoryProjection { pub schema_version: String, pub world: GhostlightWorld, pub agents: Vec, #[serde(default)] - pub relationships: Vec, + pub relationships: Vec, #[serde(default)] - pub events: Vec, + pub events: Vec, #[serde(default)] - pub scenes: Vec, + pub scenes: Vec, #[serde(flatten)] pub extra: BTreeMap, } diff --git a/epiphany-core/src/bin/epiphany-character-loop.rs b/epiphany-core/src/bin/epiphany-character-loop.rs index 5084d7f8..a8839905 100644 --- a/epiphany-core/src/bin/epiphany-character-loop.rs +++ b/epiphany-core/src/bin/epiphany-character-loop.rs @@ -557,13 +557,12 @@ fn strongest_overlay_pressure( .iter() .map(|overlay| { let mut tokens = BTreeSet::new(); - collect_json_tokens(overlay, &mut tokens); + collect_typed_tokens(overlay, &mut tokens); let overlap = token_overlap(&tokens, thought_tokens); - let summary = overlay - .get("summary") - .and_then(Value::as_str) - .or_else(|| overlay.get("label").and_then(Value::as_str)) - .unwrap_or("Perceived overlay relevance"); + let summary = nonempty_or( + &overlay.summary, + nonempty_str_or(&overlay.label, "Perceived overlay relevance"), + ); (overlap, summary.to_string()) }) .max_by(|left, right| left.0.total_cmp(&right.0)) @@ -590,6 +589,12 @@ fn stimulus_token_set( tokens } +fn collect_typed_tokens(value: &T, tokens: &mut BTreeSet) { + if let Ok(value) = serde_json::to_value(value) { + collect_json_tokens(&value, tokens); + } +} + fn collect_json_tokens(value: &Value, tokens: &mut BTreeSet) { match value { Value::String(text) => tokens.extend(summary_tokens(text)), @@ -608,6 +613,18 @@ fn collect_json_tokens(value: &Value, tokens: &mut BTreeSet) { } } +fn nonempty_or(value: &str, fallback: &str) -> String { + nonempty_str_or(value, fallback).to_string() +} + +fn nonempty_str_or<'a>(value: &'a str, fallback: &'a str) -> &'a str { + if value.trim().is_empty() { + fallback + } else { + value + } +} + fn summary_tokens(text: &str) -> BTreeSet { text.split(|ch: char| !ch.is_ascii_alphanumeric() && ch != '_' && ch != '-') .filter_map(|item| { diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 7f494941..16fa193a 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -95,7 +95,7 @@ remembers doctrine; the branch remembers the blade. - Epiphany now publishes those CultNet receipts locally under `schemas/cultnet/`, and `epiphany-runtime-spine schema-catalog --include-schema-json true` emits a merged builtin-plus-local schema catalog Aquarium can consume directly. The local catalog covers runtime-spine documents, durable agent/heartbeat/ledger state, operator-safe `epiphany.surface.*` projections, control intents, and receipt/artifact payloads. The vendored `cultnet-rs` wire contract was aligned with the C# canon at the same time: raw document replication now keys on `schemaId` and `recordKey`, snapshot filters use `schemaIds` / `recordKeys`, and hello supports typed mutation-contract advertisement instead of the old half-remembered payload-schema-version folklore. - Epiphany now owns the canonical schema paperwork locally under `schemas/`. The key receipts are `schemas/ghostlight.agent-state.schema.json`, `schemas/canonical-agent-state-schema.md`, `schemas/agent-state-variable-glossary.md`, `schemas/repo-personality-birth-projection.md`, and `schemas/heartbeat-state-schema.md`. If a standing trait name like `routing_discipline` changes, or if dossier/heartbeat/birth-projection semantics move, update those docs in the same pass instead of relying on old Ghostlight notes or live store archaeology. - The schema doctrine now makes the dossier split explicit: most resident Epiphany organs are `lane_core` dossiers with a lean role lattice and growth via rumination/distillation, while Face is an `embodied_actor` dossier that should trend toward dense Ghostlight-family personality, relationship pressure, and fallible character-loop response. `epiphany-agent-memory-store status` and `epiphany-character-loop` now surface that classification on the wire. -- Face packets now carry deterministic Ghostlight-style `projectionSeed`, `appraisalSeed`, and `reactionSeed` surfaces rebuilt from local dossier traits, relationship memories, perceived overlays, and visible stimulus so the public mouth can use actual projection/appraisal machinery instead of decorative prompt text. Also record this now before some future fool hard-codes singularity: multiple Face actors are part of the plan, even though the current MVP still routes through one `face` role. +- Face packets now carry deterministic Ghostlight-style `projectionSeed`, `appraisalSeed`, and `reactionSeed` surfaces rebuilt from local dossier traits, relationship memories, typed perceived overlays, and visible stimulus so the public mouth can use actual projection/appraisal machinery instead of decorative prompt text. Also record this now before some future fool hard-codes singularity: multiple Face actors are part of the plan, even though the current MVP still routes through one `face` role. - Repo personality initialization now has a terrain-reduced plan and native birth surface. `epiphany-repo-personality scout/project/agent-packet/status` scouts local git repos, scores body taxonomy/history temperament/memory doctrine, writes typed CultCache terrain/profile/role-projection MessagePack stores, emits JSON/Markdown inspection exports, and renders a birth-only Repo Personality Distiller specialist prompt packet. `epiphany-repo-personality startup` now checks for accepted personality/memory initialization records, launches packet generation only when absent, and `accept-init` can route reviewed role `selfPatch` candidates into initial role memory, stamp the newborn Ghostlight trait lattice from deterministic role projections, and seed heartbeat physiology from the same typed role personality projections. The birth specialists are startup-only initialization actuators, not heartbeat lanes; heartbeat receives only the accepted physiology seed. `epiphany-repo-birth-runner` now owns the startup-only execution path: plan mode writes prompts/schemas/accept commands, and run mode defaults to `epiphany-openai-runtime` typed model-request documents plus runtime-spine receipts and reviewable `result.json`; `codex exec` remains only as explicit `--executor codex-exec` fallback. The remaining seam is Aquarium review/action surfacing. After accepted birth, personality drift belongs to heartbeat, mood, rumination, sleep consolidation, lived evidence, and reviewed `selfPatch`, not repeated startup distillation. - Repo trajectory initialization is now a separate birth-only organ. `epiphany-repo-personality` derives a typed `repo_trajectory_report` from early-history, recent-history, doctrine/content excerpts, and deterministic theme scoring, and `trajectory-packet` renders a startup-only Repo Trajectory Distiller prompt/packet so Self can review historical direction, self-image, implicit goals, and anti-goals before the newborn wakes. - Repo memory initialization is now split from personality initialization. `epiphany-repo-personality memory-packet` renders a birth-only Repo Memory Distiller packet from the same typed terrain/profile/projection store plus bounded source excerpts. It gives each organ its own mission filter: Self for routing/authority, Face for public surface, Imagination for plans/backlog, Eyes for prior art, Body for architecture, Hands for implementation habits, Soul for evidence, and Life for continuity. The output is still a Self-reviewed petition, not direct memory mutation. @@ -108,7 +108,7 @@ remembers doctrine; the branch remembers the blade. - The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline. Rendered state intro/doctrine text lives in `epiphany-core/src/prompts/`, and lane/control prompt text lives in `vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml`: modeling is the Body, implementation is the Hands and GUI-launched main coding lane, verification is the Soul, reorientation is Life, coordinator remains the read-only Self, and CRRC owns the pre-compaction intervention template. - The machine-priest voice now says the quiet part plainly: crusade/heresy/purity language is aimed at technical rot, hidden state, duplicate truth, drift, and lying structures, not at humans. Future Epiphany swarms should inherit severity toward systems and curiosity toward people. - The Ghostlight memory pass is landed. `epiphany_specialists.toml` now has a shared persistent-memory projection prepended by the harness to fixed role specialists, reorientation workers, coordinator notes, and CRRC checkpoint interventions. The rendered base doctrine also states the Perfect Machine rule directly: prompt is projection, durable typed state is the mind, every lane must improve its own memory/model/prompt/evidence habit or name the repair, and each lane phrases that duty in its own organ language so the salience sticks. -- The role self-memory persistence pass is native now. Each lane has a Ghostlight-shaped typed dossier in `state/agents.msgpack`, and specialists may return optional `selfPatch` requests beside their normal role result. `roleResult`/`roleAccept` project coordinator review as `selfPersistence`: accepted requests are role-matched, bounded lane memory/goal/value/private-note mutations; refused requests explain wrong role, project-truth smuggling, authority grabs, bloat, missing reason, or malformed records. GUI/coordinator accept paths apply accepted `selfPatch` requests through the native `epiphany-agent-memory-store` binary; project truth still belongs only in `EpiphanyThreadState`. +- The role self-memory persistence pass is native now. Each lane has a Ghostlight-shaped typed dossier in `state/agents.msgpack`, and specialists may return optional `selfPatch` requests beside their normal role result. Dossier relationships, events, scenes, and perceived overlays are typed permissive records; `extra` remains only as legacy/forward-compat quarantine rather than raw durable arrays. `roleResult`/`roleAccept` project coordinator review as `selfPersistence`: accepted requests are role-matched, bounded lane memory/goal/value/private-note mutations; refused requests explain wrong role, project-truth smuggling, authority grabs, bloat, missing reason, or malformed records. GUI/coordinator accept paths apply accepted `selfPatch` requests through the native `epiphany-agent-memory-store` binary; project truth still belongs only in `EpiphanyThreadState`. - The heartbeat initiative pass is landed as a bounded tool seam. `state/agent-heartbeats.msgpack` tracks Self, Face, Imagination, Eyes, Body, Hands, Soul, and Life as Ghostlight-style initiative participants with arena, participant kind, speed, next-ready time, reaction bias, interrupt threshold, load, status, constraints, personality cooldown, mood cooldown, effective cooldown, adaptive pacing, history, and pending turns through `epiphany-core::EpiphanyHeartbeatStateEntry` and the native `epiphany-heartbeat-store` binary. Role dossiers set baseline timing; appraisal mood/anxiety bends it through urgency, arousal, thought pressure, guardedness, and reaction intensity, so Hands-like work pressure and high-need anxious lanes recover sooner without being heartbeaten while a prior turn is running. `epiphany-heartbeat-store pump` computes pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load, then chooses tempo plus target concurrency: calm can launch zero and sleep slow; alarm can fill most active lanes. Idle turns are for rumination: light thought shuffling, role-quality attention, and candidate selfPatch pressure. Sleep/dream cycle passes are the intended distillation window for durable self-memory and doctrine. JSON heartbeat state and Python wrapper state are gone; general CultCache schema sync, polyglot domain loading, and debug display tools belong in CultLib. This is a callable scheduler seam, not yet an always-on daemon; a heart valve, not a whole circulatory god. - The first Ghostlight-derived timing slice is landed in Epiphany, but Ghostlight is reference lineage rather than a sibling runtime to preserve. `epiphany-heartbeat-store init --profile ghostlight-scene --scene-id --scene-participant ` creates a typed CultCache MessagePack scene heartbeat store whose participants are `arena=scene`, `participantKind=character`; `tick` emits `ghostlight.initiative_schedule.v0` receipts with `scene_turn` actions and local-affordance basis. The generic Epiphany maintenance lanes are not auto-patched into scene stores. - The first Void-derived routine slice is landed in Epiphany, but VoidBot is reference lineage rather than a runtime dependency. `epiphany-heartbeat-store routine --store .\state\agent-heartbeats.msgpack --artifact-dir .\.epiphany-heartbeats --agent-store .\state\agents.msgpack` reads typed role dossiers, computes bounded memory resonance, maintains incubation themes, runs analytic and associative cognition lanes, writes bridge syntheses/saturation/tension, projects the active thought cluster through each role's Ghostlight-shaped personality vectors, derives participant-local reactions, applies personality/mood timing, advances the sleep/dream cycle, updates the typed heartbeat store, and emits an auditable `epiphany.void_routine.v0` receipt. The routine now also carries anti-loop physiology imported from Void's calmer brain: `noveltyToSelf`, `noveltyToRoom`, source coverage, saturation pressure, refractory cooling, and explicit permission to let a live unsaturated thought deepen without forcing novelty theater every pass. This mutates only heartbeat physiology fields: project truth and role memory mutation remain on their reviewed surfaces. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 57fb7f08..ea96cd0f 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index f8ac58c0..0c97e4aa 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -197,7 +197,7 @@ accepted_design: - Runtime-spine hello now advertises the interactive surface catalog as CultNet contracts, not just the deep runtime documents. Scene, pressure, reorient, CRRC, jobs, roles, role-result, reorient-result, planning, coordinator, Face, Void memory, repo initialization/birth runner, Rider bridge, and Unity bridge all publish explicit read/write posture so Aquarium can discover affordances from the wire contract instead of carrying a private button-to-command gospel. - Epiphany publishes its Aquarium-facing CultNet receipts locally under `schemas/cultnet/`, and `epiphany-runtime-spine schema-catalog --include-schema-json true` emits a merged builtin-plus-local schema catalog for consumers. The local receipts cover runtime-spine documents, durable agent/heartbeat/ledger state, `epiphany.surface.*` operator projections, control intents, and receipt/artifact payloads. Vendored `cultnet-rs` is aligned to the canonical C# CultNet raw record shapes: replication uses `schemaId` plus `recordKey`, snapshot filters use `schemaIds` / `recordKeys`, and hello advertises typed mutation contracts. - Epiphany now owns the canonical schema paperwork in `schemas/`: a local mirror of `ghostlight.agent-state.schema.json`, plus human-facing receipts for canonical agent-state shape, standing role-trait glossary, heartbeat store shape, and repo-personality birth projection. Trait names like `routing_discipline` are now documented at the source instead of existing only in live dossiers, startup templates, or stale Ghostlight notes. - - The dossier doctrine now distinguishes `lane_core` from `embodied_actor`. Most Epiphany sub-agents want a lean role lattice plus memory/goals/values/private-note growth, because effectiveness matters more than theatrical density. Face and Ghostlight-style characters want dense Ghostlight-family personality, relationship pressure, perceived overlays, and appraisal-shaped fallibility. The classification is now queryable through native agent-memory status and character-loop packets instead of hiding only in docs. + - The dossier doctrine now distinguishes `lane_core` from `embodied_actor`. Most Epiphany sub-agents want a lean role lattice plus memory/goals/values/private-note growth, because effectiveness matters more than theatrical density. Face and Ghostlight-style characters want dense Ghostlight-family personality, relationship pressure, perceived overlays, and appraisal-shaped fallibility. Dossier relationships, events, scenes, and perceived overlays are typed permissive records with `extra` only as legacy/forward-compat quarantine, not raw durable JSON arrays. The classification is queryable through native agent-memory status and character-loop packets instead of hiding only in docs. - Face packets now expose deterministic Ghostlight-style projection, appraisal, and reaction seeds built from local canonical traits, relationship memories, perceived overlays, and visible stimulus. This makes embodied response machinery available to the public mouth without granting omniscience or silent state mutation. Multiple Face actors remain part of the long-plan; the current singular `face` role is an MVP simplification, not the intended endpoint. - Repo personality initialization is now specified as a map-reduce projection, not a hand-written vibe pass: read-only scouts score body taxonomy, history temperament, and memory doctrine across nearby repos, reduce them into normalized variance criteria, and emit reviewable `repoTerrainReport`, `repoPersonalityProfile`, and `rolePersonalityProjection` candidates before touching agent memory. - Native `epiphany-repo-personality` is the first startup-personality scout and birth-only distiller packet renderer: it deterministically inventories local git repos, scores repo terrain/history/state surfaces, writes typed CultCache terrain/profile/role-projection MessagePack stores, emits JSON/Markdown inspection glass, and renders a Repo Personality Distiller specialist prompt packet for Self-reviewed first role-memory petitions. The distiller must run only when a repo/swarm has no accepted personality initialization; after that, personality drift belongs to heartbeat, mood, rumination, sleep consolidation, lived evidence, and reviewed `selfPatch`. Startup routing now checks accepted initialization records, generates missing startup-only packets only once, applies reviewed birth memory and heartbeat physiology seeds, and leaves later drift alone. Birth specialists are not heartbeat lanes; heartbeat receives only accepted seed pressure. @@ -225,7 +225,7 @@ accepted_design: - Major Epiphany prompt surfaces live in prompt files rather than Rust/Python string slabs: rendered state intro/doctrine under `epiphany-core/src/prompts/`, and modeling/Body, research/Eyes, implementation/Hands, verification/Soul, reorientation/Life, coordinator/Self, Face/public-surface, and CRRC intervention templates in `vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml`. - Specialist prompts are role-distilled instead of generic and their live text is config-backed in app-server: modeling/checkpoint is the Body of code, dataflow, seams, and frontier; research/scout is the Eyes prompt surface for existing work, vendor guidance, libraries, papers, and anti-Greenspun source selection; implementation is the Hands, the main coding lane and actuator rather than a `roleLaunch` specialist; verification/review is the Soul of promise, invariants, evidence, and user truth; reorientation is Life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting; Face is the public Discord #aquarium surface that translates agent thought-weather without moderating or leaking sealed thought. - Epiphany prompt surfaces now carry a shared Ghostlight-derived persistent memory projection before lane-specific text: prompt is not memory, durable typed state is the mind, personality and protected values are first-class salience handles, and every lane is explicitly responsible for making its own memory/model/prompt/evidence habit sharper or naming the needed repair. Each lane states self-improvement in its own rite-language: Imagination selects futures, Body clarifies anatomy, Eyes sees earlier, Hands touches source more precisely, Soul becomes harder to fool, Life loses less continuity, Self routes repair, and Face becomes clearer at turning inner weather into useful social presence. - - Specialist self-memory now has a bounded Ghostlight-shaped CultCache persistence surface in `state/agents.msgpack`: Imagination, Body, Eyes, Hands, Soul, Life, Self, and Face each have an individual typed role dossier for identity, personality, semantic/episodic/relationship memory, goals, and values. These entries are lane memory only; project truth remains in authoritative `EpiphanyThreadState`. + - Specialist self-memory now has a bounded Ghostlight-shaped CultCache persistence surface in `state/agents.msgpack`: Imagination, Body, Eyes, Hands, Soul, Life, Self, and Face each have an individual typed role dossier for identity, personality, semantic/episodic/relationship memory, goals, values, relationships, events, scenes, and perceived overlays. These entries are lane memory only; project truth remains in authoritative `EpiphanyThreadState`. - `state/agent-heartbeats.msgpack`, `epiphany-core::EpiphanyHeartbeatStateEntry`, and the native `epiphany-heartbeat-store` binary are the Ghostlight-derived heartbeat initiative seam. The harness sets a target heartbeat rate; participants carry arena, participant kind, initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, constraints, personality cooldown, mood cooldown, and effective cooldown; pending coordinator work can pull its owning lane through a reaction window; otherwise the earliest ready active participant wins the slot. Role dossiers set the personality baseline, appraisals bend it with mood/anxiety signals such as urgency, arousal, thought pressure, guardedness, and reaction intensity, and lower effective cooldown means the lane recovers sooner and gets the floor more often. The native `pump` command computes adaptive swarm pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load; relaxed pressure can launch nothing and run at crawl tempo, while alarm pressure can fill most or all active lanes up to a configured concurrency cap without waking any lane already running. If the winner has no routeable maintenance work, it ruminates on role quality and prepares bounded selfPatch pressure rather than pretending rumination has already consolidated doctrine. Sleep/dream cycle passes are the intended distillation window for reviewed self-memory and doctrine. Face can win `surfaceAgentThoughts` or `discordAquariumChat` work slots. Epiphany also owns native character-loop projection through `epiphany-character-loop`, so role dossiers can respond to visible stimuli without importing Ghostlight as runtime. The same heartbeat store now owns the Void-derived routine fields `sleep_cycle`, `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, and `candidate_interventions` through the native `epiphany-heartbeat-store routine` command. - `state/ledgers.msgpack`, `epiphany-core::EpiphanyStateLedgerEntry`, the `epiphany-state-ledger-store` binary, and the native `epiphany-state` CLI now own durable branch and evidence ledgers. The old tracked JSON ledger files and the migration/projection CLI hatches are gone. - CultCache inspection, cross-language schema synchronization, and debug display tooling belong in CultLib, not in EpiphanyAgent. Epiphany should consume typed CultCache documents and expose product-specific status through its API, while general polyglot domain loading/inspection lives with the shared CultCache ecosystem.