Skip to content

Power policy event pass and clean-up#747

Open
RobertZ2011 wants to merge 12 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-event-refactor
Open

Power policy event pass and clean-up#747
RobertZ2011 wants to merge 12 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-event-refactor

Conversation

@RobertZ2011
Copy link
Contributor

@RobertZ2011 RobertZ2011 commented Mar 12, 2026

  • Add broadcasting power policy service events back
  • Introduce Named trait
  • Add provider tests
  • Add unconstrained logic test
  • General clean-up

@RobertZ2011 RobertZ2011 self-assigned this Mar 12, 2026
Copilot AI review requested due to automatic review settings March 12, 2026 21:23
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 1ff2ae6 to 5b931a9 Compare March 12, 2026 21:24
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

This PR reintroduces power-policy service event broadcasting and refactors naming by introducing a shared Named trait, updating PSU implementations accordingly, and adding/expanding tests to validate provider and unconstrained behavior.

Changes:

  • Add embedded_services::named::Named and update Psu to require Named instead of defining name() directly.
  • Add power-policy service event broadcasting via configurable event senders, plus introduce EventData for device-agnostic service events.
  • Add/expand power-policy service integration tests for consumer/provider/unconstrained flows.

Reviewed changes

Copilot reviewed 15 out of 22 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
type-c-service/src/wrapper/proxy.rs Implements Named for PowerProxyDevice to satisfy updated Psu: Named bound.
power-policy-service/tests/unconstrained.rs Adds unconstrained multi-device flow test using service event receiver assertions.
power-policy-service/tests/provider.rs Adds provider connection/upgrade behavior tests and validates service events.
power-policy-service/tests/consumer.rs Updates consumer tests to validate service-level events instead of only mock calls.
power-policy-service/tests/common/mod.rs Extends test harness to provide a service event channel/receiver and adds assertion helpers.
power-policy-service/tests/common/mock.rs Updates mock PSU simulation API and implements Named for the mock device.
power-policy-service/src/service/task.rs Updates task generics to support event broadcasting sender types.
power-policy-service/src/service/provider.rs Moves/expands provider disconnect handling into provider module and broadcasts provider events.
power-policy-service/src/service/mod.rs Adds event_senders and implements broadcast_event; updates detach/disconnect flows accordingly.
power-policy-service/src/service/consumer.rs Updates service impl generics and uses Named for logging.
power-policy-service/Cargo.toml Comment formatting tweak.
power-policy-interface/src/service/event.rs Adds EventData and From<Event> conversion; renames generics to PSU.
power-policy-interface/src/psu/mod.rs Changes Psu to extend Named and removes fn name() from Psu.
examples/std/src/bin/type_c/unconstrained.rs Updates power-policy service construction to pass event sender storage (currently discard).
examples/std/src/bin/type_c/ucsi.rs Updates power-policy service task signature and adds discard event sender storage.
examples/std/src/bin/type_c/service.rs Updates power-policy service construction to pass event sender storage (discard).
examples/std/src/bin/power_policy.rs Updates example PSU to implement Named and passes discard event sender storage.
examples/rt685s-evk/src/bin/type_c_cfu.rs Updates power-policy service task signature and adds discard event sender storage.
examples/rt685s-evk/src/bin/type_c.rs Updates power-policy service task signature and adds discard event sender storage.
embedded-service/src/named.rs Introduces Named trait.
embedded-service/src/lib.rs Exposes named module.
embedded-service/src/event.rs Adds DiscardSender and MapSender utilities for event sending pipelines.

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

You can also share your feedback on Copilot code review. Take the survey.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 5b931a9 to 50c4c4b Compare March 12, 2026 21:53
Copilot AI review requested due to automatic review settings March 12, 2026 22:00
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 50c4c4b to 44539e4 Compare March 12, 2026 22: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 15 out of 22 changed files in this pull request and generated 1 comment.


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

You can also share your feedback on Copilot code review. Take the survey.

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 15 out of 22 changed files in this pull request and generated 2 comments.


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

You can also share your feedback on Copilot code review. Take the survey.

kurtjd
kurtjd previously approved these changes Mar 16, 2026
@github-project-automation github-project-automation bot moved this to In progress in ODP Backlog Mar 17, 2026
@jerrysxie jerrysxie added the enhancement New feature or request label Mar 17, 2026
Copilot AI review requested due to automatic review settings March 17, 2026 17:49
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from f62040d to ec00c9d Compare March 17, 2026 17:56
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 17 out of 24 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

embedded-service/src/event.rs:15

  • Sender/Receiver use impl Future in their method signatures, but Future isn’t in scope in this module. This won’t compile unless you import core::future::Future (or fully qualify it as core::future::Future in the signatures).
//! Common traits for event senders and receivers

use core::marker::PhantomData;

use embassy_sync::channel::{DynamicReceiver, DynamicSender};

/// Common event sender trait
pub trait Sender<E> {
    /// Attempt to send an event
    ///
    /// Return none if the event cannot currently be sent
    fn try_send(&mut self, event: E) -> Option<()>;
    /// Send an event
    fn send(&mut self, event: E) -> impl Future<Output = ()>;
}

You can also share your feedback on Copilot code review. Take the survey.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from ec00c9d to 18d82b3 Compare March 17, 2026 18:07
Copilot AI review requested due to automatic review settings March 17, 2026 18:27
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 18d82b3 to 2fa818d Compare March 17, 2026 18:27
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 17 out of 24 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

embedded-service/src/event.rs:15

  • Future is referenced in the Sender/Receiver trait method signatures (and later impls) but isn’t imported or fully qualified in this file, which will fail to compile. Add use core::future::Future; (or qualify as core::future::Future) near the top.
/// Common event sender trait
pub trait Sender<E> {
    /// Attempt to send an event
    ///
    /// Return none if the event cannot currently be sent
    fn try_send(&mut self, event: E) -> Option<()>;
    /// Send an event
    fn send(&mut self, event: E) -> impl Future<Output = ()>;
}

You can also share your feedback on Copilot code review. Take the survey.

@RobertZ2011 RobertZ2011 requested review from jerrysxie and kurtjd March 17, 2026 19:22
Rename the current `'a` lifetime to `'device` for clarity. Introduce a
separate `device_storage` lifetime since a single lifetime
overconstrains things and can lead to situations where borrows live too
long and lead to issues with drops.
A receiver might only care that an event has happened and not what PSU
generated the event. Currently, such a receiver would have to be generic
over a PSU type that it never uses. Introduce `EventData` as a version
of `Event` for use in these cases. Also rename `D` generic argument to
`PSU` for clarity.
Add event broadcasting based on `Sender<_>` trait, a few utility
structs, and update tests to check broadcast events.
Rename to match corresponding registration struct.
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 2fa818d to 799b585 Compare March 18, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants