[WSLC] Harden state-aware daemon (PR 2a/3): typed errors, validate-then-admit exec, idle-watchdog - #767
Open
Soham Das (SohamDas2021) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Soham Das (SohamDas2021)
changed the base branch from
main
to
user/sodas/wslc-state-aware-daemon
August 7, 2026 00:38
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens the internal WSLC state-aware daemon’s error handling, exec admission, and idle shutdown behavior.
Changes:
- Adds typed worker errors and protocol mappings.
- Adds pre-admission exec validation.
- Tracks connection activity and deduplicates SDK error handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/backends/wslc/daemon/src/session_manager.rs |
Adds typed errors and exec validation commands. |
src/backends/wslc/daemon/src/main.rs |
Hardens idle-watchdog activity tracking. |
src/backends/wslc/daemon/src/control_server.rs |
Returns typed errors and validates exec admission. |
src/backends/wslc/common/src/wsl_container_runner.rs |
Reuses the shared SDK error helper. |
Comment on lines
268
to
272
| if let Err(e) = session.validate_exec(config.sandbox_id.clone()).await { | ||
| write_frame(&mut pipe, &worker_err_response(e)).await?; | ||
| return Ok(()); | ||
| } | ||
| write_frame(&mut pipe, &DaemonResponse::Ok).await?; |
Soham Das (SohamDas2021)
force-pushed
the
user/sodas/wslc-daemon-hardening
branch
from
August 7, 2026 03:21
2336f9a to
884d80b
Compare
Soham Das (SohamDas2021)
marked this pull request as ready for review
August 7, 2026 03:21
|
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.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/backends/wslc/daemon/src/control_server.rs:306
- This does put
ErrKindon the wire, but the repository'sDaemonClientimmediately convertsDaemonResponse::Err { kind, message }intoanyhow!("daemon error [{kind:?}]: ...")(common/src/daemon_client.rs:297-300). Consequently actual client callers still cannot distinguishNotProvisioned/NotStartedwithout parsing the error string, contrary to this PR's typed-error goal. PreserveErrKindin a concrete client error type (or a typed result) so callers can inspect it directly.
fn worker_err_response(e: WorkerError) -> DaemonResponse {
DaemonResponse::Err {
kind: e.kind(),
message: e.to_string(),
src/backends/wslc/daemon/src/session_manager.rs:370
- The added admission tests cover only the
Nonebranch; no test exercises this newNotStartedclassification, even though distinguishing an unstarted sandbox is one of the core behaviors introduced here. Add an exec-before-start assertion (for example in the WSL-host lifecycle test), or factor the lifecycle state from the SDK handle so this branch can be unit-tested without WSL.
Some(entry) if !entry.started => Err(WorkerError::NotStarted(sandbox_id.to_string())),
Comment on lines
+159
to
+161
| let active = active_clients.load(Ordering::SeqCst); | ||
| let generation = activity.load(Ordering::SeqCst); | ||
| let idle = count == 0 && active == 0 && generation == last_activity; |
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.
Summary
PR 1/3 of the WSLc state-aware split landed the per-user daemon + owner-only named-pipe IPC. This PR (call it 2a/3) hardens the daemon internals with no public wire or schema surface, so it lands independently.
Four changes:
WorkerError{NotProvisioned, NotStarted, Backend}with akind() -> ErrKindmapping instead of collapsing every worker failure toErrKind::Backend. The control server returns the real classification, so clients can distinguish an unknown/not-started sandbox from a backend fault without string-matching.Displaypreserves the existing"unknown sandbox"message.ValidateExecworker command validates the sandbox exists and is started before theOkadmission is written, so an unknown/not-started sandbox comes back as a pre-admission typedErrrather than a post-admission streamErrorframe.activitycounter bumped on each accepted connection; the watchdog declares idle only when the container count is zero, no request is in flight, and the activity generation is unchanged since the last poll (generation read last, so a connect that starts and finishes between two polls is not missed).container_steps::sdk_errorinstead of a byte-identical private copy.Testing
kind+validate_execassertions) and the#[ignore]d WSL2-host lifecycle tests (in-proc and over the pipe): provision → start → exec → exec → stop → deprovision.wslc_commonsuite; fullrun_wslc_all_tests.ps1corpus 24/24.cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkclean.Coming in the pipeline
wslc/common/state_aware.rs(StatefulSandboxBackend, prefixwslc) translating the publicexperimental.wslc.*wire schema into daemon protocol frames;mxc_enginestate-aware arm + config-parser wiring; regenerated dev schema + generated TS wire types; multi-invocation E2E script with warm-reuse + idle-teardown assertions.Wslc*Config/*Resulttypes + brandedSandboxId<'wslc'>and helper prefix wiring, mirroring the LXC state-aware SDK surface.🔗 References
🔍 Validation
✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see docs/pull-requests.md)📋 Issue Type
GitHub Actions runs the PR validation build automatically. The ADO pipeline
(
MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHubActions build; it runs on merge to
main, and Microsoft reviewers with write access can trigger iton a PR with
/azp run. See docs/pull-requests.md.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See docs/pull-requests.md
for the steps.
Microsoft Reviewers: Open in CodeFlow