phase1c: add UiJobObject + split UI policy resolution from encoding#291
Merged
Conversation
bb44689 to
2e7f5cc
Compare
2e7f5cc to
793b93a
Compare
1a3f242 to
15b40af
Compare
15b40af to
69c3d62
Compare
69c3d62 to
00dbfc9
Compare
00dbfc9 to
e58e646
Compare
shschaefer
approved these changes
May 12, 2026
e58e646 to
dd7e0ce
Compare
…from encoding The phase1a `ui_policy` module mixed two concerns: resolving the cross-platform `UiPolicy` + `BaseProcessUiConfig` into a set of intended UI restrictions (platform-agnostic logic), and encoding those restrictions as a Windows `JOB_OBJECT_UILIMIT_*` bitmask (Windows-specific). This change splits them so the policy layer stays platform-agnostic and the Windows encoding lives next to the Job Object that consumes it. `crate::ui_policy` now exposes: - `EffectiveUiRestrictions`, a record of ten booleans naming which UI capabilities the child must be denied. Platform-agnostic. - `resolve_ui_restrictions(&UiPolicy, &BaseProcessUiConfig) -> EffectiveUiRestrictions`, replacing `ui_restrictions_bitmask`. - The `UILIMIT_*` bare-`u64` constants are gone. `crate::job_object` (new, Windows-only) exposes: - `UiJobObject`, an RAII wrapper around a Windows Job Object used to apply UI restrictions to a child process and its descendants. `set_ui_limits` takes an `&EffectiveUiRestrictions` directly so callers never deal in raw bits. - `to_job_object_uilimit_mask(&EffectiveUiRestrictions) -> u32`, the Windows-specific encoder. Sources nine of the ten flag bits from the `windows` crate (`Win32::System::JobObjects::JOB_OBJECT_UILIMIT_*` for eight, `Win32::System::SystemServices::JOB_OBJECT_UILIMIT_IME` for IME). The tenth, `JOB_OBJECT_UILIMIT_INJECTION`, is hand-typed because the `windows` crate metadata does not include it; if a future release adds it, the local constant can be removed. Side effects: - `wxc_common::ui_policy` returns to the platform-agnostic section of `lib.rs`. The Windows-specific encoding moved out, so there is no longer any OS-specific code in the module. - `base_container_runner.rs` is updated to use the new APIs: `resolve_ui_restrictions` + `to_job_object_uilimit_mask`, with the encoder's `u32` cast to `u64` for the FlatBuffer `ui_restrictions` field (which the BaseContainer SandboxSpec schema defines as u64). - Enables the `Win32_System_JobObjects` feature on the workspace `windows` crate dependency. - Drops `UiJobObject::handle()`; no caller used it and exposing the raw HANDLE was a footgun. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dd7e0ce to
4a7c83a
Compare
shschaefer
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📖 Description
Splits the phase1a
ui_policymodule into two concerns and introduces the Windows Job Object wrapper that consumes the second one.The policy layer (
crate::ui_policy) stays platform-agnostic. It exposes:EffectiveUiRestrictions, a record of ten booleans naming which UI capabilities the child must be denied.resolve_ui_restrictions(&UiPolicy, &BaseProcessUiConfig) -> EffectiveUiRestrictions, replacingui_restrictions_bitmask. Nowindows-crate references; ready for future macOS/Linux consumers.The
UILIMIT_*bare-u64constants are gone.The Windows encoding layer (
crate::job_object, new) is Windows-only. It exposes:UiJobObject, an RAII wrapper around a Windows Job Object that applies UI restrictions to a child and its descendants.set_ui_limitstakes an&EffectiveUiRestrictionsdirectly so callers never deal in raw bits.to_job_object_uilimit_mask(&EffectiveUiRestrictions) -> u32, the encoder. Sources nine of the ten flag bits from thewindowscrate (Win32::System::JobObjects::JOB_OBJECT_UILIMIT_*for eight,Win32::System::SystemServices::JOB_OBJECT_UILIMIT_IMEfor IME). The tenth,JOB_OBJECT_UILIMIT_INJECTION, is hand-typed because thewindowscrate metadata does not include it; if a future release adds it, the local constant can be removed.Side effects:
wxc_common::ui_policyreturns to the platform-agnostic section oflib.rs. The Windows-specific encoding moved out, so the module no longer has any OS-specific code.base_container_runner.rsis updated to use the new APIs (encoder'su32is cast tou64for the BaseContainer FlatBufferui_restrictionsfield).Win32_System_JobObjectsfeature on the workspacewindowscrate dependency.UiJobObject::handle(); no caller used it and exposing the raw HANDLE was a footgun.🔗 References
Stacked on top of #290 (phase1b → main).
🔍 Validation
cargo test -p wxc_common --lib— 336/336 passcargo build -p wxc_commoncleanWin25H2Safe-Tests.ps1in phase5 (held)