Promote affect vector into heartbeat mood

This commit is contained in:
Meta Vens 2026-05-20 23:12:01 +01:00
commit b88ad337fa
8 changed files with 236 additions and 11 deletions

View file

@ -240,15 +240,29 @@ fn derive_utterance_mood(
.map(str::to_string)
.unwrap_or_else(|| inferred_mood_label(timing.map(|mood| mood.arousal), situational)),
source: timing.and_then(|mood| mood.source.clone()),
emotional_dimensions: emotional_dimensions(
situational,
anxiety,
urgency,
arousal,
thought_pressure,
guardedness,
reaction_intensity,
),
emotional_dimensions: timing
.filter(|mood| !mood.emotional_dimensions.is_empty())
.map(|mood| {
mood.emotional_dimensions
.iter()
.map(|dimension| AgentUtteranceMoodDimension {
name: dimension.name.clone(),
value: dimension.value,
source_path: dimension.source_path.clone(),
})
.collect()
})
.unwrap_or_else(|| {
emotional_dimensions(
situational,
anxiety,
urgency,
arousal,
thought_pressure,
guardedness,
reaction_intensity,
)
}),
anxiety,
urgency,
arousal,

View file

@ -1386,11 +1386,14 @@ fn apply_mood_timing_from_appraisals(
.clamp(0.0, 1.0);
let multiplier =
(1.10 - urgency * 0.24 - anxiety * 0.38 - reaction_intensity * 0.12).clamp(0.55, 1.25);
let emotional_dimensions =
heartbeat_emotional_dimensions(appraisal, anxiety, reaction_intensity);
participant.mood_cooldown_multiplier = round3(multiplier);
participant.mood_timing = Some(HeartbeatMoodTiming {
schema_version: "epiphany.mood_timing.v0".to_string(),
source: Some(appraisal.appraisal_id.clone()),
cooldown_multiplier: round3(multiplier),
emotional_dimensions,
anxiety: round3(anxiety),
urgency: round3(urgency),
arousal: round3(arousal),
@ -1402,6 +1405,120 @@ fn apply_mood_timing_from_appraisals(
}
}
fn heartbeat_emotional_dimensions(
appraisal: &HeartbeatAgentThoughtAppraisal,
anxiety: f64,
reaction_intensity: f64,
) -> Vec<HeartbeatMoodDimension> {
let emotional = &appraisal.emotional_appraisal;
let dimensions = [
("valence", emotional.valence),
("arousal", emotional.arousal),
(
"dominance",
projected_emotion(appraisal, &["dominance", "command_force"]),
),
("urgency", emotional.urgency),
(
"anger",
projected_emotion(appraisal, &["anger", "rage", "fury"]),
),
(
"despair",
projected_emotion(appraisal, &["despair", "hopelessness"]),
),
(
"sadness",
projected_emotion(appraisal, &["sadness", "grief", "sorrow"]),
),
(
"fear",
projected_emotion(appraisal, &["fear", "terror"]).max(anxiety),
),
("anxiety", anxiety),
(
"disgust",
projected_emotion(appraisal, &["disgust", "revulsion"]),
),
("contempt", projected_emotion(appraisal, &["contempt"])),
(
"annoyance",
projected_emotion(appraisal, &["annoyance", "irritation"]),
),
(
"dismissal",
projected_emotion(appraisal, &["dismissal", "dismissiveness"]),
),
(
"flippancy",
projected_emotion(appraisal, &["flippancy", "playfulness"]),
),
(
"playfulness",
projected_emotion(appraisal, &["playfulness", "play"]),
),
("irony", projected_emotion(appraisal, &["irony", "dryness"])),
("tenderness", projected_emotion(appraisal, &["tenderness"])),
("warmth", projected_emotion(appraisal, &["warmth"])),
("joy", projected_emotion(appraisal, &["joy", "delight"])),
(
"excitement",
projected_emotion(appraisal, &["excitement"])
.max(emotional.arousal * emotional.curiosity),
),
(
"fatigue",
projected_emotion(appraisal, &["fatigue", "exhaustion"]),
),
("guardedness", emotional.guardedness),
("confidence", projected_emotion(appraisal, &["confidence"])),
("shame", projected_emotion(appraisal, &["shame"])),
("pride", projected_emotion(appraisal, &["pride"])),
(
"threat",
projected_emotion(appraisal, &["threat", "menace"]),
),
(
"secrecy",
projected_emotion(appraisal, &["secrecy", "low_projection"]),
),
("hesitation", projected_emotion(appraisal, &["hesitation"])),
(
"emotionalContainment",
projected_emotion(appraisal, &["emotional_containment", "containment"]),
),
("thoughtPressure", emotional.thought_pressure),
("reactionIntensity", reaction_intensity),
(
"commandForce",
projected_emotion(appraisal, &["command_force"]),
),
];
dimensions
.into_iter()
.map(|(name, value)| HeartbeatMoodDimension {
name: name.to_string(),
value: round3(value.clamp(0.0, 1.0)),
source_path: format!("heartbeat.appraisal.{}.{}", appraisal.appraisal_id, name),
})
.collect()
}
fn projected_emotion(appraisal: &HeartbeatAgentThoughtAppraisal, needles: &[&str]) -> f64 {
appraisal
.personality_projection
.iter()
.filter(|projection| {
let name = projection.name.to_ascii_lowercase();
needles.iter().any(|needle| {
let spaced = needle.replace('_', " ");
name.contains(*needle) || name.contains(&spaced)
})
})
.map(|projection| projection.projection)
.fold(0.0_f64, f64::max)
}
fn build_memory_resonance(records: &[RoleMemoryRecord]) -> HeartbeatMemoryResonance {
let mut pairs = Vec::new();
for (left_index, left) in records.iter().enumerate() {
@ -3141,4 +3258,71 @@ mod tests {
assert_eq!(tick["schedule"]["participants"][0]["arena"], "scene");
Ok(())
}
#[test]
fn appraisal_mood_timing_carries_affect_vector() {
let mut state = default_heartbeat_state(1.0);
patch_missing_participants(&mut state);
let appraisals = HeartbeatAgentThoughtAppraisals {
schema_version: "epiphany.agent_thought_appraisals.v0".to_string(),
updated_at: "2026-05-20T00:00:00+00:00".to_string(),
thought_cluster_ref: "test-affect".to_string(),
participant_appraisals: vec![HeartbeatAgentThoughtAppraisal {
appraisal_id: "appraisal-face-affect".to_string(),
participant_agent_id: "epiphany.face".to_string(),
role_id: "face".to_string(),
emotional_appraisal: HeartbeatEmotionalAppraisal {
valence: 0.2,
arousal: 0.81,
urgency: 0.66,
curiosity: 0.14,
guardedness: 0.72,
thought_pressure: 0.77,
},
personality_projection: vec![
HeartbeatPersonalityProjection {
name: "anger".to_string(),
projection: 0.88,
..HeartbeatPersonalityProjection::default()
},
HeartbeatPersonalityProjection {
name: "dismissal".to_string(),
projection: 0.63,
..HeartbeatPersonalityProjection::default()
},
HeartbeatPersonalityProjection {
name: "flippancy".to_string(),
projection: 0.41,
..HeartbeatPersonalityProjection::default()
},
],
candidate_implications: HeartbeatCandidateImplications {
reaction_intensity: 0.79,
..HeartbeatCandidateImplications::default()
},
..HeartbeatAgentThoughtAppraisal::default()
}],
};
apply_mood_timing_from_appraisals(&mut state, &appraisals);
let face = state
.participants
.iter()
.find(|participant| participant.role_id == "face")
.expect("face participant");
let mood = face.mood_timing.as_ref().expect("face mood timing");
assert_eq!(mood.emotional_dimensions.len(), 32);
assert_eq!(mood_dimension(mood, "anger"), Some(0.88));
assert_eq!(mood_dimension(mood, "dismissal"), Some(0.63));
assert_eq!(mood_dimension(mood, "flippancy"), Some(0.41));
assert_eq!(mood_dimension(mood, "valence"), Some(0.2));
assert_eq!(mood_dimension(mood, "arousal"), Some(0.81));
}
fn mood_dimension(mood: &HeartbeatMoodTiming, name: &str) -> Option<f64> {
mood.emotional_dimensions
.iter()
.find(|dimension| dimension.name == name)
.map(|dimension| dimension.value)
}
}

View file

@ -671,6 +671,8 @@ pub struct HeartbeatMoodTiming {
pub schema_version: String,
pub source: Option<String>,
pub cooldown_multiplier: f64,
#[serde(default)]
pub emotional_dimensions: Vec<HeartbeatMoodDimension>,
pub anxiety: f64,
pub urgency: f64,
pub arousal: f64,
@ -680,6 +682,13 @@ pub struct HeartbeatMoodTiming {
pub contract: String,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct HeartbeatMoodDimension {
pub name: String,
pub value: f64,
pub source_path: String,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct HeartbeatBirthPersonalitySeed {
pub schema_version: String,

View file

@ -92,6 +92,8 @@ pub use heartbeat_state::HeartbeatHeatUpdateOptions;
pub use heartbeat_state::HeartbeatHistoryEvent;
pub use heartbeat_state::HeartbeatInitiativeHeatPolicy;
pub use heartbeat_state::HeartbeatInitiativeMultiplier;
pub use heartbeat_state::HeartbeatMoodDimension;
pub use heartbeat_state::HeartbeatMoodTiming;
pub use heartbeat_state::HeartbeatPacingPolicy;
pub use heartbeat_state::HeartbeatParticipant;
pub use heartbeat_state::HeartbeatParticipantLocalContext;

View file

@ -143,7 +143,7 @@ remembers doctrine; the branch remembers the blade.
- 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. Relationship, event, scene, and perceived-overlay arrays are typed dossier documents, not JSON cargo, and the durable structs do not keep unknown `extra` maps. `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, Python wrapper state, live heartbeat timing `extra` maps, JSON `sleepCycle` persistence, and JSON `memoryResonance` persistence 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 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. Mood is now official physiology, not prose: `HeartbeatMoodTiming.emotional_dimensions` carries the 32-axis current affect vector that utterance state turns into the Weksa/AquaSynth 64-float character-state lane. `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, Python wrapper state, live heartbeat timing `extra` maps, JSON `sleepCycle` persistence, and JSON `memoryResonance` persistence 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.
- Heartbeat initiative heat is now part of that seam. `EpiphanyHeartbeatStateEntry` owns `initiative_heat`, pacing applies active global/all/agent/role/arena/participant-kind/group/constraint multipliers into per-participant `initiativeHeatMultiplier`, and recovery divides by that multiplier. The CLI exposes `epiphany-heartbeat-store heat`, status/schedule projections show heat, and the CultNet catalog advertises both `epiphany.heartbeat_initiative_heat.v0` and coordinator intent `epiphany.heartbeat_heat_intent.v0`; runtime-spine hello lists the heat intent on the heartbeat mutation contract. Smoke proves a heated implementation lane reaches the live action catalog with `initiative_heat_multiplier: 4.0`.

View file

@ -74,6 +74,15 @@ Each participant tracks:
- `constraints`
- last action metadata
- optional `pending_turn`
- optional `mood_timing`
- `cooldown_multiplier`
- scalar timing pressures: `anxiety`, `urgency`, `arousal`,
`thought_pressure`, `guardedness`, `reaction_intensity`
- `emotional_dimensions`: the 32-axis current affect vector used by
utterance-state projection, including anger, despair, sadness, fear,
contempt, annoyance, dismissal, flippancy, tenderness, warmth, shame,
pride, fatigue, secrecy, hesitation, emotional containment, and command
force
Maintenance participants are the standing Epiphany organs. Scene participants
reuse the same timing law for Ghostlight-style character turns.
@ -104,6 +113,13 @@ Heartbeat is physiology, not identity.
Role dossiers describe what an organ is. Heartbeat describes how often it gets
the floor, how reactive it is, and how current pressure bends that timing.
Current emotional state is heartbeat physiology. Appraisals write a bounded
named affect vector into `mood_timing`; utterance state consumes that live vector
before falling back to slower dossier traits. If anger, despair, annoyance,
dismissal, flippancy, or any other speech-relevant feeling is meant to color a
voice, it must exist here or in the typed appraisal feeding this field, not only
as prose in a prompt.
Birth-time repo personality may seed heartbeat timing once. After that, routine
state, appraisal, mood, continuity pressure, and live work should carry the
motion.

Binary file not shown.

View file

@ -173,7 +173,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`, `candidate_interventions`, typed `appraisals`, and typed `reactions` 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. `HeartbeatMoodTiming` now also owns the 32-axis current affect vector used by utterance state: anger, despair, sadness, fear, contempt, annoyance, dismissal, flippancy, tenderness, warmth, shame, pride, fatigue, secrecy, hesitation, emotional containment, and related speech pressures are heartbeat physiology, not decorative prompt adjectives. 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.