55//! `OpenShell` server.
66//!
77//! Every request carries a sandbox bearer credential in the `Authorization`
8- //! header. Each supervisor session owns its [`GatewayCredentials`], usually
8+ //! header. Each sandbox instance owns its [`GatewayCredentials`], usually
99//! built from the trusted launch bundle with
1010//! [`GatewayCredentials::from_auth_bundle`]. Diagnostic tools can instead
1111//! resolve a token with [`GatewayCredentials::from_environment`] from one of:
1616//! caller exchanges it for a gateway JWT via `IssueSandboxToken`.
1717//!
1818//! Callers reach the gateway through a [`GatewayEndpoint`], which pairs the
19- //! URL with one session 's credentials. No credential is installed
20- //! process-wide, so sessions hosted by one supervisor process cannot use or
19+ //! URL with one sandbox instance 's credentials. No credential is installed
20+ //! process-wide, so instances hosted by one supervisor process cannot use or
2121//! rotate each other's identity.
2222
2323use std:: collections:: HashMap ;
@@ -65,7 +65,7 @@ pub const MAX_SUPERVISOR_STREAM_MESSAGE_BYTES: usize = 9 * 1024 * 1024;
6565
6666/// Shared, refreshable Bearer header. All [`AuthInterceptor`] clones read
6767/// the same slot, so the renewal task can replace the token in place without
68- /// rebuilding the channel. `None` means the owning session revoked it.
68+ /// rebuilding the channel. `None` means the owning sandbox instance revoked it.
6969type TokenSlot = Arc < RwLock < Option < AsciiMetadataValue > > > ;
7070
7171#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
@@ -75,7 +75,7 @@ enum TokenSource {
7575 K8sServiceAccount ,
7676}
7777
78- /// Gateway credentials owned by one supervisor session .
78+ /// Gateway credentials owned by one sandbox instance .
7979///
8080/// Clients built from a [`GatewayEndpoint`] read only these slots, and the
8181/// renewal task started by the first connection updates only them. Dropping
@@ -200,7 +200,7 @@ impl GatewayCredentials {
200200 }
201201
202202 /// Start the renewal task once for these credentials, on the caller's
203- /// runtime, so a hosted session 's renewal stops with that session .
203+ /// runtime, so a hosted sandbox instance 's renewal stops with that instance .
204204 fn start_renewal ( & self , channel : & AuthedChannel , plain_channel : & Channel , endpoint : & str ) {
205205 let mut renewal = self
206206 . inner
@@ -239,14 +239,16 @@ impl GatewayCredentials {
239239 . bearer
240240 . write ( )
241241 . unwrap_or_else ( std:: sync:: PoisonError :: into_inner) ;
242- // A revoked session must not be revived by an in-flight response.
242+ // Revoked instance credentials must not be revived by an in-flight
243+ // response.
243244 if slot. is_some ( ) {
244245 * slot = Some ( bearer) ;
245246 }
246247 }
247248}
248249
249- /// The gateway URL a session uses, paired with that session's credentials.
250+ /// The gateway URL a sandbox instance uses, paired with that instance's
251+ /// credentials.
250252#[ derive( Clone ) ]
251253pub struct GatewayEndpoint {
252254 url : Arc < str > ,
@@ -271,7 +273,7 @@ impl GatewayEndpoint {
271273 & self . credentials
272274 }
273275
274- /// Reach another gateway address with the same session credentials.
276+ /// Reach another gateway address with the same sandbox instance credentials.
275277 #[ must_use]
276278 pub fn with_url ( & self , url : impl Into < Arc < str > > ) -> Self {
277279 Self :: new ( url, self . credentials . clone ( ) )
@@ -357,7 +359,9 @@ impl tonic::service::Interceptor for AuthInterceptor {
357359 . read ( )
358360 . unwrap_or_else ( std:: sync:: PoisonError :: into_inner)
359361 . clone ( )
360- . ok_or_else ( || Status :: unauthenticated ( "gateway session credentials were revoked" ) ) ?;
362+ . ok_or_else ( || {
363+ Status :: unauthenticated ( "sandbox instance gateway credentials were revoked" )
364+ } ) ?;
361365 req. metadata_mut ( ) . insert ( "authorization" , bearer) ;
362366 #[ cfg( feature = "trace-context" ) ]
363367 let req =
@@ -458,11 +462,14 @@ impl Drop for ClientSpanStatus {
458462 }
459463}
460464
461- /// Build a Bearer-authenticated channel to the gateway with one session's
462- /// credentials. The first connection starts that session's renewal task.
465+ /// Build a Bearer-authenticated channel to the gateway with one sandbox
466+ /// instance's credentials. The first connection starts that instance's
467+ /// renewal task.
463468async fn connect_channel ( gateway : & GatewayEndpoint ) -> Result < AuthedChannel > {
464469 if gateway. credentials . is_revoked ( ) {
465- return Err ( miette:: miette!( "gateway session credentials were revoked" ) ) ;
470+ return Err ( miette:: miette!(
471+ "sandbox instance gateway credentials were revoked"
472+ ) ) ;
466473 }
467474 let channel = build_plain_channel ( gateway. url ( ) ) . await ?;
468475 let intercepted = InterceptedService :: new (
@@ -577,8 +584,9 @@ pub async fn report_provider_readiness(
577584 . into_diagnostic ( )
578585}
579586
580- /// Slots and transport retained by one session's renewal task. It holds no
581- /// reference to [`GatewayCredentials`], so dropping them still stops it.
587+ /// Slots and transport retained by one sandbox instance's renewal task. It
588+ /// holds no reference to [`GatewayCredentials`], so dropping them still stops
589+ /// it.
582590struct RenewalTarget {
583591 channel : AuthedChannel ,
584592 bearer : TokenSlot ,
@@ -590,10 +598,10 @@ struct RenewalTarget {
590598}
591599
592600/// Background task that renews the sandbox JWT at ~80% of its remaining
593- /// lifetime. The new token replaces the value in the session 's slot, so all
594- /// in-flight and future clients of that session pick it up on their next
595- /// request. The loop never panics: every failure is logged and re-attempted
596- /// after a bounded backoff.
601+ /// lifetime. The new token replaces the value in the sandbox instance 's slot,
602+ /// so all in-flight and future clients of that instance pick it up on their
603+ /// next request. The loop never panics: every failure is logged and
604+ /// re-attempted after a bounded backoff.
597605async fn refresh_token_loop ( target : RenewalTarget ) {
598606 let RenewalTarget {
599607 channel,
@@ -832,7 +840,7 @@ fn compute_refresh_delay(slot: &TokenSlot) -> Option<Duration> {
832840 let current = slot
833841 . read ( )
834842 . unwrap_or_else ( std:: sync:: PoisonError :: into_inner) ;
835- // A revoked session has nothing to renew.
843+ // Revoked instance credentials have nothing to renew.
836844 current. as_ref ( ) ?. to_str ( ) . ok ( ) . map ( str:: to_string)
837845 }
838846 . unwrap_or_default ( ) ;
@@ -1058,7 +1066,7 @@ mod workspace_tests {
10581066 }
10591067}
10601068
1061- /// Connect to the `OpenShell` server with one session 's credentials.
1069+ /// Connect to the `OpenShell` server with one sandbox instance 's credentials.
10621070async fn connect ( gateway : & GatewayEndpoint ) -> Result < OpenShellClient < AuthedChannel > > {
10631071 let channel = connect_channel ( gateway) . await ?;
10641072 Ok ( OpenShellClient :: new ( channel) )
@@ -1711,7 +1719,8 @@ mod token_grant_exchange_tests {
17111719#[ derive( Clone ) ]
17121720pub struct CachedOpenShellClient {
17131721 client : OpenShellClient < AuthedChannel > ,
1714- /// Session credentials rotated alongside extension credentials.
1722+ /// Sandbox instance gateway credentials rotated alongside extension
1723+ /// credentials.
17151724 credentials : GatewayCredentials ,
17161725 workspace : Arc < tokio:: sync:: OnceCell < String > > ,
17171726 /// Extension credentials for this supervisor. Cloning the client shares
0 commit comments