Skip to content

Commit a00b721

Browse files
committed
refactor(runtime): defer UI policy support to MXC integration
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 114b493 commit a00b721

25 files changed

Lines changed: 197 additions & 1287 deletions

File tree

‎crates/openshell-core/README.md‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ configuration validation live in `openshell_core::middleware`. Policy admission
5858
and the supervisor runtime consume the same contract without introducing a
5959
dependency from the policy crate to the supervisor implementation.
6060

61-
## Extension Capabilities
62-
63-
Extensions advertise namespaced string capabilities through `PeerMetadata`.
64-
Use shared constants in `extension_protocol` and pass optional capabilities to
65-
`extension_metadata`; do not add per-driver booleans for policy features.
66-
Negotiation validates and retains the extension's supported capability list.
67-
68-
`POLICY_UI_V1` (`openshell.policy.ui.v1`) declares complete startup UI-policy
69-
support. The gateway checks the effective policy before driver validation or
70-
creation and rejects any explicit UI section when the capability is absent.
71-
Supporting drivers validate and enforce the concrete settings. Omitted UI
72-
preserves existing driver behavior; changing UI requires sandbox recreation.
73-
7461
## Protobuf Struct Conversion
7562

7663
Use `openshell_core::proto_struct` when crossing between `serde_json` values and

‎crates/openshell-core/src/extension_protocol.rs‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ pub const PROTOCOL_MINOR: u32 = 0;
1919
/// configured signer before accepting sandbox creation.
2020
pub const COMPUTE_LAUNCH_AUTHENTICATION: &str = "openshell.compute.launch-authentication";
2121

22-
/// Compute drivers advertising this capability enforce the complete startup UI
23-
/// policy contract. Absence means explicit UI policy must be rejected.
24-
pub const POLICY_UI_V1: &str = "openshell.policy.ui.v1";
25-
2622
const MAX_IMPLEMENTATION_NAME_BYTES: usize = 128;
2723
const MAX_IMPLEMENTATION_VERSION_BYTES: usize = 128;
2824
const MAX_CAPABILITY_BYTES: usize = 128;
@@ -402,36 +398,6 @@ mod tests {
402398
);
403399
}
404400

405-
#[test]
406-
fn ui_policy_capability_uses_existing_optional_negotiation() {
407-
let gateway = gateway_metadata(ExtensionFamily::Compute);
408-
let extension = extension_metadata(
409-
ExtensionFamily::Compute,
410-
"openshell/test-ui-driver",
411-
"test",
412-
[POLICY_UI_V1.to_string()],
413-
);
414-
let result = negotiate(
415-
ExtensionFamily::Compute,
416-
"test-ui-driver",
417-
&gateway,
418-
Some(extension),
419-
)
420-
.unwrap();
421-
assert!(
422-
result
423-
.supported_capabilities
424-
.iter()
425-
.any(|value| value == POLICY_UI_V1)
426-
);
427-
assert!(
428-
!result
429-
.required_capabilities
430-
.iter()
431-
.any(|value| value == POLICY_UI_V1)
432-
);
433-
}
434-
435401
#[test]
436402
fn missing_metadata_and_major_skew_are_actionable() {
437403
let (gateway, mut extension) = compatible();

‎crates/openshell-core/src/policy.rs‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ impl TryFrom<ProtoSandboxPolicy> for SandboxPolicy {
113113
type Error = miette::Report;
114114

115115
fn try_from(proto: ProtoSandboxPolicy) -> Result<Self, Self::Error> {
116-
// UI capabilities are intentionally absent from the portable supervisor
117-
// runtime. Non-Windows compute paths do not expose them, so even a
118-
// schema-level UI allowance cannot grant a UI surface there. A capable
119-
// compute driver consumes the typed proto directly.
120116
// In cluster mode we always run with proxy networking so all egress
121117
// can be evaluated by OPA.
122118
let network = NetworkPolicy {
@@ -196,7 +192,6 @@ impl From<ProtoProcessPolicy> for ProcessPolicy {
196192
#[cfg(test)]
197193
mod tests {
198194
use super::*;
199-
use crate::proto::{UiClipboardAccess, UiPolicy};
200195

201196
#[test]
202197
fn try_from_maps_known_compatibility_values() {
@@ -238,26 +233,4 @@ mod tests {
238233
assert!(!is_valid_landlock_compatibility("nope"));
239234
assert!(!is_valid_landlock_compatibility("BestEffort"));
240235
}
241-
242-
#[test]
243-
fn portable_runtime_does_not_activate_ui_allowances() {
244-
let converted = SandboxPolicy::try_from(ProtoSandboxPolicy {
245-
version: 1,
246-
ui: Some(UiPolicy {
247-
allow_graphical_ui: true,
248-
clipboard: UiClipboardAccess::All as i32,
249-
allow_input_injection: true,
250-
}),
251-
..Default::default()
252-
})
253-
.expect("portable policy conversion succeeds");
254-
255-
assert_eq!(converted.version, 1);
256-
assert!(matches!(converted.network.mode, NetworkMode::Proxy));
257-
assert!(converted.network.proxy.is_some());
258-
assert!(converted.filesystem.read_only.is_empty());
259-
assert!(converted.filesystem.read_write.is_empty());
260-
assert!(converted.process.run_as_user.is_none());
261-
assert!(converted.process.run_as_group.is_none());
262-
}
263236
}

‎crates/openshell-driver-mxc/tests/policy_mapper_matrix.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,6 @@ fn handled_fields_inventory() {
11091109
// ── (1) Top-level keys: serialize a SandboxPolicy with every section
11101110
// present-but-minimal, then collect YAML keys. ──────────────────────────
11111111
let full_toplevel_policy = SandboxPolicy {
1112-
ui: None,
11131112
version: 1,
11141113
filesystem: Some(FilesystemPolicy {
11151114
include_workdir: false,

‎crates/openshell-policy-schema/src/lib.rs‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,6 @@ pub struct PolicyDocument {
193193
skip_serializing_if = "Option::is_none"
194194
)]
195195
pub process: Option<ProcessPolicy>,
196-
#[serde(
197-
default,
198-
deserialize_with = "deserialize_non_null_optional_field",
199-
skip_serializing_if = "Option::is_none"
200-
)]
201-
pub ui: Option<UiPolicy>,
202196
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
203197
pub network_policies: BTreeMap<String, NetworkPolicyRule>,
204198
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
@@ -240,34 +234,6 @@ pub struct ProcessPolicy {
240234
pub run_as_group: String,
241235
}
242236

243-
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
244-
#[serde(deny_unknown_fields)]
245-
pub struct UiPolicy {
246-
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
247-
pub allow_graphical_ui: bool,
248-
#[serde(default, skip_serializing_if = "UiClipboardAccess::is_none")]
249-
pub clipboard: UiClipboardAccess,
250-
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
251-
pub allow_input_injection: bool,
252-
}
253-
254-
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
255-
#[serde(rename_all = "snake_case")]
256-
pub enum UiClipboardAccess {
257-
#[default]
258-
None,
259-
Read,
260-
Write,
261-
All,
262-
}
263-
264-
impl UiClipboardAccess {
265-
#[must_use]
266-
pub const fn is_none(&self) -> bool {
267-
matches!(self, Self::None)
268-
}
269-
}
270-
271237
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
272238
#[serde(deny_unknown_fields)]
273239
pub struct NetworkPolicyRule {
@@ -732,7 +698,6 @@ fn inspect_document(root: &serde_yml::Value) -> InspectionResult {
732698
"filesystem_policy",
733699
"landlock",
734700
"process",
735-
"ui",
736701
"network_policies",
737702
"network_middlewares",
738703
],
@@ -752,11 +717,6 @@ fn inspect_document(root: &serde_yml::Value) -> InspectionResult {
752717
"process",
753718
&["run_as_user", "run_as_group"],
754719
)?;
755-
inspect_named(
756-
root.get("ui"),
757-
"ui",
758-
&["allow_graphical_ui", "clipboard", "allow_input_injection"],
759-
)?;
760720

761721
for (name, rule) in open_map(root.get("network_policies")) {
762722
let path = join("network_policies", name);
@@ -1216,7 +1176,6 @@ mod tests {
12161176
for source in [
12171177
"version: 1\nfilesystem_policy: null\n",
12181178
"version: 1\nprocess: null\n",
1219-
"version: 1\nui: null\n",
12201179
"version: 1\nmetadata: null\n",
12211180
"version: 1\nnetwork_policies:\n x:\n endpoints:\n - host: x\n port: 443\n mcp: null\n",
12221181
] {
@@ -1253,7 +1212,6 @@ mod tests {
12531212
"landlock.future",
12541213
),
12551214
("version: 1\nprocess: { future: true }\n", "process.future"),
1256-
("version: 1\nui: { future: true }\n", "ui.future"),
12571215
(
12581216
"version: 1\nnetwork_policies: { api: { future: true } }\n",
12591217
"network_policies.api.future",

0 commit comments

Comments
 (0)