1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! MeshOS SDK — daemon-author surface.
//!
//! This is the customer-facing entry point for writing daemons
//! that participate in MeshOS supervision. The actual
//! implementation lives in the substrate at
//! `net::adapter::net::behavior::meshos::sdk`; this module
//! re-exports the SDK types under a clean `net_sdk::meshos::*`
//! path so consumers don't reach into substrate internals.
//!
//! # Surface
//!
//! - [`MeshOsDaemonSdk`] — one-call entry point. Wraps a
//! [`MeshOsRuntime`] with daemon-control routing; provides
//! `register_daemon(...) -> MeshOsDaemonHandle`.
//! - [`MeshOsDaemonHandle`] — per-daemon handle. Owns the
//! control-event receiver, capability-publish surface,
//! graceful-shutdown sequence, and read-only metadata view.
//! - [`MetadataView`] / [`MaintenanceStateView`] — read-only
//! cluster context the daemon can observe.
//! - [`SdkError`] — operator-readable error surface with the
//! `<<meshos-sdk-kind:KIND>>MSG` discriminator format every
//! cross-language SDK uses.
//! - Re-exported substrate types: [`DaemonControl`],
//! [`DaemonHealth`], [`MeshDaemon`], [`CapabilitySet`],
//! [`EntityKeypair`], [`MeshOsConfig`], [`MeshOsRuntime`].
//!
//! # Daemon-author quickstart
//!
//! ```ignore
//! use net_sdk::meshos::{
//! CapabilitySet, DaemonControl, DaemonHealth, EntityKeypair, MeshDaemon,
//! MeshOsConfig, MeshOsDaemonSdk,
//! };
//! use std::sync::Arc;
//!
//! struct TelemetryDaemon { /* … */ }
//!
//! impl MeshDaemon for TelemetryDaemon {
//! fn name(&self) -> &str { "telemetry" }
//! fn requirements(&self) -> _ { Default::default() }
//! fn process(&mut self, _event: &_) -> _ { Ok(vec![]) }
//! fn health(&self) -> DaemonHealth { DaemonHealth::Healthy }
//! }
//!
//! # async fn run(dispatcher: Arc<impl _>) -> Result<(), Box<dyn std::error::Error>> {
//! let sdk = MeshOsDaemonSdk::start(MeshOsConfig::default(), dispatcher);
//! let mut handle = sdk.register_daemon(
//! Box::new(TelemetryDaemon { /* … */ }),
//! EntityKeypair::generate(),
//! )?;
//!
//! while let Some(ev) = handle.next_control().await {
//! match ev {
//! DaemonControl::Shutdown { .. } => break,
//! DaemonControl::BackpressureOn { level } => { /* throttle */ }
//! _ => {}
//! }
//! }
//!
//! handle.graceful_shutdown(std::time::Duration::from_secs(5)).await?;
//! sdk.shutdown().await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Macro convenience
//!
//! The substrate re-exports a `daemon_main!` macro that
//! collapses the boilerplate into a single block — see the
//! macro's own documentation in
//! `net::adapter::net::behavior::meshos::sdk::daemon_main`.
//!
//! # Non-goals
//!
//! Per `MESHOS_SDK_PLAN.md`'s locked decisions, this SDK is
//! **daemon-side only**:
//!
//! - No placement / replica / scheduler APIs.
//! - No admin-event issuance (drain, cordon, maintenance, etc).
//! - No "control MeshOS" surfaces (avoid lists, backpressure
//! tuning, scheduler config).
//! - No federated-execution / MeshDB-query plumbing — those
//! belong to the (forthcoming) Deck SDK.
//!
//! Operator tooling lives in `DECK_SDK_PLAN.md`'s surface.
// Re-export the substrate-side SDK types under a clean
// `net_sdk::meshos::*` path. The implementation lives in
// `net::adapter::net::behavior::meshos::sdk` — this module is
// the customer-facing seam.
pub use ;
// Supporting types daemon authors need.
pub use CapabilitySet;
pub use ;
// Event-source supporting types — exposed so test / demo
// callers can write probes that report `NodeHealth` values
// and so consumers wiring custom event sources can match
// against `NodeId` in the public surface.
pub use ;
// Direct event injection — for in-process / test / demo
// consumers that want to publish events into the runtime's
// fold without going through a source converter. Daemon
// authors don't need these; the daemon-side SDK exposes
// `publish_log` and `next_control` and refuses every other
// event-issuance path by design.
pub use ;
pub use ;
pub use EntityKeypair;
// Production RedEX-backed chain appenders. Operators wire
// these when constructing a runtime via
// `MeshOsRuntime::start_with_all_chains(...)` to persist admin
// audit, log, and failure history to cluster-lifetime storage.
pub use ;
// Migration-abort dispatcher seam. Operators wire the
// `OrchestratorMigrationAborter` adapter so an
// `AdminEvent::KillMigration` chain commit actually aborts the
// in-flight migration on every node hosting it.
pub use ;
// Migration-snapshot source seam. Operators wire the
// `OrchestratorMigrationSnapshotSource` so the snapshot's
// `in_flight_migrations` field reflects the local
// `MigrationOrchestrator`'s state, letting the ICE blast-radius
// preview enumerate the daemon a `KillMigration` would affect.
pub use ;