Repository navigation
[WSLC] (4/4) Expose explicit session lifecycle - #1512
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
ece05e7 to
9df17ae
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Windows VM ownership, shared-session capabilities, and store isolation warrant human review of the reported integration results.
0 open findings
What changed in this PR
Completes the WSLc session lifecycle stack for #1460, exposing explicit VM creation, sharing, and release through development request JSON, the engine, and CLI. Published contracts and SDK V1 remain unchanged.
Changes:
- Adds session operations, sizing, placement, and CLI identity routing.
- Separates session telemetry correlation and improves cold-store diagnostics.
- Adds contract and lifecycle tests, generated artifacts, and documentation.
| File | Description |
|---|---|
| tests/scripts/run_wslc_state_aware_tests.ps1 | Tests shared sessions, independent lifetimes, and cold-store refusal. |
| tests/scripts/run_wslc_all_tests.ps1 | Warms three daemon stores. |
| tests/scripts/README.md | Documents expanded test prerequisites. |
| tests/configs/wslc_state_aware_provision_session.json | Adds session creation fixture. |
| tests/configs/wslc_state_aware_provision_in_session.json | Adds named-session placement fixture. |
| tests/configs/wslc_state_aware_deprovision_session.json | Adds session release fixture. |
| src/tools/wxc/src/main.rs | Exposes session operations and identity flags. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_provision/valid/named_session.json | Covers valid session placement. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_provision_session/valid/sized.json | Covers explicit VM sizing. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_provision_session/valid/minimal.json | Covers default session creation. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_provision_session/invalid/foreign_session_id.json | Rejects identity on session creation. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_provision_session/invalid/foreign_sandbox_provision.json | Rejects sandbox configuration on session creation. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_deprovision_session/valid/minimal.json | Covers valid session release. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_deprovision_session/invalid/missing_session_id.json | Requires release identity. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures/wslc_deprovision_session/invalid/foreign_sandbox_id.json | Rejects sandbox identity for session release. |
| src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures.rs | Registers and tests session fixtures. |
| src/mxc-sdk/src/state_aware_sdk.rs | Preserves implicit placement for SDK V1. |
| src/mxc-sdk/src/core/mxc_engine/state_aware.rs | Updates correlation and session validation tests. |
| src/mxc-sdk/src/core/mxc_contract/registry.rs | Registers development session request roots. |
| src/mxc-sdk/src/core/mxc_contract/dev/state_aware/provision/wslc.rs | Adds optional session placement. |
| src/mxc-sdk/src/core/mxc_contract/dev/state_aware/provision_session.rs | Defines session creation requests. |
| src/mxc-sdk/src/core/mxc_contract/dev/state_aware/phase.rs | Recognizes session phase names. |
| src/mxc-sdk/src/core/mxc_contract/dev/state_aware/mod.rs | Exports session contract types. |
| src/mxc-sdk/src/core/mxc_contract/dev/state_aware/deprovision_session.rs | Defines session release requests. |
| src/mxc-sdk/src/core/mxc_contract/dev/schema.rs | Generates session schema branches. |
| src/mxc-sdk/src/core/mxc_contract/dev/request.rs | Parses WSLc session requests. |
| src/mxc-sdk/src/core/mxc_contract/dev/mod.rs | Exports development session types. |
| src/mxc-sdk/src/core/mxc_common/telemetry/correlation_state.rs | Keeps session operations outside sandbox correlation storage. |
| src/mxc-sdk/src/core/mxc_common/state_aware_dispatch.rs | Uses valid session IDs in tests. |
| src/mxc-sdk/src/core/mxc_common/state_aware_binding_tests.rs | Updates session binding test identities. |
| src/mxc-sdk/src/core/mxc_common/splice.rs | Updates session routing test identity. |
| src/mxc-sdk/src/core/mxc_common/sdk_input.rs | Restricts named sessions to the development contract. |
| src/mxc-sdk/src/core/mxc_common/policy_identity.rs | Records named placement without session values. |
| src/mxc-sdk/src/core/mxc_common/models.rs | Carries optional placement identity. |
| src/mxc-sdk/src/core/mxc_common/config_parser.rs | Parses session roots and validates CLI target flags. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/v1_0/state_aware.rs | Preserves published-contract implicit placement. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/v0_9/state_aware.rs | Preserves older-contract implicit placement. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/state_aware.rs | Adapts session sizing and identities. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/state_aware_tests/session.rs | Tests session adaptation and field presence. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/state_aware_tests/mod.rs | Includes session adapter tests. |
| src/mxc-sdk/src/core/mxc_common/config_contract_adapters/dev/mod.rs | Routes session request adaptation. |
| src/mxc-sdk/src/backends/wslc/common/state_aware.rs | Implements session operations and validation. |
| src/mxc-sdk/src/backends/wslc/common/image.rs | Explains selected cold-store failures and recovery. |
| src/mxc-sdk/src/backends/wslc/common/daemon_client.rs | Adds session lifecycle client calls. |
| sdk/node/src/generated/v1_1_0_alpha/wire.ts | Regenerates development session types. |
| scripts/versioning/check-schema-versions.js | Checks required session request roots. |
| schemas/schema-version.json | Updates the WSLc compatibility selector. |
| schemas/dev/mxc-config.schema.1.1.0-alpha.json | Adds generated session schemas. |
| docs/telemetry.md | Links lifecycle correlation documentation. |
| docs/schema.md | Documents session requests and identity routing. |
| docs/development/build-and-test/schema-codegen.md | Updates request-root generation documentation. |
| docs/development/architecture/versioning.md | Explains development-only session availability. |
| docs/development/architecture/telemetry.md | Documents internal correlation and session separation. |
| docs/development/architecture/container-lifecycle.md | Documents session CLI transport. |
| docs/backends/wslc/wslc-state-aware.md | Explains session behavior, testing, and limitations. |
| docs/backends/wslc/wsl-container-getting-started.md | Adds session sizing and placement examples. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9df17ae to
354d88c
Compare
354d88c to
28edaee
Compare
28edaee to
a995390
Compare
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
Summary
Changes requested: Use one session-ID format rule and consistent error classification for joining versus releasing a session; assert in the live session suite that requested CPU/memory sizing reaches the VM; update the self-contained development policy and raw Rust/FFI entry-point documentation for the new exact request roots; fix the copy-paste-invalid --session-id example. The first two have inline comments below; the out-of-diff documentation gaps are detailed here. These are attributable to this fourth PR, not inherited #1489/#1503 findings.
Verified clean, with receipts: The PR head is a995390 and its base is 0565dd1; my captured 56-file stack diff matches gh pr diff 1512 after newline normalization. The development-contract target cargo test --quiet -p mxc-sdk --features wslc --test mxc_contract_v1_1_0_alpha passed 371/371 locally. New exact request roots are closed and versioned; the stable-contract files remain outside this diff. Session phases seed their own correlation vector before touching the sandbox store. The PR description reports 122/122 live WSL2 tests, which I did not independently rerun.
Findings outside the diff (newly exposed by this PR)
- Medium (documentation) — development policy has no session shapes.
docs/containment-policy/dev/policy.md:167-180—newly_exposed_by_change: the file is byte-identical across this PR, still listing only five sandbox phases and omitting named placement. The changed exact contract atsrc/mxc-sdk/src/core/mxc_contract/dev/request.rs:153-162now acceptsprovision-session,deprovision-session, andwslc.provision.sessionId. Update the self-contained development-policy reference with fields, routing, results, and examples. - Medium (documentation) — raw Rust/FFI API entry points omit supported session phases.
src/mxc-sdk/src/lib.rs:419-424andsrc/ffi/mxc_ffi/src/{lib.rs,state_aware.rs}—newly_exposed_by_change: those three descriptions are byte-identical across this PR and still list only provision/start/stop/deprovision envelopes. The new contract and dispatch make both session phases reachable through those existing raw-JSON paths. Document theirresult.sessionId, empty deprovision result, and dry-run semantics without implying typed V1 support.
Claim-only and nonblocking findings
- Medium (claim mismatch) — policy-hash emission is not universal.
docs/backends/wslc/wslc-state-aware.md:172-174—claim_mismatch: the new claim thatMXC.PolicyHashis computed before dispatch forprovision-sessionholds forwxc-exec, but in-process raw-JSON/typed engine entry points never callstate_aware_policy_hashorlog_policy_hash. The underlying in-process logging gap predates this PR; narrow the new claim to the CLI or add privacy-preserving in-process emission. This claim is not a merge condition by itself. - Low (test setup) — extra prewarming cost. The preflight inline comment explains why
-DaemonSlots 3fills two additional multi-GiB stores with images those new tests do not use. This is not a production hot-path issue, and selective warming would add interface complexity; treat it as an optimization, not a blocker. - Low (testability) — session response mapping remains host-dependent.
src/mxc-sdk/src/backends/wslc/common/state_aware.rs:91-103—introduced_by_change: new methods call the concrete daemon client, so deterministic tests cannot fake a successfulSessionProvisionedor release failure through this adapter. The reported live suite exercises sessions; a small injectable transport would make regressions cheaper to catch. - Low (maintainability) — two memory-width checks.
state_aware.rs:568-585—introduced_by_change: the added backend validation duplicatescontainer_steps.rs:907-914. The exact contract's u64 shape is not the defect; the backend intentionally owns semantic rejection of a value its SDK cannot enforce. Share the backend width check to prevent error-text drift. - Low (contract coverage) — new root edge cases lack targeted invalid fixtures.
src/mxc-sdk/tests/mxc_contract/v1_1_0_alpha/fixtures.rs:35-45—introduced_by_change: new optional session fields have only a few root fixtures; add focused null, wrong-type, unknown-key and numeric-boundary cases. The full development-contract test target passed; this is a future regression gap. - Low (audit identity) — successful session-only CLI phases use a sandbox marker.
src/tools/wxc/src/main.rs:495-509,643—newly_exposed_by_change: this old helper labels any successful WSLc lifecycle operationwslc-sandbox, while the newly exposed session phases may have no sandbox. An entry-point regression test should assert an appropriate phase-aware diagnostic identity; no bearer ID should be logged. - Low (policy-hash test) — named-session key is not pinned.
src/mxc-sdk/src/core/mxc_common/policy_identity.rs:150,985—introduced_by_change: the new test compares hash equality/inequality but does not assert the canonicaljoinsNamedSession: trueprojection, so a key rename can pass. Reuse the existing exact projection/hash oracle. - Low (guide wording) — in-process raw JSON is omitted from the access list.
docs/backends/wslc/wslc-state-aware.md:143-146—claim_mismatch: the new text says FFI orwxc-execare the only paths, butmxc_sdk::run_lifecycle_jsonalso accepts the exact development contract. This wording is not a merge condition.
Verified pre-existing / withdrawn — not charged to this PR
docs/containment-policy/dev/policy.mdand the Rust/FFI entry-point docs are byte-identical at base and head. Their omissions are raised only because the new exact roots make them newly incomplete; they are not presented as edits made to those files.- The in-process policy-hash logging gap existed before this PR. Only the unqualified claim added in this PR is criticized.
- Seven low-signal suggestions from the first-pass report (flag-string duplication, comments, harness refactors, script negative tests, and adjacent accurate telemetry docs) are withdrawn rather than used as merge conditions.
| "quay.io/fedora/fedora-minimal:latest" | ||
| ) | ||
| & $SetupScript -WxcExecPath $WxcExec -Image $images -DaemonSlots 1 -Force | ||
| & $SetupScript -WxcExecPath $WxcExec -Image $images -DaemonSlots 3 -Force |
There was a problem hiding this comment.
Medium (test-setup performance; nonblocking) — prewarm only the images needed in the extra daemon slots.
Attribution: introduced_by_change — changing from -DaemonSlots 1 to 3 makes this preflight warm the create-and-run store plus three daemon stores with all five images. That grows from 10 to 20 store-image fills and adds two multi-GiB persistent stores; the new explicit-session scenarios use only alpine:latest in slots 1 and 2. The standalone lifecycle preflight likewise replicates Python into those extra slots.
Fix: If setup time/disk justify a targeted warming option, keep the full image set only in stores that require it and put alpine:latest in slots 1–2. Avoid a new public knob if this is not a material CI cost.
a995390 to
1480469
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
1480469 to
44eac85
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
| DaemonProvisionSessionConfig { | ||
| cpu_count: config.cpu_count, | ||
| memory_mb: config.memory_mb, | ||
| gpu: config.gpu.unwrap_or(false), |
Gudge (MGudgin)
left a comment
There was a problem hiding this comment.
Re-verified #1512 at head 460405e. The prior requested changes are addressed: join and release share session-ID validation and return the same error classification, the live harness now asserts guest CPU and memory for different VM sizes, and the development policy, raw Rust/FFI entry-point docs, CLI example, and policy-hash wording have been corrected. Targeted local checks passed (2 session-ID library tests, 1 FFI test, 371 exact development-contract tests, and PowerShell parse). Current PR checks have no failures or pending jobs. I did not independently rerun live WSL2 tests; GPU enforcement is explicitly documented as unverified by that suite.nnNonblocking items remain, including broad test prewarming, deterministic daemon-transport coverage, sparse contract edge fixtures, and audit/hash test refinements. This approval does not claim those were fixed.

📖 Description
Explicit WSLc sessions are now reachable through development
1.1.0-alphaMXC request JSON, the in-process engine, and CLI. Callers can create a VM with CPU/memory/GPU sizing, share it across sandboxes, and release it when empty. OmittingsessionIdpreserves implicit-session behavior.Dry runs validate without allocating resources, session operations avoid the sandbox correlation store, and isolated provisions identify the selected cold image store instead of reporting a misleading missing-image error. Published contracts and SDK V1 remain unchanged. Sandbox policy hashes record named-session placement but do not include the joined VM's sizing; this limitation is documented.
🔗 References
Part of #1460. Fourth of four PRs; stacked on #1503.
🔍 Validation
All results are from the rebased stack on Windows with a live WSL2 host.
From
src\:cargo fmt --all -- --checkcargo test --quiet --workspacecargo test --quiet --workspace --features wxc/wslccargo clippy --quiet --workspace --all-targets -- -D warningscargo clippy --quiet --workspace --all-targets --features wxc/wslc -- -D warningscargo build --quiet -p wxc --features wslccargo build --quiet -p mxc-sdk --features wslc --bin wxc-wslc-daemonFrom the repository root:
node .\scripts\versioning\check-schema-versions.jsnode .\scripts\versioning\validate-configs.jsnode .\scripts\versioning\check-contract-codegen.jsLive E2E: 122/122 passed, including shared sandboxes, independently releasable identically sized sessions, and the private one-warmed-slot refusal case.
Host-gated/ignored Rust cases were not enabled by the workspace commands; the live WSLc coverage above ran separately.
✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 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 pull request builds.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See pull request builds
for the steps.
Microsoft Reviewers: Open in CodeFlow