Skip to content

Comments

power-policy-service: Refactor module structure and renaming#711

Open
RobertZ2011 wants to merge 5 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-clean-up
Open

power-policy-service: Refactor module structure and renaming#711
RobertZ2011 wants to merge 5 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-clean-up

Conversation

@RobertZ2011
Copy link
Contributor

@RobertZ2011 RobertZ2011 commented Feb 10, 2026

Refactor the power policy service to achieve the following:

  • Move power policy and type-C code out of embedded-service and into their respective service implementations
  • Introduce Psu name instead of Device.

@RobertZ2011 RobertZ2011 self-assigned this Feb 10, 2026
Copilot AI review requested due to automatic review settings February 10, 2026 01:00
@RobertZ2011 RobertZ2011 changed the base branch from main to v0.2.0 February 10, 2026 01:02
@github-actions
Copy link

github-actions bot commented Feb 10, 2026

Cargo Vet Audit Passed

cargo vet has passed in this PR. No new unvetted dependencies were found.

@github-actions github-actions bot added the cargo vet PRs pending auditor review label Feb 10, 2026
Copy link
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 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::relay with MCTP routing helpers and new per-service *-messages crates (battery/thermal/debug/time-alarm).
  • Refactors power-policy-service into 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.

Copilot AI review requested due to automatic review settings February 12, 2026 01:18
@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from f8eef7d to 60c28de Compare February 12, 2026 01:18
Copy link
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 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.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 60c28de to 6dec555 Compare February 14, 2026 01:05
Copilot AI review requested due to automatic review settings February 19, 2026 21:16
Copy link
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 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.

Copilot AI review requested due to automatic review settings February 19, 2026 23:36
@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 71eb447 to 298bf63 Compare February 19, 2026 23:36
Copy link
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 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.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 298bf63 to 468b6a4 Compare February 19, 2026 23:38
@RobertZ2011 RobertZ2011 changed the title Power policy clean up power-policy-service: Refactor PSU away from intrusive_list and 'static Feb 19, 2026
Copilot AI review requested due to automatic review settings February 20, 2026 00:00
Copy link
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 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.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 92fabf4 to cfcabcf Compare February 20, 2026 00:02
Copilot AI review requested due to automatic review settings February 20, 2026 00:42
Copy link
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 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_command stores 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.

@jerrysxie
Copy link
Contributor

@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.

zerocopy.workspace = true
mctp-rs = { workspace = true, features = ["espi"] }
heapless.workspace = true
power-policy-service.workspace = true
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 6fbe2a0 to 6771553 Compare February 24, 2026 19:43
@RobertZ2011 RobertZ2011 changed the title power-policy-service: Refactor PSU away from intrusive_list and 'static power-policy-service: Refactor module structure and renaming Feb 24, 2026
Copilot AI review requested due to automatic review settings February 24, 2026 22:52
@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from 6771553 to ece1606 Compare February 24, 2026 22:52
Copy link
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 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
  • Psu trait methods return impl Future<...>, but this module doesn’t import core::future::Future (and it isn’t fully qualified), so this won’t compile. Add use core::future::Future; (or fully qualify core::future::Future in the trait signatures).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to +109
error!(
"Device{}: Invalid state for notify consumer capability, catching up: {:#?}",
device.id().0,
e,
);
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch 2 times, most recently from 4c37822 to c64f762 Compare February 24, 2026 23:09
Copilot AI review requested due to automatic review settings February 24, 2026 23:09
Copy link
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 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

  • Psu trait method signatures use Future, but this module doesn’t import core::future::Future (and it’s not in the Rust prelude). This will fail to compile unless Future is brought into scope or fully qualified. Add use core::future::Future; near the top (or change the signatures to core::future::Future).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-clean-up branch from c64f762 to 09f865b Compare February 25, 2026 00:43
@jerrysxie jerrysxie self-requested a review February 25, 2026 04:14
Copy link
Contributor

@jerrysxie jerrysxie left a comment

Choose a reason for hiding this comment

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

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" }
Copy link
Contributor

Choose a reason for hiding this comment

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

@asasine @tullom Any concern now that type-c-service depends directly on power-policy-service?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cargo vet PRs pending auditor review

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants