@@ -960,6 +960,29 @@ fn settings_poll_result(inner: crate::proto::GetSandboxConfigResponse) -> Settin
960960 }
961961}
962962
963+ impl From < crate :: proto:: SandboxConfigSnapshot > for SettingsPollResult {
964+ fn from ( inner : crate :: proto:: SandboxConfigSnapshot ) -> Self {
965+ Self {
966+ policy : inner. policy ,
967+ version : inner. version ,
968+ policy_hash : inner. policy_hash ,
969+ config_revision : inner. config_revision ,
970+ policy_source : PolicySource :: try_from ( inner. policy_source )
971+ . unwrap_or ( PolicySource :: Unspecified ) ,
972+ settings : inner. settings ,
973+ global_policy_version : inner. global_policy_version ,
974+ provider_env_revision : inner. provider_env_revision ,
975+ supervisor_middleware_services : inner. supervisor_middleware_services ,
976+ workspace : inner. workspace ,
977+ policy_validation_failure_mode : inner
978+ . policy_validation_failure_mode
979+ . parse ( )
980+ . unwrap_or_default ( ) ,
981+ extension_authentication_enabled : inner. extension_authentication_enabled ,
982+ }
983+ }
984+ }
985+
963986#[ cfg( test) ]
964987mod settings_poll_tests {
965988 use super :: settings_poll_result;
@@ -1001,6 +1024,25 @@ mod settings_poll_tests {
10011024 let legacy = settings_poll_result ( GetSandboxConfigResponse :: default ( ) ) ;
10021025 assert ! ( !legacy. extension_authentication_enabled) ;
10031026 }
1027+
1028+ #[ test]
1029+ fn delivered_sandbox_snapshot_uses_the_polling_projection ( ) {
1030+ let result = super :: SettingsPollResult :: from ( crate :: proto:: SandboxConfigSnapshot {
1031+ version : 7 ,
1032+ policy_hash : "hash-7" . to_string ( ) ,
1033+ config_revision : 42 ,
1034+ provider_env_revision : 9 ,
1035+ workspace : "workspace-a" . to_string ( ) ,
1036+ extension_authentication_enabled : true ,
1037+ ..Default :: default ( )
1038+ } ) ;
1039+ assert_eq ! ( result. version, 7 ) ;
1040+ assert_eq ! ( result. policy_hash, "hash-7" ) ;
1041+ assert_eq ! ( result. config_revision, 42 ) ;
1042+ assert_eq ! ( result. provider_env_revision, 9 ) ;
1043+ assert_eq ! ( result. workspace, "workspace-a" ) ;
1044+ assert ! ( result. extension_authentication_enabled) ;
1045+ }
10041046}
10051047
10061048pub struct ProviderEnvironmentResult {
@@ -1012,6 +1054,80 @@ pub struct ProviderEnvironmentResult {
10121054 pub non_secret_environment_keys : Vec < String > ,
10131055}
10141056
1057+ impl From < crate :: proto:: ProviderEnvironmentSnapshot > for ProviderEnvironmentResult {
1058+ fn from ( snapshot : crate :: proto:: ProviderEnvironmentSnapshot ) -> Self {
1059+ use crate :: proto:: ProviderEnvironmentValueClassification ;
1060+
1061+ let mut environment = HashMap :: with_capacity ( snapshot. values . len ( ) ) ;
1062+ let mut credential_expires_at_ms = HashMap :: new ( ) ;
1063+ let mut static_credential_bindings = HashMap :: new ( ) ;
1064+ let mut non_secret_environment_keys = Vec :: new ( ) ;
1065+ for value in snapshot. values {
1066+ environment. insert ( value. name . clone ( ) , value. value ) ;
1067+ if let Some ( expires_at_ms) = value. expires_at_ms {
1068+ credential_expires_at_ms. insert ( value. name . clone ( ) , expires_at_ms) ;
1069+ }
1070+ match ProviderEnvironmentValueClassification :: try_from ( value. classification )
1071+ . unwrap_or_default ( )
1072+ {
1073+ ProviderEnvironmentValueClassification :: NonSecret => {
1074+ non_secret_environment_keys. push ( value. name ) ;
1075+ }
1076+ ProviderEnvironmentValueClassification :: StaticCredential => {
1077+ if let Some ( binding) = value. static_credential_binding {
1078+ static_credential_bindings. insert ( value. name , binding) ;
1079+ }
1080+ }
1081+ ProviderEnvironmentValueClassification :: Unspecified => { }
1082+ }
1083+ }
1084+ Self {
1085+ environment,
1086+ provider_env_revision : snapshot. provider_env_revision ,
1087+ credential_expires_at_ms,
1088+ dynamic_credentials : snapshot. dynamic_credentials ,
1089+ static_credential_bindings,
1090+ non_secret_environment_keys,
1091+ }
1092+ }
1093+ }
1094+
1095+ #[ cfg( test) ]
1096+ mod provider_snapshot_tests {
1097+ use super :: ProviderEnvironmentResult ;
1098+ use crate :: proto:: {
1099+ ProviderEnvironmentSnapshot , ProviderEnvironmentValue ,
1100+ ProviderEnvironmentValueClassification , StaticCredentialBinding ,
1101+ } ;
1102+
1103+ #[ test]
1104+ fn delivered_provider_snapshot_preserves_secret_classification_metadata ( ) {
1105+ let result = ProviderEnvironmentResult :: from ( ProviderEnvironmentSnapshot {
1106+ provider_env_revision : 11 ,
1107+ values : vec ! [
1108+ ProviderEnvironmentValue {
1109+ name: "REGION" . to_string( ) ,
1110+ value: "west" . to_string( ) ,
1111+ classification: ProviderEnvironmentValueClassification :: NonSecret . into( ) ,
1112+ ..Default :: default ( )
1113+ } ,
1114+ ProviderEnvironmentValue {
1115+ name: "TOKEN" . to_string( ) ,
1116+ value: "redacted" . to_string( ) ,
1117+ classification: ProviderEnvironmentValueClassification :: StaticCredential . into( ) ,
1118+ static_credential_binding: Some ( StaticCredentialBinding :: default ( ) ) ,
1119+ ..Default :: default ( )
1120+ } ,
1121+ ] ,
1122+ ..Default :: default ( )
1123+ } ) ;
1124+ assert_eq ! ( result. provider_env_revision, 11 ) ;
1125+ assert_eq ! ( result. environment. len( ) , 2 ) ;
1126+ assert_eq ! ( result. non_secret_environment_keys, [ "REGION" ] ) ;
1127+ assert ! ( result. static_credential_bindings. contains_key( "TOKEN" ) ) ;
1128+ }
1129+ }
1130+
10151131pub struct ProviderSubjectTokenExchangeResult {
10161132 pub access_token : String ,
10171133 pub expires_in : i64 ,
0 commit comments