Enforce target-aware working directories - #1253
Gudge (MGudgin) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
2515905 to
3bc3eed
Compare
There was a problem hiding this comment.
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
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.
There was a problem hiding this comment.
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
3bc3eed to
cef27b9
Compare
There was a problem hiding this comment.
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
Open (1)
cef27b9 to
91f29d0
Compare
There was a problem hiding this comment.
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
Resolved since last review (1)
91f29d0 to
18a3050
Compare
There was a problem hiding this comment.
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)
18a3050 to
a39273e
Compare
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
a39273e to
13aa8b2
Compare
| 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. |



📖 Description
This PR fixes
process.cwdvalidation 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
normalized execution request.
depending on the compilation host.
success, or state-aware backend dispatch.
failures.
documentation.
E2E coverage.
Tests
cargo fmt --all -- --checkwxc_common,wslc_common,mxc_engine,process_container_common,windows_sandbox_lifecycle,mxc_config_contract, andnanvix_runnercargo clippy --workspace --all-targets -- -D warningsMicrosoft Reviewers: Open in CodeFlow