Skip to content

Enforce target-aware working directories - #1253

Open
Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/process_cwd_fix
Open

Gudge (MGudgin) wants to merge 1 commit into
mainfrom
user/gudge/process_cwd_fix

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Sep 23, 2026

Copy link
Copy Markdown
Member

📖 Description

This PR fixes process.cwd validation across MXC execution surfaces.

Current JSON contracts and typed SDK requests now require a path that is
absolute for the target backend and lifecycle surface. Released v0.6-v0.8
relative-path compatibility is preserved for ordinary backends, while WSLc
continues to reject any explicit value it cannot map faithfully.

Resolves #902

Details

  • Carries cwd compatibility semantics from exact contract adapters into the
    normalized execution request.
  • Validates Windows, POSIX, and WSLc one-shot/state-aware path forms without
    depending on the compilation host.
  • Rejects invalid cwd before backend selection, host DACL changes, dry-run
    success, or state-aware backend dispatch.
  • Separates strict WSLc cwd mapping from legacy filesystem-mount mapping.
  • Preserves stable public error classifications for policy and availability
    failures.
  • Updates canonical, backend, generated-contract, and Rust/Node/.NET SDK
    documentation.
  • Adds adapter, normalization, validator, dispatcher, backend, regression, and
    E2E coverage.

Tests

  • cargo fmt --all -- --check
  • Focused tests for wxc_common, wslc_common, mxc_engine,
    process_container_common, windows_sandbox_lifecycle,
    mxc_config_contract, and nanvix_runner
  • cargo clippy --workspace --all-targets -- -D warnings
  • Node SDK build and unit tests
  • .NET SDK build
  • Exact-contract codegen drift check
  • Working-directory E2E tests
  • Issue [Cross-backend] process.cwd is silently discarded or resolved against host state #902 regression for strict rejection and v0.8 compatibility
  • Three-round iterative adversarial review converged with all findings closed
Microsoft Reviewers: Open in CodeFlow

@MGudgin
Gudge (MGudgin) requested review from a team and a balanced review from Copilot September 23, 2026 22:06
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner September 23, 2026 22:06
@azure-pipelines

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

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Copilot-Instructions PR modifies Copilot instruction files (.github/copilot-instructions.md or .github/instructions/) label Sep 23, 2026
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from 2515905 to 3bc3eed Compare September 23, 2026 22:13

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.

Copilot review overview

🟡 Changes recommended

Legacy WSLc preflight and executor-backed Node typed requests do not consistently enforce the intended strict semantics.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

This PR introduces target-aware process.cwd validation across contracts, backends, execution surfaces, and SDKs.

Changes:

  • Adds version- and backend-aware working-directory validation.
  • Preserves legacy contract compatibility while hardening WSLc mapping.
  • Updates SDKs, diagnostics, documentation, and regression coverage.
File Description
tests/​regression_tests/​test_cases/​Invoke-Issue902-RelativeWorkingDirectory.ps1 Tests strict and v0.8 behavior.
src/​testing/​wxc_e2e_tests/​tests/​e2e_working_directory.rs Adds cross-platform cwd E2E tests.
src/​core/​wxc_common/​src/​working_directory.rs Implements target-aware validation.
src/​core/​wxc_common/​src/​validator.rs Integrates one-shot and exec validation.
src/​core/​wxc_common/​src/​state_aware_dispatch.rs Tests pre-dispatch rejection.
src/​core/​wxc_common/​src/​script_runner.rs Preserves public error classifications.
src/​core/​wxc_common/​src/​policy_identity.rs Excludes compatibility metadata from identity.
src/​core/​wxc_common/​src/​models.rs Adds cwd compatibility and style models.
src/​core/​wxc_common/​src/​lib.rs Exports shared path helpers.
src/​core/​wxc_common/​src/​config_parser.rs Validates cwd during normalization.
src/​core/​wxc_common/​src/​config_deserialize.rs Exposes diagnostic escaping.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_9/​state_aware.rs Selects strict state-aware semantics.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_9/​state_aware_tests/​common.rs Tests strict adapter output.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_9/​one_shot.rs Selects strict one-shot semantics.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_9/​one_shot_tests/​common.rs Tests strict adapter output.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_8.rs Selects legacy cwd compatibility.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_7.rs Selects legacy cwd compatibility.
src/​core/​wxc_common/​src/​config_contract_adapters/​v0_6.rs Selects legacy cwd compatibility.
src/​core/​wxc_common/​src/​config_contract_adapters/​dev/​state_aware.rs Selects strict development semantics.
src/​core/​wxc_common/​src/​config_contract_adapters/​dev/​state_aware_tests/​common.rs Tests development adapter output.
src/​core/​wxc_common/​src/​config_contract_adapters/​dev/​one_shot.rs Selects strict development semantics.
src/​core/​wxc_common/​src/​config_contract_adapters/​dev/​one_shot_tests/​common.rs Tests development adapter output.
src/​core/​wxc_common/​src/​common_request_ir.rs Carries cwd compatibility metadata.
src/​core/​mxc-sdk/​README.md Documents Rust SDK cwd rules.
src/​core/​mxc_engine/​src/​run.rs Validates before runner resolution.
src/​core/​mxc_engine/​src/​policy/​exact/​mod.rs Makes typed requests strict.
src/​core/​mxc_engine/​src/​policy.rs Documents and tests typed requests.
src/​core/​mxc_engine/​src/​dispatch.rs Validates streaming requests early.
src/​core/​mxc_config_contract/​src/​dev/​stable.rs Documents development contract semantics.
src/​backends/​wslc/​common/​src/​wsl_container_runner.rs Rejects or maps one-shot cwd.
src/​backends/​wslc/​common/​src/​policy_mapping.rs Separates strict cwd mapping.
src/​backends/​windows_sandbox/​lifecycle/​src/​error.rs Corrects unavailable-backend classification.
src/​backends/​seatbelt/​common/​src/​seatbelt_runner.rs Preserves legacy relative behavior.
src/​backends/​nanvix/​runner/​src/​lib.rs Corrects test containment context.
sdk/​node/​tests/​integration/​wslc-e2e.test.ts Verifies WSLc cwd mapping.
sdk/​node/​tests/​integration/​common.test.ts Tests buffered Node rejection.
sdk/​node/​src/​types.ts Documents Node cwd requirements.
sdk/​node/​src/​sandbox.ts Updates Node API documentation.
sdk/​node/​src/​generated/​v0_10_0_alpha/​wire.ts Regenerates wire documentation.
sdk/​node/​README.md Documents Node compatibility rules.
sdk/​dotnet/​README.md Documents .NET cwd rules.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​StateAwareTypes.cs Documents state-aware cwd forms.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​SandboxRequest.cs Documents one-shot cwd forms.
schemas/​dev/​mxc-config.schema.0.10.0-alpha.json Updates generated schema description.
docs/​wsl/​wsl-container-getting-started.md Documents WSLc path mapping.
docs/​windows-sandbox/​windows-sandbox.md Documents Windows Sandbox cwd rules.
docs/​state-aware-lifecycle/​mxc-state-aware-sandbox-api.md Documents pre-dispatch validation.
docs/​seatbelt/​seatbelt-backend.md Documents Seatbelt compatibility.
docs/​schema.md Defines canonical cwd semantics.
docs/​lxc-support/​lxc-backend.md Documents LXC cwd behavior.
docs/​isolation-session/​state-aware-rust.md Documents IsolationSession exec rules.
docs/​isolation-session/​oneshot.md Documents IsolationSession one-shot rules.
docs/​bwrap-support/​bubblewrap-backend.md Documents Bubblewrap cwd behavior.
.github/​copilot-instructions.md Adds repository cwd invariants.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/node/tests/integration/common.test.ts
Comment thread src/core/wxc_common/src/working_directory.rs Outdated
Comment thread src/core/wxc_common/src/models.rs Outdated
Copilot AI review requested due to automatic review settings September 23, 2026 22:13

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.

Copilot review overview

🟡 Changes recommended

Legacy WSLc requests bypass pre-selection validation, and unresolved state-aware targets can receive incorrect error classifications.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 Medium severity · 1 Low severity

Open (4)

Comment thread src/core/wxc_common/src/config_parser.rs
Copilot AI review requested due to automatic review settings September 23, 2026 22:46
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from 3bc3eed to cef27b9 Compare September 23, 2026 22:46

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.

Copilot review overview

🟡 Changes recommended

The IsolationSession one-shot documentation describes a broader Windows path form than the validator accepts.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (4)

Comment thread docs/isolation-session/oneshot.md Outdated
Copilot AI review requested due to automatic review settings September 23, 2026 23:24
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from cef27b9 to 91f29d0 Compare September 23, 2026 23: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.

Copilot review overview

🟡 Changes recommended

WSLc parent-directory components are mapped with POSIX rather than rooted Windows semantics, potentially selecting the wrong container directory.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread src/backends/wslc/common/src/policy_mapping.rs Outdated
Copilot AI review requested due to automatic review settings September 23, 2026 23:32
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from 91f29d0 to 18a3050 Compare September 23, 2026 23:32

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.

Copilot review overview

🔵 Needs a closer look

Cross-platform path semantics, compatibility behavior, generated contracts, and multiple SDK surfaces warrant final human validation.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Comment thread docs/schema.md Outdated
Copilot AI review requested due to automatic review settings September 23, 2026 23:51
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from 18a3050 to a39273e Compare September 23, 2026 23:51
Comment thread docs/schema.md Outdated

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.

🕐

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Issue needs attention from issue or PR author label Sep 23, 2026

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.

Copilot review overview

🟡 Changes recommended

The Bubblewrap guide and canonical schema documentation give contradictory omitted-cwd behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Comment thread docs/bwrap-support/bubblewrap-backend.md
@jsidewhite

Copy link
Copy Markdown
Member

mapping and its table-driven tests.

nit: prefer to keep this file hand-authored (though it, admittedly, was not hand authored)


Refers to: .github/copilot-instructions.md:78 in a39273e. [](commit_id = a39273e, deletion_comment = False)

This PR fixes #902 by validating process.cwd against the resolved backend and
lifecycle surface, preserving released compatibility where intended, and
rejecting values that cannot be represented faithfully.

Details

* Carry cwd compatibility semantics from exact contract adapters.
* Require target-absolute paths for current JSON and typed SDK requests.
* Unify WSLc one-shot and state-aware exec on in-container POSIX paths.
* Keep Windows host-path mapping limited to WSLc filesystem grants.
* Validate before backend selection or host policy changes.
* Map one-shot policy and availability errors to stable public error codes.
* Correct Bubblewrap's documented omitted-cwd behavior.
* Document backend conventions and public Rust, Node, and .NET SDK behavior.
* Add regression, E2E, backend-style, and generated-contract coverage.

Tests

* `cargo fmt --all -- --check`
* `cargo check --workspace --all-targets`
* Full `wxc_common` and `wslc_common` unit suites
* Targeted Clippy for `wxc_common` and `wslc_common` with warnings denied
* Node SDK build, unit tests, and changed WSLC E2E type-check
* .NET SDK tests: 323 passed, 27 host-dependent tests skipped
* Exact-contract codegen drift and repository config validation
* Working-directory E2E tests and the #902 regression

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 65717fe2-44ac-4aa4-9629-24ae8c7d1f5e
Generated-with: gpt-5.6-sol
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/process_cwd_fix branch from a39273e to 13aa8b2 Compare September 24, 2026 00:17
Copilot AI review requested due to automatic review settings September 24, 2026 00:17
@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Attention Issue needs attention from Microsoft and removed Needs-Author-Feedback Issue needs attention from issue or PR author labels Sep 24, 2026

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.

Copilot review overview

🔵 Needs a closer look

The cross-platform parser, engine, backend, and SDK changes require final human validation despite extensive coverage.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment on lines +460 to +463
Relative, Windows, whitespace-padded, and interior-NUL cwd values are rejected
before WSLC startup rather than being silently ignored. If `process.cwd` is
omitted, the workload starts at the container root (`/`). WSLc applies this
strict rule in every contract version.

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

Copilot-Instructions PR modifies Copilot instruction files (.github/copilot-instructions.md or .github/instructions/) Needs-Attention Issue needs attention from Microsoft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cross-backend] process.cwd is silently discarded or resolved against host state

3 participants