Skip to content

Add caller-owned policy preparation - #1718

Open
Ross Nichols (rossnichols) wants to merge 22 commits into
mainfrom
user/rnichols/caller-owned-policy-feedback
Open

Ross Nichols (rossnichols) wants to merge 22 commits into
mainfrom
user/rnichols/caller-owned-policy-feedback

Conversation

@rossnichols

@rossnichols Ross Nichols (rossnichols) commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📖 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:

  • Strict creation returns owned, structured policy observations when Windows
    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.
  • Additive V1.Dev preparation accepts complete MXC request JSON, required
    PolicyFailures and separate PolicyPreparationOptions. It returns a
    PreparedPolicyRequest containing candidate JSON and ordered before/after
    changes, without creating a container or launching a workload.
  • The caller can inspect, reject, edit or accept the candidate, then submit its
    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, not Copy,
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 original
request 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 BackendUnavailable
for 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, string in
.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 resourceUnits is 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
MxcErrorDetail layout, 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::Error while keeping it out
of 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 1 instead of 5); restoring it made the
test 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 no
workload 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. Every
MxcProcessTests case must still execute. Result fixtures check both the
permitted skip and failures for missing or skipped required rows.

Executed local checks and results (Windows)
Working directory Command Result
src cargo fmt --all -- --check Passed
src cargo test -p mxc-sdk --lib error::tests 42 passed, 0 skipped or failed
src cargo test -p mxc-sdk --lib policy_preparation 22 passed, 0 skipped or failed
src cargo test -p mxc-sdk --lib policy_restriction 21 passed, 0 skipped or failed
src cargo test -p mxc-sdk --lib policy_projection 1 passed, 0 skipped or failed
src cargo test -p mxc-sdk --lib policy_diagnostics_tests 22 passed, 0 skipped or failed; includes public dispatch with capture off/on
src cargo test -p mxc-sdk --lib script_runner::tests 11 passed, 0 skipped or failed
src cargo test -p mxc_ffi --lib --features "dotnetsdk test-support" 90 passed, 3 ignored, 0 failed
src cargo test -p mxc_ffi --lib policy_preparation_tests 4 passed, 0 skipped or failed
src cargo test -p mxc_ffi --lib --features "dotnetsdk test-support" streaming::tests 20 passed, 3 real-host cases ignored, 0 failed; includes the detailed-wait exports
src cargo clippy -p mxc-sdk -p mxc_ffi --all-targets --features "mxc_ffi/dotnetsdk,mxc_ffi/test-support" -- -D warnings Passed
sdk\node npm test 488 passed, 23 host-dependent skips, 0 failed; selected the frozen rebuilt native library
sdk\node npm run typecheck Passed, including the isolated packed-SDK integration build
sdk\node\tests\integration npm run build Passed
sdk\node\tests\integration node --test --test-force-exit --test-name-pattern '^V1\.Dev installs both npm packages and discovers NVX without overrides$' dist\dev.test.js 1 passed, 0 skipped; selected shipping SDK/NVX tarballs with MXC_SDK_PACKAGE_DIR and MXC_NVX_PACKAGE_DIR
sdk\dotnet dotnet build Microsoft.Mxc.Sdk.Tests\Microsoft.Mxc.Sdk.Tests.csproj --no-restore --verbosity minimal -p:MxcPrebuiltNativeDir="$unit" -p:MxcTestPrebuiltNativeLibrary="$native" Passed for net8.0 and net10.0, no warnings
sdk\dotnet dotnet $dll -class Microsoft.Mxc.Sdk.Tests.DevEntryPointTests -result-xml $xml -noLogo -noColor 47 passed per framework, 0 skipped or failed
Repository root .\scripts\ci\test-policy-preparation-test-results.ps1 19 cases passed in PowerShell 7 and Windows PowerShell 5.1

$unit contains the frozen native unit and matching generated bindings;
$native is its debug test-support library. $dll is the newly built
TargetPath for each framework, resolved in the same MSVC environment and with
the same build properties; $xml records 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

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

The final two conditional items do not apply: no new build/architecture
conventions and no Cargo.lock changes.

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

@rossnichols
Ross Nichols (rossnichols) requested a review from a team November 10, 2026 01:37
@rossnichols
Ross Nichols (rossnichols) requested a review from a team as a code owner November 10, 2026 01:37
Copilot AI balanced review requested due to automatic review settings November 10, 2026 01:37
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Copilot AI balanced review requested due to automatic review settings November 10, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI balanced review requested due to automatic review settings November 10, 2026 17:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread sdk/node/src/v1/errors.ts Resolved
Copilot AI max review requested due to automatic review settings November 10, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI max review requested due to automatic review settings November 10, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI max review requested due to automatic review settings November 12, 2026 22:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Restoring stored before and after values silently collapses duplicate object keys, causing recorded change data to be lost when reports are saved.

1 open issue

Review effort: Max

Comment thread src/mxc-sdk/src/dev.rs Resolved
Copilot AI max review requested due to automatic review settings November 12, 2026 23:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The preparation gate rejects unrelated x64-only test skips, causing scheduled ARM64 ProcessContainer validation to fail even when all required preparation tests pass.

1 open issue

Review effort: Max

Allow unrelated architecture skips without relaxing preparation checks.
Keep Rust README usage in the canonical API guide.

Co-authored-by: Copilot <[email protected]>
Copilot AI max review requested due to automatic review settings November 18, 2026 20:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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]>
Copilot AI max review requested due to automatic review settings November 18, 2026 21:20
@rossnichols

Copy link
Copy Markdown
Contributor Author

🤖 Follow-up to Copilot's review: dd0fb78 removes the duplicate Dev cross-references introduced during the merge and adds a warning to the .NET MxcException.Details reference to filter sensitive backend values before logging or serialization. Existing cross-references and supported API behavior remain intact. Documentation checks passed; no runtime code changed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI max review requested due to automatic review settings November 18, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Native Windows policy-result capture and restrictive enforcement require maintainer validation because a real governed refusal and the full capable-host suite remain untested.

No open issues 🎉

Review effort: Max

Copilot AI max review requested due to automatic review settings November 18, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Deriving Copy for the extensible PolicyPreparationOptions type makes adding owned fields later a breaking API change, so Copy should be removed before publication.

1 open issue

Review effort: Max

Comment thread src/mxc-sdk/src/dev.rs Resolved

@MGudgin Gudge (MGudgin) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Nov 19, 2026
Preserve console privacy and filesystem ceilings; bound SDK serialization.

Co-authored-by: Copilot <[email protected]>
Copilot AI max review requested due to automatic review settings November 19, 2026 01:52
@rossnichols

Ross Nichols (rossnichols) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 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 spawn_json regression injects the native refusal through normal dispatch with capture off and on. The capture-enabled branch uses the real capture factory. Both preserve the original error category, operation and HRESULT, retain owned observations after native cleanup, and assert one creation attempt, zero workload launches, zero trace starts and cleanup of the failed handle and diagnostic buffer. These cases passed on the Windows VM.

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 resourceUnits; expose resource as a string. Invalid UTF-16 therefore becomes an unavailable, incomplete resource and cannot authorize preparation. This intentionally does not preserve the original invalid code units or their distinct diagnostic identity; the feature/API specifications, references and tests describe that representation rather than claiming native-unit fidelity.

For 12, the confirmed direction is to retain cross-backend empty-observation pass-through. A valid results: [] returns the original request text and no changes after request-contract, create-and-run phase and experimental authorization checks, without checking backend serviceability or backend-specific policy. It is not approval or a prediction that creation will succeed; ordinary creation remains strict. 27c4142d aligns both specifications with that decision and the other implemented boundaries. No review vote or approval state has been changed.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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]>
Copilot AI max review requested due to automatic review settings November 19, 2026 03:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved empty-observation semantics and missing real governed-Windows refusal validation require maintainer design review and capable-host testing.

No open issues 🎉

Review effort: Max

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Attention Requires attention or a decision from the MXC maintainers. Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProcessContainer: structured policy diagnostics and caller-owned preparation

4 participants