Skip to content

Change ElectricalComponentId from CID to ECID - #289

Merged
llucax merged 2 commits into
frequenz-floss:v0.x.xfrom
llucax:electrical-component-id-prefix
Sep 22, 2026
Merged

llucax merged 2 commits into
frequenz-floss:v0.x.xfrom
llucax:electrical-component-id-prefix

Conversation

@llucax

@llucax llucax commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

This is a long due update. It is hard because we've been using CID for a while now, but it is right because we now have electrical components and communication components, so CID is ambiguous.

@llucax
llucax requested a review from a team as a code owner September 21, 2026 12:49
@llucax
llucax requested review from Marenz and removed request for a team September 21, 2026 12:49
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:microgrid Affects the microgrid protobuf definitions labels Sep 21, 2026
@llucax
llucax marked this pull request as draft September 21, 2026 12:57
@llucax
llucax requested a balanced review from Copilot September 21, 2026 12:57
@llucax llucax self-assigned this Sep 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation, tests, documentation, and release notes consistently apply the collision-free prefix.

Review effort: Balanced
Findings: None

What changed in this PR

Updates ElectricalComponentId to use the distinct ECID display prefix, eliminating conflicts with deprecated ComponentId.

Changes:

  • Changes the prefix from CID to ECID.
  • Updates string-representation and import-order tests.
  • Documents the user-visible compatibility impact.
File Description
src/​.../​_ids.py Defines the new ECID prefix.
tests/​microgrid/​test_ids.py Tests prefix uniqueness and warning removal.
tests/​.../​test_problematic.py Updates component string expectations.
tests/​.../​test_problematic_connection.py Updates connection string expectations.
tests/​.../​test_inverter.py Updates inverter string expectation.
tests/​.../​test_ev_charger.py Updates charger string expectation.
tests/​.../​test_electrical_component_connection.py Updates connection string expectation.
tests/​.../​test_electrical_component_base.py Updates base component expectations.
tests/​.../​test_battery.py Updates battery string expectation.
RELEASE_NOTES.md Explains the display-only compatibility change.
docs/​user-guide/​typed-ids.md Documents the ECID prefix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

`ComponentId` (the deprecated v0.3.x compatibility class restored
in frequenz-floss#287) and `ElectricalComponentId` both claimed the `str_prefix`
"CID". Importing both triggered a `"Prefix 'CID' is already registered"`
warning from `frequenz-core`'s `BaseId`, and two objects with the same
numeric value would print identically (`CID42`) while comparing unequal
and hashing differently, a subtle correctness hazard.

The deprecated `ComponentId` keeps `CID` because that is its historical
representation and changing it would defeat the compatibility it
exists for. `ElectricalComponentId` moves to `ECID`.

The prefix is output-only: `BaseId` uses it in `__str__` and the
`str_prefix` property only. There is no parse-from-string path in
`BaseId`, and IDs cross the wire as plain integers. This cannot break
round-tripping, persistence or the protocol.

The import-order test that previously asserted the duplicate
prefix warning is updated to assert the warning is gone.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax force-pushed the electrical-component-id-prefix branch from 6b907b9 to ae3ecca Compare September 21, 2026 13:26
@llucax llucax changed the title Change ElectricalComponentId str_prefix from CID to ECID Change ElectricalComponentId from CID to ECID Sep 21, 2026
@llucax
llucax marked this pull request as ready for review September 21, 2026 13:28
@llucax
llucax enabled auto-merge September 21, 2026 13:28
@llucax
llucax disabled auto-merge September 22, 2026 08:23
@llucax
llucax added this pull request to the merge queue Sep 22, 2026
@llucax llucax added this to the v0.4.1 milestone Sep 22, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 66fb404 Sep 22, 2026
9 checks passed
@llucax
llucax deleted the electrical-component-id-prefix branch September 22, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:microgrid Affects the microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants