Skip to content

[WSLC] (4/4) Expose explicit session lifecycle - #1512

Merged
Soham Das (SohamDas2021) merged 5 commits into
mainfrom
sohamdas2021-pr4-session-contract-and-cli
Oct 21, 2026
Merged

Soham Das (SohamDas2021) merged 5 commits into
mainfrom
sohamdas2021-pr4-session-contract-and-cli

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Explicit WSLc sessions are now reachable through development 1.1.0-alpha MXC 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. Omitting sessionId preserves 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.

PR Title
1 [WSLC] (1/4) Move the lifecycle daemon off the create-and-run image store
2 [WSLC] (2/4) Hold multiple sessions in the lifecycle daemon
3 [WSLC] (3/4) Add the session lifecycle phases and dispatch routing
4 [WSLC] (4/4) Expose explicit session lifecycle — this PR

🔍 Validation

All results are from the rebased stack on Windows with a live WSL2 host.

From src\:

Command Result
cargo fmt --all -- --check passed
cargo test --quiet --workspace passed
cargo test --quiet --workspace --features wxc/wslc passed; SDK library 3252, daemon 139, executor 72 tests passed
cargo clippy --quiet --workspace --all-targets -- -D warnings passed
cargo clippy --quiet --workspace --all-targets --features wxc/wslc -- -D warnings passed
cargo build --quiet -p wxc --features wslc passed
cargo build --quiet -p mxc-sdk --features wslc --bin wxc-wslc-daemon passed

From the repository root:

Command Result
node .\scripts\versioning\check-schema-versions.js passed
node .\scripts\versioning\validate-configs.js passed; 412 configs validated, 14 intentionally-invalid exemptions
node .\scripts\versioning\check-contract-codegen.js passed; all 3 generated artifact sets match; published schemas unchanged

Live E2E: 122/122 passed, including shared sandboxes, independently releasable identically sized sessions, and the private one-warmed-slot refusal case.

$wxc = Join-Path (Get-Location) 'src\target\debug\wxc-exec.exe'
& .\tests\scripts\run_wslc_state_aware_tests.ps1 -WxcExecPath $wxc -Debug

Host-gated/ignored Rust cases were not enabled by the workspace commands; the live WSLc coverage above ran separately.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

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 GitHub
Actions build; it runs on merge to main, and Microsoft reviewers with write access can trigger it
on a PR with /azp run. See pull request builds.

If the dependency-feed-check check fails on a new dependency, the crate must be added to
the feed before the PR can pass. See pull request builds
for the steps.

Microsoft Reviewers: Open in CodeFlow

@SohamDas2021
Soham Das (SohamDas2021) requested a review from a team as a code owner October 15, 2026 23:37
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@SohamDas2021
Soham Das (SohamDas2021) added this pull request to stack #1502 October 15, 2026 23:39
Comment thread src/mxc-sdk/src/backends/wslc/common/state_aware.rs Fixed
Comment thread src/mxc-sdk/src/backends/wslc/common/state_aware.rs Fixed
Comment thread src/mxc-sdk/src/core/mxc_engine/state_aware.rs Fixed
@SohamDas2021
Soham Das (SohamDas2021) requested review from a team and a balanced review from Copilot October 16, 2026 02:34
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-pr4-session-contract-and-cli branch from ece05e7 to 9df17ae Compare October 16, 2026 02:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 03:29
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-pr4-session-contract-and-cli branch from 9df17ae to 354d88c Compare October 16, 2026 03:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-process VM sharing, GPU configuration, and resource teardown warrant final human review of the reported Windows/WSL2 validation.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 16, 2026 15:43
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-pr4-session-contract-and-cli branch from 354d88c to 28edaee Compare October 16, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Windows-only VM ownership, shared-session placement, and resource cleanup warrant final human review despite no confirmed blocking defects.

0 open findings

🧠 Review effort: Balanced

@MGudgin Gudge (MGudgin) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at src/mxc-sdk/src/core/mxc_contract/dev/request.rs:153-162 now accepts provision-session, deprovision-session, and wslc.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-424 and src/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 their result.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 that MXC.PolicyHash is computed before dispatch for provision-session holds for wxc-exec, but in-process raw-JSON/typed engine entry points never call state_aware_policy_hash or log_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 3 fills 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 successful SessionProvisioned or 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 duplicates container_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 operation wslc-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 canonical joinsNamedSession: true projection, 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 or wxc-exec are the only paths, but mxc_sdk::run_lifecycle_json also 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.md and 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.

Comment thread src/mxc-sdk/src/backends/wslc/common/state_aware.rs Outdated
Comment thread tests/scripts/run_wslc_state_aware_tests.ps1
Comment thread docs/development/architecture/container-lifecycle.md Outdated
"quay.io/fedora/fedora-minimal:latest"
)
& $SetupScript -WxcExecPath $WxcExec -Image $images -DaemonSlots 1 -Force
& $SetupScript -WxcExecPath $WxcExec -Image $images -DaemonSlots 3 -Force

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Oct 20, 2026
Copilot AI balanced review requested due to automatic review settings October 20, 2026 16:10
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-pr4-session-contract-and-cli branch from a995390 to 1480469 Compare October 20, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Session-release error classification is inconsistent, and functional tests do not verify requested VM sizing.

2 open issues

Review effort: Balanced

Comment thread tests/scripts/run_wslc_state_aware_tests.ps1
Base automatically changed from sohamdas2021-pr3-session-phase-vocabulary to main October 20, 2026 16:56
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
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-pr4-session-contract-and-cli branch from 1480469 to 44eac85 Compare October 20, 2026 16:56
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a56b1c8c-bb73-41f2-83c1-f27ef0f37c66
Copilot AI balanced review requested due to automatic review settings October 20, 2026 19:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Host-dependent VM ownership and the unresolved GPU functional-coverage gap require final maintainer review.

1 open issue
2 resolved since last review

Review effort: Balanced

DaemonProvisionSessionConfig {
cpu_count: config.cpu_count,
memory_mb: config.memory_mb,
gpu: config.gpu.unwrap_or(false),

@MGudgin Gudge (MGudgin) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@SohamDas2021
Soham Das (SohamDas2021) merged commit 9642639 into main Oct 21, 2026
31 of 32 checks passed
@SohamDas2021
Soham Das (SohamDas2021) deleted the sohamdas2021-pr4-session-contract-and-cli branch October 21, 2026 15:53
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants