From 887fa1d01b3c2f4c1efa62261590df5c0a9036ac Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 19 May 2026 12:03:49 +0100 Subject: [PATCH] Type heartbeat appraisals and reactions --- epiphany-core/src/heartbeat_state.rs | 253 ++++++++---------- .../heartbeat_state/heartbeat_documents.rs | 119 +++++++- .../src/heartbeat_state/heartbeat_store.rs | 4 +- notes/fresh-workspace-handoff.md | 6 +- state/ledgers.msgpack | Bin 129911 -> 130217 bytes state/map.yaml | 16 +- 6 files changed, 237 insertions(+), 161 deletions(-) diff --git a/epiphany-core/src/heartbeat_state.rs b/epiphany-core/src/heartbeat_state.rs index c3ebcfdb..6860056d 100644 --- a/epiphany-core/src/heartbeat_state.rs +++ b/epiphany-core/src/heartbeat_state.rs @@ -127,8 +127,8 @@ pub fn run_void_routine_store( "thoughtLanes": thought_lanes, "bridge": bridge, "candidateInterventions": candidate_interventions, - "appraisals": appraisals, - "reactions": reactions, + "appraisals": &appraisals, + "reactions": &reactions, "reviewNotes": [ "Void is reference material, not a runtime dependency.", "The routine mutates only typed heartbeat physiology fields; project truth and role memory mutation stay on their dedicated reviewed surfaces.", @@ -1355,47 +1355,28 @@ fn trait_match_score(traits: &[PersonalityTraitProjection], needles: &[&str]) -> } } -fn apply_mood_timing_from_appraisals(state: &mut EpiphanyHeartbeatStateEntry, appraisals: &Value) { - let Some(items) = appraisals - .get("participantAppraisals") - .and_then(Value::as_array) - else { - return; - }; +fn apply_mood_timing_from_appraisals( + state: &mut EpiphanyHeartbeatStateEntry, + appraisals: &HeartbeatAgentThoughtAppraisals, +) { for participant in &mut state.participants { - let Some(appraisal) = items + let Some(appraisal) = appraisals + .participant_appraisals .iter() - .find(|item| item.get("roleId").and_then(Value::as_str) == Some(&participant.role_id)) + .find(|item| item.role_id == participant.role_id) else { continue; }; - let emotional = appraisal - .get("emotionalAppraisal") - .and_then(Value::as_object); - let urgency = emotional - .and_then(|value| value.get("urgency")) - .and_then(Value::as_f64) - .unwrap_or(0.0) - .clamp(0.0, 1.0); - let arousal = emotional - .and_then(|value| value.get("arousal")) - .and_then(Value::as_f64) - .unwrap_or(0.0) - .clamp(0.0, 1.0); - let thought_pressure = emotional - .and_then(|value| value.get("thoughtPressure")) - .and_then(Value::as_f64) - .unwrap_or(0.0) - .clamp(0.0, 1.0); - let guardedness = emotional - .and_then(|value| value.get("guardedness")) - .and_then(Value::as_f64) - .unwrap_or(0.0) + let urgency = appraisal.emotional_appraisal.urgency.clamp(0.0, 1.0); + let arousal = appraisal.emotional_appraisal.arousal.clamp(0.0, 1.0); + let thought_pressure = appraisal + .emotional_appraisal + .thought_pressure .clamp(0.0, 1.0); + let guardedness = appraisal.emotional_appraisal.guardedness.clamp(0.0, 1.0); let reaction_intensity = appraisal - .pointer("/candidateImplications/reactionIntensity") - .and_then(Value::as_f64) - .unwrap_or(0.0) + .candidate_implications + .reaction_intensity .clamp(0.0, 1.0); let anxiety = (urgency * 0.32 + arousal * 0.22 @@ -1408,10 +1389,7 @@ fn apply_mood_timing_from_appraisals(state: &mut EpiphanyHeartbeatStateEntry, ap participant.mood_cooldown_multiplier = round3(multiplier); participant.mood_timing = Some(HeartbeatMoodTiming { schema_version: "epiphany.mood_timing.v0".to_string(), - source: appraisal - .get("appraisalId") - .and_then(Value::as_str) - .map(str::to_string), + source: Some(appraisal.appraisal_id.clone()), cooldown_multiplier: round3(multiplier), anxiety: round3(anxiety), urgency: round3(urgency), @@ -1982,7 +1960,7 @@ fn build_agent_appraisals( thought_lanes: &Value, incubation: &Value, bridge: &Value, -) -> Value { +) -> HeartbeatAgentThoughtAppraisals { let thought_tokens = cognition_tokens(thought_lanes, incubation, bridge); let thought_pressure = thought_pressure(thought_lanes, incubation); let bridge_decision = bridge @@ -2002,7 +1980,7 @@ fn build_agent_appraisals( let projection = personality_projection(profile, &thought_tokens); let alignment = projection .iter() - .filter_map(|item| item.get("projection").and_then(Value::as_f64)) + .map(|item| item.projection) .next() .unwrap_or(profile.reactivity); let arousal = round3( @@ -2020,111 +1998,99 @@ fn build_agent_appraisals( let urgency = round3((arousal * 0.65 + guardedness * 0.25 + thought_pressure * 0.1).clamp(0.0, 1.0)); let valence = round3((0.55 + curiosity * 0.2 - guardedness * 0.18).clamp(0.0, 1.0)); let label = interpretation_label(bridge_decision, arousal, guardedness, curiosity); - serde_json::json!({ - "schema_version": "epiphany.agent_thought_appraisal.v0", - "appraisalId": format!("appraisal-{}-{}", profile.role_id, stable_theme_suffix(focus)), - "reviewStatus": "generated_unreviewed", - "participantAgentId": profile.agent_id, - "roleId": profile.role_id, - "currentCharacterStateRef": format!("state/agents.msgpack#{}", profile.role_id), - "thoughtClusterRef": focus, - "participantLocalContext": { - "displayName": profile.display_name, - "values": profile.values, - "reactivity": profile.reactivity, - "plasticity": profile.plasticity, - "expressiveness": profile.expressiveness, - "guardedness": profile.guardedness, + HeartbeatAgentThoughtAppraisal { + schema_version: "epiphany.agent_thought_appraisal.v0".to_string(), + appraisal_id: format!("appraisal-{}-{}", profile.role_id, stable_theme_suffix(focus)), + review_status: "generated_unreviewed".to_string(), + participant_agent_id: profile.agent_id.clone(), + role_id: profile.role_id.clone(), + current_character_state_ref: format!("state/agents.msgpack#{}", profile.role_id), + thought_cluster_ref: focus.to_string(), + participant_local_context: HeartbeatParticipantLocalContext { + display_name: profile.display_name.clone(), + values: profile.values.clone(), + reactivity: profile.reactivity, + plasticity: profile.plasticity, + expressiveness: profile.expressiveness, + guardedness: profile.guardedness, }, - "observableThoughtSummary": strongest_thought_summary(thought_lanes, incubation), - "personalityProjection": projection, - "interpretation": format!("{} appraises {} through its current personality vector; reaction should follow this appraisal rather than a global mood knob.", profile.display_name, focus), - "emotionalAppraisal": { - "valence": valence, - "arousal": arousal, - "urgency": urgency, - "curiosity": curiosity, - "guardedness": guardedness, - "thoughtPressure": round3(thought_pressure), + observable_thought_summary: strongest_thought_summary(thought_lanes, incubation), + personality_projection: projection, + interpretation: format!("{} appraises {} through its current personality vector; reaction should follow this appraisal rather than a global mood knob.", profile.display_name, focus), + emotional_appraisal: HeartbeatEmotionalAppraisal { + valence, + arousal, + urgency, + curiosity, + guardedness, + thought_pressure: round3(thought_pressure), }, - "interpretationLabel": label, - "confidenceNotes": "Deterministic first-pass appraisal from typed role personality vectors and clustered thought state; useful as reaction guidance, not reviewed truth.", - "candidateImplications": { - "reactionMode": reaction_mode(&label, bridge_decision), - "reactionIntensity": round3((urgency * 0.55 + arousal * 0.3 + curiosity * 0.15).clamp(0.0, 1.0)), - "shouldSpeak": bridge_decision == "draft" && profile.role_id == "face" && guardedness < 0.75, - "shouldIncubate": bridge_decision != "silence" && guardedness >= 0.55, + interpretation_label: label.to_string(), + confidence_notes: "Deterministic first-pass appraisal from typed role personality vectors and clustered thought state; useful as reaction guidance, not reviewed truth.".to_string(), + candidate_implications: HeartbeatCandidateImplications { + reaction_mode: reaction_mode(&label, bridge_decision).to_string(), + reaction_intensity: round3((urgency * 0.55 + arousal * 0.3 + curiosity * 0.15).clamp(0.0, 1.0)), + should_speak: bridge_decision == "draft" && profile.role_id == "face" && guardedness < 0.75, + should_incubate: bridge_decision != "silence" && guardedness >= 0.55, }, - "review": { - "acceptedForMutation": false, - "rationale": "Appraisal may steer reaction and display; state mutation still requires the explicit selfPatch or project-state review path.", + review: HeartbeatAppraisalReview { + accepted_for_mutation: false, + rationale: "Appraisal may steer reaction and display; state mutation still requires the explicit selfPatch or project-state review path.".to_string(), }, - }) + } }) .collect::>(); - serde_json::json!({ - "schema_version": "epiphany.agent_thought_appraisals.v0", - "updatedAt": now_iso(), - "thoughtClusterRef": focus, - "participantAppraisals": appraisals, - }) + HeartbeatAgentThoughtAppraisals { + schema_version: "epiphany.agent_thought_appraisals.v0".to_string(), + updated_at: now_iso(), + thought_cluster_ref: focus.to_string(), + participant_appraisals: appraisals, + } } -fn build_agent_reactions(appraisals: &Value, bridge: &Value) -> Value { +fn build_agent_reactions( + appraisals: &HeartbeatAgentThoughtAppraisals, + bridge: &Value, +) -> HeartbeatAgentReactions { let bridge_decision = bridge .pointer("/decision/speakDecision") .and_then(Value::as_str) .unwrap_or("silence"); let reactions = appraisals - .get("participantAppraisals") - .and_then(Value::as_array) - .into_iter() - .flatten() + .participant_appraisals + .iter() .map(|appraisal| { - let role_id = appraisal - .get("roleId") - .and_then(Value::as_str) - .unwrap_or("unknown"); - let arousal = appraisal - .pointer("/emotionalAppraisal/arousal") - .and_then(Value::as_f64) - .unwrap_or(0.0); - let guardedness = appraisal - .pointer("/emotionalAppraisal/guardedness") - .and_then(Value::as_f64) - .unwrap_or(0.0); - let curiosity = appraisal - .pointer("/emotionalAppraisal/curiosity") - .and_then(Value::as_f64) - .unwrap_or(0.0); - let mode = appraisal - .pointer("/candidateImplications/reactionMode") - .and_then(Value::as_str) - .unwrap_or("hold"); - let intensity = appraisal - .pointer("/candidateImplications/reactionIntensity") - .and_then(Value::as_f64) - .unwrap_or(0.0); - serde_json::json!({ - "reactionId": format!("reaction-{}-{}", role_id, now_stamp()), - "roleId": role_id, - "participantAgentId": appraisal.get("participantAgentId"), - "appraisalId": appraisal.get("appraisalId"), - "mode": mode, - "moodLabel": mood_label(arousal, guardedness, curiosity), - "intensity": round3(intensity), - "bridgeDecision": bridge_decision, - "surface": if role_id == "face" { "aquarium" } else { "internal" }, - "recommendedUse": reaction_recommended_use(role_id, mode), - }) + let role_id = appraisal.role_id.as_str(); + let arousal = appraisal.emotional_appraisal.arousal; + let guardedness = appraisal.emotional_appraisal.guardedness; + let curiosity = appraisal.emotional_appraisal.curiosity; + let mode = appraisal.candidate_implications.reaction_mode.as_str(); + let intensity = appraisal.candidate_implications.reaction_intensity; + HeartbeatAgentReaction { + reaction_id: format!("reaction-{}-{}", role_id, now_stamp()), + role_id: role_id.to_string(), + participant_agent_id: appraisal.participant_agent_id.clone(), + appraisal_id: appraisal.appraisal_id.clone(), + mode: mode.to_string(), + mood_label: mood_label(arousal, guardedness, curiosity).to_string(), + intensity: round3(intensity), + bridge_decision: bridge_decision.to_string(), + surface: if role_id == "face" { + "aquarium" + } else { + "internal" + } + .to_string(), + recommended_use: reaction_recommended_use(role_id, mode).to_string(), + } }) .collect::>(); - serde_json::json!({ - "schema_version": "epiphany.agent_reactions.v0", - "updatedAt": now_iso(), - "reactions": reactions, - "contract": "Reaction is appraisal output. It may pace, color, draft, or display behavior; it does not mutate state without review.", - }) + HeartbeatAgentReactions { + schema_version: "epiphany.agent_reactions.v0".to_string(), + updated_at: now_iso(), + reactions, + contract: "Reaction is appraisal output. It may pace, color, draft, or display behavior; it does not mutate state without review.".to_string(), + } } fn cognition_tokens(thought_lanes: &Value, incubation: &Value, bridge: &Value) -> BTreeSet { @@ -2174,7 +2140,7 @@ fn max_number_at(value: &Value, pointer: &str, key: &str) -> f64 { fn personality_projection( profile: &RoleAppraisalProfile, thought_tokens: &BTreeSet, -) -> Vec { +) -> Vec { let mut scored = profile .traits .iter() @@ -2182,22 +2148,17 @@ fn personality_projection( let trait_tokens = summary_tokens(&format!("{} {}", item.group, item.name)); let overlap = token_overlap(&trait_tokens, thought_tokens); let projection = round3((item.weight * (0.55 + overlap * 1.8)).clamp(0.0, 1.0)); - serde_json::json!({ - "group": item.group, - "name": item.name, - "activation": round3(item.activation), - "plasticity": round3(item.plasticity), - "tokenOverlap": round3(overlap), - "projection": projection, - }) + HeartbeatPersonalityProjection { + group: item.group.clone(), + name: item.name.clone(), + activation: round3(item.activation), + plasticity: round3(item.plasticity), + token_overlap: round3(overlap), + projection, + } }) .collect::>(); - scored.sort_by(|left, right| { - right["projection"] - .as_f64() - .unwrap_or_default() - .total_cmp(&left["projection"].as_f64().unwrap_or_default()) - }); + scored.sort_by(|left, right| right.projection.total_cmp(&left.projection)); scored.truncate(6); scored } diff --git a/epiphany-core/src/heartbeat_state/heartbeat_documents.rs b/epiphany-core/src/heartbeat_state/heartbeat_documents.rs index c2516b54..d3330881 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_documents.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_documents.rs @@ -71,9 +71,9 @@ pub struct EpiphanyHeartbeatCognitionEntry { #[cultcache(key = 10, default)] pub candidate_interventions: Option, #[cultcache(key = 11, default)] - pub appraisals: Option, + pub appraisals: Option, #[cultcache(key = 12, default)] - pub reactions: Option, + pub reactions: Option, } #[derive(Clone, Debug, PartialEq, DatabaseEntry)] @@ -219,6 +219,121 @@ pub struct HeartbeatSleepCycle { pub last_distillation_summary: String, } +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatAgentThoughtAppraisals { + #[serde(rename = "schema_version")] + pub schema_version: String, + pub updated_at: String, + pub thought_cluster_ref: String, + pub participant_appraisals: Vec, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatAgentThoughtAppraisal { + #[serde(rename = "schema_version")] + pub schema_version: String, + pub appraisal_id: String, + pub review_status: String, + pub participant_agent_id: String, + pub role_id: String, + pub current_character_state_ref: String, + pub thought_cluster_ref: String, + pub participant_local_context: HeartbeatParticipantLocalContext, + pub observable_thought_summary: String, + pub personality_projection: Vec, + pub interpretation: String, + pub emotional_appraisal: HeartbeatEmotionalAppraisal, + pub interpretation_label: String, + pub confidence_notes: String, + pub candidate_implications: HeartbeatCandidateImplications, + pub review: HeartbeatAppraisalReview, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatParticipantLocalContext { + pub display_name: String, + pub values: Vec, + pub reactivity: f64, + pub plasticity: f64, + pub expressiveness: f64, + pub guardedness: f64, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatPersonalityProjection { + pub group: String, + pub name: String, + pub activation: f64, + pub plasticity: f64, + pub token_overlap: f64, + pub projection: f64, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatEmotionalAppraisal { + pub valence: f64, + pub arousal: f64, + pub urgency: f64, + pub curiosity: f64, + pub guardedness: f64, + pub thought_pressure: f64, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatCandidateImplications { + pub reaction_mode: String, + pub reaction_intensity: f64, + pub should_speak: bool, + pub should_incubate: bool, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatAppraisalReview { + pub accepted_for_mutation: bool, + pub rationale: String, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatAgentReactions { + #[serde(rename = "schema_version")] + pub schema_version: String, + pub updated_at: String, + pub reactions: Vec, + pub contract: String, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(default)] +pub struct HeartbeatAgentReaction { + pub reaction_id: String, + pub role_id: String, + pub participant_agent_id: String, + pub appraisal_id: String, + pub mode: String, + pub mood_label: String, + pub intensity: f64, + pub bridge_decision: String, + pub surface: String, + pub recommended_use: String, +} + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct HeartbeatInitiativeHeatPolicy { #[serde(default = "default_heat_schema_version")] diff --git a/epiphany-core/src/heartbeat_state/heartbeat_store.rs b/epiphany-core/src/heartbeat_state/heartbeat_store.rs index c19a7c46..2e000eb1 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_store.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_store.rs @@ -131,8 +131,8 @@ fn legacy_heartbeat_cognition_entry( thought_lanes: legacy.thought_lanes, bridge: legacy.bridge, candidate_interventions: legacy.candidate_interventions, - appraisals: legacy.appraisals, - reactions: legacy.reactions, + appraisals: decode_legacy_document(legacy.appraisals)?, + reactions: decode_legacy_document(legacy.reactions)?, })) } diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4a1a2592..78e742e9 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -61,7 +61,7 @@ remembers doctrine; the branch remembers the blade. - Thread start route handling and its async lifecycle task now live in `codex_message_processor/thread_start_routes.rs`; root no longer owns `thread_start_task`. - Thread config helpers now live in `codex_message_processor/thread_config.rs`: instruction-source loading, thread config override construction, config-load error shaping, and dynamic-tool validation. The pure dynamic-tool validation contract has module-local unit tests. - Turn control routes now live in `codex_message_processor/turn_routes.rs`: turn start, thread item injection, app-server client info setting, turn steer, turn interrupt, mode normalization, and input-limit validation with module-local unit tests. -- Heartbeat durable document/schema types now live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`, role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`, persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`, and status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`. Adaptive pacing, scene protocol, participant personality/mood timing, initiative heat projection, birth personality seed receipts, pending-turn freeze/multiplier facts, Void routine sleep-cycle physiology, and Void routine memory-resonance pairs are typed fields rather than `extra` maps or generic JSON cargo; only the sealed legacy combined-state reader still carries `extra` for old `voidRoutine` migration. The root `heartbeat_state.rs` keeps scheduling and the remaining Void cognition orchestration for the next cuts. +- Heartbeat durable document/schema types now live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`, role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`, persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`, and status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`. Adaptive pacing, scene protocol, participant personality/mood timing, initiative heat projection, birth personality seed receipts, pending-turn freeze/multiplier facts, Void routine sleep-cycle physiology, Void routine memory-resonance pairs, role thought appraisals, and derived reactions are typed fields rather than `extra` maps or generic JSON cargo; only the sealed legacy combined-state reader still carries `extra` for old `voidRoutine` migration. The root `heartbeat_state.rs` keeps scheduling and the remaining Void cognition orchestration for the next cuts. - Heartbeat role/default and store seams now have module-local unit tests: fixed lane catalog, Ghostlight scene role projection, and typed state/cognition CultCache round-trip. Keep future heartbeat cuts aligned to those seam tests instead of growing root integration-only coverage. - Heartbeat adaptive pacing now lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`, including running-turn count and effective cooldown multipliers. It has a module-local unit test for pending-turn counting; root scheduling calls the pacing seam instead of owning pressure/concurrency math directly. - Thread projection now lives in `codex_message_processor/thread_projection.rs`: state-db/thread-store/rollout summary projection, `ConversationSummary` to API `Thread` mapping, thread-title attachment helpers, turn pagination, and rollout turn reconstruction. `codex_message_processor.rs` is about 1,009 lines after this extraction and mostly owns JSON-RPC dispatch, processor construction, shared thread lookup/submit/error helpers, and lifecycle shutdown. @@ -101,7 +101,7 @@ remembers doctrine; the branch remembers the blade. - Active heartbeat turns now freeze initiative explicitly. A running pending turn carries `initiativeFrozen` and `initiativeFreezeReason`; schedule/status/readiness projections expose `initiative_frozen`; the scheduler still rejects attempts to wake that lane again; and completion receipts mark `cooldownStartedAfterCompletion: true`. A focused high-heat test proves a 25x heated implementation lane cannot be queued again while it is still thinking. - 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 typed 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 typed sleep/dream-cycle state, 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. +- 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 typed 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 typed participant-local reactions from typed appraisals, applies personality/mood timing, advances typed sleep/dream-cycle state, 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. - The next memory foundation must not build separate engines for repo graph and agent mind. Heartbeat cognition, role self-memory, repo architecture/dataflow, evidence scars, incubation, agency pressure, and context packets should converge through `EpiphanyMemoryGraph` profiles so one typed graph owns anchors, lifecycle, summaries, freshness, context cuts, and Qdrant embedding manifests. Repo, agent, and heartbeat profile producers now map accepted graph truth, reviewed role dossier memories/goals/values, and provisional heartbeat short-term/incubation/agency/candidate pressure into memory graph documents without scanner/Qdrant/model work. Heartbeat import deliberately does not mark durable promotion. Compose now merges profile snapshots into one validated graph and rejects duplicate authority; `epiphany-memory-graph compose` writes a composed typed CultCache graph from typed source graph stores; `epiphany-memory-graph refresh` can invoke live agent-memory plus heartbeat-cognition producers from their typed stores into one graph store; `epiphany-core` has a native typed `EpiphanyThreadState` CultCache store seam; the bridge mirrors loaded Codex-thread Epiphany state into `state/thread-state.msgpack`; and CultNet now advertises logical `EpiphanyThreadState` plus `EpiphanyMemoryGraph` snapshot contracts. The next clean slice is local refresh/dogfood once a mirrored thread-state store exists, then a Qdrant embedding cache writer that treats embeddings as rebuildable manifests, not canonical memory. - Manual Codex-run rumination still has an explicit aftercare rule until Epiphany owns the full sleep consolidator. In the intended Epiphany cycle, sub-agents ruminate when idle and distill when they sleep; in this supervising Codex thread, a heartbeat/routine vigil is only physiology until a separate closing pass reviews the receipts and decides whether map, handoff, evidence, or role self-memory should change. - The Face public-surface pass is landed as a bounded lane. Face's role dossier lives in `state/agents.msgpack`; `epiphany_specialists.toml` gives it a VoidBot-heartbeat-derived prompt stripped of moderation authority; `state/face-discord.toml` and the native `epiphany-face-discord` binary enforce that Face may interact only through #aquarium. Missing channel id or token writes candidate chat artifacts instead of posting elsewhere. If a Face has a persona name/avatar, `post` uses the shared Discord webhook pipe so each Epiphany can speak with its own nickname and avatar without a separate bot identity. @@ -198,7 +198,7 @@ The current spine, blessed but not yet finished: - distilled shared and config-backed prompt doctrine through the base prompt, rendered Epiphany state prompt files, modeling/Body, implementation/Hands, verification/Soul, reorientation/Life, coordinator/Self, and CRRC intervention surfaces - shared Ghostlight-derived persistent memory projection across Imagination, Body, Soul, Life, Self, CRRC checkpoint steering, and the GUI-launched Hands implementation lane - Ghostlight-derived heartbeat initiative scheduling through the native `epiphany-heartbeat-store` binary, with Self and Face included as first-class Epiphany maintenance participants, Ghostlight scene characters supported through the same timing law, role-personality cooldowns, appraisal mood/anxiety cooldowns, effective recovery timing, adaptive pressure-based pump tempo/concurrency, idle rumination feeding candidate self-memory pressure, sleep/dream passes serving as the distillation window, and heartbeat state persisted through typed CultCache MessagePack stores -- Void-derived native routine physiology through `epiphany-heartbeat-store routine`, with typed sleep cycle, typed memory resonance, incubation, analytic/associative cognition lanes, bridge judgment, candidate interventions, Ghostlight-style personality appraisals, mood/anxiety timing, derived reactions, and dream maintenance stored in the typed heartbeat store +- Void-derived native routine physiology through `epiphany-heartbeat-store routine`, with typed sleep cycle, typed memory resonance, incubation, analytic/associative cognition lanes, bridge judgment, candidate interventions, typed Ghostlight-style personality appraisals, mood/anxiety timing, typed derived reactions, and dream maintenance stored in the typed heartbeat store - Epiphany-native character-loop packet projection through `epiphany-character-loop`, with Face as the first public-surface actor over its typed role dossier - Face as the public #aquarium-only surface for translating agent thought-weather into short chats or candidate drafts, with persona webhook presentation and Void memory/search access, without moderator authority - Ghostlight-shaped role dossiers in `state/agents.msgpack`, plus `selfPatch` review projection through `roleResult`/`roleAccept` and accepted memory application through the native `epiphany-agent-memory-store` binary diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index d2729c9d308498572f9b8326ecefc0fed1f968a3..0a9145c3ea893be5e0f1efc84cfd794526f863a8 100644 GIT binary patch delta 305 zcmZvXu}Z{15QfQF+!F|5H7IsDO(KfM@;VDGOm&TnyJNDF?8Mz!nmAjT44 z-#auO+Z{)!#IOa$){6_vC54VzgP6|PI)$E`H(tmpN&&5gmTFW}(4<%sSiXVatfBH{;0EB^U A=>Px# delta 48 zcmZ4all}WQ_6f>Nzil_F7BVsxHBV>UKAn;A^iR<(Mg~S^x(24YhL$0Q23DpZ6a@g; C%n*J6 diff --git a/state/map.yaml b/state/map.yaml index d6d6e9f4..45c0c387 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -101,7 +101,7 @@ accepted_design: - Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. The old JSON-value selfPatch functions remain only as edge compatibility wrappers for CLI/artifact ingress; `epiphany-agent-memory-store`, heartbeat rumination application, and repo initialization selfPatch processing parse once at the edge and then operate on typed documents. Role-result self-persistence no longer exports a JSON-value reviewer; native review uses `review_role_self_patch_document`. - Durable Ghostlight role dossiers are typed through their relationship/event/scene/perceived-overlay surfaces now. `EpiphanyAgentMemoryEntry` no longer stores those arrays as `serde_json::Value`, and durable Ghostlight structs no longer carry flattened unknown `extra` bags. `AgentSelfPatch.extra` remains only as an ingress guard so unknown patch keys can be rejected with reasons. - The state ledger CultCache document is now a closed typed ledger shape. Branch and evidence records no longer carry flattened `extra` maps; evidence additions remain explicit records with `ts`, `type`, `status`, `note`, and optional branch. - - Heartbeat durable document/schema types live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`; role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`; heartbeat persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`; heartbeat status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`; the root heartbeat module remains the scheduling/cognition orchestration surface until those responsibilities are split into their own tested seams. Heartbeat timing authority is now typed state: adaptive pacing, scene protocol, participant personality/mood timing, initiative heat projection, birth personality seed receipts, pending-turn freeze/multiplier facts, Void routine sleep-cycle physiology, and Void routine memory-resonance pairs are named fields rather than `extra` maps or generic JSON cargo. The only remaining heartbeat `extra` bag is the sealed legacy combined-state reader for old `voidRoutine` migration. + - Heartbeat durable document/schema types live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`; role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`; heartbeat persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`; heartbeat status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`; the root heartbeat module remains the scheduling/cognition orchestration surface until those responsibilities are split into their own tested seams. Heartbeat timing authority is now typed state: adaptive pacing, scene protocol, participant personality/mood timing, initiative heat projection, birth personality seed receipts, pending-turn freeze/multiplier facts, Void routine sleep-cycle physiology, Void routine memory-resonance pairs, role thought appraisals, and derived reactions are named fields rather than `extra` maps or generic JSON cargo. The only remaining heartbeat `extra` bag is the sealed legacy combined-state reader for old `voidRoutine` migration. - Heartbeat role/default and store seams are pinned by module-local unit tests for fixed lane catalog, Ghostlight scene role projection, and typed state/cognition CultCache round-trip. - Heartbeat adaptive pacing lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`; it owns pressure/concurrency derivation, running-turn count, initiative heat projection, and effective cooldown multipliers for scheduler/projection callers. - `epiphany-openai-auth-spine` is now a thin Epiphany-named boundary over retained vendored `codex-login`, not a clean-room credential store or token-refresh clone. Keep this impurity sealed as the Codex-compatible subscription auth organ while Epiphany owns typed request/status/event/runtime documents around it. @@ -174,7 +174,7 @@ accepted_design: - 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`. - - `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, initiative heat, active-turn freeze state, 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. Initiative heat is typed heartbeat policy, not a side flag: `epiphany-heartbeat-store heat` and the CultNet `epiphany.heartbeat_heat_intent.v0` contract can set or clear global, all, agent, role, arena, participant-kind, group, and constraint multipliers, with optional scene-clock expiry. Active thinking freezes initiative explicitly: running pending turns project `initiativeFrozen` / `initiative_frozen`, are ineligible for reaction, cannot be selected again, and start cooldown only after completion. 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 typed `sleep_cycle`, typed `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, and `candidate_interventions` through the native `epiphany-heartbeat-store routine` command. + - `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, initiative heat, active-turn freeze state, 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. Initiative heat is typed heartbeat policy, not a side flag: `epiphany-heartbeat-store heat` and the CultNet `epiphany.heartbeat_heat_intent.v0` contract can set or clear global, all, agent, role, arena, participant-kind, group, and constraint multipliers, with optional scene-clock expiry. Active thinking freezes initiative explicitly: running pending turns project `initiativeFrozen` / `initiative_frozen`, are ineligible for reaction, cannot be selected again, and start cooldown only after completion. 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 typed `sleep_cycle`, typed `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, `candidate_interventions`, typed `appraisals`, and typed `reactions` 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. - VoidBot's current routine is reference lineage only. Epiphany's native routine pass lives in Rust as `epiphany-heartbeat-store routine`: it reads typed role dossiers, projects typed memory-resonance pair documents, maintains incubation themes, runs analytic and associative cognition lanes, writes bridge syntheses/saturation/tension, produces reviewed candidate interventions, advances typed sleep/dream-cycle state, and writes an auditable routine receipt while leaving project truth and role memory mutation on their dedicated reviewed surfaces. Qdrant-backed memory vectors remain a future enhancement; the current native pass uses bounded local resonance over typed memories. @@ -293,9 +293,9 @@ rejected_paths: current_status: summary: The Codex starvation pass has five typing receipts, fifty-six processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state plus prompt-state rendering, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, native exact retrieval path matching in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines durable `Epiphany*` state structs; it re-exports the native model and renderer for legacy rollout/API compatibility. `epiphany-core` has no direct vendored Codex dependency, and `codex-core` no longer depends on `epiphany-core`: pressure derives from native `EpiphanyTokenUsageSnapshot`, Codex rollout replay stays in the real Codex rollout adapter, prompt rendering lives in `epiphany-state-model`, and `CodexThread` exposes only host state/path/persistence facts. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing execution and projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, state update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, watcher invalidation adaptation, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, and acceptance/evidence signal helpers. Vendored app-server no longer retains root Epiphany modules; `codex_message_processor.rs` still contains route dispatch, JSON-RPC response shaping, watcher registration/snapshotting calls, and notification emission. Codex product surfaces for apps, skills, plugins, marketplace, external agent config import, SDK scaffolding, connectors, ChatGPT app discovery, plugin provenance, and skill mention plumbing have been cut from the live path. `codex_thread.rs` is now about 449 lines and owns Codex thread hosting, not Epiphany policy. `epiphany-openai-codex-spine` owns the native OpenAI model transport path while intentionally reaching retained vendored `codex-login` only through `epiphany-openai-auth-spine`; auth identity, credential storage, and ChatGPT token refresh remain owned by the Codex-compatible auth organ. `epiphany-openai-runtime` writes typed OpenAI/runtime documents, loads durable worker launch requests, persists typed role/reorient worker result documents, and completes heartbeat/specialist runtime jobs without Codex worker execution. MCP itself is correctly JSON at its protocol edge; the target remains typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON. latest_cut: > - The heartbeat memory-resonance and sleep-cycle routine documents are typed. - Native routine construction, cognition persistence, legacy decode, - memory-graph import, and sleep/dream-cycle update now operate on named - CultCache documents instead of generic JSON; status still projects JSON only - as operator glass. - next_action: Continue internal CultCache purification before outward feature growth. The remaining high-signal internal JSON is the rest of `EpiphanyHeartbeatCognitionEntry`: `incubation`, `thought_lanes`, `bridge`, `candidate_interventions`, `appraisals`, and `reactions` still persist as `serde_json::Value`. Type those cognition documents one bounded organ at a time, keeping JSON only at artifact/status/wire projections and legacy decode seams; then return to app-server JSON-RPC route starvation toward CultNet contracts. + The heartbeat memory-resonance, sleep-cycle, role thought appraisal, and + derived reaction routine documents are typed. Native routine construction, + cognition persistence, legacy decode, memory-graph import, mood timing, and + sleep/dream-cycle update now operate on named CultCache documents instead of + generic JSON; status still projects JSON only as operator glass. + next_action: Continue internal CultCache purification before outward feature growth. The remaining high-signal internal JSON is the rest of `EpiphanyHeartbeatCognitionEntry`: `incubation`, `thought_lanes`, `bridge`, and `candidate_interventions` still persist as `serde_json::Value`. Type those cognition documents one bounded organ at a time, keeping JSON only at artifact/status/wire projections and legacy decode seams; then return to app-server JSON-RPC route starvation toward CultNet contracts.