Dissolve the M0 crates (core/io/proto/telemetry/hip/cli) into the approved service layout abi/kn/ld/cc/rt/lab/sp/nt/tm/gw (docs/ARCHITECTURE.md). - kn: Lean-verified control bus + service registry (bus_lifecycle.lean, 14 thms) and SlabRing/UMA broker; rt: PrefixState + hybrid checkpoint pool. - sp: faithful throughput-aware Adaptive-K port of clover_policy.h (cooldowns, probes, throughput guards) with scenario parity tests. - gw: strata-ctl-compatible wire emitters + serve session FSM (serve_session.lean, 10 thms); abi::serve accepts image= (Vision delta closed). - abi: pure contracts, checked JSON/VTC1/GEN parsers, zero-alloc sampler. - ld/cc: checked safetensors reader + write-once VTC1 writer / O_RDONLY reader. - tm: lock-free telemetry; nt: LyraRpc; lab shares the rt executor core. - Docs: ARCHITECTURE.md decision-complete spec (MoE-only scope, .vbundle, .vplan->CompiledPlan, wire contract, migration map); AGENTS.md Lean rule + tandem/review workflow. Verified live: cargo test --workspace -D warnings = 46/46 PASS; lean proofs = 34 theorems (slab_ring_dma 10, bus_lifecycle 14, serve_session 10), 0 sorryAx, standard axioms only; vetta-infer info on Inkling = 1244 tensors, 18.18 GiB, checked bounds.
77 lines
2.5 KiB
Rust
77 lines
2.5 KiB
Rust
//! Control-bus contracts: service identity, lifecycle states and message formats.
|
|
//!
|
|
//! Lifecycle transitions are verified in `proofs/bus_lifecycle.lean` and
|
|
//! enforced by `vetta-infer-kn` (registry + bus). These are the shared types
|
|
//! every service speaks; the bus carries control-plane messages only — the
|
|
//! data plane exchanges UMA memory handles, never tensor copies.
|
|
|
|
/// Stable identity of a registered service (handed out by the registry, two-phase).
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
pub struct ServiceId(pub u32);
|
|
|
|
/// The service kinds of the approved architecture (docs/ARCHITECTURE.md §2).
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
pub enum ServiceKind {
|
|
/// `ld` — loader & compiler (dual-step → `.vbundle/`)
|
|
Loader,
|
|
/// `cc` — cache & storage (UMA residency, NVMe streaming, Hot/Cold experts)
|
|
Cache,
|
|
/// `rt` — operational runtime (CompiledPlan on HIP, zero probes)
|
|
Runtime,
|
|
/// `lab` — laboratory runtime (same executor + probe hooks)
|
|
Lab,
|
|
/// `sp` — speculative coordinator (lossless verification, Adaptive-K)
|
|
Spec,
|
|
/// `nt` — LAN bridge to Lyra
|
|
Net,
|
|
/// `tm` — telemetry observer
|
|
Telemetry,
|
|
/// `gw` — gateway & CLI (`--serve`, HTTP, `vetta-infer`)
|
|
Gateway,
|
|
}
|
|
|
|
/// Lifecycle of one service — mirrors `SvcState` in `proofs/bus_lifecycle.lean`.
|
|
/// `Stopping` = STOP issued, draining in-flight work; `Stopped` is terminal.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum ServiceState {
|
|
Registered,
|
|
Running,
|
|
Stopping,
|
|
Stopped,
|
|
}
|
|
|
|
/// Typed control-plane payloads. Extended additively as services land;
|
|
/// unknown-to-a-service payloads are rejected explicitly, never silently.
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum BusPayload {
|
|
/// Kernel → service: stop accepting new work and drain.
|
|
Stop,
|
|
/// Service → kernel: drain complete, resources released (acks `Stop`).
|
|
StopAck,
|
|
/// Domain routing hint (e.g. `"lean4"`, `"dante"`) for cache pre-warm.
|
|
DomainHint(String),
|
|
}
|
|
|
|
/// One routed control-plane message.
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BusMsg {
|
|
pub src: ServiceId,
|
|
pub dst: ServiceId,
|
|
pub payload: BusPayload,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn msg_shape() {
|
|
let m = BusMsg {
|
|
src: ServiceId(0),
|
|
dst: ServiceId(1),
|
|
payload: BusPayload::DomainHint("lean4".into()),
|
|
};
|
|
assert_eq!(m.dst, ServiceId(1));
|
|
assert_eq!(m.payload, BusPayload::DomainHint("lean4".into()));
|
|
}
|
|
} |