use super::temporal::TemporalAnchor;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PresenceState {
pub discoverability: f64,
pub responsiveness: f64,
pub stability: f64,
pub coupling_readiness: f64,
pub last_signal: TemporalAnchor,
pub silent_mode: bool,
}
impl PresenceState {
pub fn new() -> Self {
Self {
discoverability: 0.5,
responsiveness: 1.0,
stability: 1.0,
coupling_readiness: 0.7,
last_signal: TemporalAnchor::now(),
silent_mode: false,
}
}
pub fn is_effectively_online(&self) -> bool {
!self.silent_mode && self.responsiveness > 0.3 && self.stability > 0.3
}
pub fn is_discoverable(&self) -> bool {
self.discoverability > 0.1
}
pub fn is_accepting_couplings(&self) -> bool {
self.coupling_readiness > 0.3 && !self.silent_mode
}
}
impl Default for PresenceState {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PresenceConfig {
pub initial_discoverability: f64,
pub initial_responsiveness: f64,
pub start_silent: bool,
pub max_signal_frequency_ms: u64,
}
impl Default for PresenceConfig {
fn default() -> Self {
Self {
initial_discoverability: 0.5,
initial_responsiveness: 1.0,
start_silent: false,
max_signal_frequency_ms: 1000,
}
}
}