Skip to content

type-c-service: Remove interior mutability from service#766

Merged
jerrysxie merged 3 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-refactor-direct-async
Apr 2, 2026
Merged

type-c-service: Remove interior mutability from service#766
jerrysxie merged 3 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-refactor-direct-async

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

@RobertZ2011 RobertZ2011 commented Mar 27, 2026

  • Hook-up power policy events again
  • Remove interior mutability from service and move event receivers to a separate struct.

@RobertZ2011 RobertZ2011 self-assigned this Mar 27, 2026
Copilot AI review requested due to automatic review settings March 27, 2026 20:55
@RobertZ2011 RobertZ2011 changed the base branch from main to v0.2.0 March 27, 2026 20:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 host↔EC communication path (notably eSPI) toward a direct async “relay” model, and decouples several services’ wire/message types into dedicated *-messages crates to improve composability and testability.

Changes:

  • Introduces a generic MCTP relay framework (embedded-service::relay) and updates eSPI service to use it.
  • Splits debug/battery message types into new debug-service-messages / battery-service-messages crates and updates services accordingly.
  • Updates examples/workspace/CI to account for new crates, features, and adds coverage reporting in GitHub Actions.

Reviewed changes

Copilot reviewed 33 out of 43 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
examples/std/Cargo.toml Updates deps/features to use new interface/message crates and newer battery async crate; removes an example bin.
examples/rt685s-evk/Cargo.toml Adds new interface/common deps needed by refactored services.
examples/rt685s-evk/.cargo/config.toml Reformats rustflags and lowers default DEFMT_LOG verbosity.
examples/rt633/Cargo.toml Tidies embassy-sync features; bumps battery crate and bq40z50-rx versions; adds power-policy interface.
examples/pico-de-gallo/Cargo.toml Adds a new standalone example workspace with updated deps.
espi-service/src/task.rs Removes old task entrypoint in favor of the new runner-based service structure.
espi-service/src/lib.rs Gates eSPI module for tests and re-exports new implementation.
espi-service/src/espi_service.rs Major refactor: introduces Resources/Runner and integrates relay handler for request/response.
espi-service/Cargo.toml Adds deps to support relay/bitfield/num_enum and runnable-service integration.
embedded-service/src/type_c/mod.rs Removes old Type-C service module from embedded-service crate.
embedded-service/src/type_c/external.rs Removes old external Type-C command/message definitions.
embedded-service/src/relay/mod.rs Adds generic relay + MCTP header/message macro to support direct async relay services.
embedded-service/src/power/policy/policy.rs Removes old in-crate power policy implementation.
embedded-service/src/power/policy/mod.rs Removes old power policy public API/types.
embedded-service/src/power/policy/device.rs Removes old power policy device state machine.
embedded-service/src/power/policy/charger.rs Removes old power policy charger integration.
embedded-service/src/power/policy/action/policy.rs Removes old policy action type-state API.
embedded-service/src/power/policy/action/mod.rs Removes old policy action module entry.
embedded-service/src/power/policy/action/device.rs Removes old device action type-state API.
embedded-service/src/power/mod.rs Removes old power module entry.
embedded-service/src/named.rs Adds a small Named trait utility.
embedded-service/src/lib.rs Updates module exports and adds hidden macro re-exports used by relay macro.
embedded-service/src/event.rs Adds generic sender/receiver abstractions over embassy channels/pubsub.
embedded-service/src/ec_type/structure.rs Removes old EC memory map structure definitions.
embedded-service/src/ec_type/protocols/mptf.rs Removes protocol enum definitions from embedded-service crate.
embedded-service/src/ec_type/protocols/mod.rs Removes protocol module tree from embedded-service crate.
embedded-service/src/ec_type/protocols/debug.rs Removes debug protocol enum definitions from embedded-service crate.
embedded-service/src/ec_type/protocols/acpi.rs Removes ACPI protocol enum definitions from embedded-service crate.
embedded-service/src/ec_type/message.rs Removes old host message/request envelope types from embedded-service crate.
embedded-service/src/ec_type/generator/ec_memory_map.yaml Removes old EC memory map generator input.
embedded-service/src/ec_type/generator/ec-memory-generator.py Removes old EC memory map generator script.
embedded-service/src/comms.rs Tightens message payload bounds to Any + Send + Sync and removes a TimeAlarm endpoint.
embedded-service/src/cfu/mod.rs Removes old in-crate CFU client implementation.
embedded-service/Cargo.toml Adjusts deps to support relay/macro infra and target cfg changes.
docs/api-guidelines.md Adds service API guidelines aligned with resources/runner/traits patterns.
debug-service/src/task.rs Refactors debug service tasks to use message crate + signals rather than comms to host.
debug-service/src/lib.rs Gates debug service on not(test) to avoid desktop build issues.
debug-service/src/debug_service.rs Converts Debug service into an MCTP relay handler using debug-service-messages.
debug-service/Cargo.toml Adds debug-service-messages dep and feature wiring.
debug-service-messages/src/lib.rs New message crate defining debug request/response/error serialization.
debug-service-messages/Cargo.toml New crate manifest for debug message types.
cfu-service/src/task.rs Removes internal singleton init; task now takes a provided CFU client instance.
cfu-service/src/splitter.rs Refactors CFU splitter routing to use CfuClient context instead of embedded-service CFU module.
cfu-service/src/lib.rs Re-homes CFU client context into cfu-service and adds init/registration helpers.
cfu-service/src/component.rs Updates component processing to route requests via CfuClient.
cfu-service/src/buffer.rs Updates buffering logic to route/send/wait via CfuClient context.
battery-service/src/task.rs Changes task init flow: registers devices, returns structured init errors.
battery-service/src/mock.rs Adds mock battery implementation to support host/std testing.
battery-service/src/lib.rs Converts battery ACPI handling to relay handler types and modernizes APIs.
battery-service/src/device.rs Switches DeviceId to message-crate definition.
battery-service/src/context.rs Converts ACPI request processing to typed requests/results; starts migration off comms for power policy updates.
battery-service/src/acpi.rs Reworks ACPI handlers to return typed AcpiBatteryResponse results.
battery-service/Cargo.toml Adds message crate + power-policy interface dep; introduces mock feature.
battery-service-messages/Cargo.toml New crate manifest for battery message types.
Cargo.toml Adds new workspace members and workspace deps for interfaces/messages/common crates.
.vscode/settings.json Adds new example manifest to TOML schema associations.
.github/workflows/check.yml Adds coverage instrumentation + grcov report generation and checks new example workspace.
.github/workflows/cargo-vet.yml Bumps cargo-vet version and forces stable toolchain for install.

@RobertZ2011 RobertZ2011 force-pushed the type-c-refactor-direct-async branch from 456a40b to 55aaa45 Compare March 31, 2026 23:07
@RobertZ2011 RobertZ2011 changed the title Type c refactor direct async type-c-service: Remove interior mutability from service Mar 31, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-refactor-direct-async branch from 55aaa45 to 7d95c3a Compare March 31, 2026 23:16
Copilot AI review requested due to automatic review settings March 31, 2026 23:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 14 changed files in this pull request and generated 4 comments.

@RobertZ2011 RobertZ2011 force-pushed the type-c-refactor-direct-async branch from 7d95c3a to 1c322f7 Compare April 1, 2026 16:42
@RobertZ2011 RobertZ2011 marked this pull request as ready for review April 1, 2026 16:54
@RobertZ2011 RobertZ2011 requested a review from a team as a code owner April 1, 2026 16:54
Copilot AI review requested due to automatic review settings April 1, 2026 16:54
@RobertZ2011 RobertZ2011 requested a review from a team as a code owner April 1, 2026 16:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 14 changed files in this pull request and generated no new comments.

@RobertZ2011 RobertZ2011 force-pushed the type-c-refactor-direct-async branch from 1c322f7 to 07aa6e3 Compare April 1, 2026 17:47
@RobertZ2011 RobertZ2011 requested a review from kurtjd April 1, 2026 17:55
@github-project-automation github-project-automation bot moved this to In progress in ODP Backlog Apr 2, 2026
@jerrysxie jerrysxie merged commit 5a0ed0d into OpenDevicePartnership:v0.2.0 Apr 2, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in ODP Backlog Apr 2, 2026
@RobertZ2011 RobertZ2011 deleted the type-c-refactor-direct-async branch April 2, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants