Collapse heartbeat to owned physiology
This commit is contained in:
parent
17a867e89d
commit
2164bd0a21
17 changed files with 118 additions and 2145 deletions
|
|
@ -3,29 +3,17 @@ use anyhow::Result;
|
|||
use anyhow::anyhow;
|
||||
use epiphany_core::EpiphanyCultMeshSwarmBrakeEntry;
|
||||
use epiphany_core::EpiphanyHeartbeatArtifactRetentionReceipt;
|
||||
use epiphany_core::GhostlightSceneParticipantSeed;
|
||||
use epiphany_core::HeartbeatCompleteOptions;
|
||||
use epiphany_core::HeartbeatHeatUpdateOptions;
|
||||
use epiphany_core::HeartbeatPumpOptions;
|
||||
use epiphany_core::HeartbeatQueueMentionOptions;
|
||||
use epiphany_core::HeartbeatStaleTurnRepairOptions;
|
||||
use epiphany_core::HeartbeatTickOptions;
|
||||
use epiphany_core::complete_heartbeat_store;
|
||||
use epiphany_core::heartbeat_local_provider_status;
|
||||
use epiphany_core::heartbeat_status_projection;
|
||||
use epiphany_core::initialize_ghostlight_scene_heartbeat_store;
|
||||
use epiphany_core::initialize_heartbeat_store;
|
||||
use epiphany_core::load_epiphany_cultmesh_swarm_brake;
|
||||
use epiphany_core::load_heartbeat_state_entry;
|
||||
use epiphany_core::pulse_persona_heartbeat;
|
||||
use epiphany_core::pulse_resident_self_heartbeat;
|
||||
use epiphany_core::pump_heartbeat_store;
|
||||
use epiphany_core::queue_heartbeat_pending_mention_store;
|
||||
use epiphany_core::recover_stale_heartbeat_store;
|
||||
use epiphany_core::resident_cognitive_runtime_id;
|
||||
use epiphany_core::retain_heartbeat_pulse_artifacts;
|
||||
use epiphany_core::tick_heartbeat_store;
|
||||
use epiphany_core::update_heartbeat_heat_store;
|
||||
use epiphany_core::{
|
||||
ResidentProviderReadiness, acquire_resident_process_singleton,
|
||||
authenticate_epiphany_packaged_release, capture_process_instance,
|
||||
|
|
@ -51,46 +39,12 @@ fn main() -> Result<()> {
|
|||
let mut artifact_dir: Option<PathBuf> = None;
|
||||
let mut local_verse_store: Option<PathBuf> = None;
|
||||
let mut target_heartbeat_rate = 1.0_f64;
|
||||
let mut min_heartbeat_rate = 0.05_f64;
|
||||
let mut max_heartbeat_rate = 4.0_f64;
|
||||
let mut min_concurrency = 1_usize;
|
||||
let mut max_concurrency = 8_usize;
|
||||
let mut max_ticks = 8_usize;
|
||||
let mut coordinator_action: Option<String> = None;
|
||||
let mut target_role: Option<String> = None;
|
||||
let mut urgency = 0.75_f64;
|
||||
let mut urgency_explicit = false;
|
||||
let mut schedule_id = "epiphany-heartbeat".to_string();
|
||||
let mut source_scene_ref = "epiphany/coordinator".to_string();
|
||||
let mut defer_completion = false;
|
||||
let mut role: Option<String> = None;
|
||||
let mut action_id: Option<String> = None;
|
||||
let mut limit = 8_usize;
|
||||
let mut resident_self_store: Option<PathBuf> = None;
|
||||
let mut resident_runtime_store: Option<PathBuf> = None;
|
||||
let mut profile = "epiphany".to_string();
|
||||
let mut scene_id = "ghostlight.scene".to_string();
|
||||
let mut scene_participants = Vec::<GhostlightSceneParticipantSeed>::new();
|
||||
let mut heat_scope = "global".to_string();
|
||||
let mut heat_selector = String::new();
|
||||
let mut heat_multiplier = 1.0_f64;
|
||||
let mut heat_id: Option<String> = None;
|
||||
let mut heat_label: Option<String> = None;
|
||||
let mut heat_reason: Option<String> = None;
|
||||
let mut heat_expires_after: Option<f64> = None;
|
||||
let mut heat_clear = false;
|
||||
let mut channel_id: Option<String> = None;
|
||||
let mut message_id: Option<String> = None;
|
||||
let mut author_id: Option<String> = None;
|
||||
let mut author_name: Option<String> = None;
|
||||
let mut content: Option<String> = None;
|
||||
let mut visible_prompt: Option<String> = None;
|
||||
let mut reply_to_message_id: Option<String> = None;
|
||||
let mut source_surface = "operator".to_string();
|
||||
let mut mention_id: Option<String> = None;
|
||||
let mut source_visibility = "private".to_string();
|
||||
let mut data_classification = "operator_input".to_string();
|
||||
let mut model_provider_id = "operator-configured".to_string();
|
||||
let mut repair_reason: Option<String> = None;
|
||||
let mut max_age_seconds = 1800_i64;
|
||||
let mut now_utc: Option<String> = None;
|
||||
let mut interval_seconds = 120_u64;
|
||||
|
|
@ -112,32 +66,8 @@ fn main() -> Result<()> {
|
|||
"--target-heartbeat-rate" => {
|
||||
target_heartbeat_rate = next_value(&mut args, "--target-heartbeat-rate")?.parse()?
|
||||
}
|
||||
"--min-heartbeat-rate" => {
|
||||
min_heartbeat_rate = next_value(&mut args, "--min-heartbeat-rate")?.parse()?
|
||||
}
|
||||
"--max-heartbeat-rate" => {
|
||||
max_heartbeat_rate = next_value(&mut args, "--max-heartbeat-rate")?.parse()?
|
||||
}
|
||||
"--min-concurrency" => {
|
||||
min_concurrency = next_value(&mut args, "--min-concurrency")?.parse()?
|
||||
}
|
||||
"--max-concurrency" => {
|
||||
max_concurrency = next_value(&mut args, "--max-concurrency")?.parse()?
|
||||
}
|
||||
"--max-ticks" => max_ticks = next_value(&mut args, "--max-ticks")?.parse()?,
|
||||
"--coordinator-action" => {
|
||||
coordinator_action = Some(next_value(&mut args, "--coordinator-action")?)
|
||||
}
|
||||
"--target-role" => target_role = Some(next_value(&mut args, "--target-role")?),
|
||||
"--urgency" => {
|
||||
urgency = next_value(&mut args, "--urgency")?.parse()?;
|
||||
urgency_explicit = true;
|
||||
}
|
||||
"--schedule-id" => schedule_id = next_value(&mut args, "--schedule-id")?,
|
||||
"--source-scene-ref" => source_scene_ref = next_value(&mut args, "--source-scene-ref")?,
|
||||
"--defer-completion" => defer_completion = true,
|
||||
"--role" => role = Some(next_value(&mut args, "--role")?),
|
||||
"--action-id" => action_id = Some(next_value(&mut args, "--action-id")?),
|
||||
"--limit" => limit = next_value(&mut args, "--limit")?.parse()?,
|
||||
"--resident-self-store" => {
|
||||
resident_self_store = Some(next_path(&mut args, "--resident-self-store")?)
|
||||
|
|
@ -145,41 +75,7 @@ fn main() -> Result<()> {
|
|||
"--resident-runtime-store" => {
|
||||
resident_runtime_store = Some(next_path(&mut args, "--resident-runtime-store")?)
|
||||
}
|
||||
"--profile" => profile = next_value(&mut args, "--profile")?,
|
||||
"--scene-id" => scene_id = next_value(&mut args, "--scene-id")?,
|
||||
"--scene-participant" => scene_participants.push(parse_scene_participant(
|
||||
&next_value(&mut args, "--scene-participant")?,
|
||||
)?),
|
||||
"--scope" => heat_scope = next_value(&mut args, "--scope")?,
|
||||
"--selector" => heat_selector = next_value(&mut args, "--selector")?,
|
||||
"--multiplier" => heat_multiplier = next_value(&mut args, "--multiplier")?.parse()?,
|
||||
"--id" => heat_id = Some(next_value(&mut args, "--id")?),
|
||||
"--label" => heat_label = Some(next_value(&mut args, "--label")?),
|
||||
"--reason" => heat_reason = Some(next_value(&mut args, "--reason")?),
|
||||
"--expires-after" => {
|
||||
heat_expires_after = Some(next_value(&mut args, "--expires-after")?.parse()?)
|
||||
}
|
||||
"--clear" => heat_clear = true,
|
||||
"--channel-id" => channel_id = Some(next_value(&mut args, "--channel-id")?),
|
||||
"--message-id" => message_id = Some(next_value(&mut args, "--message-id")?),
|
||||
"--author-id" => author_id = Some(next_value(&mut args, "--author-id")?),
|
||||
"--author-name" => author_name = Some(next_value(&mut args, "--author-name")?),
|
||||
"--content" => content = Some(next_value(&mut args, "--content")?),
|
||||
"--visible-prompt" => visible_prompt = Some(next_value(&mut args, "--visible-prompt")?),
|
||||
"--reply-to-message-id" => {
|
||||
reply_to_message_id = Some(next_value(&mut args, "--reply-to-message-id")?)
|
||||
}
|
||||
"--source-surface" => source_surface = next_value(&mut args, "--source-surface")?,
|
||||
"--mention-id" => mention_id = Some(next_value(&mut args, "--mention-id")?),
|
||||
"--source-visibility" => {
|
||||
source_visibility = next_value(&mut args, "--source-visibility")?
|
||||
}
|
||||
"--data-classification" => {
|
||||
data_classification = next_value(&mut args, "--data-classification")?
|
||||
}
|
||||
"--model-provider-id" => {
|
||||
model_provider_id = next_value(&mut args, "--model-provider-id")?
|
||||
}
|
||||
"--reason" => repair_reason = Some(next_value(&mut args, "--reason")?),
|
||||
"--max-age-seconds" => {
|
||||
max_age_seconds = next_value(&mut args, "--max-age-seconds")?.parse()?
|
||||
}
|
||||
|
|
@ -212,22 +108,12 @@ fn main() -> Result<()> {
|
|||
match command.as_str() {
|
||||
"init" => {
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("init requires --store"))?;
|
||||
let state = match profile.as_str() {
|
||||
"epiphany" => initialize_heartbeat_store(&store_path, target_heartbeat_rate)?,
|
||||
"ghostlight-scene" => initialize_ghostlight_scene_heartbeat_store(
|
||||
&store_path,
|
||||
target_heartbeat_rate,
|
||||
scene_id.clone(),
|
||||
scene_participants,
|
||||
)?,
|
||||
other => return Err(anyhow!("unknown heartbeat profile {other:?}")),
|
||||
};
|
||||
let state = initialize_heartbeat_store(&store_path, target_heartbeat_rate)?;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
"ok": true,
|
||||
"command": "init",
|
||||
"profile": profile,
|
||||
"storeFile": store_path,
|
||||
"schemaVersion": state.schema_version,
|
||||
"participants": state.participants.len(),
|
||||
|
|
@ -235,44 +121,6 @@ fn main() -> Result<()> {
|
|||
})
|
||||
);
|
||||
}
|
||||
"tick" => {
|
||||
assert_swarm_brake_allows_heartbeat(
|
||||
&local_verse_store,
|
||||
release_runtime_id.as_deref(),
|
||||
"tick",
|
||||
)?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("tick requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("tick requires --artifact-dir"))?;
|
||||
let tick_schedule_id = schedule_id.clone();
|
||||
let mut result = tick_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatTickOptions {
|
||||
target_heartbeat_rate,
|
||||
coordinator_action,
|
||||
target_role,
|
||||
urgency,
|
||||
schedule_id: tick_schedule_id,
|
||||
source_scene_ref,
|
||||
defer_completion,
|
||||
resident_self_store: resident_self_store.clone(),
|
||||
},
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"complete" => {
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("complete requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("complete requires --artifact-dir"))?;
|
||||
let role = role.ok_or_else(|| anyhow!("complete requires --role"))?;
|
||||
let result = complete_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatCompleteOptions { role, action_id },
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"repair-stale" => {
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("repair-stale requires --store"))?;
|
||||
let artifact_dir =
|
||||
|
|
@ -283,7 +131,7 @@ fn main() -> Result<()> {
|
|||
HeartbeatStaleTurnRepairOptions {
|
||||
max_age_seconds,
|
||||
now_utc,
|
||||
reason: heat_reason.unwrap_or_else(|| {
|
||||
reason: repair_reason.unwrap_or_else(|| {
|
||||
"Operator requested stale heartbeat turn recovery.".to_string()
|
||||
}),
|
||||
},
|
||||
|
|
@ -312,91 +160,6 @@ fn main() -> Result<()> {
|
|||
})
|
||||
);
|
||||
}
|
||||
"pump" => {
|
||||
assert_swarm_brake_allows_heartbeat(
|
||||
&local_verse_store,
|
||||
release_runtime_id.as_deref(),
|
||||
"pump",
|
||||
)?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("pump requires --store"))?;
|
||||
let artifact_dir =
|
||||
artifact_dir.ok_or_else(|| anyhow!("pump requires --artifact-dir"))?;
|
||||
let result = pump_heartbeat_store(
|
||||
&store_path,
|
||||
&artifact_dir,
|
||||
HeartbeatPumpOptions {
|
||||
base_heartbeat_rate: target_heartbeat_rate,
|
||||
min_heartbeat_rate,
|
||||
max_heartbeat_rate,
|
||||
min_concurrency,
|
||||
max_concurrency,
|
||||
max_ticks,
|
||||
external_urgency: if urgency_explicit { urgency } else { 0.0 },
|
||||
coordinator_action,
|
||||
target_role,
|
||||
schedule_id,
|
||||
source_scene_ref,
|
||||
resident_self_store,
|
||||
},
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"heat" => {
|
||||
assert_swarm_brake_allows_heartbeat(
|
||||
&local_verse_store,
|
||||
release_runtime_id.as_deref(),
|
||||
"heat",
|
||||
)?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("heat requires --store"))?;
|
||||
let result = update_heartbeat_heat_store(
|
||||
&store_path,
|
||||
HeartbeatHeatUpdateOptions {
|
||||
scope: heat_scope,
|
||||
selector: heat_selector,
|
||||
multiplier: heat_multiplier,
|
||||
id: heat_id,
|
||||
label: heat_label,
|
||||
reason: heat_reason,
|
||||
expires_after_scene_clock: heat_expires_after,
|
||||
clear: heat_clear,
|
||||
},
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"queue-mention" => {
|
||||
assert_swarm_brake_allows_heartbeat(
|
||||
&local_verse_store,
|
||||
release_runtime_id.as_deref(),
|
||||
"queue-mention",
|
||||
)?;
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("queue-mention requires --store"))?;
|
||||
let target_role_id = role.unwrap_or_else(|| "Persona".to_string());
|
||||
let result = queue_heartbeat_pending_mention_store(
|
||||
&store_path,
|
||||
HeartbeatQueueMentionOptions {
|
||||
target_role_id,
|
||||
source_surface,
|
||||
channel_id: channel_id
|
||||
.ok_or_else(|| anyhow!("queue-mention requires --channel-id"))?,
|
||||
message_id: message_id
|
||||
.ok_or_else(|| anyhow!("queue-mention requires --message-id"))?,
|
||||
author_id: author_id
|
||||
.ok_or_else(|| anyhow!("queue-mention requires --author-id"))?,
|
||||
author_name,
|
||||
content: content.ok_or_else(|| anyhow!("queue-mention requires --content"))?,
|
||||
visible_prompt: visible_prompt
|
||||
.ok_or_else(|| anyhow!("queue-mention requires --visible-prompt"))?,
|
||||
reply_to_message_id,
|
||||
queued_at: None,
|
||||
mention_id,
|
||||
source_visibility,
|
||||
data_classification,
|
||||
model_provider_id,
|
||||
model_provider_disclosure_allowed: true,
|
||||
},
|
||||
)?;
|
||||
println!("{}", result);
|
||||
}
|
||||
"status" => {
|
||||
let store_path = store_path.ok_or_else(|| anyhow!("status requires --store"))?;
|
||||
if let Some(artifact_dir) = artifact_dir {
|
||||
|
|
@ -752,36 +515,14 @@ fn next_value(args: &mut impl Iterator<Item = String>, name: &str) -> Result<Str
|
|||
|
||||
fn usage() -> Result<()> {
|
||||
Err(anyhow!(concat!(
|
||||
"usage: epiphany-heartbeat-store init --store <path> [--profile epiphany|ghostlight-scene] [--scene-id <id>] [--scene-participant <seed>]\n",
|
||||
" epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store pump --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store heat --store <path> [options]\n",
|
||||
" epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n",
|
||||
"usage: epiphany-heartbeat-store init --store <path> [--target-heartbeat-rate <n>]\n",
|
||||
" epiphany-heartbeat-store repair-stale --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store retain-artifacts --store <path> --artifact-dir <path> [--retain-pulse-artifacts <n>] [--retention-batch-size <n>]\n",
|
||||
" epiphany-heartbeat-store queue-mention --store <path> [options]\n",
|
||||
" epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n",
|
||||
" epiphany-heartbeat-store serve --store <path> --artifact-dir <path> [--local-verse-store <path>] [--resident-self-store <path> --resident-runtime-store <path>] [--interval-seconds <n>] [--max-iterations <n>]"
|
||||
)))
|
||||
}
|
||||
|
||||
fn assert_swarm_brake_allows_heartbeat(
|
||||
local_verse_store: &Option<PathBuf>,
|
||||
runtime_id: Option<&str>,
|
||||
command: &str,
|
||||
) -> Result<()> {
|
||||
if let Some(brake) = active_swarm_brake(local_verse_store, runtime_id)? {
|
||||
anyhow::bail!(
|
||||
"epiphany-heartbeat-store {command} refusing to run: local Verse swarm brake engaged; scope={}; protected={}; affected={}; reason={}",
|
||||
brake.scope,
|
||||
brake.protected_surfaces.join(","),
|
||||
brake.affected_clusters.join(","),
|
||||
brake.reason
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn heartbeat_brake_runtime_id(
|
||||
resident_self_store: &Option<PathBuf>,
|
||||
resident_runtime_store: &Option<PathBuf>,
|
||||
|
|
@ -878,25 +619,6 @@ mod brake_tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retention_receipt_projection_names_operator_fields() {
|
||||
let projection = retention_receipt_projection(&EpiphanyHeartbeatArtifactRetentionReceipt {
|
||||
schema_version: "epiphany.heartbeat.artifact_retention_receipt.v0".into(),
|
||||
receipt_id: "receipt-1".into(),
|
||||
plan_id: "plan-1".into(),
|
||||
status: "completed".into(),
|
||||
deleted_directories: vec!["pulse-000001".into()],
|
||||
deleted_file_count: 2,
|
||||
deleted_byte_count: 3,
|
||||
completed_at_utc: "2026-08-08T21:00:00Z".into(),
|
||||
private_state_exposed: false,
|
||||
});
|
||||
assert_eq!(projection["receiptId"], "receipt-1");
|
||||
assert_eq!(projection["deletedDirectories"][0], "pulse-000001");
|
||||
assert_eq!(projection["deletedFileCount"], 2);
|
||||
assert!(projection.as_array().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resident_heartbeat_resumes_after_highest_artifact_sequence() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
@ -908,25 +630,3 @@ mod brake_tests {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_scene_participant(raw: &str) -> Result<GhostlightSceneParticipantSeed> {
|
||||
let parts = raw.split('|').collect::<Vec<_>>();
|
||||
if parts.len() != 6 {
|
||||
return Err(anyhow!(
|
||||
"--scene-participant must be id|name|speed|reaction|threshold|constraint;constraint"
|
||||
));
|
||||
}
|
||||
Ok(GhostlightSceneParticipantSeed {
|
||||
agent_id: parts[0].trim().to_string(),
|
||||
display_name: parts[1].trim().to_string(),
|
||||
initiative_speed: parts[2].trim().parse()?,
|
||||
reaction_bias: parts[3].trim().parse()?,
|
||||
interrupt_threshold: parts[4].trim().parse()?,
|
||||
constraints: parts[5]
|
||||
.split(';')
|
||||
.map(str::trim)
|
||||
.filter(|item| !item.is_empty())
|
||||
.map(str::to_string)
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -5,9 +5,9 @@ use serde_json::Value;
|
|||
|
||||
pub const HEARTBEAT_STATE_TYPE: &str = "epiphany.agent_heartbeat";
|
||||
pub const HEARTBEAT_STATE_KEY: &str = "default";
|
||||
pub const HEARTBEAT_STATE_SCHEMA_VERSION: &str = "epiphany.agent_heartbeat.v0";
|
||||
pub const HEARTBEAT_STATE_SCHEMA_VERSION: &str = "epiphany.agent_heartbeat.v1";
|
||||
pub const HEARTBEAT_STATUS_SCHEMA_VERSION: &str = "epiphany.agent_heartbeat_status.v0";
|
||||
pub const INITIATIVE_SCHEMA_VERSION: &str = "ghostlight.initiative_schedule.v0";
|
||||
pub const INITIATIVE_SCHEMA_VERSION: &str = "epiphany.heartbeat_schedule.v0";
|
||||
pub const HEARTBEAT_STALE_TURN_REPAIR_TYPE: &str = "epiphany.heartbeat.stale_turn_repair";
|
||||
pub const HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION: &str =
|
||||
"epiphany.heartbeat.stale_turn_repair.v0";
|
||||
|
|
@ -52,12 +52,6 @@ pub struct EpiphanyHeartbeatStateEntry {
|
|||
pub participants: Vec<HeartbeatParticipant>,
|
||||
#[cultcache(key = 6)]
|
||||
pub history: Vec<HeartbeatHistoryEvent>,
|
||||
#[cultcache(key = 16, default)]
|
||||
pub initiative_heat: HeartbeatInitiativeHeatPolicy,
|
||||
#[cultcache(key = 17, default)]
|
||||
pub protocol: Option<HeartbeatProtocol>,
|
||||
#[cultcache(key = 18, default)]
|
||||
pub adaptive_pacing: Option<HeartbeatAdaptivePacing>,
|
||||
#[cultcache(key = 19, default)]
|
||||
pub pending_mentions: Vec<HeartbeatPendingMention>,
|
||||
#[cultcache(key = 20, default)]
|
||||
|
|
@ -181,73 +175,6 @@ pub struct HeartbeatPacingPolicy {
|
|||
pub minimum_effective_rate: f64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatProtocol {
|
||||
pub domain: String,
|
||||
#[serde(default)]
|
||||
pub scene_id: Option<String>,
|
||||
pub arena: String,
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatAdaptivePacing {
|
||||
pub schema_version: String,
|
||||
pub contract: String,
|
||||
pub pressure: f64,
|
||||
pub effective_heartbeat_rate: f64,
|
||||
pub target_concurrency: usize,
|
||||
pub running_turns: usize,
|
||||
pub active_participants: usize,
|
||||
pub signals: HeartbeatAdaptivePacingSignals,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatAdaptivePacingSignals {
|
||||
pub external_urgency: f64,
|
||||
pub pending_pressure: f64,
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatInitiativeHeatPolicy {
|
||||
#[serde(default = "default_heat_schema_version")]
|
||||
pub schema_version: String,
|
||||
#[serde(default = "default_heat_global_multiplier")]
|
||||
pub global_multiplier: f64,
|
||||
#[serde(default)]
|
||||
pub multipliers: Vec<HeartbeatInitiativeMultiplier>,
|
||||
}
|
||||
|
||||
impl Default for HeartbeatInitiativeHeatPolicy {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
schema_version: default_heat_schema_version(),
|
||||
global_multiplier: default_heat_global_multiplier(),
|
||||
multipliers: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatInitiativeMultiplier {
|
||||
pub id: String,
|
||||
#[serde(default)]
|
||||
pub label: String,
|
||||
#[serde(default = "default_heat_scope")]
|
||||
pub scope: String,
|
||||
#[serde(default)]
|
||||
pub selector: String,
|
||||
#[serde(default = "default_heat_global_multiplier")]
|
||||
pub multiplier: f64,
|
||||
#[serde(default)]
|
||||
pub reason: String,
|
||||
#[serde(default)]
|
||||
pub updated_at: Option<String>,
|
||||
#[serde(default)]
|
||||
pub expires_at_scene_clock: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatParticipant {
|
||||
pub agent_id: String,
|
||||
|
|
@ -268,32 +195,6 @@ pub struct HeartbeatParticipant {
|
|||
pub last_woke_at: Option<String>,
|
||||
pub last_finished_at: Option<String>,
|
||||
pub pending_turn: Option<HeartbeatPendingTurn>,
|
||||
#[serde(default)]
|
||||
pub scene_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub groups: Vec<String>,
|
||||
#[serde(default = "default_heat_global_multiplier")]
|
||||
pub initiative_heat_multiplier: f64,
|
||||
#[serde(default)]
|
||||
pub initiative_heat: Option<HeartbeatInitiativeHeatProjection>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatInitiativeHeatProjection {
|
||||
pub schema_version: String,
|
||||
pub global_multiplier: f64,
|
||||
pub effective_multiplier: f64,
|
||||
pub basis: Vec<HeartbeatInitiativeHeatBasis>,
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct HeartbeatInitiativeHeatBasis {
|
||||
pub id: String,
|
||||
pub scope: String,
|
||||
pub selector: String,
|
||||
pub multiplier: f64,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
|
|
@ -324,16 +225,6 @@ pub struct HeartbeatPendingTurn {
|
|||
pub completed_scene_clock: Option<f64>,
|
||||
#[serde(rename = "nextReadyAt", default)]
|
||||
pub next_ready_at: Option<f64>,
|
||||
#[serde(
|
||||
rename = "initiativeHeatMultiplier",
|
||||
default = "default_heat_global_multiplier"
|
||||
)]
|
||||
pub initiative_heat_multiplier: f64,
|
||||
#[serde(
|
||||
rename = "effectiveCooldownMultiplier",
|
||||
default = "default_heat_global_multiplier"
|
||||
)]
|
||||
pub effective_cooldown_multiplier: f64,
|
||||
#[serde(rename = "initiativeFrozen", default)]
|
||||
pub initiative_frozen: bool,
|
||||
#[serde(rename = "initiativeFreezeReason", default)]
|
||||
|
|
@ -528,43 +419,11 @@ pub struct HeartbeatHistoryEvent {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatTickOptions {
|
||||
pub target_heartbeat_rate: f64,
|
||||
pub coordinator_action: Option<String>,
|
||||
pub target_role: Option<String>,
|
||||
pub urgency: f64,
|
||||
pub schedule_id: String,
|
||||
pub source_scene_ref: String,
|
||||
pub defer_completion: bool,
|
||||
pub resident_self_store: Option<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatPumpOptions {
|
||||
pub base_heartbeat_rate: f64,
|
||||
pub min_heartbeat_rate: f64,
|
||||
pub max_heartbeat_rate: f64,
|
||||
pub min_concurrency: usize,
|
||||
pub max_concurrency: usize,
|
||||
pub max_ticks: usize,
|
||||
pub external_urgency: f64,
|
||||
pub coordinator_action: Option<String>,
|
||||
pub target_role: Option<String>,
|
||||
pub schedule_id: String,
|
||||
pub source_scene_ref: String,
|
||||
pub resident_self_store: Option<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatHeatUpdateOptions {
|
||||
pub scope: String,
|
||||
pub selector: String,
|
||||
pub multiplier: f64,
|
||||
pub id: Option<String>,
|
||||
pub label: Option<String>,
|
||||
pub reason: Option<String>,
|
||||
pub expires_after_scene_clock: Option<f64>,
|
||||
pub clear: bool,
|
||||
pub(super) struct HeartbeatTickOptions {
|
||||
pub(super) target_heartbeat_rate: f64,
|
||||
pub(super) schedule_id: String,
|
||||
pub(super) source_scene_ref: String,
|
||||
pub(super) resident_self_store: Option<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
@ -586,37 +445,9 @@ pub struct HeartbeatQueueMentionOptions {
|
|||
pub model_provider_disclosure_allowed: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatCompleteOptions {
|
||||
pub role: String,
|
||||
pub action_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct HeartbeatStaleTurnRepairOptions {
|
||||
pub max_age_seconds: i64,
|
||||
pub now_utc: Option<String>,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct GhostlightSceneParticipantSeed {
|
||||
pub agent_id: String,
|
||||
pub display_name: String,
|
||||
pub initiative_speed: f64,
|
||||
pub reaction_bias: f64,
|
||||
pub interrupt_threshold: f64,
|
||||
pub constraints: Vec<String>,
|
||||
}
|
||||
|
||||
fn default_heat_schema_version() -> String {
|
||||
"epiphany.heartbeat_initiative_heat.v0".to_string()
|
||||
}
|
||||
|
||||
fn default_heat_global_multiplier() -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
fn default_heat_scope() -> String {
|
||||
"agent".to_string()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,239 +0,0 @@
|
|||
use super::EpiphanyHeartbeatStateEntry;
|
||||
use super::HeartbeatAdaptivePacingSignals;
|
||||
use super::HeartbeatInitiativeHeatBasis;
|
||||
use super::HeartbeatInitiativeHeatProjection;
|
||||
use super::HeartbeatInitiativeMultiplier;
|
||||
use super::HeartbeatParticipant;
|
||||
use super::HeartbeatPumpOptions;
|
||||
use super::round3;
|
||||
use super::round6;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct AdaptiveSwarmPacing {
|
||||
pub(super) pressure: f64,
|
||||
pub(super) effective_heartbeat_rate: f64,
|
||||
pub(super) target_concurrency: usize,
|
||||
pub(super) running_turns: usize,
|
||||
pub(super) active_participants: usize,
|
||||
pub(super) signals: HeartbeatAdaptivePacingSignals,
|
||||
}
|
||||
|
||||
pub(super) fn adaptive_swarm_pacing(
|
||||
state: &EpiphanyHeartbeatStateEntry,
|
||||
options: &HeartbeatPumpOptions,
|
||||
) -> AdaptiveSwarmPacing {
|
||||
let active_participants = state
|
||||
.participants
|
||||
.iter()
|
||||
.filter(|participant| participant.status == "active")
|
||||
.count();
|
||||
let running_turns = running_turn_count(state);
|
||||
let external_urgency = options.external_urgency.clamp(0.0, 1.0);
|
||||
let pending_pressure = if active_participants == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(running_turns as f64 / active_participants as f64).clamp(0.0, 1.0)
|
||||
};
|
||||
let pressure = [external_urgency, pending_pressure * 0.65]
|
||||
.into_iter()
|
||||
.fold(0.0_f64, f64::max)
|
||||
.clamp(0.0, 1.0);
|
||||
|
||||
let base_rate = options
|
||||
.base_heartbeat_rate
|
||||
.max(state.pacing_policy.minimum_effective_rate)
|
||||
.max(0.001);
|
||||
let min_rate = options.min_heartbeat_rate.max(0.001).min(base_rate);
|
||||
let max_rate = options.max_heartbeat_rate.max(base_rate).max(min_rate);
|
||||
let pressure_curve = pressure * pressure;
|
||||
let effective_heartbeat_rate = round6(min_rate + (max_rate - min_rate) * pressure_curve);
|
||||
|
||||
let max_concurrency = options
|
||||
.max_concurrency
|
||||
.max(1)
|
||||
.min(active_participants.max(1));
|
||||
let relaxed_floor = if pressure < 0.18 {
|
||||
0
|
||||
} else {
|
||||
options.min_concurrency.min(max_concurrency)
|
||||
};
|
||||
let target_concurrency = if pressure < 0.18 {
|
||||
relaxed_floor
|
||||
} else {
|
||||
let span = max_concurrency.saturating_sub(relaxed_floor);
|
||||
(relaxed_floor + (span as f64 * pressure).ceil() as usize).min(max_concurrency)
|
||||
};
|
||||
AdaptiveSwarmPacing {
|
||||
pressure: round3(pressure),
|
||||
effective_heartbeat_rate,
|
||||
target_concurrency,
|
||||
running_turns,
|
||||
active_participants,
|
||||
signals: HeartbeatAdaptivePacingSignals {
|
||||
external_urgency: round3(external_urgency),
|
||||
pending_pressure: round3(pending_pressure),
|
||||
contract: "Explicit external urgency and running-turn pressure determine scheduler tempo and concurrency.".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn running_turn_count(state: &EpiphanyHeartbeatStateEntry) -> usize {
|
||||
state
|
||||
.participants
|
||||
.iter()
|
||||
.filter(|participant| {
|
||||
participant
|
||||
.pending_turn
|
||||
.as_ref()
|
||||
.is_some_and(|turn| turn.status == "running")
|
||||
})
|
||||
.count()
|
||||
}
|
||||
|
||||
pub(super) fn effective_cooldown_multiplier(participant: &HeartbeatParticipant) -> f64 {
|
||||
round3(1.0 / initiative_heat_multiplier(participant)).clamp(0.05, 8.0)
|
||||
}
|
||||
|
||||
pub(super) fn initiative_heat_multiplier(participant: &HeartbeatParticipant) -> f64 {
|
||||
nonzero_multiplier(participant.initiative_heat_multiplier).clamp(0.05, 25.0)
|
||||
}
|
||||
|
||||
fn nonzero_multiplier(value: f64) -> f64 {
|
||||
if value.is_finite() && value > 0.0 {
|
||||
value
|
||||
} else {
|
||||
1.0
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn apply_initiative_heat_policy(state: &mut EpiphanyHeartbeatStateEntry) {
|
||||
let global = state.initiative_heat.global_multiplier.clamp(0.05, 25.0);
|
||||
let active_multipliers = state
|
||||
.initiative_heat
|
||||
.multipliers
|
||||
.iter()
|
||||
.filter(|multiplier| {
|
||||
multiplier
|
||||
.expires_at_scene_clock
|
||||
.is_none_or(|expires| expires > state.scene_clock)
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
for participant in &mut state.participants {
|
||||
let mut heat = global;
|
||||
let mut basis = Vec::<HeartbeatInitiativeHeatBasis>::new();
|
||||
for multiplier in &active_multipliers {
|
||||
if multiplier_matches_participant(multiplier, participant) {
|
||||
let value = multiplier.multiplier.clamp(0.05, 25.0);
|
||||
heat *= value;
|
||||
basis.push(HeartbeatInitiativeHeatBasis {
|
||||
id: multiplier.id.clone(),
|
||||
scope: multiplier.scope.clone(),
|
||||
selector: multiplier.selector.clone(),
|
||||
multiplier: value,
|
||||
reason: multiplier.reason.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
let heat = round3(heat.clamp(0.05, 25.0));
|
||||
participant.initiative_heat_multiplier = heat;
|
||||
participant.initiative_heat = Some(HeartbeatInitiativeHeatProjection {
|
||||
schema_version: "epiphany.heartbeat_initiative_heat_projection.v0".to_string(),
|
||||
global_multiplier: global,
|
||||
effective_multiplier: heat,
|
||||
basis,
|
||||
contract: "Initiative heat accelerates turn recovery. Proximity or agency pressure may raise heat, but the typed heat policy remains the authority.".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn multiplier_matches_participant(
|
||||
multiplier: &HeartbeatInitiativeMultiplier,
|
||||
participant: &HeartbeatParticipant,
|
||||
) -> bool {
|
||||
let selector = multiplier.selector.trim();
|
||||
match multiplier.scope.as_str() {
|
||||
"all" => true,
|
||||
"agent" | "agent_id" => eq_key(&participant.agent_id, selector),
|
||||
"role" | "role_id" => eq_key(&participant.role_id, selector),
|
||||
"arena" => eq_key(participant.arena.as_str(), selector),
|
||||
"participant_kind" | "kind" => eq_key(participant.participant_kind.as_str(), selector),
|
||||
"group" | "constraint" => {
|
||||
participant
|
||||
.constraints
|
||||
.iter()
|
||||
.any(|constraint| eq_key(constraint, selector))
|
||||
|| participant
|
||||
.groups
|
||||
.iter()
|
||||
.any(|group| eq_key(group, selector))
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn eq_key(left: &str, right: &str) -> bool {
|
||||
left.trim().eq_ignore_ascii_case(right.trim())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::heartbeat_state::default_heartbeat_state;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn running_turn_count_reads_only_running_pending_turns() {
|
||||
let mut state = default_heartbeat_state(1.0);
|
||||
state.participants[0].pending_turn = Some(crate::heartbeat_state::HeartbeatPendingTurn {
|
||||
status: "running".to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
state.participants[1].pending_turn = Some(crate::heartbeat_state::HeartbeatPendingTurn {
|
||||
status: "completed".to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
assert_eq!(running_turn_count(&state), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn initiative_heat_multiplies_agent_and_group_recovery_speed() {
|
||||
let mut state = default_heartbeat_state(1.0);
|
||||
state.initiative_heat.global_multiplier = 2.0;
|
||||
state.initiative_heat.multipliers = vec![
|
||||
HeartbeatInitiativeMultiplier {
|
||||
id: "hands".to_string(),
|
||||
scope: "role".to_string(),
|
||||
selector: "implementation".to_string(),
|
||||
multiplier: 3.0,
|
||||
..Default::default()
|
||||
},
|
||||
HeartbeatInitiativeMultiplier {
|
||||
id: "all-maintenance".to_string(),
|
||||
scope: "arena".to_string(),
|
||||
selector: "maintenance".to_string(),
|
||||
multiplier: 1.5,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
apply_initiative_heat_policy(&mut state);
|
||||
let implementation = state
|
||||
.participants
|
||||
.iter()
|
||||
.find(|participant| participant.role_id == "implementation")
|
||||
.expect("implementation participant");
|
||||
let research = state
|
||||
.participants
|
||||
.iter()
|
||||
.find(|participant| participant.role_id == "research")
|
||||
.expect("research participant");
|
||||
|
||||
assert_eq!(initiative_heat_multiplier(implementation), 9.0);
|
||||
assert_eq!(initiative_heat_multiplier(research), 3.0);
|
||||
assert!(
|
||||
effective_cooldown_multiplier(implementation) < effective_cooldown_multiplier(research)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,6 @@ use super::HeartbeatHistoryEvent;
|
|||
use super::HeartbeatParticipant;
|
||||
use super::HeartbeatPendingTurn;
|
||||
use super::HeartbeatSelectionPolicy;
|
||||
use super::effective_cooldown_multiplier;
|
||||
use super::initiative_heat_multiplier;
|
||||
use super::load_heartbeat_state_entry;
|
||||
use super::participant_arena;
|
||||
use super::participant_kind;
|
||||
|
|
@ -39,7 +37,7 @@ pub fn heartbeat_status_projection(
|
|||
"latestEvent": null,
|
||||
"history": [],
|
||||
"latestArtifacts": latest_json_artifacts(artifact_dir, artifact_limit),
|
||||
"availableActions": ["init", "tick", "pump", "complete", "status"],
|
||||
"availableActions": ["init", "repair-stale", "retain-artifacts", "status", "serve"],
|
||||
}));
|
||||
};
|
||||
let scheduler_status = if state.participants.is_empty() {
|
||||
|
|
@ -77,28 +75,11 @@ pub fn heartbeat_status_projection(
|
|||
"artifactDir": artifact_dir.as_ref(),
|
||||
"targetHeartbeatRate": state.target_heartbeat_rate,
|
||||
"sceneClock": state.scene_clock,
|
||||
"initiativeHeat": {
|
||||
"schemaVersion": state.initiative_heat.schema_version,
|
||||
"globalMultiplier": state.initiative_heat.global_multiplier,
|
||||
"multipliers": state.initiative_heat.multipliers.iter().map(|multiplier| {
|
||||
serde_json::json!({
|
||||
"id": multiplier.id,
|
||||
"label": multiplier.label,
|
||||
"scope": multiplier.scope,
|
||||
"selector": multiplier.selector,
|
||||
"multiplier": multiplier.multiplier,
|
||||
"reason": multiplier.reason,
|
||||
"updatedAt": multiplier.updated_at,
|
||||
"expiresAtSceneClock": multiplier.expires_at_scene_clock,
|
||||
})
|
||||
}).collect::<Vec<_>>(),
|
||||
},
|
||||
"participants": state.participants.iter().map(participant_status_json).collect::<Vec<_>>(),
|
||||
"latestEvent": history.last().cloned(),
|
||||
"history": history,
|
||||
"latestArtifacts": latest_json_artifacts(artifact_dir, artifact_limit),
|
||||
"adaptivePacing": state.adaptive_pacing.as_ref(),
|
||||
"availableActions": ["init", "tick", "pump", "heat", "complete", "status"],
|
||||
"availableActions": ["init", "repair-stale", "retain-artifacts", "status", "serve"],
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -196,9 +177,6 @@ fn participant_status_json(participant: &HeartbeatParticipant) -> Value {
|
|||
"arena": participant_arena(participant),
|
||||
"participantKind": participant_kind(participant),
|
||||
"initiativeSpeed": participant.initiative_speed,
|
||||
"initiativeHeatMultiplier": initiative_heat_multiplier(participant),
|
||||
"initiativeHeat": participant.initiative_heat.as_ref(),
|
||||
"effectiveCooldownMultiplier": effective_cooldown_multiplier(participant),
|
||||
"initiativeFrozen": participant
|
||||
.pending_turn
|
||||
.as_ref()
|
||||
|
|
@ -227,8 +205,6 @@ pub(super) fn schedule_participant_json(participant: &HeartbeatParticipant) -> V
|
|||
"arena": participant_arena(participant),
|
||||
"participant_kind": participant_kind(participant),
|
||||
"initiative_speed": participant.initiative_speed,
|
||||
"initiative_heat_multiplier": initiative_heat_multiplier(participant),
|
||||
"effective_cooldown_multiplier": effective_cooldown_multiplier(participant),
|
||||
"initiative_frozen": participant
|
||||
.pending_turn
|
||||
.as_ref()
|
||||
|
|
@ -267,8 +243,6 @@ pub(super) fn pending_turn_json(turn: &HeartbeatPendingTurn) -> Value {
|
|||
"startedAt": turn.started_at,
|
||||
"startedSceneClock": turn.started_scene_clock,
|
||||
"baseRecovery": turn.base_recovery,
|
||||
"initiativeHeatMultiplier": turn.initiative_heat_multiplier,
|
||||
"effectiveCooldownMultiplier": turn.effective_cooldown_multiplier,
|
||||
"initiativeFrozen": turn.initiative_frozen,
|
||||
"initiativeFreezeReason": turn.initiative_freeze_reason.as_ref(),
|
||||
"recovery": turn.recovery,
|
||||
|
|
|
|||
|
|
@ -1,28 +1,15 @@
|
|||
use super::EpiphanyHeartbeatStateEntry;
|
||||
use super::GhostlightSceneParticipantSeed;
|
||||
use super::HEARTBEAT_ARENA_MAINTENANCE;
|
||||
use super::HEARTBEAT_ARENA_SCENE;
|
||||
use super::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
use super::HeartbeatPacingPolicy;
|
||||
use super::HeartbeatParticipant;
|
||||
use super::HeartbeatProtocol;
|
||||
use super::HeartbeatSelectionPolicy;
|
||||
use super::PARTICIPANT_KIND_AGENT;
|
||||
use super::PARTICIPANT_KIND_CHARACTER;
|
||||
use super::write_heartbeat_state_entry;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use std::path::Path;
|
||||
|
||||
pub(super) const ROLE_ORDER: &[&str] = &[
|
||||
"coordinator",
|
||||
"Persona",
|
||||
"imagination",
|
||||
"research",
|
||||
"modeling",
|
||||
"implementation",
|
||||
"verification",
|
||||
];
|
||||
pub(super) const ROLE_ORDER: &[&str] = &["coordinator", "Persona"];
|
||||
|
||||
pub fn default_heartbeat_state(target_heartbeat_rate: f64) -> EpiphanyHeartbeatStateEntry {
|
||||
EpiphanyHeartbeatStateEntry {
|
||||
|
|
@ -52,9 +39,6 @@ pub fn default_heartbeat_state(target_heartbeat_rate: f64) -> EpiphanyHeartbeatS
|
|||
.map(|role_id| default_participant(role_id))
|
||||
.collect(),
|
||||
history: Vec::new(),
|
||||
initiative_heat: Default::default(),
|
||||
protocol: None,
|
||||
adaptive_pacing: None,
|
||||
pending_mentions: Vec::new(),
|
||||
persona_turn_requests: Vec::new(),
|
||||
blocked_persona_pressures: Vec::new(),
|
||||
|
|
@ -70,42 +54,6 @@ pub fn initialize_heartbeat_store(
|
|||
write_heartbeat_state_entry(store_path, &default_heartbeat_state(target_heartbeat_rate))
|
||||
}
|
||||
|
||||
pub fn ghostlight_scene_heartbeat_state(
|
||||
target_heartbeat_rate: f64,
|
||||
scene_id: impl Into<String>,
|
||||
participants: Vec<GhostlightSceneParticipantSeed>,
|
||||
) -> Result<EpiphanyHeartbeatStateEntry> {
|
||||
if participants.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"Ghostlight scene heartbeat requires at least one participant"
|
||||
));
|
||||
}
|
||||
let scene_id = scene_id.into();
|
||||
let mut state = default_heartbeat_state(target_heartbeat_rate);
|
||||
state.participants = participants
|
||||
.into_iter()
|
||||
.map(|seed| ghostlight_scene_participant(&scene_id, seed))
|
||||
.collect();
|
||||
state.protocol = Some(HeartbeatProtocol {
|
||||
domain: "ghostlight".to_string(),
|
||||
scene_id: Some(scene_id),
|
||||
arena: HEARTBEAT_ARENA_SCENE.to_string(),
|
||||
contract: "Characters and maintenance organs use one initiative timing law; scene participants receive only projected local context.".to_string(),
|
||||
});
|
||||
super::validate_heartbeat_state(&state)?;
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
pub fn initialize_ghostlight_scene_heartbeat_store(
|
||||
store_path: impl AsRef<Path>,
|
||||
target_heartbeat_rate: f64,
|
||||
scene_id: impl Into<String>,
|
||||
participants: Vec<GhostlightSceneParticipantSeed>,
|
||||
) -> Result<EpiphanyHeartbeatStateEntry> {
|
||||
let state = ghostlight_scene_heartbeat_state(target_heartbeat_rate, scene_id, participants)?;
|
||||
write_heartbeat_state_entry(store_path, &state)
|
||||
}
|
||||
|
||||
pub(super) fn default_participant(role_id: &str) -> HeartbeatParticipant {
|
||||
HeartbeatParticipant {
|
||||
agent_id: agent_id_for_role(role_id).to_string(),
|
||||
|
|
@ -127,67 +75,13 @@ pub(super) fn default_participant(role_id: &str) -> HeartbeatParticipant {
|
|||
last_woke_at: None,
|
||||
last_finished_at: None,
|
||||
pending_turn: None,
|
||||
scene_id: None,
|
||||
groups: Vec::new(),
|
||||
initiative_heat_multiplier: 1.0,
|
||||
initiative_heat: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn ghostlight_scene_participant(
|
||||
scene_id: &str,
|
||||
seed: GhostlightSceneParticipantSeed,
|
||||
) -> HeartbeatParticipant {
|
||||
let role_id = ghostlight_role_id(seed.agent_id.as_str());
|
||||
HeartbeatParticipant {
|
||||
agent_id: seed.agent_id,
|
||||
role_id,
|
||||
display_name: seed.display_name,
|
||||
arena: HEARTBEAT_ARENA_SCENE.to_string(),
|
||||
participant_kind: PARTICIPANT_KIND_CHARACTER.to_string(),
|
||||
initiative_speed: seed.initiative_speed,
|
||||
next_ready_at: 0.0,
|
||||
reaction_bias: seed.reaction_bias,
|
||||
interrupt_threshold: seed.interrupt_threshold,
|
||||
current_load: 0.0,
|
||||
status: "active".to_string(),
|
||||
constraints: seed.constraints,
|
||||
last_action_id: None,
|
||||
last_woke_at: None,
|
||||
last_finished_at: None,
|
||||
pending_turn: None,
|
||||
scene_id: Some(scene_id.to_string()),
|
||||
groups: Vec::new(),
|
||||
initiative_heat_multiplier: 1.0,
|
||||
initiative_heat: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn ghostlight_role_id(agent_id: &str) -> String {
|
||||
let sanitized = agent_id
|
||||
.chars()
|
||||
.map(|character| {
|
||||
if character.is_ascii_alphanumeric() {
|
||||
character.to_ascii_lowercase()
|
||||
} else {
|
||||
'-'
|
||||
}
|
||||
})
|
||||
.collect::<String>()
|
||||
.trim_matches('-')
|
||||
.to_string();
|
||||
format!("ghostlight.character.{sanitized}")
|
||||
}
|
||||
|
||||
pub(super) fn agent_id_for_role(role_id: &str) -> &'static str {
|
||||
match role_id {
|
||||
"coordinator" => "epiphany.self",
|
||||
"Persona" => "epiphany.Persona",
|
||||
"imagination" => "epiphany.imagination",
|
||||
"research" => "epiphany.eyes",
|
||||
"modeling" => "epiphany.modeling",
|
||||
"implementation" => "epiphany.hands",
|
||||
"verification" => "epiphany.soul",
|
||||
_ => "epiphany.unknown",
|
||||
}
|
||||
}
|
||||
|
|
@ -196,11 +90,6 @@ pub(super) fn display_name_for_role(role_id: &str) -> &'static str {
|
|||
match role_id {
|
||||
"coordinator" => "Self",
|
||||
"Persona" => "Persona",
|
||||
"imagination" => "Imagination",
|
||||
"research" => "Eyes",
|
||||
"modeling" => "Modeling",
|
||||
"implementation" => "Hands",
|
||||
"verification" => "Soul",
|
||||
_ => "Unknown",
|
||||
}
|
||||
}
|
||||
|
|
@ -209,11 +98,6 @@ fn initiative_speed_for_role(role_id: &str) -> f64 {
|
|||
match role_id {
|
||||
"coordinator" => 1.28,
|
||||
"Persona" => 1.12,
|
||||
"imagination" => 0.82,
|
||||
"research" => 0.78,
|
||||
"modeling" => 0.92,
|
||||
"implementation" => 0.74,
|
||||
"verification" => 0.88,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
|
|
@ -222,11 +106,6 @@ fn reaction_bias_for_role(role_id: &str) -> f64 {
|
|||
match role_id {
|
||||
"coordinator" => 0.88,
|
||||
"Persona" => 0.84,
|
||||
"imagination" => 0.54,
|
||||
"research" => 0.62,
|
||||
"modeling" => 0.74,
|
||||
"implementation" => 0.58,
|
||||
"verification" => 0.82,
|
||||
_ => 0.5,
|
||||
}
|
||||
}
|
||||
|
|
@ -235,11 +114,6 @@ fn interrupt_threshold_for_role(role_id: &str) -> f64 {
|
|||
match role_id {
|
||||
"coordinator" => 0.42,
|
||||
"Persona" => 0.52,
|
||||
"imagination" => 0.64,
|
||||
"research" => 0.58,
|
||||
"modeling" => 0.5,
|
||||
"implementation" => 0.5,
|
||||
"verification" => 0.48,
|
||||
_ => 0.5,
|
||||
}
|
||||
}
|
||||
|
|
@ -252,78 +126,7 @@ fn participant_constraints(role_id: &str) -> Vec<&'static str> {
|
|||
"Persona" => {
|
||||
"Publicly translates agent thought into #aquarium only; must not moderate or speak outside the room."
|
||||
}
|
||||
"imagination" => "Synthesizes futures; must not adopt objectives.",
|
||||
"research" => "Scouts known work; must not turn research into procrastination.",
|
||||
"modeling" => {
|
||||
"Grows source-grounded maps and checkpoints; must not edit implementation code."
|
||||
}
|
||||
"implementation" => {
|
||||
"Touches source only with accepted guidance and verifier-readable evidence."
|
||||
}
|
||||
"verification" => "Falsifies promises; must not bless theater.",
|
||||
_ => "Unknown role.",
|
||||
};
|
||||
vec![role_specific]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn default_state_defines_the_fixed_lane_catalog() {
|
||||
let state = default_heartbeat_state(1.5);
|
||||
|
||||
assert_eq!(state.target_heartbeat_rate, 1.5);
|
||||
assert_eq!(state.pacing_policy.work_base_recovery, 6.0);
|
||||
assert_eq!(state.pacing_policy.idle_base_recovery, 2.0);
|
||||
assert_eq!(
|
||||
state
|
||||
.participants
|
||||
.iter()
|
||||
.map(|participant| participant.role_id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
ROLE_ORDER
|
||||
);
|
||||
assert_eq!(
|
||||
state
|
||||
.participants
|
||||
.iter()
|
||||
.find(|participant| participant.role_id == "Persona")
|
||||
.map(|participant| participant.agent_id.as_str()),
|
||||
Some("epiphany.Persona")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ghostlight_scene_state_replaces_maintenance_lanes_with_scene_characters() -> Result<()> {
|
||||
let state = ghostlight_scene_heartbeat_state(
|
||||
0.5,
|
||||
"room",
|
||||
vec![GhostlightSceneParticipantSeed {
|
||||
agent_id: "Ariadne Prime".to_string(),
|
||||
display_name: "Ariadne".to_string(),
|
||||
initiative_speed: 1.2,
|
||||
reaction_bias: 0.8,
|
||||
interrupt_threshold: 0.4,
|
||||
constraints: vec!["Speak only in the room.".to_string()],
|
||||
}],
|
||||
)?;
|
||||
|
||||
assert_eq!(state.participants.len(), 1);
|
||||
let participant = &state.participants[0];
|
||||
assert_eq!(participant.role_id, "ghostlight.character.ariadne-prime");
|
||||
assert_eq!(participant.arena, HEARTBEAT_ARENA_SCENE);
|
||||
assert_eq!(participant.participant_kind, PARTICIPANT_KIND_CHARACTER);
|
||||
assert_eq!(participant.scene_id.as_deref(), Some("room"));
|
||||
assert_eq!(
|
||||
state
|
||||
.protocol
|
||||
.as_ref()
|
||||
.map(|protocol| protocol.domain.as_str()),
|
||||
Some("ghostlight")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ use super::EpiphanyHeartbeatArtifactRetentionReceipt;
|
|||
use super::EpiphanyHeartbeatStaleTurnRepairReceipt;
|
||||
use super::EpiphanyHeartbeatStateEntry;
|
||||
use super::HEARTBEAT_ARENA_MAINTENANCE;
|
||||
use super::HEARTBEAT_ARENA_SCENE;
|
||||
use super::HEARTBEAT_STALE_TURN_REPAIR_LATEST_KEY;
|
||||
use super::HEARTBEAT_STALE_TURN_REPAIR_SCHEMA_VERSION;
|
||||
use super::HEARTBEAT_STATE_KEY;
|
||||
use super::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
use super::PARTICIPANT_KIND_AGENT;
|
||||
use super::PARTICIPANT_KIND_CHARACTER;
|
||||
use super::PERSONA_CONVERSATION_RETENTION_HEAD_SCHEMA_VERSION;
|
||||
use super::PERSONA_CONVERSATION_RETENTION_PLAN_SCHEMA_VERSION;
|
||||
use super::PERSONA_TURN_REQUEST_SCHEMA_VERSION;
|
||||
|
|
@ -242,29 +240,6 @@ pub fn validate_heartbeat_state(state: &EpiphanyHeartbeatStateEntry) -> Result<(
|
|||
"heartbeat target_heartbeat_rate must be non-negative"
|
||||
));
|
||||
}
|
||||
if state.initiative_heat.global_multiplier <= 0.0 {
|
||||
return Err(anyhow!(
|
||||
"heartbeat initiative_heat global_multiplier must be positive"
|
||||
));
|
||||
}
|
||||
for multiplier in &state.initiative_heat.multipliers {
|
||||
if multiplier.id.trim().is_empty() {
|
||||
return Err(anyhow!("heartbeat initiative heat multiplier has empty id"));
|
||||
}
|
||||
if multiplier.multiplier <= 0.0 {
|
||||
return Err(anyhow!(
|
||||
"heartbeat initiative heat multiplier {} must be positive",
|
||||
multiplier.id
|
||||
));
|
||||
}
|
||||
if multiplier.selector.trim().is_empty() && multiplier.scope != "all" {
|
||||
return Err(anyhow!(
|
||||
"heartbeat initiative heat multiplier {} selector is empty for scope {}",
|
||||
multiplier.id,
|
||||
multiplier.scope
|
||||
));
|
||||
}
|
||||
}
|
||||
for participant in &state.participants {
|
||||
if participant.agent_id.trim().is_empty() {
|
||||
return Err(anyhow!("heartbeat participant has empty agent_id"));
|
||||
|
|
@ -282,7 +257,7 @@ pub fn validate_heartbeat_state(state: &EpiphanyHeartbeatStateEntry) -> Result<(
|
|||
));
|
||||
}
|
||||
let arena = participant_arena(participant);
|
||||
if !matches!(arena, HEARTBEAT_ARENA_MAINTENANCE | HEARTBEAT_ARENA_SCENE) {
|
||||
if arena != HEARTBEAT_ARENA_MAINTENANCE {
|
||||
return Err(anyhow!(
|
||||
"heartbeat participant {} arena {:?} is unsupported",
|
||||
participant.agent_id,
|
||||
|
|
@ -290,10 +265,7 @@ pub fn validate_heartbeat_state(state: &EpiphanyHeartbeatStateEntry) -> Result<(
|
|||
));
|
||||
}
|
||||
let participant_kind = participant_kind(participant);
|
||||
if !matches!(
|
||||
participant_kind,
|
||||
PARTICIPANT_KIND_AGENT | PARTICIPANT_KIND_CHARACTER
|
||||
) {
|
||||
if participant_kind != PARTICIPANT_KIND_AGENT {
|
||||
return Err(anyhow!(
|
||||
"heartbeat participant {} participant_kind {:?} is unsupported",
|
||||
participant.agent_id,
|
||||
|
|
|
|||
|
|
@ -491,7 +491,6 @@ pub use heartbeat_state::EpiphanyHeartbeatArtifactRetentionPlan;
|
|||
pub use heartbeat_state::EpiphanyHeartbeatArtifactRetentionReceipt;
|
||||
pub use heartbeat_state::EpiphanyHeartbeatStaleTurnRepairReceipt;
|
||||
pub use heartbeat_state::EpiphanyHeartbeatStateEntry;
|
||||
pub use heartbeat_state::GhostlightSceneParticipantSeed;
|
||||
pub use heartbeat_state::HEARTBEAT_ARTIFACT_RETENTION_PLAN_LATEST_KEY;
|
||||
pub use heartbeat_state::HEARTBEAT_ARTIFACT_RETENTION_PLAN_SCHEMA_VERSION;
|
||||
pub use heartbeat_state::HEARTBEAT_ARTIFACT_RETENTION_PLAN_TYPE;
|
||||
|
|
@ -505,45 +504,33 @@ pub use heartbeat_state::HEARTBEAT_STATE_KEY;
|
|||
pub use heartbeat_state::HEARTBEAT_STATE_SCHEMA_VERSION;
|
||||
pub use heartbeat_state::HEARTBEAT_STATE_TYPE;
|
||||
pub use heartbeat_state::HeartbeatArtifactRetentionMember;
|
||||
pub use heartbeat_state::HeartbeatCompleteOptions;
|
||||
pub use heartbeat_state::HeartbeatHeatUpdateOptions;
|
||||
pub use heartbeat_state::HeartbeatHistoryEvent;
|
||||
pub use heartbeat_state::HeartbeatInitiativeHeatPolicy;
|
||||
pub use heartbeat_state::HeartbeatInitiativeMultiplier;
|
||||
pub use heartbeat_state::HeartbeatPacingPolicy;
|
||||
pub use heartbeat_state::HeartbeatParticipant;
|
||||
pub use heartbeat_state::HeartbeatPendingMention;
|
||||
pub use heartbeat_state::HeartbeatPendingTurn;
|
||||
pub use heartbeat_state::HeartbeatPumpOptions;
|
||||
pub use heartbeat_state::HeartbeatQueueMentionOptions;
|
||||
pub use heartbeat_state::HeartbeatSelectionPolicy;
|
||||
pub use heartbeat_state::HeartbeatStaleTurnRepairOptions;
|
||||
pub use heartbeat_state::HeartbeatTickOptions;
|
||||
pub use heartbeat_state::PersonaBlockedConversationPressure;
|
||||
pub use heartbeat_state::PersonaTurnBlockedEvidence;
|
||||
pub use heartbeat_state::PersonaTurnRequest;
|
||||
pub use heartbeat_state::PersonaTurnTerminalOptions;
|
||||
pub use heartbeat_state::PersonaTurnTerminalReceipt;
|
||||
pub use heartbeat_state::ResidentSelfHeartbeatPulse;
|
||||
pub use heartbeat_state::complete_heartbeat_store;
|
||||
pub use heartbeat_state::complete_persona_turn_request_store;
|
||||
pub use heartbeat_state::default_heartbeat_state;
|
||||
pub use heartbeat_state::ghostlight_scene_heartbeat_state;
|
||||
pub use heartbeat_state::heartbeat_state_cache;
|
||||
pub use heartbeat_state::heartbeat_status_projection;
|
||||
pub use heartbeat_state::initialize_ghostlight_scene_heartbeat_store;
|
||||
pub use heartbeat_state::initialize_heartbeat_store;
|
||||
pub use heartbeat_state::load_heartbeat_state_entry;
|
||||
pub use heartbeat_state::load_latest_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_state::pulse_persona_heartbeat;
|
||||
pub use heartbeat_state::pulse_resident_self_heartbeat;
|
||||
pub use heartbeat_state::pump_heartbeat_store;
|
||||
pub use heartbeat_state::queue_heartbeat_pending_mention_store;
|
||||
pub use heartbeat_state::reconcile_resident_self_heartbeat_ack;
|
||||
pub use heartbeat_state::recover_stale_heartbeat_store;
|
||||
pub use heartbeat_state::retain_heartbeat_pulse_artifacts;
|
||||
pub use heartbeat_state::tick_heartbeat_store;
|
||||
pub use heartbeat_state::update_heartbeat_heat_store;
|
||||
pub use heartbeat_state::validate_heartbeat_state;
|
||||
pub use heartbeat_state::write_heartbeat_stale_turn_repair_receipt;
|
||||
pub use heartbeat_state::write_heartbeat_state_entry;
|
||||
|
|
|
|||
|
|
@ -13195,14 +13195,13 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
|
|||
RUNTIME_SPINE_SCHEMA_VERSION,
|
||||
vec![
|
||||
CultNetDocumentOperation::Snapshot,
|
||||
CultNetDocumentOperation::IntentSubmit,
|
||||
CultNetDocumentOperation::ReceiptWatch,
|
||||
],
|
||||
CultNetMutationAuthority::Coordinator,
|
||||
vec!["epiphany.heartbeat_pump_intent.v0"],
|
||||
vec!["epiphany.swarm_control_receipt.v0"],
|
||||
CultNetMutationAuthority::ReadOnly,
|
||||
vec![],
|
||||
vec![],
|
||||
vec![
|
||||
"Heartbeat activation owns agent work; external callers submit intents and watch receipts.",
|
||||
"Runtime jobs are lifecycle receipts derived from admitted worker-launch requests.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
|
|
@ -13951,19 +13950,13 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
|
|||
HEARTBEAT_STATE_SCHEMA_VERSION,
|
||||
vec![
|
||||
CultNetDocumentOperation::Snapshot,
|
||||
CultNetDocumentOperation::IntentSubmit,
|
||||
CultNetDocumentOperation::ReceiptWatch,
|
||||
],
|
||||
CultNetMutationAuthority::Coordinator,
|
||||
CultNetMutationAuthority::ReadOnly,
|
||||
vec![],
|
||||
vec![],
|
||||
vec![
|
||||
"epiphany.heartbeat_pump_intent.v0",
|
||||
"epiphany.heartbeat_heat_intent.v0",
|
||||
"epiphany.circadian_rhythm_intent.v0",
|
||||
],
|
||||
vec!["epiphany.swarm_control_receipt.v0"],
|
||||
vec![
|
||||
"Aquarium controls heartbeat and circadian rhythm through typed intents, not blind state replacement.",
|
||||
"Initiative heat is heartbeat policy: global, group, role, and agent tempo changes enter through the heartbeat heat intent.",
|
||||
"Heartbeat is internal scheduling physiology for Resident Self grants and Persona turns; external callers may inspect it but cannot steer it.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.agent-heartbeat-cognition.schema.json",
|
||||
"title": "Epiphany Heartbeat Cognition Quarantine",
|
||||
"description": "Experimental Void/Ghostlight routine thought-weather kept outside stable heartbeat scheduler state. These values are inspectable receipts, not project truth or scheduling authority.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"schemaVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"latestRunId": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"latestArtifactRef": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"source": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"sleepCycle": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"memoryResonance": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"incubation": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"thoughtLanes": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"bridge": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"candidateInterventions": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"appraisals": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"reactions": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"extra": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schemaVersion",
|
||||
"updatedAt"
|
||||
]
|
||||
}
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.agent-heartbeat.schema.json",
|
||||
"title": "Epiphany Heartbeat State",
|
||||
"description": "Stable typed heartbeat scheduler state for initiative, readiness, pacing, pending turns, and history. Experimental cognition thought-weather lives in epiphany.agent-heartbeat-cognition.",
|
||||
"description": "Typed scheduling physiology for Resident Self grants and Persona turns.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"schemaVersion": {
|
||||
"type": "string"
|
||||
"const": "epiphany.agent_heartbeat.v1"
|
||||
},
|
||||
"targetHeartbeatRate": {
|
||||
"type": "number"
|
||||
|
|
@ -23,9 +23,6 @@
|
|||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"initiativeHeat": {
|
||||
"$ref": "epiphany.heartbeat_initiative_heat.v0.schema.json"
|
||||
},
|
||||
"participants": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
|
@ -39,10 +36,6 @@
|
|||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.circadian_rhythm_intent.v0.schema.json",
|
||||
"title": "epiphany circadian_rhythm_intent v0",
|
||||
"description": "Circadian rhythm intent for letting the swarm sleep or wake.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"sleeping": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"targetHeartbeatRate": {
|
||||
"type": "number"
|
||||
},
|
||||
"allowDream": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"sleeping"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json",
|
||||
"title": "epiphany heartbeat_heat_intent v0",
|
||||
"description": "Coordinator intent for changing heartbeat initiative heat at global, group, arena, role, or agent scope.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"storeKey": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "Optional heartbeat store key when the coordinator hosts more than one heartbeat arena."
|
||||
},
|
||||
"scope": {
|
||||
"$ref": "epiphany.heartbeat_initiative_heat.v0.schema.json#/definitions/scope"
|
||||
},
|
||||
"selector": {
|
||||
"type": "string",
|
||||
"description": "Agent id, role id, arena, participant kind, group, or constraint selected by scope. Empty only for global/all."
|
||||
},
|
||||
"multiplier": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0,
|
||||
"description": "Recovery-speed multiplier. Values above 1 turn up heat; values below 1 cool the selected lane."
|
||||
},
|
||||
"id": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "Stable policy id. Defaults to global or scope:selector when omitted."
|
||||
},
|
||||
"label": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"reason": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"expiresAfterSceneClock": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"description": "Relative scene-clock duration before the multiplier stops affecting participants."
|
||||
},
|
||||
"clear": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"scope"
|
||||
],
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"clear": {
|
||||
"const": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"multiplier"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json",
|
||||
"title": "epiphany heartbeat_initiative_heat v0",
|
||||
"description": "Heartbeat initiative heat policy. Multipliers accelerate or relax turn recovery without granting project authority.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"schemaVersion": {
|
||||
"const": "epiphany.heartbeat_initiative_heat.v0"
|
||||
},
|
||||
"globalMultiplier": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"multipliers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/multiplier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schemaVersion",
|
||||
"globalMultiplier",
|
||||
"multipliers"
|
||||
],
|
||||
"definitions": {
|
||||
"scope": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"global",
|
||||
"all",
|
||||
"agent",
|
||||
"agent_id",
|
||||
"role",
|
||||
"role_id",
|
||||
"arena",
|
||||
"participant_kind",
|
||||
"kind",
|
||||
"group",
|
||||
"constraint"
|
||||
]
|
||||
},
|
||||
"multiplier": {
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"scope": {
|
||||
"$ref": "#/definitions/scope"
|
||||
},
|
||||
"selector": {
|
||||
"type": "string"
|
||||
},
|
||||
"multiplier": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"format": "date-time"
|
||||
},
|
||||
"expiresAtSceneClock": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"scope",
|
||||
"selector",
|
||||
"multiplier"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_pump_intent.v0.schema.json",
|
||||
"title": "epiphany heartbeat_pump_intent v0",
|
||||
"description": "Heartbeat pump intent for waking lanes and pacing the swarm.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"scheduleId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"sourceSceneRef": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"coordinatorAction": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetRole": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"externalUrgency": {
|
||||
"type": "number"
|
||||
},
|
||||
"maxTicks": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId"
|
||||
]
|
||||
}
|
||||
|
|
@ -263,33 +263,11 @@
|
|||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.agent_heartbeat.v0",
|
||||
"schemaVersion": "epiphany.agent_heartbeat.v1",
|
||||
"documentType": "epiphany.agent_heartbeat",
|
||||
"title": "Epiphany Heartbeat State",
|
||||
"path": "epiphany.agent-heartbeat.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.heartbeat_initiative_heat.v0",
|
||||
"documentType": "epiphany.heartbeat_initiative_heat.v0",
|
||||
"title": "epiphany heartbeat_initiative_heat v0",
|
||||
"path": "epiphany.heartbeat_initiative_heat.v0.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.agent-heartbeat-cognition.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.agent_heartbeat_cognition.v0",
|
||||
"documentType": "epiphany.agent_heartbeat_cognition",
|
||||
"title": "Epiphany Heartbeat Cognition Quarantine",
|
||||
"path": "epiphany.agent-heartbeat-cognition.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.state-ledger.schema.json",
|
||||
"kind": "document_payload",
|
||||
|
|
@ -510,39 +488,6 @@
|
|||
"title": "epiphany runtime session_intent v0",
|
||||
"path": "epiphany.runtime.session_intent.v0.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_pump_intent.v0.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.heartbeat_pump_intent.v0",
|
||||
"documentType": "epiphany.heartbeat_pump_intent.v0",
|
||||
"title": "epiphany heartbeat_pump_intent v0",
|
||||
"path": "epiphany.heartbeat_pump_intent.v0.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.heartbeat_heat_intent.v0",
|
||||
"documentType": "epiphany.heartbeat_heat_intent.v0",
|
||||
"title": "epiphany heartbeat_heat_intent v0",
|
||||
"path": "epiphany.heartbeat_heat_intent.v0.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.circadian_rhythm_intent.v0.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.circadian_rhythm_intent.v0",
|
||||
"documentType": "epiphany.circadian_rhythm_intent.v0",
|
||||
"title": "epiphany circadian_rhythm_intent v0",
|
||||
"path": "epiphany.circadian_rhythm_intent.v0.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.job_launch_intent.v0.schema.json",
|
||||
"kind": "document_payload",
|
||||
|
|
|
|||
|
|
@ -6,18 +6,19 @@ the organism believes or invent cognition to fill idle time.
|
|||
|
||||
The executable contract lives in
|
||||
`epiphany-core/src/heartbeat_state/heartbeat_documents.rs` and the scheduling
|
||||
law lives in `heartbeat_state.rs`, `heartbeat_pacing.rs`, and
|
||||
`heartbeat_store.rs`.
|
||||
law lives in `heartbeat_state.rs` and `heartbeat_store.rs`.
|
||||
|
||||
## Store identity
|
||||
|
||||
- document type: `epiphany.agent_heartbeat`
|
||||
- schema version: `epiphany.agent_heartbeat.v0`
|
||||
- schema version: `epiphany.agent_heartbeat.v1`
|
||||
- key: `default`
|
||||
|
||||
The singleton carries pacing policy, participant readiness, pending turns,
|
||||
bounded scheduling history, initiative heat, explicit Persona transport
|
||||
pressure, and retention bookkeeping.
|
||||
The singleton currently carries coordinator/Persona readiness, pending turns,
|
||||
bounded scheduling history, explicit Persona transport pressure, and retention
|
||||
bookkeeping. The remaining social fields are the next ownership cut: they must
|
||||
become keyed Persona documents so social writes do not share the scheduler CAS
|
||||
identity.
|
||||
|
||||
## Scheduling invariants
|
||||
|
||||
|
|
@ -28,8 +29,6 @@ pressure, and retention bookkeeping.
|
|||
- Persona may wake only from explicit queued social pressure.
|
||||
- The swarm brake prevents new Persona cognition while allowing terminal
|
||||
acknowledgement and recovery physiology to settle.
|
||||
- Initiative heat changes scheduling tempo only. It cannot create Mind state,
|
||||
route an organ, or make a semantic decision.
|
||||
- When no typed obligation or social pressure exists, the scheduler sleeps.
|
||||
|
||||
Heartbeat owns no personality, mood, appraisal, rumination, dreaming, memory
|
||||
|
|
|
|||
Reference in a new issue