Add 0.6 configuration contract adapter - #835
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
e6d82e0 to
8903f5c
Compare
There was a problem hiding this comment.
Pull request overview
Adds the exact 0.6.0-alpha contract adapter into the canonical wxc_common wire model.
Changes:
- Adds exhaustive contract-to-wire mappings.
- Preserves aliases, optional sections, and later-version field absence.
- Adds comprehensive mapping and equivalence tests.
Show a summary per file
| File | Description |
|---|---|
src/Cargo.toml |
Registers the contract crate dependency. |
src/Cargo.lock |
Records the new dependency edge. |
src/core/wxc_common/Cargo.toml |
Adds the contract crate to wxc_common. |
src/core/wxc_common/src/lib.rs |
Exposes the internal adapter module. |
src/core/wxc_common/src/config_contract_adapters/mod.rs |
Declares the versioned adapter. |
src/core/wxc_common/src/config_contract_adapters/v0_6.rs |
Implements and tests the 0.6 adapter. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 5/6 changed files
- Comments generated: 0
- Review effort level: Balanced
This PR adds the typed adapter from exact 0.6.0-alpha contract requests to the current wxc_common wire model. Details * Adds the contract-crate dependency and a version-scoped adapter with exhaustive source and destination mappings. * Preserves optional-field presence, canonical compatibility aliases, and explicit absence for later-version fields. * Adds expected-wire and current-wire equivalence coverage for representative requests, proxies, enums, and aliases. Tests * `cargo fmt --all -- --check` * `cargo check -p wxc_common` * `cargo clippy -p wxc_common --all-targets -- -D warnings` * `cargo test -p wxc_common` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: da2ef4f8-31d6-4979-bd6b-fb822b25b694
8903f5c to
7741e74
Compare
| use mxc_config_contract::published::v0_6_0_alpha as contract; | ||
| use mxc_config_contract::ContractVersion; | ||
|
|
||
| fn convert_version(value: contract::Version) -> &'static str { |
There was a problem hiding this comment.
suggestion: I saw these conversion helpers and immediately thought they might be a good fit for the From/Into traits. Since these are infallible conversions between the contract and wire types, we could implement From<contract::X> for wire::X, which would simplify the nested conversions quite a bit when converting from request to MxcConfig:
Self {
// ...
containment: containment.into_option().map(Into::into),
process: Some(process.into()),
lifecycle: lifecycle.into_option().map(Into::into),
process_container: process_container.into_option().map(Into::into),
lxc: lxc.into_option().map(Into::into),
filesystem: filesystem.into_option().map(Into::into),
fallback: fallback.into_option().map(Into::into),
network: network.into_option().map(Into::into),
ui: ui.into_option().map(Into::into),
// ...
}So if we implement From<contract::Request> for wire::MxcConfig, I think we could remove into_wire entirely aswell and have callers just use request.into(). What do you think?
There was a problem hiding this comment.
Sorry, only saw this comment after I'd merged. Looking into this now.
This PR adds the typed adapter from exact 0.6.0-alpha contract requests to the current wxc_common wire model.
Details
Tests
cargo fmt --all -- --checkcargo check -p wxc_commoncargo clippy -p wxc_common --all-targets -- -D warningscargo test -p wxc_commonMicrosoft Reviewers: Open in CodeFlow