Type heartbeat thought lanes

This commit is contained in:
Meta Vens 2026-05-18 10:55:07 +01:00
commit 5863d97f8b
7 changed files with 139 additions and 62 deletions

View file

@ -87,12 +87,14 @@ pub fn run_void_routine_store(
&resonance,
&memory_records,
);
let thought_lanes = build_thought_lanes(&resonance_view, &incubation, &memory_records);
let thought_lanes = build_thought_lanes(&resonance, &incubation, &memory_records);
let thought_lanes_view =
serde_json::to_value(&thought_lanes).context("failed to project typed thought lanes")?;
let bridge = build_thought_bridge(
&previous_cognition
.as_ref()
.and_then(|entry| entry.bridge.clone()),
&thought_lanes,
&thought_lanes_view,
&resonance_view,
&incubation,
);
@ -101,7 +103,7 @@ pub fn run_void_routine_store(
let candidate_interventions = build_candidate_interventions(&bridge_view, &incubation);
let appraisals = build_agent_appraisals(
&appraisal_profiles,
&thought_lanes,
&thought_lanes_view,
&incubation,
&bridge_view,
);
@ -1583,35 +1585,31 @@ fn build_incubation(
}
fn build_thought_lanes(
resonance: &Value,
resonance: &HeartbeatMemoryResonance,
incubation: &Value,
records: &[RoleMemoryRecord],
) -> Value {
) -> HeartbeatThoughtLanes {
let analytic_threads = resonance
.get("pairs")
.and_then(Value::as_array)
.into_iter()
.flatten()
.pairs
.iter()
.take(4)
.enumerate()
.map(|(index, pair)| {
let left_role = pair.get("leftRole").and_then(Value::as_str).unwrap_or("left");
let right_role = pair.get("rightRole").and_then(Value::as_str).unwrap_or("right");
let strength = pair.get("strength").and_then(Value::as_f64).unwrap_or(0.0);
serde_json::json!({
"threadId": format!("analytic-{left_role}-{right_role}-{index}"),
"topic": format!("{left_role}/{right_role} evidence seam"),
"claim": format!("{} and {} share a recurring memory edge; inspect whether this changes lane routing or evidence expectations.", display_name_for_role(left_role), display_name_for_role(right_role)),
"evidenceRefs": [
pair.get("leftMemoryId").and_then(Value::as_str).unwrap_or_default(),
pair.get("rightMemoryId").and_then(Value::as_str).unwrap_or_default()
],
"salience": round3(strength),
"confidence": round3((0.55 + strength).min(0.95)),
"desireToAct": round3((strength * 1.4).min(0.85)),
"counterweight": "Shared vocabulary is not proof of shared truth; verify against artifacts before changing project state.",
"lastTouchedAt": now_iso(),
})
let left_role = pair.left_role.as_str();
let right_role = pair.right_role.as_str();
let strength = pair.strength;
HeartbeatThoughtThread {
thread_id: format!("analytic-{left_role}-{right_role}-{index}"),
topic: format!("{left_role}/{right_role} evidence seam"),
claim: format!("{} and {} share a recurring memory edge; inspect whether this changes lane routing or evidence expectations.", display_name_for_role(left_role), display_name_for_role(right_role)),
evidence_refs: vec![pair.left_memory_id.clone(), pair.right_memory_id.clone()],
salience: round3(strength),
confidence: round3((0.55 + strength).min(0.95)),
desire_to_act: Some(round3((strength * 1.4).min(0.85))),
counterweight: "Shared vocabulary is not proof of shared truth; verify against artifacts before changing project state.".to_string(),
last_touched_at: now_iso(),
..Default::default()
}
})
.collect::<Vec<_>>();
@ -1628,18 +1626,40 @@ fn build_thought_lanes(
.and_then(Value::as_str)
.unwrap_or("incubating-theme");
let strength = theme.get("strength").and_then(Value::as_f64).unwrap_or(0.0);
serde_json::json!({
"threadId": format!("associative-{topic}-{index}"),
"topic": topic,
"claim": theme.get("summary").and_then(Value::as_str).unwrap_or("An incubating thought wants another pass before it speaks."),
"sourceThemeId": topic,
"novelty": theme.get("novelty").cloned().unwrap_or_else(|| serde_json::json!(round3((0.42 + strength).min(0.92)))),
"roomRelevance": theme.get("noveltyToRoom").cloned().unwrap_or_else(|| serde_json::json!(round3((0.35 + strength).min(0.88)))),
"desireToSpeak": theme.get("desireToSpeak").cloned().unwrap_or_else(|| serde_json::json!(round3((strength * 1.25).min(0.8)))),
"status": theme.get("status").cloned().unwrap_or_else(|| serde_json::json!("incubating")),
"counterweight": "A theme that keeps returning may be signal, obsession, or stale echo; the bridge must decide.",
"lastTouchedAt": now_iso(),
})
HeartbeatThoughtThread {
thread_id: format!("associative-{topic}-{index}"),
topic: topic.to_string(),
claim: theme.get("summary").and_then(Value::as_str).unwrap_or("An incubating thought wants another pass before it speaks.").to_string(),
source_theme_id: Some(topic.to_string()),
novelty: Some(
theme
.get("novelty")
.and_then(Value::as_f64)
.unwrap_or_else(|| round3((0.42 + strength).min(0.92))),
),
room_relevance: Some(
theme
.get("noveltyToRoom")
.and_then(Value::as_f64)
.unwrap_or_else(|| round3((0.35 + strength).min(0.88))),
),
desire_to_speak: Some(
theme
.get("desireToSpeak")
.and_then(Value::as_f64)
.unwrap_or_else(|| round3((strength * 1.25).min(0.8))),
),
status: Some(
theme
.get("status")
.and_then(Value::as_str)
.unwrap_or("incubating")
.to_string(),
),
counterweight: "A theme that keeps returning may be signal, obsession, or stale echo; the bridge must decide.".to_string(),
last_touched_at: now_iso(),
..Default::default()
}
})
.collect::<Vec<_>>();
@ -1647,35 +1667,42 @@ fn build_thought_lanes(
records
.first()
.map(|record| {
vec![serde_json::json!({
"threadId": format!("analytic-{}-seed", record.role_id),
"topic": format!("{} strongest memory", record.role_id),
"claim": record.summary,
"evidenceRefs": [record.memory_id],
"salience": round3(record.salience),
"confidence": round3(record.confidence),
"desireToAct": 0.2,
"counterweight": "One hot memory is only a seed; do not let it annex the whole mind.",
"lastTouchedAt": now_iso(),
})]
vec![HeartbeatThoughtThread {
thread_id: format!("analytic-{}-seed", record.role_id),
topic: format!("{} strongest memory", record.role_id),
claim: record.summary.clone(),
evidence_refs: vec![record.memory_id.clone()],
salience: round3(record.salience),
confidence: round3(record.confidence),
desire_to_act: Some(0.2),
counterweight:
"One hot memory is only a seed; do not let it annex the whole mind."
.to_string(),
last_touched_at: now_iso(),
..Default::default()
}]
})
.unwrap_or_default()
} else {
Vec::new()
};
serde_json::json!({
"schema_version": "epiphany.cognition_lanes.v0",
"updatedAt": now_iso(),
"analytic": {
"description": "Literal, evidence-facing lane: what is happening, what constraints matter, what action is justified.",
"activeThreads": if analytic_threads.is_empty() { seed_threads } else { analytic_threads },
HeartbeatThoughtLanes {
schema_version: "epiphany.cognition_lanes.v0".to_string(),
updated_at: now_iso(),
analytic: HeartbeatThoughtLane {
description: "Literal, evidence-facing lane: what is happening, what constraints matter, what action is justified.".to_string(),
active_threads: if analytic_threads.is_empty() {
seed_threads
} else {
analytic_threads
},
},
"associative": {
"description": "Pattern-facing lane: what this rhymes with, what seam is ripening, what surprising branch may be worth a later retrieval hop.",
"activeThreads": associative_threads,
associative: HeartbeatThoughtLane {
description: "Pattern-facing lane: what this rhymes with, what seam is ripening, what surprising branch may be worth a later retrieval hop.".to_string(),
active_threads: associative_threads,
},
})
}
}
fn build_thought_bridge(

View file

@ -63,7 +63,7 @@ pub struct EpiphanyHeartbeatCognitionEntry {
#[cultcache(key = 7, default)]
pub incubation: Option<Value>,
#[cultcache(key = 8, default)]
pub thought_lanes: Option<Value>,
pub thought_lanes: Option<HeartbeatThoughtLanes>,
#[cultcache(key = 9, default)]
pub bridge: Option<HeartbeatCognitionBridge>,
#[cultcache(key = 10, default)]
@ -180,6 +180,49 @@ pub struct HeartbeatCognitionBridge {
pub decision: HeartbeatBridgeDecision,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HeartbeatThoughtLanes {
#[serde(rename = "schema_version")]
pub schema_version: String,
pub updated_at: String,
pub analytic: HeartbeatThoughtLane,
pub associative: HeartbeatThoughtLane,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HeartbeatThoughtLane {
pub description: String,
pub active_threads: Vec<HeartbeatThoughtThread>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HeartbeatThoughtThread {
pub thread_id: String,
pub topic: String,
pub claim: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub evidence_refs: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_theme_id: Option<String>,
pub salience: f64,
pub confidence: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub desire_to_act: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub novelty: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub room_relevance: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub desire_to_speak: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
pub counterweight: String,
pub last_touched_at: String,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HeartbeatBridgeSynthesis {

View file

@ -81,7 +81,7 @@ pub fn heartbeat_status_projection(
"sleepCycle": cognition.as_ref().and_then(|entry| entry.sleep_cycle.as_ref()).and_then(typed_json),
"memoryResonance": cognition.as_ref().and_then(|entry| entry.memory_resonance.as_ref()).and_then(typed_json),
"incubation": cognition.as_ref().and_then(|entry| entry.incubation.clone()),
"thoughtLanes": cognition.as_ref().and_then(|entry| entry.thought_lanes.clone()),
"thoughtLanes": cognition.as_ref().and_then(|entry| entry.thought_lanes.as_ref()).and_then(typed_json),
"bridge": cognition.as_ref().and_then(|entry| entry.bridge.as_ref()).and_then(typed_json),
"candidateInterventions": cognition.as_ref().and_then(|entry| entry.candidate_interventions.as_ref()).and_then(typed_json),
"appraisals": cognition.as_ref().and_then(|entry| entry.appraisals.as_ref()).and_then(typed_json),

View file

@ -134,7 +134,9 @@ fn legacy_heartbeat_cognition_entry(
.memory_resonance
.and_then(|value| serde_json::from_value(value).ok()),
incubation: legacy.incubation,
thought_lanes: legacy.thought_lanes,
thought_lanes: legacy
.thought_lanes
.and_then(|value| serde_json::from_value(value).ok()),
bridge: legacy
.bridge
.and_then(|value| serde_json::from_value(value).ok()),

View file

@ -73,6 +73,7 @@ remembers doctrine; the branch remembers the blade.
- Heartbeat cognition memory resonance now lives as typed resonance pairs instead of an `Option<Value>` blob. Incubation and memory graph import read typed pairs directly; temporary JSON projection remains only for still-untyped thought-lane/bridge builders and status/artifact output.
- Heartbeat cognition sleep cycle now lives as typed physiology state instead of an `Option<Value>` blob. Legacy sleep JSON is parsed only during old-store migration; status and routine artifacts receive JSON projections.
- Heartbeat cognition bridge judgment now lives as typed durable state instead of an `Option<Value>` blob: syntheses, source coverage, topic saturation, refractory topics, tensions, and speech decision are typed fields. The memory graph heartbeat profile reads typed bridge decisions directly; only incubation and thought lanes remain as live cognition JSON pockets.
- Heartbeat cognition thought lanes now live as typed durable state instead of `Option<Value>` analytic/associative lane blobs. Temporary JSON projection remains only for still-untyped incubation-adjacent cognition helpers and status/artifact output; incubation is the last live cognition JSON pocket.
- 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`. The root `heartbeat_state.rs` keeps scheduling and Void cognition orchestration for the next cuts. Focused heartbeat tests and `epiphany-core` check pass after the splits.
- 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.

Binary file not shown.

View file

@ -70,6 +70,10 @@ objective:
decision are typed fields. Incubation/thought lanes are the remaining live
cognition JSON pockets, with bridge consuming them through explicit
temporary projections until their own cuts land.
Heartbeat cognition thought lanes are typed durable state; analytic and
associative active-thread lists no longer persist as arbitrary JSON. The
only remaining live cognition `Option<Value>` pocket is incubation, while
legacy cognition fields remain JSON only for old-store migration.
constraints:
- No frontier-scale training tithe.