power-policy-service: Refactor module structure and renaming#711
power-policy-service: Refactor module structure and renaming#711RobertZ2011 wants to merge 5 commits intoOpenDevicePartnership:v0.2.0from
Conversation
Cargo Vet Audit Passed
|
There was a problem hiding this comment.
Pull request overview
Refactors power/thermal/host-relay messaging to remove legacy EC memory-map types, introduce shared “*-messages” crates with explicit serialization, and modernize service initialization patterns.
Changes:
- Introduces
embedded_services::relaywith MCTP routing helpers and new per-service*-messagescrates (battery/thermal/debug/time-alarm). - Refactors
power-policy-serviceinto a generic, testable policy core with new unit tests and updated device state-machine handling. - Updates eSPI + debug + battery services to use the new relay/messages flow and gates hardware/defmt-only modules from desktop test builds.
Reviewed changes
Copilot reviewed 53 out of 70 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| thermal-service/src/lib.rs | Refactors thermal service into an explicit Service instance with storage provided by caller; updates comms receive types. |
| thermal-service/src/fan.rs | Threads &Service into fan auto-control logic instead of using global wrappers. |
| thermal-service/src/context.rs | Simplifies context (removes MCTP queue/buffer) and switches MPTF queue to thermal-service-messages. |
| thermal-service/Cargo.toml | Adds dependency + defmt feature wiring for thermal-service-messages. |
| thermal-service-messages/src/lib.rs | New no_std message types + serialization for thermal requests/responses/errors. |
| thermal-service-messages/Cargo.toml | Defines the new message crate and feature flags. |
| supply-chain/audits.toml | Adds cargo-vet audit entries and minor trusted metadata tweak. |
| power-policy-service/tests/consumer.rs | Adds async integration-style tests for consumer attach/detach and swapping. |
| power-policy-service/tests/common/mod.rs | Adds shared harness utilities and a policy task runner for tests. |
| power-policy-service/tests/common/mock.rs | Adds a mock device implementing the policy device trait. |
| power-policy-service/src/task.rs | Reworks task entry to accept a prebuilt policy instance (removes singleton init). |
| power-policy-service/src/provider.rs | Refactors provider connection logic to new generic policy/device model. |
| power-policy-service/src/policy/policy.rs | New policy context abstraction with device/charger registration + request selection. |
| power-policy-service/src/policy/mod.rs | Reshapes policy module exports and adjusts Error::InvalidState signature. |
| power-policy-service/src/policy/device.rs | New device state machine + device container abstractions for policy. |
| power-policy-service/src/policy/charger.rs | Updates charger types/import paths; aligns NodeContainer usage. |
| power-policy-service/src/lib.rs | Makes PowerPolicy generic over device locks/receivers; rewires request processing. |
| power-policy-service/src/consumer.rs | Refactors consumer selection + charger configuration to new context/device APIs. |
| power-policy-service/src/config.rs | Updates config to use local PowerCapability type. |
| power-policy-service/src/charger.rs | Repoints charger wrapper imports to the new policy charger module. |
| power-policy-service/Cargo.toml | Adds deps needed by new policy core + introduces dev-deps for tests. |
| partition-manager/partition-manager/Cargo.toml | Removes defmt from default features. |
| keyboard-service/src/lib.rs | Derives Debug for KeyboardError. |
| examples/std/src/lib/type_c/mock_controller.rs | Updates mock Type-C controller to new wrapper generics and power-policy request types. |
| examples/std/Cargo.toml | Bumps deps and adds new message crates to std example. |
| examples/rt685s-evk/Cargo.toml | Adds time-alarm services and embedded-mcu-hal dependency. |
| examples/rt633/Cargo.toml | Formatting + dependency bumps (e.g., embedded-batteries-async, bq40z50-rx). |
| examples/pico-de-gallo/Cargo.toml | Adds a new standalone example workspace manifest. |
| espi-service/src/task.rs | Removes EC memory map buffer init/validation; updates event loop to “response” path. |
| espi-service/src/mctp.rs | Adds hardcoded ODP MCTP relay type list via new relay macro. |
| espi-service/src/lib.rs | Gates eSPI modules from tests to allow workspace tests on Windows. |
| espi-service/src/espi_service.rs | Replaces legacy EC mem-map routing with relay-based MCTP request/response handling. |
| espi-service/Cargo.toml | Adds relay dependencies and message crates; wires defmt features. |
| embedded-service/src/type_c/external.rs | Removes external Type-C command definitions module (legacy API removal). |
| embedded-service/src/relay/mod.rs | Adds generic message serialization traits + MCTP relay macro and routing helper. |
| embedded-service/src/power/policy/policy.rs | Removes legacy embedded-service power-policy context implementation. |
| embedded-service/src/power/policy/device.rs | Removes legacy embedded-service power-policy device implementation. |
| embedded-service/src/power/policy/action/policy.rs | Removes legacy policy action typestate module. |
| embedded-service/src/power/policy/action/mod.rs | Removes legacy action kind definitions. |
| embedded-service/src/power/policy/action/device.rs | Removes legacy device action typestate module. |
| embedded-service/src/power/mod.rs | Removes legacy power module root. |
| embedded-service/src/lib.rs | Removes legacy ec_type/power/type_c module wiring; adds relay + event modules. |
| embedded-service/src/event.rs | Introduces common Sender/Receiver traits for dynamic channels. |
| embedded-service/src/ec_type/structure.rs | Deletes legacy EC memory-map structures. |
| embedded-service/src/ec_type/protocols/mptf.rs | Deletes legacy MPTF protocol enum. |
| embedded-service/src/ec_type/protocols/mod.rs | Deletes legacy protocol module aggregator. |
| embedded-service/src/ec_type/protocols/debug.rs | Deletes legacy debug protocol enum. |
| embedded-service/src/ec_type/protocols/acpi.rs | Deletes legacy ACPI battery command enum. |
| embedded-service/src/ec_type/message.rs | Deletes legacy StdHostRequest/StdHostPayload host message types. |
| embedded-service/src/ec_type/generator/ec_memory_map.yaml | Deletes EC memory-map generator input. |
| embedded-service/src/ec_type/generator/ec-memory-generator.py | Deletes EC memory-map code generator script. |
| embedded-service/src/comms.rs | Tightens message data to Any + Send + Sync and updates downcast APIs accordingly. |
| embedded-service/Cargo.toml | Moves embassy-futures to normal deps (used by relay/context code). |
| debug-service/src/task.rs | Switches debug-to-host messages to debug-service-messages types. |
| debug-service/src/lib.rs | Gates debug module from tests to avoid defmt dependency on desktop. |
| debug-service/src/debug_service.rs | Updates mailbox receive to new DebugRequest type + uses new buffer size const. |
| debug-service/Cargo.toml | Adds debug-service-messages dependency + defmt feature plumbing. |
| debug-service-messages/src/lib.rs | New no_std debug request/response/error message types + serialization. |
| debug-service-messages/Cargo.toml | Defines the new debug message crate and feature flags. |
| battery-service/src/task.rs | Refactors battery task to accept an explicit Service + device list; returns structured init errors. |
| battery-service/src/lib.rs | Switches ACPI request handling to message crates and sends responses via comms. |
| battery-service/src/device.rs | Reuses battery_service_messages::DeviceId instead of defining a local type. |
| battery-service/src/context.rs | Refactors ACPI command processing to typed requests/responses + updated power-policy comms types. |
| battery-service/src/acpi.rs | Replaces legacy host payload types with battery-service-messages responses. |
| battery-service/Cargo.toml | Adds battery-service-messages, heapless, and power-policy-service deps; wires defmt feature. |
| battery-service-messages/Cargo.toml | Adds new battery message crate manifest. |
| Cargo.toml | Adds new workspace members and dependency versions/paths for message crates. |
| .vscode/settings.json | Adds the new example manifest to watched TOMLs. |
| .github/workflows/check.yml | Adds CI job to clippy the new pico-de-gallo example. |
| .github/workflows/cargo-vet.yml | Bumps cargo-vet version and installs via cargo +stable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f8eef7d to
60c28de
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 51 out of 65 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
type-c-service/src/type_c/event.rs:5
- Typo in module docs: "acessing" -> "accessing".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
60c28de to
6dec555
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 56 out of 70 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
71eb447 to
298bf63
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 72 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
298bf63 to
468b6a4
Compare
intrusive_list and 'static
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 72 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
92fabf4 to
cfcabcf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 59 out of 73 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (2)
power-policy-service/src/service/consumer.rs:239
- The log format string has an extra '(':
"(({}): ...", which will produce malformed logs and makes grepping harder. It should match the other log prefixes (e.g."({}): ...").
type-c-service/src/type_c/controller.rs:470 execute_commandstores the result in a temporary (let r = ...; r). This adds noise without changing behavior. Please return the awaited result directly (or add a comment if this is intentional for debugging/breakpoints).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@RobertZ2011 There are multiple rounds of changes layered on top of each other. Can we break this PR into multiple smaller PRs? It is very hard to evaluate all the changes together. It seems like moving code from embedded-service into power-policy-service can be one PR, moving away from intrusive list and 'static can be another PR. |
battery-service/Cargo.toml
Outdated
| zerocopy.workspace = true | ||
| mctp-rs = { workspace = true, features = ["espi"] } | ||
| heapless.workspace = true | ||
| power-policy-service.workspace = true |
There was a problem hiding this comment.
One of our design goal is to have service to have no hard link between easy other, so one can use battery-serbvice without pulling in power-policy-service. With this redesign, is that still possible?
6fbe2a0 to
6771553
Compare
intrusive_list and 'static6771553 to
ece1606
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 57 out of 71 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
type-c-service/src/type_c/event.rs:4
- Typo in module docs: "acessing" → "accessing".
power-policy-interface/src/psu/mod.rs:295 Psutrait methods returnimpl Future<...>, but this module doesn’t importcore::future::Future(and it isn’t fully qualified), so this won’t compile. Adduse core::future::Future;(or fully qualifycore::future::Futurein the trait signatures).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| error!( | ||
| "Device{}: Invalid state for notify consumer capability, catching up: {:#?}", | ||
| device.id().0, | ||
| e, | ||
| ); |
There was a problem hiding this comment.
The error log message in the provider-capability request path says "notify consumer capability", which is misleading when debugging provider behavior. Update the message text to refer to provider capability / requested provider capability.
4c37822 to
c64f762
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 72 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
power-policy-interface/src/psu/mod.rs:292
Psutrait method signatures useFuture, but this module doesn’t importcore::future::Future(and it’s not in the Rust prelude). This will fail to compile unlessFutureis brought into scope or fully qualified. Adduse core::future::Future;near the top (or change the signatures tocore::future::Future).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c64f762 to
09f865b
Compare
jerrysxie
left a comment
There was a problem hiding this comment.
Thanks, much easier to review as a smaller PR.
| tps6699x = { workspace = true, features = ["embassy"] } | ||
| cfu-service.workspace = true | ||
| power-policy-interface.workspace = true | ||
| power-policy-service = { path = "../power-policy-service" } |
Refactor the power policy service to achieve the following:
embedded-serviceand into their respective service implementationsPsuname instead ofDevice.