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
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
//! actors, codec/transport routing, and the actor-directory mirrors. Protocol
|
|
|
|
|
//! tick injection is owned by the swactor engine (see
|
|
|
|
|
//! [`DistributionRuntimeStack::spawn_protocol_ticker`]); the application loop
|
|
|
|
|
//! no longer manually ticks core.
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
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;
|
2026-08-11 12:08:06 +00:00
|
|
|
use swactor::runtime::{Ctx, Runtime, RuntimeParts};
|
2026-08-03 10:18:24 +00:00
|
|
|
use swactor::stats::StatsHook;
|
2026-06-24 09:30:29 +00:00
|
|
|
use swactor::std::StdExtension;
|
feat(provisioning): add level-triggered cluster reconciler
Introduce a pure, level-triggered reconciler in `crates/provisioning`
that drives a declared cluster shape toward convergence over the
existing node lifecycle, replacing the edge-triggered imperative node
orchestration in `apps/myelin`.
- `reconcile`/`reconcile_node`/`observe`: pure decider and observation
folder with stable logical-node identity, per-attempt operation
identity, and deterministic retry backoff; `ClusterDriver` is the sole
writer of observed state, coalescing triggers, recording operations as
pending before dispatch, and scheduling timed requeues.
- `IdempotentEffectExecutor`: deduplicates submissions by
`(run_id, logical_node_id, attempt)` and runs provider work on the
engine-hosted blocking substrate, never blocking a reconcile pass.
- Myelin integration: `MyelinEffectBackend` bridges `ProvisionPlugin` to
the executor contract; `LocalProcessPlugin`/`LocalDockerPlugin`
provider adapters; `ProvisionedClusterGuard` pumps triggers,
observations, and due operations.
- Retire the imperative acquire/bootstrap/teardown sequencing across
`apps/myelin` orchestration, staging, observability, and provider
adapters in favor of the declarative driver.
- Move the reconciler specification to `docs/specs/archive`.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-08-12 07:49:18 +00:00
|
|
|
use swactor_engine::EngineHandle;
|
2026-06-24 09:30:29 +00:00
|
|
|
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-08-11 12:08:06 +00:00
|
|
|
pub runtime: Runtime,
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
/// The node engine this stack is bound to. Protocol ticking and all
|
|
|
|
|
/// supporting work schedule on this stored handle; the stack does not
|
|
|
|
|
/// accept an unrelated engine at each call (ENGINE_SPEC.md).
|
|
|
|
|
pub engine: EngineHandle,
|
2026-06-24 09:30:29 +00:00
|
|
|
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-08-11 12:08:06 +00:00
|
|
|
/// Build and configure the core swactor runtime parts + codec, returning the
|
|
|
|
|
/// cloned runtime handle and shared transport router needed by
|
|
|
|
|
/// [`new_from_runtime`]. The parts are fully configured — extension, remote
|
|
|
|
|
/// sink, statistics hook — but no actors are spawned yet.
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
///
|
2026-08-11 12:08:06 +00:00
|
|
|
/// This split lets the engine own the runtime workers before the driver
|
|
|
|
|
/// exists: construct the parts, clone the runtime handle, hand the parts to
|
|
|
|
|
/// [`Engine::new`](swactor_engine::Engine), create the driver (which needs
|
|
|
|
|
/// the engine handle), then spawn actors via [`new_from_runtime`] using
|
|
|
|
|
/// `driver.node_id()`.
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
pub(crate) fn build_runtime(
|
2026-06-24 09:30:29 +00:00
|
|
|
extend_codecs: impl FnOnce(&mut CodecRegistry),
|
2026-08-03 10:18:24 +00:00
|
|
|
stats_hook: Option<Arc<dyn StatsHook>>,
|
feat(provisioning): add level-triggered cluster reconciler
Introduce a pure, level-triggered reconciler in `crates/provisioning`
that drives a declared cluster shape toward convergence over the
existing node lifecycle, replacing the edge-triggered imperative node
orchestration in `apps/myelin`.
- `reconcile`/`reconcile_node`/`observe`: pure decider and observation
folder with stable logical-node identity, per-attempt operation
identity, and deterministic retry backoff; `ClusterDriver` is the sole
writer of observed state, coalescing triggers, recording operations as
pending before dispatch, and scheduling timed requeues.
- `IdempotentEffectExecutor`: deduplicates submissions by
`(run_id, logical_node_id, attempt)` and runs provider work on the
engine-hosted blocking substrate, never blocking a reconcile pass.
- Myelin integration: `MyelinEffectBackend` bridges `ProvisionPlugin` to
the executor contract; `LocalProcessPlugin`/`LocalDockerPlugin`
provider adapters; `ProvisionedClusterGuard` pumps triggers,
observations, and due operations.
- Retire the imperative acquire/bootstrap/teardown sequencing across
`apps/myelin` orchestration, staging, observability, and provider
adapters in favor of the declarative driver.
- Move the reconciler specification to `docs/specs/archive`.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-08-12 07:49:18 +00:00
|
|
|
) -> (
|
|
|
|
|
RuntimeParts,
|
|
|
|
|
Runtime,
|
|
|
|
|
Arc<CodecRegistry>,
|
|
|
|
|
Arc<TransportRouter>,
|
|
|
|
|
) {
|
2026-08-11 12:08:06 +00:00
|
|
|
let mut parts = RuntimeParts::new(RuntimeConfig::default())
|
|
|
|
|
.with_extension(Arc::new(StdExtension::new()));
|
2026-06-24 09:30:29 +00:00
|
|
|
let mut codec = actor_codec_registry();
|
|
|
|
|
extend_codecs(&mut codec);
|
|
|
|
|
let codec = Arc::new(codec);
|
|
|
|
|
let transport_router = Arc::new(TransportRouter::new());
|
2026-08-11 12:08:06 +00:00
|
|
|
let runtime = parts.runtime().clone();
|
2026-06-24 09:30:29 +00:00
|
|
|
runtime.set_remote_sink(Arc::new(CodecRemoteSink::new(
|
|
|
|
|
Arc::clone(&codec),
|
|
|
|
|
Arc::clone(&transport_router),
|
|
|
|
|
)));
|
2026-08-03 10:18:24 +00:00
|
|
|
if let Some(hook) = stats_hook {
|
2026-08-11 12:08:06 +00:00
|
|
|
parts = parts.with_stats_hook(hook);
|
2026-08-03 10:18:24 +00:00
|
|
|
}
|
2026-08-11 12:08:06 +00:00
|
|
|
(parts, runtime, codec, transport_router)
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
}
|
2026-06-24 09:30:29 +00:00
|
|
|
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
/// Spawn the four distribution protocol actors on a pre-built runtime.
|
2026-08-11 12:08:06 +00:00
|
|
|
/// Used after [`build_runtime`] when the engine already owns the workers.
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
pub(crate) fn new_from_runtime(
|
2026-08-11 12:08:06 +00:00
|
|
|
runtime: Runtime,
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
codec: Arc<CodecRegistry>,
|
|
|
|
|
transport_router: Arc<TransportRouter>,
|
|
|
|
|
node_id: NodeId,
|
|
|
|
|
config: DistributedNodeConfig,
|
|
|
|
|
engine: EngineHandle,
|
|
|
|
|
) -> Self {
|
2026-06-24 09:30:29 +00:00
|
|
|
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 {
|
|
|
|
|
runtime,
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
engine,
|
2026-06-24 09:30:29 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
feat(engine): substrate-neutral execution engine abstraction
Introduce the swactor engine: a swactor-owned composite that retains a
selected execution substrate, drives the core runtime, and hosts the
async/blocking/timer work that backs actors. Integrations receive one
cloneable EngineHandle and never construct or borrow a raw Tokio
runtime/handle.
Engine crate (crates/engine):
- The contract: spawn / spawn_blocking / timer / interval / now, a
per-implementation capability model with construction-time binding
(require()), and engine-owned time. The engine owns all progression;
actor handlers stay synchronous and never .await.
- TokioBackend owns the Tokio runtime and schedules core ticks and
supporting futures on it; SteppingBackend is a single-threaded
deterministic scheduler with virtual time (the non-Tokio portability
proof). Core is driven through its existing tick() surface; a
self-rescheduling CoreDriver is installed at construction and is the
sole place permitted to call try_tick.
iroh-driver:
- Receives an EngineHandle instead of a raw Tokio Handle. Accepts,
reads, dials, writes, endpoint construction, and teardown schedule
through it; required capabilities (tasks/timers/io) are validated
before the endpoint binds. Engine-hosted interval pumps drive
actor-bridge, datastream, and edge ingress.
myelin:
- One node/orchestrator engine owns core, protocol tick injection, and
transport progression; the application loop only drains
integration-owned queues. Stage-shard process readers, delayed actor
messages, helper stdout/stderr, prompt RPC, and CPU sampling all
schedule through the engine (spawn_blocking / engine tasks / timers).
- Removed the split-engine APIs: install_actor_bridge_pump(period) and
spawn_protocol_ticker(period) use each component's stored engine;
deleted the no-op pump_network callback and its plumbing; deleted the
dashboard raw-Tokio/standalone-runtime conveniences.
Enforcement:
- A clippy disallowed-methods boundary forbids direct runtime/scheduling/
time/core-driving bypasses, denied in swactor-engine, iroh-driver, and
myelin. Retained excluded uses (VastAI provider, provider process
supervision/log capture, OS-signal/stdin/process-control sequencing)
carry narrow allowances with reasons.
Verification:
- Engine contract + unit tests (incl. the SteppingBackend portability
proof), iroh integration tests (capability rejection before binding,
multi-node actor behavior), and a production execution-composition
smoke test that observes engine-driven actor progress with no ambient
Tokio runtime and no manual tick/pump. Workspace all-target/all-feature
clippy and tests are green.
Specs co-located with their crates: ENGINE_SPEC.md in crates/engine,
IROH_DRIVER_SPEC.md in crates/iroh-driver. VastAI remains explicitly out
of scope pending its separate redesign.
2026-08-10 20:23:03 +00:00
|
|
|
/// Spawn an engine-hosted interval task that injects protocol Tick messages
|
|
|
|
|
/// (SWIM, registry, metadata, directory), replacing the manual tick
|
|
|
|
|
/// injection previously done by the application pump loop
|
|
|
|
|
/// (ENGINE_SPEC.md). The engine owns protocol progression; the
|
|
|
|
|
/// application loop no longer calls tick or core-driving methods.
|
|
|
|
|
pub(crate) fn spawn_protocol_ticker(&self, period: Duration) {
|
|
|
|
|
let runtime = self.runtime.clone();
|
|
|
|
|
let swim = self.actors.swim;
|
|
|
|
|
let registry = self.actors.registry;
|
|
|
|
|
let metadata = self.actors.metadata;
|
|
|
|
|
let directory = self.actors.directory;
|
|
|
|
|
let engine = self.engine.clone();
|
|
|
|
|
engine.clone().spawn(async move {
|
|
|
|
|
let mut interval = engine.interval(period);
|
|
|
|
|
loop {
|
|
|
|
|
(&mut interval).await;
|
|
|
|
|
let now = engine.now().to_instant();
|
|
|
|
|
let _ = runtime.send_to(swim, SwimIn::Tick { now });
|
|
|
|
|
let _ = runtime.send_to(registry, RegistryIn::Tick);
|
|
|
|
|
let _ = runtime.send_to(metadata, MetadataIn::Tick);
|
|
|
|
|
let _ = runtime.send_to(directory, DirectoryIn::Tick);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-06-24 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|