Repository navigation
[refac & fix] Simplify ProcessContainer selection & stop creating extra sandbox - #1285
Merged
Jeff Whiteside (jsidewhite) merged 1 commit intoSep 25, 2026
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: c7101cd5-4604-4caf-a8be-7c140b26804c
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Jeff Whiteside (jsidewhite)
requested a review
from Branden Bonaby (bbonaby)
September 25, 2026 20:26
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Obsolete duplicate probing and stale documentation remain, and one test can leak process-wide state after a panic.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Consolidates ProcessContainer backend selection and replaces sandbox-creating capability probes with Windows API-set checks.
Changes:
- Centralizes request serviceability and tier selection.
- Adds reusable API-set detection and refactors PSEC/Learning Mode handling.
- Updates tests, examples, and ProcessContainer documentation.
| File | Description |
|---|---|
src/core/wxc_common/src/lib.rs |
Exposes the Windows API-set module. |
src/core/wxc_common/src/api_set.rs |
Adds the shared API-set probe. |
src/core/wxc_common/Cargo.toml |
Enables the required Windows API feature. |
src/core/mxc_engine/src/run.rs |
Uses the consolidated dispatcher. |
src/core/mxc_engine/src/probe.rs |
Uses read-only BaseContainer capability probes. |
src/core/mxc_engine/src/guarded_capture.rs |
Simplifies capture-factory documentation and assertion. |
src/core/mxc_engine/src/dispatch.rs |
Uses the consolidated streaming dispatcher. |
src/core/learning_mode_platforms/windows/src/lib.rs |
Exposes revised Learning Mode APIs and error classification. |
src/core/learning_mode_platforms/windows/src/ffi.rs |
Adds API-set gating and handle-owned stop operations. |
src/backends/process_container/common/src/test_env.rs |
Removes the deny-path test guard. |
src/backends/process_container/common/src/secenv.rs |
Centralizes typed PSEC capability and version queries. |
src/backends/process_container/common/src/probe.rs |
Uses the authoritative tier decision. |
src/backends/process_container/common/src/native_capture.rs |
Simplifies capture-session initialization. |
src/backends/process_container/common/src/guarded_capture.rs |
Updates dispatcher references. |
src/backends/process_container/common/src/fallback_detector.rs |
Consolidates tier selection around request serviceability. |
src/backends/process_container/common/src/dispatcher.rs |
Unifies capture-aware dispatch entry points. |
src/backends/process_container/common/src/base_container_runner.rs |
Implements authoritative BaseContainer serviceability checks. |
src/backends/process_container/common/src/base_container_helpers/tests.rs |
Updates PSEC helper tests. |
src/backends/process_container/common/src/base_container_helpers.rs |
Refactors PSEC v1 specification construction. |
src/backends/process_container/common/examples/lm_probe.rs |
Updates probe documentation. |
src/backends/process_container/common/examples/lm_capture.rs |
Uses simplified capture-session startup. |
docs/process-container/os-version-support.md |
Documents API-set-based selection. |
docs/process-container/guide.md |
Documents centralized serviceability decisions. |
docs/backend-support-probe-api-plan.md |
Updates the BaseContainer probe description. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
368
to
+378
| let _lock = crate::test_env::lock(); | ||
| // SAFETY: env-var mutation is serialized by the shared test lock. | ||
| unsafe { | ||
| std::env::set_var("MXC_FORCE_BC_USABLE", "1"); | ||
| } | ||
| let request = ExecutionRequest::default(); | ||
| let probes = test_probe_facts(false, false); | ||
|
|
||
| let selected = run_probe_with_capabilities( | ||
| &request, | ||
| probes, | ||
| request_capabilities(true, true, true), | ||
| false, | ||
| ); | ||
| let selected = run_probe(&request, false); | ||
| // SAFETY: env-var mutation is serialized by the shared test lock. | ||
| unsafe { | ||
| std::env::remove_var("MXC_FORCE_BC_USABLE"); | ||
| } |
| | Backend | How presence is detected today | Where | Risk with this method | | ||
| | --- | --- | --- | --- | | ||
| | `base-container` | `fallback_detector::is_base_container_usable()` loads `processmodel.dll`<br>and calls an OS capability/create API.<br>No process or VM launch; result cached in a `OnceLock`. | Rust | A cached result (`true` **or** `false`) can go stale if BaseContainer enablement<br>changes mid-process, and the probe is not perfectly pure since it loads a DLL. | | ||
| | `base-container` | `BaseContainerRunner::is_base_container_api_present()` calls `IsApiSetImplemented` for the process-security-environment API set. It does not load `processmodel.dll`, create a security environment, or start a process. | Rust | This proves that Windows implements the API-set contract; request-specific support bits are queried separately when the policy requires them. | |
Comment on lines
+282
to
+286
| pub(crate) fn choose_backend_tier( | ||
| request: &ExecutionRequest, | ||
| ) -> Result<TierDecision, FallbackError> { | ||
| let policy = &request.policy; | ||
| let base_container_decision = BaseContainerRunner::can_backend_service_request(request); |
Branden Bonaby (bbonaby)
approved these changes
Sep 25, 2026
|
|
||
| /// Whether Windows implements the named API-set contract. | ||
| #[must_use] | ||
| pub fn is_api_set_implemented(name: &core::ffi::CStr) -> bool { |
| const STOP_NAME: &core::ffi::CStr = c"StopLearningModeTrace"; | ||
| const CLOSE_NAME: &core::ffi::CStr = c"CloseLearningModeTrace"; | ||
|
|
||
| /// Which Learning Mode trace exports resolved on this machine. |
Collaborator
There was a problem hiding this comment.
jeff the code janitor 😊
Jeff Whiteside (jsidewhite)
deleted the
jsidewhite/mxc_network_policy_helpers_RB
branch
September 25, 2026 21:56
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.


For BaseContainer,
The one decision point:
can_backend_service_requestDecides if a backend for ProcessContainer can honor the ExecutionRequest very very clearly.
The one choice point:
choose_backend_tierChooses a backend tier for ProcessContainer very very clearly.
Stop creating an extra Sandbox
Move to
IsApiSetImplementedAPI-set availability checks instead of creating a real security environment.Sandbox creation BEFORE
Sandbox creatin AFTER
Refactor (delete)
..really this is just deleting the 7 extra "is_usable" duplicate checks for basecontainer availability.
Closes #1263
Microsoft Reviewers: Open in CodeFlow