Skip to content

Add direct typed Rust state-aware transport - #1254

Open
Gudge (MGudgin) wants to merge 2 commits into
mainfrom
user/gudge/rust-sdk-direct-transport
Open

Gudge (MGudgin) wants to merge 2 commits into
mainfrom
user/gudge/rust-sdk-direct-transport

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Sep 23, 2026

Copy link
Copy Markdown
Member

📖 Description

This PR adds a direct typed Rust transport for state-aware lifecycle calls.
High-level Rust requests now adapt directly into MXC's common request model
without serializing or parsing JSON. Raw exact-contract JSON APIs remain as a
separate compatibility lane.

Details

  • Add typed lifecycle requests, options, results, and backend metadata.
  • Normalize typed requests directly into CommonRequestIR and
    StateAwareOperation while sharing binding, validation, telemetry, and
    backend execution with raw exact requests.
  • Return typed backend outcomes without constructing JSON response envelopes.
  • Preserve existing raw JSON entry points and add explicit raw aliases.
  • Add typed-versus-exact equivalence, facade, telemetry, and correlation tests.

This is PR 1 of 3 in the state-aware operation API stack.

🔗 References

🔍 Validation

  • cargo fmt --all -- --check
  • All-feature wxc_common, mxc_engine, and mxc-sdk tests passed.
  • mxc-sdk Rustdoc tests passed.
  • Changed-crate clippy passed with --no-deps -D warnings.
  • git diff --check

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

This PR adds a direct typed Rust SDK path for state-aware lifecycle
requests so high-level callers reach CommonRequestIR without serializing
or parsing JSON. The existing exact JSON APIs remain available as a
separate compatibility lane.

Details

* Add typed lifecycle requests, results, SDK normalization DTOs, and engine
  entry points for provision, start, stop, deprovision, and exec.
* Share normalization, binding, telemetry, correlation, authorization, and
  backend dispatch between typed and exact JSON callers.
* Keep JSON response envelopes confined to raw APIs and preserve exact-contract
  diagnostics and source attribution.
* Document the two ingress lanes and add typed-versus-exact equivalence tests.

Tests

* `cargo fmt --all -- --check`
* `cargo check` for `wxc_common`, `mxc_engine`, and `mxc-sdk`, including all
  features.
* `cargo test` for `wxc_common`, `mxc_engine`, and `mxc-sdk`, including
  all-feature engine and SDK suites.
* `cargo clippy` for changed crates with all targets/features, no dependencies,
  and warnings denied.
* Rustdoc examples and `git diff --check`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1d91874d-feea-4a33-b183-67d506ae61b5
Generated-with: gpt-5.6-sol
@MGudgin
Gudge (MGudgin) requested review from a team and a balanced review from Copilot September 23, 2026 22:23
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner September 23, 2026 22:23
@azure-pipelines

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

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.

Copilot review overview

🟡 Changes recommended

Critical request-semantics and moderate configuration and telemetry issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds a direct typed Rust transport for state-aware lifecycle operations while preserving raw JSON compatibility.

Changes:

  • Adds typed lifecycle requests, results, metadata, and dispatch.
  • Shares normalization, validation, telemetry, and correlation handling.
  • Adds typed/raw equivalence tests and documentation.
File Review
src/​core/​wxc_common/​src/​telemetry/​mod.rs Adds typed-result telemetry.
src/​core/​wxc_common/​src/​telemetry/​correlation_state.rs Tracks typed lifecycle correlation.
src/​core/​wxc_common/​src/​state_aware_dispatch.rs Adds typed backend outcomes.
src/​core/​wxc_common/​src/​sdk_input.rs Moderate: Typed telemetry defaults containment attribution to process, misreporting other backend kinds.
src/​core/​wxc_common/​src/​lib.rs Exposes the SDK input bridge.
src/​core/​wxc_common/​src/​config_parser.rs Supports shared typed normalization.
src/​core/​mxc-sdk/​tests/​state_aware.rs Tests typed facade and compatibility behavior.
src/​core/​mxc-sdk/​src/​lib.rs Exposes typed and raw lifecycle APIs.
src/​core/​mxc-sdk/​README.md Documents typed and raw API lanes.
src/​core/​mxc_engine/​src/​state_aware.rs Implements typed lifecycle execution.
src/​core/​mxc_engine/​src/​state_aware_sdk.rs Critical: Empty network sections lose policy-presence semantics. Moderate: app_id: None incorrectly creates an empty provision config. Nits: Public constructors, builders, setters, timeout units, and zero-value behavior need rustdoc.
src/​core/​mxc_engine/​src/​lib.rs Re-exports typed APIs.
docs/​state-aware-lifecycle/​mxc-state-aware-sandbox-api.md Documents typed architecture and dispatch.
docs/​state-aware-lifecycle/​mxc-state-aware-sandbox-api-overview.md Updates the lifecycle API overview.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +430 to +437
let network = if value.egress.is_some() || value.ingress.is_some() {
Some(SdkNetworkInput {
egress: value.egress.as_ref().map(map_egress).transpose()?,
ingress: value.ingress.as_ref().map(map_ingress),
})
} else {
None
};
Comment on lines +40 to +44
Self::IsolationSession { app_id } => RuntimeProvision::IsolationSession(Some(
wxc_common::models::IsolationSessionProvisionConfig {
app_id: app_id.clone(),
},
)),
This PR fixes Unix lint failures caused by Windows-only typed lifecycle
result helpers being compiled on every target.

Details

* Gate typed dispatch conversion helpers and result constructors to Windows.
* Gate their imports so non-Windows builds remain warning-free.

Tests

* `cargo fmt --all -- --check`
* `cargo clippy -p mxc_engine --all-targets --all-features --release --
  -D warnings`
* `cargo clippy --target x86_64-apple-darwin --locked --release
  -p mxc_darwin -p seatbelt_common -- -D warnings`
* `cargo test -p mxc_engine --lib state_aware --all-features` (26 passed)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1d91874d-feea-4a33-b183-67d506ae61b5
Generated-with: gpt-5.6-sol
Copilot AI review requested due to automatic review settings September 23, 2026 22:32

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.

Copilot review overview

🔵 Needs a closer look

Three moderate typed-versus-exact equivalence issues remain unresolved.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Preserve absent WSLc configuration when options are unset

src/​core/​mxc_engine/​src/​state_aware_sdk.rs:52

When both WSLc options are None, this still produces StateAwareProvision::Wslc(Some(default_config)) instead of the absent configuration represented by exact JSON. Configuration presence is intentionally significant in StateAwareProvision and binding preserves it, so this can change backend defaulting/validation and breaks typed-versus-exact equivalence for an omitted wslc section. Map the all-None case to RuntimeProvision::Wslc(None).

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.

:shipit:

} => RuntimeProvision::Wslc(Some(wxc_common::models::WslcProvisionConfig {
image: image.clone(),
image_tar_path: image_tar_path.clone(),
})),

@jsidewhite Jeff Whiteside (jsidewhite) Sep 24, 2026

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.

nit: this kind of duplicates the representation ProvisionConfig in S:\repo_other\mxc\src\backends\wslc\common\src\daemon_protocol.rs

but i suppose that copy should eventually go away.l

},
}

impl StateAwareProvision {

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.

StateAwareProvision

so essentially this is now the "C" and the "P" part of

R = EPC

"Request == Exec Policy Continament"

This branch has not been deployed

No deployments
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