Skip to content

[IsolationSession] Refactor runner into per-responsibility module files#352

Merged
adpa-ms merged 1 commit into
mainfrom
user/adibpa/isosession-rust-refactor
May 20, 2026
Merged

[IsolationSession] Refactor runner into per-responsibility module files#352
adpa-ms merged 1 commit into
mainfrom
user/adibpa/isosession-rust-refactor

Conversation

@adpa-ms

@adpa-ms adpa-ms commented May 20, 2026

Copy link
Copy Markdown

Summary

Splits the 2,860-line src/wxc_common/src/isolation_session_runner.rs
into 9 per-responsibility module files under
src/wxc_common/src/isolation_session/:

Module Responsibility
mod.rs Re-exports IsolationSessionRunner (the only externally-reachable type)
error.rs IsolationSessionError enum + ScriptResponse/MxcError conversions
policy.rs Phase-specific policy validation + IsolationSessionUser shape check
process_options.rs ProcessOptions + WinRT IsoSessionProcessOptions translator
folder_sharing.rs ShareFolderBatchAsync request build + per-path outcome aggregation
protected_paths_filter.rs Emergency mitigation for MXC issue #330
manager.rs IsolationSessionManager lifecycle wrapper (1:1 with IsoSessionOps)
one_shot.rs ScriptRunner impl (full lifecycle in a single process)
state_aware.rs StatefulSandboxBackend impl (per-phase lifecycle methods)

No external API change: wxc_common::isolation_session::IsolationSessionRunner
remains the only externally-reachable item; every internal symbol is now
pub(super) / module-private.

Notable mechanical changes

  • IsolationSessionManager::create_process now returns i32 rather than
    ProcessResult { exit_code, stdout, stderr }. The string fields were
    always empty (output is streamed via relay threads), so this is a pure
    cosmetic simplification — ProcessResult is dropped entirely.
  • The STILL_ACTIVE shutdown ladder is extracted into a documented
    wait_with_graceful_shutdown helper. The original error-handling
    contract is preserved: first ExitCode() query is ?-propagated;
    per-tier subsequent queries fall back to STILL_ACTIVE.

Tests

All 81 existing unit tests are preserved, grouped with the code they
cover. Two new pinning tests added in state_aware.rs:
backend_key_matches_wire_format and id_prefix_matches_wire_format.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings May 20, 2026 00:07
@adpa-ms
adpa-ms requested a review from a team May 20, 2026 00:08

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.

Pull request overview

Refactors the Windows IsolationSessionRunner backend in wxc_common by splitting the former monolithic isolation_session_runner.rs into a focused module tree under src/wxc_common/src/isolation_session/, while updating call sites to the new module path.

Changes:

  • Replaced the single-file IsolationSession runner implementation with a multi-module layout (error, policy, manager, one_shot, state_aware, etc.) under wxc_common::isolation_session.
  • Updated executor/dispatcher imports to reference wxc_common::isolation_session::IsolationSessionRunner.
  • Preserved and regrouped unit tests alongside the new modules; added pinning tests for state-aware wire-format constants.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/wxc/src/main.rs Updates the IsolationSession runner import to the new module path.
src/wxc_common/src/state_aware_dispatch.rs Updates state-aware backend construction to use the new module path.
src/wxc_common/src/lib.rs Switches exported module from isolation_session_runner to isolation_session.
src/wxc_common/src/isolation_session/mod.rs Introduces the new IsolationSession module root and defines IsolationSessionRunner.
src/wxc_common/src/isolation_session/error.rs Moves typed error model + conversions into a dedicated module.
src/wxc_common/src/isolation_session/policy.rs Moves phase-specific policy validation and user-bundle validation.
src/wxc_common/src/isolation_session/process_options.rs Moves process option construction and WinRT translation helpers.
src/wxc_common/src/isolation_session/folder_sharing.rs Moves ShareFolderBatch request building and per-path outcome aggregation.
src/wxc_common/src/isolation_session/protected_paths_filter.rs Moves the MXC #330 protected-path filter/normalization and tests.
src/wxc_common/src/isolation_session/manager.rs Moves the IsoSessionOps lifecycle wrapper and process execution/relay logic.
src/wxc_common/src/isolation_session/one_shot.rs Moves the one-shot ScriptRunner implementation.
src/wxc_common/src/isolation_session/state_aware.rs Moves the StatefulSandboxBackend implementation and adds wire-format pinning tests.
src/wxc_common/src/isolation_session_runner.rs Deletes the old monolithic implementation file.

Comment thread src/wxc_common/src/lib.rs
@adpa-ms
adpa-ms merged commit 9359723 into main May 20, 2026
19 checks passed
@adpa-ms
adpa-ms deleted the user/adibpa/isosession-rust-refactor branch May 20, 2026 15:30
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.

3 participants