@@ -238,7 +238,88 @@ impl<'de> Deserialize<'de> for SupervisorInstanceId {
238238#[ error( "supervisor instance ID must be a non-nil canonical lowercase UUID" ) ]
239239pub struct SupervisorInstanceIdError ;
240240
241- pub use openshell_core:: isolation_registration:: SandboxTransport ;
241+ /// Backend-owned transport for a driver-provisioned runtime. The serialized
242+ /// variants preserve existing runtime descriptors independently of operator
243+ /// endpoint registration in core.
244+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
245+ #[ serde( tag = "kind" , rename_all = "kebab-case" , deny_unknown_fields) ]
246+ pub enum SandboxTransport {
247+ Unix {
248+ socket_path : PathBuf ,
249+ } ,
250+ Tcp {
251+ /// Logical HTTP authority used for routing.
252+ authority : String ,
253+ /// Concrete connection candidates pinned by the operator or driver.
254+ addresses : Vec < std:: net:: SocketAddr > ,
255+ } ,
256+ Vsock {
257+ guest_cid : u32 ,
258+ port : u32 ,
259+ } ,
260+ /// The supervisor accepts a connection from its sandbox runtime. TLS and
261+ /// gRPC roles stay unchanged.
262+ RuntimeInitiatedTcp {
263+ authority : String ,
264+ listen_address : std:: net:: SocketAddr ,
265+ } ,
266+ RuntimeInitiatedUnix {
267+ socket_path : PathBuf ,
268+ } ,
269+ RuntimeInitiatedVsock {
270+ guest_cid : u32 ,
271+ port : u32 ,
272+ } ,
273+ }
274+
275+ impl SandboxTransport {
276+ pub fn validate ( & self ) -> Result < ( ) , & ' static str > {
277+ let valid = match self {
278+ Self :: Unix { socket_path } | Self :: RuntimeInitiatedUnix { socket_path } => {
279+ socket_path. is_absolute ( )
280+ }
281+ Self :: Tcp {
282+ authority,
283+ addresses,
284+ } => {
285+ !authority. is_empty ( )
286+ && !addresses. is_empty ( )
287+ && addresses
288+ . iter ( )
289+ . all ( |address| address. port ( ) != 0 && !address. ip ( ) . is_unspecified ( ) )
290+ }
291+ Self :: RuntimeInitiatedTcp {
292+ authority,
293+ listen_address,
294+ } => !authority. is_empty ( ) && listen_address. port ( ) != 0 ,
295+ Self :: Vsock { guest_cid, port } | Self :: RuntimeInitiatedVsock { guest_cid, port } => {
296+ * guest_cid >= 3 && * guest_cid != u32:: MAX && * port != 0 && * port != u32:: MAX
297+ }
298+ } ;
299+ if valid {
300+ Ok ( ( ) )
301+ } else {
302+ Err ( "invalid boundary control transport endpoint" )
303+ }
304+ }
305+ }
306+
307+ impl From < openshell_core:: isolation_registration:: SandboxTransport > for SandboxTransport {
308+ fn from ( endpoint : openshell_core:: isolation_registration:: SandboxTransport ) -> Self {
309+ use openshell_core:: isolation_registration:: SandboxTransport as RegisteredEndpoint ;
310+ match endpoint {
311+ RegisteredEndpoint :: Unix { socket_path } => Self :: Unix { socket_path } ,
312+ RegisteredEndpoint :: Tcp {
313+ authority,
314+ addresses,
315+ } => Self :: Tcp {
316+ authority,
317+ addresses,
318+ } ,
319+ RegisteredEndpoint :: Vsock { guest_cid, port } => Self :: Vsock { guest_cid, port } ,
320+ }
321+ }
322+ }
242323
243324/// Supervisor-side, generation-pinned TLS server authentication.
244325#[ derive( Clone , PartialEq , Eq , Serialize , Deserialize ) ]
0 commit comments