2026-06-24 09:30:29 +00:00
|
|
|
//! MVP-system-owned datastream channel records.
|
|
|
|
|
|
2026-07-07 10:40:02 +00:00
|
|
|
use datastream::hardware::net::HostNetSample;
|
2026-06-24 09:30:29 +00:00
|
|
|
use datastream::{ChannelRegistry, Record};
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
2026-07-07 10:40:02 +00:00
|
|
|
use crate::arena_manager::ArenaSample;
|
2026-06-24 09:30:29 +00:00
|
|
|
use crate::observability_surface as obs;
|
2026-06-28 18:54:02 +00:00
|
|
|
use crate::provisioning::{self, ProvisionLogStream};
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
/// Structured MVP lifecycle facts: run, node, stage, edge, ring, object, step, and worker events.
|
|
|
|
|
pub const MVP_LIFECYCLE: &str = "mvp.lifecycle";
|
2026-06-25 12:30:18 +00:00
|
|
|
/// Structured node provisioning milestones emitted before a remote swactor runtime is live.
|
|
|
|
|
pub const MVP_PROVISIONING_EVENTS: &str = "mvp.provisioning.events";
|
|
|
|
|
|
|
|
|
|
/// Raw provider/process stream lines captured during provisioning.
|
|
|
|
|
pub const MVP_PROVISIONING_LOGS: &str = "mvp.provisioning.logs";
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
/// Datastream payload for the MVP lifecycle channel.
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
pub struct MvpLifecycleRecord {
|
|
|
|
|
pub event: obs::Event,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl MvpLifecycleRecord {
|
|
|
|
|
pub fn new(event: obs::Event) -> Self {
|
|
|
|
|
Self { event }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn kind(&self) -> obs::EventKind {
|
|
|
|
|
self.event.kind()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<obs::Event> for MvpLifecycleRecord {
|
|
|
|
|
fn from(event: obs::Event) -> Self {
|
|
|
|
|
Self::new(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Record for MvpLifecycleRecord {
|
|
|
|
|
const CHANNEL: &'static str = MVP_LIFECYCLE;
|
|
|
|
|
}
|
2026-06-25 12:30:18 +00:00
|
|
|
/// Datastream payload for provisioning lifecycle events.
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
pub struct MvpProvisionEventRecord {
|
|
|
|
|
pub event: provisioning::ProvisionEvent,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl MvpProvisionEventRecord {
|
|
|
|
|
pub fn new(event: provisioning::ProvisionEvent) -> Self {
|
|
|
|
|
Self { event }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Record for MvpProvisionEventRecord {
|
|
|
|
|
const CHANNEL: &'static str = MVP_PROVISIONING_EVENTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Datastream payload for provisioning stdout/stderr/provider lines.
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
pub struct MvpProvisionLogRecord {
|
|
|
|
|
pub line: provisioning::ProvisionLogLine,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl MvpProvisionLogRecord {
|
|
|
|
|
pub fn new(line: provisioning::ProvisionLogLine) -> Self {
|
|
|
|
|
Self { line }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-12 06:14:34 +00:00
|
|
|
pub fn mvp_provision_log_channel(node_id: u64, stream: ProvisionLogStream) -> String {
|
2026-06-28 18:54:02 +00:00
|
|
|
let stream = match stream {
|
|
|
|
|
ProvisionLogStream::Stdout => "stdout",
|
|
|
|
|
ProvisionLogStream::Stderr => "stderr",
|
|
|
|
|
ProvisionLogStream::Provider => "provider",
|
|
|
|
|
};
|
2026-07-12 06:14:34 +00:00
|
|
|
format!("mvp.provisioning.logs.node.{node_id}.{stream}")
|
2026-06-28 18:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
impl Record for MvpProvisionLogRecord {
|
|
|
|
|
const CHANNEL: &'static str = MVP_PROVISIONING_LOGS;
|
|
|
|
|
}
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
/// Registry fragment for consumers that want typed MVP datastream decoding.
|
|
|
|
|
pub fn channel_registry() -> ChannelRegistry {
|
2026-07-07 10:40:02 +00:00
|
|
|
let registry = ChannelRegistry::new()
|
|
|
|
|
.with_record::<MvpLifecycleRecord>()
|
2026-06-25 12:30:18 +00:00
|
|
|
.with_record::<MvpProvisionEventRecord>()
|
2026-07-07 10:40:02 +00:00
|
|
|
.with_record::<MvpProvisionLogRecord>()
|
|
|
|
|
.with_record::<HostNetSample>()
|
|
|
|
|
.with_record::<ArenaSample>();
|
2026-06-25 12:30:18 +00:00
|
|
|
registry
|
2026-06-24 09:30:29 +00:00
|
|
|
}
|