Repository navigation
[WSLC] (2/2) Preserve structured errors from process waits - #1711
Open
Soham Das (SohamDas2021) wants to merge 3 commits into
Open
Soham Das (SohamDas2021) wants to merge 3 commits into
Soham Das (SohamDas2021) wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The .NET test target runs Rust commands and builds the WSLc daemon even in prebuilt mode, making managed-test CI depend on a Rust toolchain and Cargo feed it does not configure.
5 open issues
Keep prebuilt-native test mode free of Rust build steps · New Isolate SDK fault-injection suites from the release daemon · New Preserve structured errors from exit_event() · New Redact backend details in legacy wait error Debug output · New Correct the wait-path guarantee for backend error details · New
What changed in this PR
Preserves structured process-wait errors across MXC’s Rust, C, .NET, and Node layers, extending the WSLc lifecycle error work from #1671 and #1644.
Changes:
- Adds detailed Rust and C wait APIs and updates managed bindings to retain backend error fields.
- Carries WSLc failure details through daemon responses and caches wait failures without disabling cleanup.
- Adds regression tests, debug-only fault injection, CI requirements, and SDK documentation.
| File | Description |
|---|---|
tests/scripts/run_wslc_state_aware_tests.ps1 |
Checks structured port-collision errors. |
src/mxc-sdk/src/sandbox.rs |
Adds detailed process-wait methods. |
src/mxc-sdk/src/lib.rs |
Uses detailed waits for captured execution. |
src/mxc-sdk/src/core/mxc_engine/error.rs |
Tests preservation of error details. |
src/mxc-sdk/src/core/mxc_common/mxc_error.rs |
Carries structured errors inside I/O errors. |
src/mxc-sdk/src/core/mxc_common/exec_stream.rs |
Preserves cached waiter failures and tests cleanup. |
src/mxc-sdk/src/bin/wslc_daemon/session_manager.rs |
Retains SDK failure details through worker errors. |
src/mxc-sdk/src/bin/wslc_daemon/control_server.rs |
Includes failure details in daemon responses. |
src/mxc-sdk/src/backends/wslc/common/wsl_container_runner.rs |
Produces structured wait errors and injects test failures. |
src/mxc-sdk/src/backends/wslc/common/state_aware.rs |
Maps daemon failure details into backend errors. |
src/mxc-sdk/src/backends/wslc/common/sandbox.rs |
Caches and replays WSLc wait failures. |
src/mxc-sdk/src/backends/wslc/common/image.rs |
Preserves SDK details in image-operation failures. |
src/mxc-sdk/src/backends/wslc/common/error.rs |
Introduces structured WSLc step errors. |
src/mxc-sdk/src/backends/wslc/common/daemon_protocol.rs |
Adds failure fields and advances protocol version. |
src/mxc-sdk/src/backends/wslc/common/daemon_client.rs |
Preserves structured daemon errors. |
src/mxc-sdk/src/backends/wslc/common/container_steps.rs |
Attaches SDK failure metadata and test hooks. |
src/mxc-sdk/README.md |
Documents detailed Rust wait APIs. |
src/ffi/mxc_ffi/src/test_fake_sandbox.rs |
Adds structured wait-failure test doubles. |
src/ffi/mxc_ffi/src/streaming.rs |
Adds C wait functions with error outputs. |
sdk/node/tests/unit/streaming-binding.test.ts |
Tests error decoding and allocation cleanup. |
sdk/node/tests/unit/sandbox-process.test.ts |
Tests shared wait rejection and cleanup. |
sdk/node/tests/integration/wslc-state-aware.test.ts |
Tests lifecycle wait failures and recovery. |
sdk/node/tests/integration/wslc-e2e.test.ts |
Tests create-and-run wait failures and recovery. |
sdk/node/src/bindings/streaming.ts |
Uses detailed native waits and frees errors. |
sdk/node/README.md |
Documents structured wait rejections. |
sdk/dotnet/README.md |
Documents structured wait exceptions. |
sdk/dotnet/Microsoft.Mxc.Sdk/V1/MxcProcess.cs |
Decodes and frees native wait-error details. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcProcessCleanupTests.cs |
Tests structured polling and blocking-wait failures. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcLifecycleWslcE2ETests.cs |
Tests lifecycle wait failures and recovery. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcContainerWslcE2ETests.cs |
Tests create-and-run wait failures and recovery. |
sdk/dotnet/Microsoft.Mxc.Sdk.Tests/Microsoft.Mxc.Sdk.Tests.csproj |
Builds and stages a test-support WSLc daemon. |
scripts/ci/run_backend_validation_tests.ps1 |
Requires eight new WSLc regression scenarios. |
scripts/ci/build-windows-sdk-test-bundle.ps1 |
Stages debug test-support binaries and checks discovery. |
docs/development/architecture/container-lifecycle.md |
Describes structured wait failures and cleanup semantics. |
docs/backends/wslc/wslc-state-aware.md |
Documents WSLc failure fields and protocol changes. |
docs/api-reference/rust/v1/types.md |
Lists detailed wait signatures and semantics. |
docs/api-reference/node/v1/types.md |
Describes process-wait rejection fields. |
docs/api-reference/dotnet/v1/types.md |
Describes process-wait exception fields. |
Review effort: Balanced
| <Target Name="BuildMxcTestSupportNativeLibrary" | ||
| AfterTargets="Build" | ||
| Condition="'$(TargetFramework)' != '' and '$(DesignTimeBuild)' != 'true' and '$(MxcUsePrebuiltTestNativeLibrary)' != 'true'"> | ||
| Condition="'$(TargetFramework)' != '' and '$(DesignTimeBuild)' != 'true'"> |
Comment on lines
+351
to
+355
| 'Node' = { | ||
| Invoke-NodeIntegrationSuite -Bundle $bundle -Name 'wslc' -TestFile 'wslc-state-aware.test.js' ` | ||
| -RequiredTests @('V1.Dev preserves WSLC lifecycle responses, captured exec, pipes, and caller ownership', | ||
| 'captured exec preserves structured post-admission wait failures', | ||
| 'process wait preserves structured post-admission wait failures') |
Comment on lines
1940
to
+1942
| let exit_event = self | ||
| .exit_event() | ||
| .map_err(|e| WslcError::Runtime(e).into_response())?; | ||
| .map_err(|e| WslcError::Runtime(e).into_step_error())?; |
Comment on lines
+179
to
+180
| #[derive(Debug)] | ||
| struct MxcIoError(MxcError); |
Comment on lines
+473
to
+475
| result after admission. The rejection preserves `code`, `message`, | ||
| `operation`, `nativeCode`, `remediation`, and `details`; it is not converted | ||
| into an exit result. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



📖 Description
When a process had started and MXC then failed to get its final result, the error lost its details. For example, when
WslcGetProcessExitCodefailed after a WSLc process exited:backend_errorthat named neither the WSLc call nor its HRESULT, because the C wait functions return only a status code.runandrun_in_containerreportedbackend_errorwith the message prefixed by "waiting for the sandbox to complete failed:", and withoperation,native_code, anddetailsempty. The Rust process wait methods returnstd::io::Error, which carries only the message.These errors now keep their details:
runandrun_in_container, and .NET and Node waits and captured runs, report the backend's code, message, operation, native code, and remediation. In the example:backend_error,WslcGetProcessExitCode failed: HRESULT 0x80004005(prefixed withexec failed:for a process in an existing container),WslcGetProcessExitCode,0x80004005.try_wait_detailed,wait_detailed, andwait_with_output_detailed, returningv1::Errorwith itsdetails.mxc_sandbox_try_wait_with_errorandmxc_sandbox_wait_with_error, which fillMxcErrorDetail.This applies to processes in an existing container on any backend, and to WSLc create-and-run processes. The existing Rust and C wait functions, timeouts, and exit codes are unchanged. Without backend details, Rust
runstill returnsbackend_error, with a reworded message prefix.Debug
test-supportbuilds can force this failure for the live WSLc tests; release builds cannot. The Windows test bundle stages those builds, and nightly WSLc validation requires the eight new tests.No spec is required: the new APIs are additive forms of existing waits that carry existing error fields, and the .NET and Node APIs do not change. Limitation:
detailsdoes not reach .NET or Node.🔗 References
Refs #1644
Stacked on #1671, which fills
operationandnativeCodeon WSLc container lifecycle errors and leaves these process waits as a limitation. This branch is rebased onto currentmainand builds on #1539, which addedv1::Error.detailsand caches exec wait results. Its first commit is #1671's change; until #1671 merges, review the last two commits.🔍 Validation
Run on Windows 11 Enterprise (build 26300, x64) with WSL 3.0.5, on
mainat 9bc16c0. Cargo commands run fromsrc.cargo fmt --all -- --check: passed.cargo clippy --workspace --all-targets -- -D warnings: passed.cargo clippy -p mxc-sdk --all-targets --features wslc,test-support -- -D warnings: passed.cargo clippy -p mxc_ffi --all-targets --features isolation_session,wslc,test-support -- -D warnings: passed.cargo test -p mxc-sdk --lib --features wslc,test-support: 2,970 passed, 8 ignored.cargo test -p mxc-sdk --bin wxc-wslc-daemon --features wslc,test-support: 176 passed, 13 ignored.cargo test -p mxc_ffi --features isolation_session,wslc,test-support: 94 passed, 4 ignored.node scripts\check-dotnet-bindings-codegen.js: passed; all 43 required entry points generated.sdk\node, with Node 26.13.0:npm run typecheckpassed, including the integration tests, andnpm testpassed 456 and skipped 22.git diff --checkpassed.Live WSLc, with
MXC_ENABLE_WSLC_TESTS=1and debugtest-supportbuilds fromcargo build -p mxc_ffi --features isolation_session,wslc,test-support --target x86_64-pc-windows-msvcandcargo build -p mxc-sdk --bin wxc-wslc-daemon --features wslc,test-support --target x86_64-pc-windows-msvc:sdk\node\tests\integration, withMXC_FFI_DIRnaming a directory that holds those builds andwslcsdk.dll:node --test --test-force-exit --test-reporter=spec --test-reporter-destination=stdout dist/wslc-e2e.test.jspassed 11 of 11, and the same command withdist/wslc-state-aware.test.jspassed 4 of 4. None were skipped.global.json:dotnet build sdk\dotnet\Microsoft.Mxc.Sdk.Tests\Microsoft.Mxc.Sdk.Tests.csproj -c Debug -p:TargetFrameworks=net8.0 -p:TargetFramework=net8.0 -p:MxcWithWslc=true -p:MxcTestPrebuiltNativeLibrary=<mxc_ffi.dll>.Microsoft.Mxc.Sdk.Tests.exe -class *.MxcLifecycleWslcE2ETests -class *.MxcContainerWslcE2ETests -class *.MxcProcessCleanupTestspassed 30 of 30, none skipped, including the four new live tests and the two new wait-failure tests.Not run:
dotnet testfor net10.0 and the Windows SDK test bundle build, which need .NET SDK 10.tests\scripts\run_wslc_all_tests.ps1.✅ Checklist
feature-acceptedCargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 Issue Type
Microsoft Reviewers: Open in CodeFlow