Skip to content

[WSLC] State-aware daemon protocol flattens every backend failure to backend_error, discarding its typed classification #1167

Closed

Description

Relevant area(s)

Windows (WSLc backend)

Brief description of your issue

Split out of #843, where this was defect 4. That issue records it as independent of the exec-streaming defects (1–3) and able to land on its own; this issue tracks it separately so the WSLc work can be scheduled without waiting on the cross-backend executor-framing work.


The daemon protocol flattens every backend failure to backend_error, discarding its typed classification.

Surfaced as a review comment on #1045. #794 gave the WSLc backend a typed WslcError whose variants carry a FailurePhase (Unavailable → BackendUnavailable, Rejected → Rejected, etc.), so the one-shot / streaming surface now reaches the Rust SDK with an accurate code via mxc_engine::dispatch::map_spawn_error. The state-aware surface does not, because the classification is destroyed crossing the daemon's named pipe: sr_err (src/backends/wslc/daemon/src/session_manager.rs:59) reduces the step helper's ScriptResponse to anyhow!(resp.error_message), dropping failure_phase; that becomes WorkerError::Backend → ErrKind::Backend (:82); and map_daemon_error (src/backends/wslc/common/src/state_aware.rs:310) maps ErrKind::Backend to MxcError::backend_error.

Concretely: provisioning on a host with missing WSLc components returns backend_error to state-aware Rust SDK callers, where the one-shot surface returns backend_unavailable. There is no local preflight that could catch it earlier — state_aware.rs has no ensure_host_supported / load_sdk_checked call, and its only backend_unavailable (connect_daemon) covers an unreachable daemon, a different condition. So a caller still has to string-match the message to distinguish an unusable host from a rejected policy.

Fix (moderate; daemon wire change): widen ErrKind with Unavailable and Rejected rather than plumbing FailurePhase through — failure_phase is a ScriptResponse concept that the state-aware boundary does not use, whereas map_daemon_error already maps ErrKind 1:1 onto MxcError codes, so the client side is a new match arm. Requires: a PROTOCOL_VERSION bump, somewhere on WorkerError to carry the classification so sr_err stops discarding it, skew handling for an already-running persistent daemon speaking the old protocol, and a docs/wsl/wslc-state-aware.md update.

Steps to reproduce

  1. On a Windows host without the WSLc components installed, build with --features wslc.
  2. Drive a state-aware provision through the Rust SDK (mxc_sdk::run_state_aware_json) or the FFI (mxc_state_aware).
  3. Observe the returned MxcError code.
  4. Run the equivalent one-shot request against the same host and compare.

Expected behavior

Both surfaces classify the same host condition identically: a host that cannot run WSLc returns backend_unavailable, and a policy the backend refuses returns policy_validation / rejected. A caller can branch on the code without string-matching the message.

Actual behavior

Every daemon-side failure — unusable host, rejected policy, busy container, protocol fault — arrives as backend_error. The state-aware and one-shot surfaces disagree for the same condition.

Additional context

Current source references (verified against main):

Location Role
src/backends/wslc/daemon/src/session_manager.rs:59 sr_err discards failure_phase
src/backends/wslc/daemon/src/session_manager.rs:82 WorkerError::Backend → ErrKind::Backend
src/backends/wslc/common/src/state_aware.rs:310 map_daemon_error collapses Busy | NotReady | Protocol | Backend → backend_error
src/backends/wslc/common/src/daemon_protocol.rs:40 PROTOCOL_VERSION
src/backends/wslc/common/src/daemon_protocol.rs:173 ErrKind variants

Source review comment: #1045 (wslc/common/src/error.rs:6-12). Split from #843.

Activity

  1. added
    Issue-BugSomething is not working as intended.
    OS-WindowsApplies specifically to Windows hosts or Windows behavior.
    Backend-WSLCWindows WSL Container backend behavior or integration.
    Priority2High-impact issue affecting key functionality; prioritize for the next appropriate release.
    on Sep 15, 2026
  2. added
    Priority3Moderate or limited impact; address as capacity permits.
    and removed
    Priority2High-impact issue affecting key functionality; prioritize for the next appropriate release.
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Backend-WSLCWindows WSL Container backend behavior or integration.Issue-BugSomething is not working as intended.OS-WindowsApplies specifically to Windows hosts or Windows behavior.Priority3Moderate or limited impact; address as capacity permits.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions