Repository navigation
Add caller-owned policy preparation - #1718
Ross Nichols (rossnichols) wants to merge 22 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The validation gate can incorrectly pass when native-preparation theory results are absent because passing pure-storage rows with the same method names satisfy its checks.
1 open issue
What changed in this PR
Implements the caller-owned policy preparation design from #1635 for Windows ProcessContainer. Applications can inspect proposed permission reductions before submitting their chosen request through ordinary strict creation.
Changes:
- Adds V1.Dev preparation APIs and candidate-storage helpers across Rust, .NET, and Node.
- Preserves structured native policy observations across SDK boundaries while keeping resource details out of default error formatting.
- Adds compatibility, ownership, preparation, and enforcement coverage, with scheduled validation checks and updated documentation.
| File | Description |
|---|---|
src/mxc-sdk/tests/streaming_processcontainer.rs |
Tests preparation, acceptance, filesystem enforcement, and request reuse. |
src/mxc-sdk/tests/dev_compatibility.rs |
Checks existing V1.Dev options and creation signatures. |
src/mxc-sdk/src/lib.rs |
Exposes bounded observation decoding for FFI. |
src/mxc-sdk/src/dev.rs |
Adds preparation APIs, exports, and storage helpers. |
src/mxc-sdk/src/core/process_security_environment_spec/README.md |
Documents policy-result schema provenance and regeneration. |
src/mxc-sdk/src/core/process_security_environment_policy_result/mod.rs |
Registers generated policy-result bindings. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/value_kind_generated.rs |
Adds generated value-kind constants. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/resource_kind_generated.rs |
Adds generated resource-kind constants. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/required_action_generated.rs |
Adds generated restriction-action constants. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/policy_result_version_generated.rs |
Adds generated result-version constants. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/policy_result_limit_generated.rs |
Adds generated diagnostic limits. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/policy_result_flags_generated.rs |
Adds generated result flags. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/policy_outcome_generated.rs |
Adds generated policy outcomes. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/policy_access_generated.rs |
Adds generated filesystem access values. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/failure_reason_generated.rs |
Adds generated refusal reasons. |
src/mxc-sdk/src/core/process_security_environment_policy_result/experimental_process_security_environment_policy_result/failure_class_generated.rs |
Adds generated policy-failure classes. |
src/mxc-sdk/src/core/mxc_engine/policy_preparation.rs |
Validates and routes preparation to ProcessContainer. |
src/mxc-sdk/src/core/mxc_engine/policy_preparation_tests.rs |
Tests invalid inputs, limits, and safe error text. |
src/mxc-sdk/src/core/mxc_engine/mod.rs |
Registers engine preparation support. |
src/mxc-sdk/src/core/mxc_engine/error.rs |
Documents and tests structured error preservation. |
src/mxc-sdk/src/core/mxc_engine/dispatch.rs |
Uses shared structured spawn-error conversion. |
src/mxc-sdk/src/core/mxc_common/splice.rs |
Preserves unchanged JSON members verbatim. |
src/mxc-sdk/src/core/mxc_common/script_runner.rs |
Emits structured backend error envelopes. |
src/mxc-sdk/src/core/mxc_common/mxc_error.rs |
Redacts diagnostic details and restores structured errors. |
src/mxc-sdk/src/core/mxc_common/mod.rs |
Registers shared observation and preparation models. |
src/mxc-sdk/src/core/mod.rs |
Registers the private policy-result module. |
src/mxc-sdk/src/backends/process_container/common/working_directory.rs |
Adds fallible working-directory resolution for preparation. |
src/mxc-sdk/src/backends/process_container/common/secenv_policy.rs |
Decodes bounded native results and recognizes restrictions. |
src/mxc-sdk/src/backends/process_container/common/network_policy_helpers.rs |
Shares capture-related capability selection. |
src/mxc-sdk/src/backends/process_container/common/native_capture.rs |
Allows capture initialization from an existing environment. |
src/mxc-sdk/src/backends/process_container/common/mod.rs |
Registers backend preparation modules. |
src/mxc-sdk/src/backends/process_container/common/launch_diagnostics.rs |
Adds administrative-policy refusal guidance. |
src/mxc-sdk/src/backends/process_container/common/base_container_helpers.rs |
Centralizes effective capability calculation. |
src/mxc-sdk/README.md |
Explains Rust caller-owned preparation. |
src/mxc-sdk/examples/policy_feedback.rs |
Demonstrates explicit approval, storage, and bounded retries. |
src/mxc-sdk/Cargo.toml |
Enables tests for the preparation example. |
src/ffi/mxc_ffi/tests/ffi.rs |
Checks initialization of the new error-details field. |
src/ffi/mxc_ffi/src/policy_preparation_tests.rs |
Tests FFI validation and allocation ownership. |
src/ffi/mxc_ffi/src/lib.rs |
Adds the preparation entry point and shared JSON-result handling. |
src/ffi/mxc_ffi/src/error_detail.rs |
Transports and frees structured error JSON. |
sdk/node/tests/unit/streaming-binding.test.ts |
Tests structured creation errors and cleanup. |
sdk/node/tests/unit/inprocess-run.test.ts |
Verifies creation options reject policy observations. |
sdk/node/tests/integration/windows-process-container.test.ts |
Reuses private Windows fixture creation. |
sdk/node/tests/integration/test-helpers.ts |
Adds a reusable private Windows directory helper. |
sdk/node/tests/integration/dev-api.ts |
Checks packaged preparation APIs and caller acceptance. |
sdk/node/src/v1/errors.ts |
Hides structured details from default inspection. |
sdk/node/src/v1/dev/policy-preparation.ts |
Defines preparation models and checked storage helpers. |
sdk/node/src/v1/dev/json-duplicate-keys.ts |
Detects duplicate JSON object keys. |
sdk/node/src/v1/dev/index.ts |
Exports observation helpers and the preparation API. |
sdk/node/src/bindings/streaming.ts |
Initializes complete native error structures. |
sdk/node/src/bindings/state-aware.ts |
Initializes structured lifecycle errors. |
sdk/node/src/bindings/run.ts |
Initializes complete native execution results. |
sdk/node/src/bindings/pty.ts |
Initializes structured terminal errors. |
sdk/node/src/bindings/probe.ts |
Initializes structured probe errors. |
sdk/node/src/bindings/policy-preparation.ts |
Adds asynchronous native preparation with cleanup. |
sdk/node/src/bindings/native-error.ts |
Decodes structured backend error details. |
sdk/node/README.md |
Documents preparation, storage, and sensitive error details. |
sdk/dotnet/README.md |
Documents preparation and explicit caller acceptance. |
sdk/dotnet/Microsoft.Mxc.Sdk/V1/MxcException.cs |
Adds independently owned backend details. |
sdk/dotnet/Microsoft.Mxc.Sdk/V1/Dev/PreparedPolicyRequest.cs |
Adds candidate models and checked JSON storage. |
sdk/dotnet/Microsoft.Mxc.Sdk/V1/Dev/PolicyPreparationOptions.cs |
Defines separate preparation controls. |
sdk/dotnet/Microsoft.Mxc.Sdk/V1/Dev/MxcContainer.cs |
Adds synchronous and asynchronous preparation APIs. |
sdk/dotnet/Microsoft.Mxc.Sdk/PolicyFailureValueJsonConverter.cs |
Preserves unsigned 64-bit values as decimal strings. |
sdk/dotnet/Microsoft.Mxc.Sdk/Native/NativeError.cs |
Converts native structured details into managed exceptions. |
sdk/dotnet/Microsoft.Mxc.Sdk/MxcJsonSerialization.cs |
Registers JSON types and duplicate-property validation. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/V1ApiSurfaceTests.cs |
Checks preparation types and signatures. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcContainerTests.cs |
Tests structured probe-error transport. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/NativeErrorTests.cs |
Tests detail ownership, extraction, and safe formatting. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/MxcExceptionTests.cs |
Verifies details survive JSON-document disposal. |
sdk/dotnet/Microsoft.Mxc.Sdk.AotSmokeTest/Program.cs |
Adds preparation and observation serialization coverage. |
scripts/ci/test-policy-preparation-test-results.ps1 |
Adds positive and negative result-check fixtures. |
scripts/ci/run_backend_validation_tests.ps1 |
Runs preparation scenarios in Windows validation. |
scripts/ci/lib/TestSuiteResults.ps1 |
Adds required-output checks for test results. |
scripts/ci/build-windows-sdk-test-bundle.ps1 |
Requires preparation test discovery in bundles. |
external/windows-sdk/ProcessSecurityEnvironment.provenance.toml |
Pins the policy-result schema source and hash. |
external/windows-sdk/ExperimentalProcessSecurityEnvironmentPolicyResult.fbs |
Defines the native refusal-diagnostics contract. |
docs/development/guides/process-container-adding-os-features.md |
Documents native diagnostics and preparation invariants. |
docs/development/build-and-test/ci-validation-infrastructure.md |
Documents preparation scenarios and validation requirements. |
docs/development/architecture/designs/1634-creation-policy-correction/README.md |
Removes the superseded prototype note. |
docs/development/architecture/designs/1634-creation-policy-correction/api.md |
Links the implemented example and SDK references. |
docs/backends/nvx/nvx.md |
Documents recovery details now exposed through managed SDKs. |
docs/api-reference/rust/v1/types.md |
Clarifies error redaction and observation extraction. |
docs/api-reference/rust/v1/README.md |
Updates the Dev API link label. |
docs/api-reference/rust/v1/api.md |
Identifies preparation in the Dev API link. |
docs/api-reference/node/v1/types.md |
Documents structured details and logging precautions. |
docs/api-reference/node/v1/README.md |
Updates the Dev API link label. |
docs/api-reference/node/v1/api.md |
Identifies preparation in the Dev API link. |
docs/api-reference/dotnet/v1/types.md |
Documents owned exception details. |
docs/api-reference/dotnet/v1/README.md |
Introduces preparation and AOT-compatible storage. |
docs/api-reference/dotnet/v1/api.md |
Identifies preparation in the Dev API link. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Windows-specific refusal capture and restrictive filesystem preparation require capable-host validation beyond this review environment, with a full scheduled-host run, a real governed-policy refusal, and fresh Native AOT execution still unverified.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Windows-specific refusal capture and policy enforcement remain unverified because the final candidate lacks capable-host validation through the full scheduled suite and a real governed refusal.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can break the scheduled test on aliased temporary paths, hide SDK remediation guidance, and allow policy-change serialization to produce saved candidates that cannot be restored.
4 open issues
Review effort: Max
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed to weigh how masking native-library loading and missing-symbol diagnostics affects troubleshooting installation and version mismatches.
No open issues 🎉
4 resolved since last review
Review effort: Max
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive Windows policy enforcement and cross-SDK ABI changes require maintainer review because the final candidate lacks governed-refusal testing, a full scheduled-host run, and fresh Native AOT publication.
No open issues 🎉
Review effort: Max
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
No open issues 🎉
1 resolved since last review
Review effort: Lite
Return structured policy refusals and prepare restricted candidates without creation. Preserve V1 creation APIs; callers own acceptance, storage and retries. Co-authored-by: Copilot <[email protected]>
Require each native storage theory row to pass in scheduled validation, and cover missing native rows when the pure-storage rows pass. Co-authored-by: Copilot <[email protected]>
Compile the request projection helper only on Windows. Keep injected policy tests independent of native PSEC attribute support and use canonical fixture paths when testing literal filesystem restrictions. Co-authored-by: Copilot <[email protected]>
Allow unrelated architecture skips without relaxing preparation checks. Keep Rust README usage in the canonical API guide. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed to weigh unpublished findings about duplicated API guidance and missing warnings about potentially sensitive exception details exposed through logging or serialization.
No open issues 🎉
1 resolved since last review
Review effort: Max
Remove duplicated Dev links and document filtering sensitive .NET error details. Co-authored-by: Copilot <[email protected]>
|
🤖 Follow-up to Copilot's review: dd0fb78 removes the duplicate Dev cross-references introduced during the merge and adds a warning to the .NET |
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive policy reduction and native refusal handling span three SDKs, while real governed Windows refusal behavior and the full capable-host test run remain unverified, requiring maintainer judgment.
No open issues 🎉
Review effort: Max
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
Summary
Changes requested for default disclosure of policy observations and for preparation paths that can report an unapplied filesystem ceiling as satisfied. Other findings distinguish representability failures, bounded-work issues, coverage requests, and deliberate changes from the approved design. Numbering follows the review discussion; independently fixable cases are split as 3a/3b/3c, 5a/5b, and 8a/8b.
Reviewed head: 4dcde8f3d60854248686b3855cb02d1cbe179311; merge-base: 8e368f0a42d6487a510363500e2ad4a14aca385a. Local and PR API inventories agree on all 119 changed paths. The review was rechecked against this head, not just the earlier 8acd8925 revision.
Approved-design contradictions
The baseline is the specification approved in #1635 at a416e83e2f4a37134bb4aae1a61860ff349721fb, not the specification edits in this implementation PR.
- Finding 1 directly contradicts the diagnostic-output boundary: approved design, lines 63-68 keeps policy resources out of ordinary console/debug/warning text.
- Findings 2 and 3a contradict the filesystem preparation guarantees: the approved restrictive rules require lowering matching writable grants and not relying on unsafe aliases or unresolved safety checks. These are implementation defects, not requests to change the caller-owned API model.
- Findings 11 and 12 below are deliberate semantic departures needing an explicit design decision: lossless native diagnostic inspection and the supported/serviceable-path requirement for empty observations. They are not claimed as containment bypasses or breaks to an already published SDK API.
What remains aligned
The separate preparation/caller-acceptance/strict-creation boundary is preserved. mxc_engine/policy_preparation.rs:23-55 returns a candidate; policy_projection.rs:24-57 derives, projects, reparses, and verifies it without creating an environment or launching a workload. Native diagnostic buffers remain owned by PolicyResultBuffer, whose Drop calls CoTaskMemFree (secenv.rs:841-861). These are source checks, not claims of a new runtime test run.
Finding 6 is withdrawn and is not a requested change. Delegating JSON projection to the backend does not violate the concern about run/spawn accepting observations and internally selecting a modified request. The approved prototype already contained manual field mappings; changing their module placement alone is not a demonstrated defect.
Non-blocking coverage requests
8a - Exercise an injected refusal through public dispatch. src/mxc-sdk/src/core/mxc_engine/dispatch.rs:183; attribution: introduced_by_change - this PR adds structured-observation propagation through resp.into_mxc_error(). The backend application-loop test calls BaseContainerRunner::spawn and converts its response directly (secenv_policy_tests.rs:318-323), while transport tests construct errors independently. Existing dispatch assertions cover categories/messages, not an actual backend refusal reaching caller-visible extraction. Add a public-dispatch regression asserting the original status/native code, owned observations, one native creation attempt, and no workload launch. This is a coverage gap, not an observed loss of details.
8b - Cover policy refusal with denial capture still enabled. src/mxc-sdk/src/backends/process_container/common/base_container_runner.rs:247,874-895; attribution: introduced_by_change - the new diagnostic creation call and refusal response have a capture-specific path. Existing refusal loops use UnusedCapture; the capture-removal preparation test removes capture before successful creation. Inject a policy refusal through the real capture factory and assert preserved observations, one creation attempt, zero trace starts, and cleanup. Trace-start-failure tests do not exercise that branch. This does not require provisioning real administrative policy.
Non-blocking simplification observations
9 - Avoid repeated full JSON round-trips for an in-memory .NET merge. sdk/dotnet/Microsoft.Mxc.Sdk/V1/Dev/PolicyFailures.cs:209-225; attribution: introduced_by_change. Both inputs use FromJson(ToJson()), each batch is serialized for deduplication, and the complete merged result is serialized and discarded. Those operations serve legitimate validation, independent ownership, whole-batch identity, and byte-limit requirements; no incorrect merge result or unacceptable latency has been demonstrated. Consider direct validated copying and bounded serialized-byte accounting while preserving every one of those guarantees. This is not a merge condition by itself.
10 - Interpret owned observation strings without reconstructing native UTF-16 objects. src/mxc-sdk/src/backends/process_container/common/policy_restriction.rs:53 and secenv_policy.rs:223-245; attribution: introduced_by_change. Preparation converts each owned result into PolicyResult, allocating UTF-16 resources, then restriction_hints immediately decodes those resources back to strings (secenv_policy.rs:112-130,157-179). Interpret the owned representation directly, or use one shared interpretation view, without duplicating restriction semantics. This is redundant representation work, not a measured latency or enforcement failure, and is non-blocking by itself.
Design decisions requiring confirmation
11 - Malformed native resource text is no longer inspectable and original flags change. src/mxc-sdk/src/backends/process_container/common/secenv_policy.rs:194-215; attribution: introduced_by_change. On invalid UTF-16, conversion drops the resource, sets ResourceUnavailable, and clears ResourceComplete. The approved observation API instead preserves unsigned UTF-16 units, keeps malformed text inspectable, and has strict text-decoding helpers; the approved validation matrix also requires that fidelity. Preparation should still reject malformed resources, but that need not discard diagnostic identity: batches differing only in discarded resource units can now collapse during deduplication. Restore the approved fidelity or explicitly accept the changed inspection/identity contract. The PR documents the new string representation; that documentation change is not itself a separate defect.
12 - Empty observations bypass the approved backend/serviceability requirement. src/mxc-sdk/src/core/mxc_engine/policy_preparation.rs:46-52; attribution: introduced_by_change. Empty results return the original request on every OS/backend after parsing and experimental authorization, before native ProcessContainer request/host validation. The approved preparation algorithm and unsupported-surfaces acceptance criterion require the supported/serviceable path even for empty observations. Restore that ordering or explicitly accept that empty preparation is only a cross-backend pass-through and does not establish serviceability. This is not permission approval, execution, or a fail-open creation path.
Verified pre-existing context - not independently attributed to this PR
src/mxc-sdk/src/core/mxc_common/config_parser.rs is byte-identical between this review's merge-base and head. Its exact-string cross-list filesystem suppression predates this PR. Findings 3a-3c concern the new preparation logic's interaction with that existing behavior; they do not charge the old parser as a separate regression or require a compatibility-changing parser rewrite.
Evidence limits
The inline findings are source-traced at the pinned head. Filesystem operation counts are calculated, not capable-host timings. The Node expansion experiment used the actual helper body with error/duplicate-check dependencies stubbed, not a native preparation result or installed-package end-to-end test. No new runtime tests were run for this filing; no governed-host refusal reproduction, full Rust suite, cross-platform backend run, or .NET AOT run is claimed. Low-severity local observations are intentionally excluded.
Co-authored-by: Copilot <[email protected]>
Preserve console privacy and filesystem ceilings; bound SDK serialization. Co-authored-by: Copilot <[email protected]>
|
🤖 Follow-up to this review: 200898e addresses the nine inline findings, with separate replies on each thread. The existing scheduled Windows filesystem scenario now includes the equivalent-grant and deny/enumeration interactions, with capability-specific rejection checks on older hosts. For 8a/8b, a new public For 9/10, I left the non-blocking representation simplifications unchanged. The merge round-trips currently supply validation, independent ownership and whole-batch identity; preparation continues using the shared native-result interpreter. There is no demonstrated incorrect result or measured performance issue justifying a second interpretation path in this fix. For 11, string resources were an explicit design direction rather than an accidental omission: do not expose For 12, the confirmed direction is to retain cross-backend empty-observation pass-through. A valid For the latest Copilot summary, the empty-observation choice is confirmed above and in both specifications. The separate real governed-Windows refusal and full scheduled-host validation gap remains as documented; no new run or maintainer approval is claimed. |
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive Windows policy enforcement and cross-SDK native error ownership need maintainer review because real governed-refusal behavior and the full scheduled-host suite remain unvalidated.
No open issues 🎉
1 resolved since last review
Review effort: Max
Document empty-observation pass-through and its validation boundary. Align resource handling, ownership and result limits with the implementation. Co-authored-by: Copilot <[email protected]>


📖 Description
When Windows refuses a container request because it exceeds administrative
policy, an application needs to understand the refusal and decide whether a
more restricted request still serves its task. For example, a caller requesting
write access may be willing to accept read-only access, but MXC must not make
that acceptance decision or run the workload on its behalf.
This implements the caller-owned preparation design across Rust, .NET and Node:
supplies them, preserving the original error category, operation and HRESULT.
Resource details remain separate from ordinary error text and default
diagnostic inspection, while remediation remains visible to callers.
PolicyFailuresand separatePolicyPreparationOptions. It returns aPreparedPolicyRequestcontaining candidate JSON and ordered before/afterchanges, without creating a container or launching a workload.
chosen JSON through ordinary strict creation. Storage and merge helpers
preserve owned observation values and enforce bounds; the caller owns persistence and retry
limits.
Preparation proves supported capability, network/capture and filesystem
reductions against the current request, preserves unrelated permissions and
workload settings, and rejects unsafe or unsupported changes. Published V1
creation signatures and options remain unchanged. Creation never accepts
observations, modifies a request or retries automatically.
The new Rust preparation options are non-exhaustive and
Clone, notCopy,so later controls can own data. Existing option types and their traits remain
unchanged; callers use
clone()when reusing preparation options.Preparation accepts create-and-run requests on every backend and OS. With a
valid empty observation collection (
results: []), it returns the originalrequest text and no changes after contract, phase and experimental opt-in
checks. It skips backend serviceability and backend-specific policy checks;
the host need not support that backend. This is not validation or approval of
later creation, which remains independent and strict.
Native Windows ProcessContainer is currently the only backend that produces
observations and the only one that applies them. Other backends reject
non-empty observations as unsupported, rather than silently accepting them or
falling back. As with creation, experimental backends require the
experimental opt-in; without it, preparation fails with
BackendUnavailablefor empty and non-empty observations alike. Windows availability is
determined through runtime API and capture-support checks, not an inferred
minimum Windows build.
Observed resources are optional strings (
Option<String>in Rust,stringin.NET and Node). If native resource text is not valid UTF-16, such as text
containing an unpaired surrogate, MXC omits the resource and marks it
unavailable and incomplete, so that detail cannot be prepared. Storage rejects
lone surrogates, and
resourceUnitsis rejected as an unknown field. Code,tests and docs refer to PSEP outcome, detail and flag values, policy HRESULTs
and format versions by named constants. JSON examples keep the numeric values
and annotate them with the matching constant names.
The existing Rust, .NET and Node test suites remain the CI route for applicable
preparation behavior; this change removes the policy-preparation-only reruns.
Linux and macOS are not treated as policy-enforcement coverage: native Windows
ProcessContainer is currently the only backend that reports or applies
non-empty observations. SDK references and backend guidance are updated
alongside the implementation; scheduled capable-host validation remains the
relevant route for native ProcessContainer behavior.
🔗 References
Refs #1634 (
feature-accepted; remains open for validation coordination).Original approved design and API proposal: #1635, merged into
main.This PR updates both specifications to describe the implemented contract:
🔍 Validation
Backend tests exercise restrictive changes and unsafe observations, including
network/capture interactions, filesystem ceilings and unchanged caller inputs.
Preparation tests check that candidates and change reports are owned and that
preparation does not launch a workload. SDK tests cover error transport and
diagnostic inspection, keeping remediation visible while details remain
redacted. They also cover storage/merge bounds, duplicate change values, large
values and text, string resources and compatibility with strict creation.
The Node packaged-runtime scenario installs the shipping SDK and NVX runtime
tarballs into an isolated consumer, with native/runtime overrides cleared. It
also checks native runtime-registration errors and cleanup using the complete
MxcErrorDetaillayout, including the structured-details pointer.Structured wait-error checks exercise polling and blocking waits, preserve
owned details after native cleanup, and reject double-freeing error storage.
Rust checks retain structured data through
io::Errorwhile keeping it outof default debug output.
Every SDK has a no-op preparation test: empty observations return the request
unchanged, while non-empty observations fail as unsupported on backends that
cannot apply them. An engine regression checks that preparation for
experimental backends fails without the experimental opt-in and succeeds as a
no-op with it. A malformed native resource regression checks that invalid
UTF-16 is recorded as unavailable and cannot be prepared. Removing that
handling made the test fail (flags
1instead of5); restoring it made thetest pass.
Injected backend tests use fake PSEC creation and startup attributes while
exercising strict request submission and a fixed child-process fixture.
Filesystem-preservation fixtures resolve temporary-directory aliases before
constructing literal grants; production alias-safety checks remain active.
Public-dispatch refusal tests exercise ordinary and capture-enabled creation
through the real capture factory. They retain owned observations and the
original native status, count one native attempt, and require zero workload
launches and trace starts. Console regressions keep a distinctive policy
resource out of child-process stderr and headless ConPTY output while explicit
SDK serialization retains the details.
Filesystem regressions cover aliases before the satisfied-constraint check,
case/trailing-backslash variants, suppressed authored grants, exact
enumeration/deny overlap, and padded authored capability names. The existing
scheduled Rust scenario checks restricted writes and an unrelated writable
control; it enforces native deny/enumeration cases when the public probe
advertises support and otherwise requires an explicit unsupported result.
Resolution is shared within a call, and the no-access-increase proof checks a
whole batch. An oversized-policy regression verifies rejection before
filesystem probes; budget exhaustion never returns a partial candidate.
Storage regressions cover compact shared Node graphs, aggregate .NET change
values and oversized single tokens. Serialization accounts for cumulative
UTF-8 output before completing an over-limit representation. Boundary tests
include escaping and exact-limit results; both .NET framework targets and
Native AOT retain the source-generated JSON path.
The .NET prepared-filesystem scenario gives its parent directory inheritable
AppContainer write access, then creates an owner-only workspace beneath it.
A positive control first writes through the original request; after caller
acceptance, strict run and spawn must leave the restricted seed unchanged
while still writing to an unrelated permitted directory and preserving the
original working directory. This prevents ambient filesystem grants from
invalidating the read-only assertions.
The prepared-filesystem execution scenario requires the capable-host opt-in
(
MXC_E2E_PSEC_CAPABLE_HOST=1). Native preparation and storage tests launch noworkload and run in the ordinary SDK suite. Scheduled validation requires the
preparation fact and exact native storage rows to pass, while accepting
unrelated architecture-dependent skips in
DevEntryPointTests. EveryMxcProcessTestscase must still execute. Result fixtures check both thepermitted skip and failures for missing or skipped required rows.
Executed local checks and results (Windows)
srccargo fmt --all -- --checksrccargo test -p mxc-sdk --lib error::testssrccargo test -p mxc-sdk --lib policy_preparationsrccargo test -p mxc-sdk --lib policy_restrictionsrccargo test -p mxc-sdk --lib policy_projectionsrccargo test -p mxc-sdk --lib policy_diagnostics_testssrccargo test -p mxc-sdk --lib script_runner::testssrccargo test -p mxc_ffi --lib --features "dotnetsdk test-support"srccargo test -p mxc_ffi --lib policy_preparation_testssrccargo test -p mxc_ffi --lib --features "dotnetsdk test-support" streaming::testssrccargo clippy -p mxc-sdk -p mxc_ffi --all-targets --features "mxc_ffi/dotnetsdk,mxc_ffi/test-support" -- -D warningssdk\nodenpm testsdk\nodenpm run typechecksdk\node\tests\integrationnpm run buildsdk\node\tests\integrationnode --test --test-force-exit --test-name-pattern '^V1\.Dev installs both npm packages and discovers NVX without overrides$' dist\dev.test.jsMXC_SDK_PACKAGE_DIRandMXC_NVX_PACKAGE_DIRsdk\dotnetdotnet build Microsoft.Mxc.Sdk.Tests\Microsoft.Mxc.Sdk.Tests.csproj --no-restore --verbosity minimal -p:MxcPrebuiltNativeDir="$unit" -p:MxcTestPrebuiltNativeLibrary="$native"net8.0andnet10.0, no warningssdk\dotnetdotnet $dll -class Microsoft.Mxc.Sdk.Tests.DevEntryPointTests -result-xml $xml -noLogo -noColor.\scripts\ci\test-policy-preparation-test-results.ps1$unitcontains the frozen native unit and matching generated bindings;$nativeis its debug test-support library.$dllis the newly builtTargetPathfor each framework, resolved in the same MSVC environment and withthe same build properties;
$xmlrecords its xUnit results.The unrelated-skip regression failed before the gate fix and passed afterward.
Windows VM validation ran the same 19 fixtures plus 14 scenarios against the
actual result-check commands extracted from the original and fixed
dispatchers. Input hashes were checked against the host files. These checks
model the ARM64 skip in result XML; they are not an ARM64 backend run.
The packaged-runtime scenario reproduced the native access violation before
the error-layout fix and passed afterward locally and on the Windows VM.
The VM ran the compiled integration helper against the same shipping tarballs
and verified its inputs against the host hashes.
Windows VM checks also execute 42 Rust error cases, 48 Node streaming and
process cases, and all 44 selected .NET public-API cases on .NET 10. They check
the actual compiled inputs and native library hashes and reject skipped cases.
These are error-transport and ownership checks, not governed-refusal proof.
The updated VM run executes 22 Rust preparation cases, 21 restriction cases,
the public-dispatch refusal case with capture off/on, 11 console cases and
4 C API preparation cases. The native filesystem scenario passes all three
contract markers and the case-variant, suppressed-grant and enumeration/deny
enforcement checks. It also reproduces six preparation failures against the
old native library and checks the fixed outcomes through the public Node
binding.
The same payload passes all 30 Node Dev/storage tests, both headless ConPTY
marker checks, all 47 selected .NET tests per framework, and both Native AOT
executables. Every payload input is hash-verified; these cases run without
skips. The supplied-observation and injected-refusal checks do not claim a
new governed Windows policy refusal.
Not run locally: the Linux and macOS CI suites, the full scheduled host suite
and a real governed Windows refusal. The ordinary SDK test suites remain
enabled in GitHub Actions without additional Linux/macOS preparation pins.
Governed-refusal CI provisioning remains separate agreed work. The host opt-in,
unit fixtures and preparation-success checks do not replace that coverage.
✅ Checklist
feature-acceptedCargo.lock, thedependency-feed-checkcheck passes (see pull request builds)The final two conditional items do not apply: no new build/architecture
conventions and no
Cargo.lockchanges.📋 Issue Type
Microsoft Reviewers: Open in CodeFlow