Skip to content

Commit 845049b

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

25 files changed

Lines changed: 194 additions & 1284 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;
@@ -422,36 +418,6 @@ mod tests {
422418
);
423419
}
424420

425-
#[test]
426-
fn ui_policy_capability_uses_existing_optional_negotiation() {
427-
let gateway = gateway_metadata(ExtensionFamily::Compute);
428-
let extension = extension_metadata(
429-
ExtensionFamily::Compute,
430-
"openshell/test-ui-driver",
431-
"test",
432-
[POLICY_UI_V1.to_string()],
433-
);
434-
let result = negotiate(
435-
ExtensionFamily::Compute,
436-
"test-ui-driver",
437-
&gateway,
438-
Some(extension),
439-
)
440-
.unwrap();
441-
assert!(
442-
result
443-
.supported_capabilities
444-
.iter()
445-
.any(|value| value == POLICY_UI_V1)
446-
);
447-
assert!(
448-
!result
449-
.required_capabilities
450-
.iter()
451-
.any(|value| value == POLICY_UI_V1)
452-
);
453-
}
454-
455421
#[test]
456422
fn missing_metadata_and_major_skew_are_actionable() {
457423
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
@@ -195,12 +195,6 @@ pub struct PolicyDocument {
195195
skip_serializing_if = "Option::is_none"
196196
)]
197197
pub process: Option<ProcessPolicy>,
198-
#[serde(
199-
default,
200-
deserialize_with = "deserialize_non_null_optional_field",
201-
skip_serializing_if = "Option::is_none"
202-
)]
203-
pub ui: Option<UiPolicy>,
204198
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
205199
pub network_policies: BTreeMap<String, NetworkPolicyRule>,
206200
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
@@ -242,34 +236,6 @@ pub struct ProcessPolicy {
242236
pub run_as_group: String,
243237
}
244238

245-
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
246-
#[serde(deny_unknown_fields)]
247-
pub struct UiPolicy {
248-
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
249-
pub allow_graphical_ui: bool,
250-
#[serde(default, skip_serializing_if = "UiClipboardAccess::is_none")]
251-
pub clipboard: UiClipboardAccess,
252-
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
253-
pub allow_input_injection: bool,
254-
}
255-
256-
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
257-
#[serde(rename_all = "snake_case")]
258-
pub enum UiClipboardAccess {
259-
#[default]
260-
None,
261-
Read,
262-
Write,
263-
All,
264-
}
265-
266-
impl UiClipboardAccess {
267-
#[must_use]
268-
pub const fn is_none(&self) -> bool {
269-
matches!(self, Self::None)
270-
}
271-
}
272-
273239
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
274240
#[serde(deny_unknown_fields)]
275241
pub struct NetworkPolicyRule {
@@ -774,7 +740,6 @@ fn inspect_document(root: &serde_yml::Value) -> InspectionResult {
774740
"filesystem_policy",
775741
"landlock",
776742
"process",
777-
"ui",
778743
"network_policies",
779744
"network_middlewares",
780745
],
@@ -794,11 +759,6 @@ fn inspect_document(root: &serde_yml::Value) -> InspectionResult {
794759
"process",
795760
&["run_as_user", "run_as_group"],
796761
)?;
797-
inspect_named(
798-
root.get("ui"),
799-
"ui",
800-
&["allow_graphical_ui", "clipboard", "allow_input_injection"],
801-
)?;
802762

803763
for (name, rule) in open_map(root.get("network_policies")) {
804764
let path = join("network_policies", name);
@@ -1262,7 +1222,6 @@ mod tests {
12621222
for source in [
12631223
"version: 1\nfilesystem_policy: null\n",
12641224
"version: 1\nprocess: null\n",
1265-
"version: 1\nui: null\n",
12661225
"version: 1\nmetadata: null\n",
12671226
"version: 1\nnetwork_policies:\n x:\n endpoints:\n - host: x\n port: 443\n mcp: null\n",
12681227
] {
@@ -1348,7 +1307,6 @@ mod tests {
13481307
"landlock.future",
13491308
),
13501309
("version: 1\nprocess: { future: true }\n", "process.future"),
1351-
("version: 1\nui: { future: true }\n", "ui.future"),
13521310
(
13531311
"version: 1\nnetwork_policies: { api: { future: true } }\n",
13541312
"network_policies.api.future",

0 commit comments

Comments
 (0)