refactor: prune public api
Collapse mvp-system's public surface to three binary entrypoints and make every domain module private, deleting dead provider/worker/membership implementations and inlining provider config.
- lib.rs: expose only run_chat_from_args/run_orchestrator_from_args/run_worker_node_from_env (plus a crate-private in-process helper) and the cached-model consts, and demote chat/node/observability/orchestration/prompt/staging/transport to private mods
- orchestration/mod.rs: make app private, gate engine_builder behind cfg(test), drop docker_cluster from provider_adapters, tighten vastai to pub(super), and replace pub re-exports with pub(super) run_from_args/run_in_process_from_args
- orchestration/config.rs: inline VastAiConfig/ResolvedVastAiConfig/looks_remote_image (removing provider_adapters/vastai/config.rs) and drop the DEFAULT_PIPELINE_CACHED_MODEL_* consts (hoisted to lib.rs)
- orchestration/provider_adapters/vastai: delete the ProviderPlugin impl VastAiProviderPlugin and all client/bootstrap/config accessors; repoint call sites to crate-level #[path] mods for provisioning/node_provisioning/node_actor/gguf_shard/run_fsm/run_plan
- delete orchestration/{membership_readiness,token_endpoint,resource_inventory}, node/{boot_lifecycle,data_plane_bridge(-74)}, and the worker crate-internal modules (control/device_bridge/process_adapter) along with their guarantees tests
- chat/node: narrow node_image and worker_node_runtime to private and expose only pub(super) run_from_args / run_worker_node_from_env
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-29 10:02:50 +00:00
|
|
|
|
refactor: `mvp-system` is now a standalone app, `myelin`
Promote the `mvp-system` workspace library crate to a standalone application at `apps/myelin`, rebranding the MVP system along with its binaries, node image, and spec.
- workspace `Cargo.toml`: swap member `crates/mvp-system` -> `apps/myelin` and drop `apps` from `exclude` so the app joins the workspace
- `apps/myelin/Cargo.toml`: declare package `myelin` with `autobins = false` and explicit `[[bin]]` targets `myelin-worker`, `myelin-orchestrator`, `myelin-chat`
- `apps/myelin/src`: move the whole `mvp-system` source tree and rebrand module surfaces (`chat/mod.rs`, `prompt/mod.rs`); add `bin/chat.rs` (`myelin::run_chat_from_args`) and delete the old `mvp_chat.rs`
- `apps/myelin/node-image`: relocate the worker image assets from `apps/mvp-node/` (Dockerfile, Dockerfile.base, tinygrad_worker.py, entrypoint, e2e script) and rename `MVP_SYSTEM_SPEC.md` -> `MYELIN_SPEC.md`
- `xtask`: rewrite build/reference paths for the rename (~1000-line churn); add `crates/dashboard/ACTOR_PANEL_SPEC.md`
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-08-01 09:46:55 +00:00
|
|
|
//! Myelin-system swactor distribution runtime wiring.
|
2026-06-24 09:30:29 +00:00
|
|
|
//!
|
|
|
|
|
//! This is the production version of the actor-stack setup that integration
|
|
|
|
|
//! tests used to copy by hand: a swactor runtime, the four distribution protocol
|
|
|
|
|
//! actors, codec/transport routing, the actor-directory mirrors, and one pumpable
|
|
|
|
|
//! tick seam for concrete network drivers such as `iroh-driver`.
|
|
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use std::sync::{Arc, Mutex, RwLock};
|
2026-07-30 11:31:23 +00:00
|
|
|
use std::time::{Duration, Instant};
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
use swactor::actor::{ActorAddress, ActorInterface};
|
|
|
|
|
use swactor::config::RuntimeConfig;
|
|
|
|
|
use swactor::runtime::{Ctx, Runtime};
|
|
|
|
|
use swactor::std::StdExtension;
|
|
|
|
|
use swactor_transport::{CodecRegistry, CodecRemoteSink, NetworkMessage, TransportRouter};
|
|
|
|
|
|
|
|
|
|
use distribution::directory_actor::{DirectoryActor, DirectoryIn};
|
|
|
|
|
use distribution::messages::{
|
|
|
|
|
DirectoryGossip, MetadataGossip, RegistryGossip, actor_codec_registry,
|
|
|
|
|
};
|
|
|
|
|
use distribution::node::DistributedNodeConfig;
|
|
|
|
|
use distribution::node_metadata_actor::{MetadataActor, MetadataIn};
|
|
|
|
|
use distribution::registry_actor::{RegistryActor, RegistryIn};
|
|
|
|
|
use distribution::swim::actor::{MembershipChanged, SwimActor, SwimIn};
|
|
|
|
|
use distribution::swim::member_list::MemberList;
|
2026-07-25 20:05:44 +00:00
|
|
|
use distribution::swim::probe::SwimConfig;
|
|
|
|
|
use distribution::swim::telemetry::{ObservedProbeEvent, ObservedTransition, SwimTelemetry};
|
2026-07-30 11:31:23 +00:00
|
|
|
use distribution::telemetry::MembershipTransition;
|
|
|
|
|
use distribution::telemetry::SwimProbeEvent;
|
2026-06-24 09:30:29 +00:00
|
|
|
use distribution::transport_bridge::{
|
|
|
|
|
Outbox, OutboxPeerDirectory, OutboxRouteBinder, RelayMirror, RouteView, RouteViewTransport,
|
|
|
|
|
};
|
|
|
|
|
use distribution::types::{DirectoryEntry, MemberState, NodeId};
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) struct DistributionActorAddrs {
|
2026-06-24 09:30:29 +00:00
|
|
|
pub swim: ActorAddress,
|
|
|
|
|
pub registry: ActorAddress,
|
|
|
|
|
pub metadata: ActorAddress,
|
|
|
|
|
pub directory: ActorAddress,
|
|
|
|
|
pub membership_fanout: ActorAddress,
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) struct DistributionRuntimeStack {
|
2026-06-24 09:30:29 +00:00
|
|
|
pub node_id: NodeId,
|
|
|
|
|
pub runtime: Arc<Runtime>,
|
|
|
|
|
pub codec: Arc<CodecRegistry>,
|
|
|
|
|
pub outbox: Outbox,
|
|
|
|
|
pub relay_mirror: RelayMirror,
|
|
|
|
|
pub route_view: RouteView,
|
|
|
|
|
pub membership_mirror: Arc<Mutex<MemberList>>,
|
2026-07-12 06:14:34 +00:00
|
|
|
pub swim_telemetry: Arc<SwimTelemetry>,
|
2026-07-25 20:05:44 +00:00
|
|
|
pub swim_config: SwimConfig,
|
2026-06-24 09:30:29 +00:00
|
|
|
pub actors: DistributionActorAddrs,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl DistributionRuntimeStack {
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn new_with_codecs(
|
2026-06-24 09:30:29 +00:00
|
|
|
node_id: NodeId,
|
|
|
|
|
config: DistributedNodeConfig,
|
|
|
|
|
extend_codecs: impl FnOnce(&mut CodecRegistry),
|
|
|
|
|
) -> Self {
|
|
|
|
|
let mut runtime =
|
|
|
|
|
Runtime::new(RuntimeConfig::default()).with_extension(Arc::new(StdExtension::new()));
|
|
|
|
|
let mut codec = actor_codec_registry();
|
|
|
|
|
extend_codecs(&mut codec);
|
|
|
|
|
let codec = Arc::new(codec);
|
|
|
|
|
let transport_router = Arc::new(TransportRouter::new());
|
|
|
|
|
runtime.set_remote_sink(Arc::new(CodecRemoteSink::new(
|
|
|
|
|
Arc::clone(&codec),
|
|
|
|
|
Arc::clone(&transport_router),
|
|
|
|
|
)));
|
|
|
|
|
let runtime = Arc::new(runtime);
|
|
|
|
|
|
|
|
|
|
let outbox: Outbox = Arc::new(Mutex::new(Vec::new()));
|
|
|
|
|
let relay_mirror: RelayMirror = Arc::new(RwLock::new(HashMap::new()));
|
|
|
|
|
let route_view: RouteView = Arc::new(RwLock::new(HashMap::new()));
|
|
|
|
|
let peer_directory = Arc::new(OutboxPeerDirectory::new(
|
|
|
|
|
Arc::clone(&transport_router),
|
|
|
|
|
Arc::clone(&outbox),
|
|
|
|
|
));
|
2026-07-25 20:05:44 +00:00
|
|
|
let swim_config = config.swim.clone();
|
2026-07-12 06:14:34 +00:00
|
|
|
let swim_telemetry = SwimTelemetry::new();
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
let swim_addr = runtime
|
2026-07-12 06:14:34 +00:00
|
|
|
.spawn(
|
|
|
|
|
SwimActor::new(
|
|
|
|
|
node_id,
|
2026-07-25 20:05:44 +00:00
|
|
|
swim_config.clone(),
|
2026-07-12 06:14:34 +00:00
|
|
|
Instant::now(),
|
|
|
|
|
peer_directory.clone(),
|
|
|
|
|
)
|
|
|
|
|
.with_observer(Box::new(Arc::clone(&swim_telemetry))),
|
|
|
|
|
)
|
2026-06-24 09:30:29 +00:00
|
|
|
.expect("spawn SwimActor");
|
|
|
|
|
let registry_addr = runtime
|
|
|
|
|
.spawn(RegistryActor::new(
|
|
|
|
|
node_id,
|
|
|
|
|
config.registry.clone(),
|
|
|
|
|
peer_directory.clone(),
|
|
|
|
|
))
|
|
|
|
|
.expect("spawn RegistryActor");
|
|
|
|
|
let metadata_addr = runtime
|
|
|
|
|
.spawn(MetadataActor::new(
|
|
|
|
|
node_id,
|
|
|
|
|
config.metadata_lambda,
|
|
|
|
|
peer_directory.clone(),
|
|
|
|
|
Arc::clone(&relay_mirror),
|
|
|
|
|
))
|
|
|
|
|
.expect("spawn MetadataActor");
|
|
|
|
|
let route_view_transport = Arc::new(RouteViewTransport::new(
|
|
|
|
|
Arc::clone(&route_view),
|
|
|
|
|
Arc::clone(&outbox),
|
|
|
|
|
));
|
|
|
|
|
let route_binder = Arc::new(OutboxRouteBinder::new(
|
|
|
|
|
Arc::clone(&transport_router),
|
|
|
|
|
Arc::clone(&route_view_transport),
|
|
|
|
|
));
|
|
|
|
|
let directory_addr = runtime
|
|
|
|
|
.spawn(DirectoryActor::new(
|
|
|
|
|
node_id,
|
|
|
|
|
peer_directory,
|
|
|
|
|
Arc::clone(&route_view),
|
|
|
|
|
route_binder,
|
|
|
|
|
))
|
|
|
|
|
.expect("spawn DirectoryActor");
|
|
|
|
|
|
|
|
|
|
let membership_mirror = Arc::new(Mutex::new(MemberList::new(NodeId([0xFF; 32]))));
|
|
|
|
|
let fanout_addr = runtime
|
|
|
|
|
.spawn(MembershipFanout {
|
|
|
|
|
registry: registry_addr,
|
|
|
|
|
metadata: metadata_addr,
|
|
|
|
|
directory: directory_addr,
|
|
|
|
|
mirror: Arc::clone(&membership_mirror),
|
|
|
|
|
})
|
|
|
|
|
.expect("spawn MembershipFanout");
|
|
|
|
|
runtime
|
|
|
|
|
.send_to(
|
|
|
|
|
swim_addr,
|
|
|
|
|
SwimIn::Subscribe {
|
|
|
|
|
observer: fanout_addr,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.expect("subscribe MembershipFanout");
|
|
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
node_id,
|
|
|
|
|
runtime,
|
|
|
|
|
codec,
|
|
|
|
|
outbox,
|
|
|
|
|
relay_mirror,
|
|
|
|
|
route_view,
|
|
|
|
|
membership_mirror,
|
2026-07-12 06:14:34 +00:00
|
|
|
swim_telemetry,
|
2026-07-25 20:05:44 +00:00
|
|
|
swim_config,
|
2026-06-24 09:30:29 +00:00
|
|
|
actors: DistributionActorAddrs {
|
|
|
|
|
swim: swim_addr,
|
|
|
|
|
registry: registry_addr,
|
|
|
|
|
metadata: metadata_addr,
|
|
|
|
|
directory: directory_addr,
|
|
|
|
|
membership_fanout: fanout_addr,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn actor_bridge_routes(&self) -> HashMap<String, ActorAddress> {
|
2026-06-24 09:30:29 +00:00
|
|
|
let mut routes = HashMap::new();
|
|
|
|
|
for tag in [
|
|
|
|
|
"swactor_dist::Ping",
|
|
|
|
|
"swactor_dist::Ack",
|
|
|
|
|
"swactor_dist::PingReq",
|
|
|
|
|
"swactor_dist::IndirectAck",
|
|
|
|
|
"swactor_dist::JoinRequest",
|
|
|
|
|
"swactor_dist::JoinResponse",
|
|
|
|
|
] {
|
|
|
|
|
routes.insert(tag.to_owned(), self.actors.swim);
|
|
|
|
|
}
|
|
|
|
|
routes.insert(RegistryGossip::type_tag().to_owned(), self.actors.registry);
|
|
|
|
|
routes.insert(MetadataGossip::type_tag().to_owned(), self.actors.metadata);
|
|
|
|
|
routes.insert(
|
|
|
|
|
DirectoryGossip::type_tag().to_owned(),
|
|
|
|
|
self.actors.directory,
|
|
|
|
|
);
|
|
|
|
|
routes
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn tick_protocol_actors(&self, now: Instant) {
|
2026-06-24 09:30:29 +00:00
|
|
|
let _ = self.runtime.send_to(self.actors.swim, SwimIn::Tick { now });
|
|
|
|
|
let _ = self.runtime.send_to(self.actors.registry, RegistryIn::Tick);
|
|
|
|
|
let _ = self.runtime.send_to(self.actors.metadata, MetadataIn::Tick);
|
|
|
|
|
let _ = self
|
|
|
|
|
.runtime
|
|
|
|
|
.send_to(self.actors.directory, DirectoryIn::Tick);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn pump_runtime_once(&self) {
|
2026-06-24 09:30:29 +00:00
|
|
|
self.runtime.tick();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn register_local_actor(&self, entry: DirectoryEntry) {
|
2026-06-24 09:30:29 +00:00
|
|
|
let _ = self
|
|
|
|
|
.runtime
|
|
|
|
|
.send_to(self.actors.directory, DirectoryIn::Register(entry));
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn member_state(&self, node_id: NodeId) -> Option<MemberState> {
|
2026-07-09 08:53:53 +00:00
|
|
|
self.membership_mirror
|
|
|
|
|
.lock()
|
|
|
|
|
.ok()?
|
|
|
|
|
.get(&node_id)
|
|
|
|
|
.map(|entry| entry.state)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn route_owner(&self, actor: ActorAddress) -> Option<NodeId> {
|
2026-07-09 08:53:53 +00:00
|
|
|
self.route_view.read().ok()?.get(&actor).copied()
|
|
|
|
|
}
|
2026-07-12 06:14:34 +00:00
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn drain_swim_transitions(&self) -> Vec<ObservedTransition> {
|
2026-07-12 06:14:34 +00:00
|
|
|
self.swim_telemetry.drain_transitions()
|
|
|
|
|
}
|
2026-07-25 20:05:44 +00:00
|
|
|
|
2026-07-29 20:23:26 +00:00
|
|
|
pub(crate) fn drain_swim_probe_events(&self) -> Vec<ObservedProbeEvent> {
|
2026-07-25 20:05:44 +00:00
|
|
|
self.swim_telemetry.drain_probe_events()
|
|
|
|
|
}
|
2026-07-30 11:31:23 +00:00
|
|
|
|
|
|
|
|
pub(crate) fn swim_recent_probe_targets(&self) -> Vec<String> {
|
|
|
|
|
self.swim_telemetry
|
|
|
|
|
.recent_targets()
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(|node_id| format!("{:?}", node_id))
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn swim_probe_event_record(
|
|
|
|
|
&self,
|
|
|
|
|
event: ObservedProbeEvent,
|
|
|
|
|
local_phase: &str,
|
|
|
|
|
) -> SwimProbeEvent {
|
|
|
|
|
let config = &self.swim_config;
|
|
|
|
|
let budget_ms = event.budget_ms;
|
|
|
|
|
SwimProbeEvent {
|
|
|
|
|
event: event.event.to_owned(),
|
|
|
|
|
target: format!("{:?}", event.target),
|
|
|
|
|
sequence: event.sequence,
|
|
|
|
|
kind: event.kind.to_owned(),
|
|
|
|
|
rtt_ms: event.rtt_ms,
|
|
|
|
|
budget_ms,
|
|
|
|
|
budget_ticks: budget_ms,
|
|
|
|
|
last_ack_age_ms: event.last_ack_age.map(duration_ms_u64),
|
|
|
|
|
consecutive_timeouts: event.consecutive_timeouts,
|
|
|
|
|
recent_probe_targets: self.swim_recent_probe_targets(),
|
|
|
|
|
member_state: self
|
|
|
|
|
.member_state(event.target)
|
|
|
|
|
.map(|state| format!("{:?}", state)),
|
|
|
|
|
local_phase: local_phase.to_owned(),
|
|
|
|
|
probe_interval_ms: duration_ms_u64(config.probe_interval),
|
|
|
|
|
probe_timeout_ms: duration_ms_u64(config.probe_timeout),
|
|
|
|
|
indirect_probes: u32::try_from(config.indirect_probes).unwrap_or(u32::MAX),
|
|
|
|
|
suspicion_timeout_ms: duration_ms_u64(config.suspicion_timeout),
|
|
|
|
|
dead_reprobe_interval_ms: duration_ms_u64(config.dead_reprobe_interval),
|
|
|
|
|
probe_mode: format!("{:?}", config.probe_mode),
|
|
|
|
|
lifeguard_enabled: config.lifeguard.is_some(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pub(crate) fn membership_transition(
|
|
|
|
|
&self,
|
|
|
|
|
transition: &ObservedTransition,
|
|
|
|
|
) -> MembershipTransition {
|
|
|
|
|
MembershipTransition {
|
|
|
|
|
peer: format!("{:?}", transition.peer),
|
|
|
|
|
from: transition
|
|
|
|
|
.from
|
|
|
|
|
.map(|state| format!("{:?}", state))
|
|
|
|
|
.unwrap_or_default(),
|
|
|
|
|
to: format!("{:?}", transition.to),
|
|
|
|
|
reason: transition.reason.to_owned(),
|
|
|
|
|
last_ack_age_ms: transition.last_ack_age.map(duration_ms_u64),
|
|
|
|
|
consecutive_timeouts: transition.consecutive_timeouts,
|
|
|
|
|
recent_probe_targets: self.swim_recent_probe_targets(),
|
|
|
|
|
member_state: self
|
|
|
|
|
.member_state(transition.peer)
|
|
|
|
|
.map(|state| format!("{:?}", state)),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn duration_ms_u64(duration: Duration) -> u64 {
|
|
|
|
|
u64::try_from(duration.as_millis()).unwrap_or(u64::MAX)
|
2026-06-24 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MembershipFanout {
|
|
|
|
|
registry: ActorAddress,
|
|
|
|
|
metadata: ActorAddress,
|
|
|
|
|
directory: ActorAddress,
|
|
|
|
|
mirror: Arc<Mutex<MemberList>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ActorInterface for MembershipFanout {
|
|
|
|
|
type Incoming = MembershipChanged;
|
|
|
|
|
type Response = ();
|
|
|
|
|
|
|
|
|
|
fn handle(&mut self, ctx: &Ctx, change: Self::Incoming) {
|
|
|
|
|
self.mirror
|
|
|
|
|
.lock()
|
|
|
|
|
.expect("membership mirror poisoned")
|
|
|
|
|
.apply(change.node_id, change.state, change.incarnation);
|
|
|
|
|
let _ = ctx.send(self.registry, RegistryIn::Membership(change.clone()));
|
|
|
|
|
let _ = ctx.send(self.metadata, MetadataIn::Membership(change.clone()));
|
|
|
|
|
let _ = ctx.send(self.directory, DirectoryIn::Membership(change));
|
|
|
|
|
}
|
|
|
|
|
}
|