Skip to content

fix(dist): replace names OpenDSS cannot carry instead of writing them verbatim - #770

Merged
samtalki merged 1 commit into
eigenergy:mainfrom
MohamedNumair:dist/dss-safe-names
Nov 10, 2026
Merged

samtalki merged 1 commit into
eigenergy:mainfrom
MohamedNumair:dist/dss-safe-names

Conversation

@MohamedNumair

@MohamedNumair MohamedNumair commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Names from other formats can be free text, such as a CIM IdentifiedObject.name like Cable type A. The OpenDSS writer handled such names in two ways, and both broke the output:

  • Bus ids. A bus id containing a character the dss tokenizer splits on made validate_emission refuse the whole conversion: "bus Node 1 is ambiguous or not representable in DSS".
  • Every other name. It was written verbatim with an EMIT.DSS.VALUE_SUBSTITUTED "will not reparse identically" warning. For example linecode=Cable type A and New Load.House 1 = flat!, which OpenDSS (and PowerIO's own dss reader) cannot parse back.

The new powerio-dist/src/dss/write/safe_names.rs runs before writing and works on a copy of the network:

  • Each character name_breaks_dss rejects becomes _ (// becomes __): whitespace, ,, =, !, quotes, brackets, and . in a bus id.
  • When the result is already taken in the same dss class, a numeric suffix keeps names unique. Lines and switches share Line, shunts and capacitors share Capacitor, and matching ignores case.
  • It covers element, line code, bus, and circuit names, and every typed reference to them: bus fields, line.linecode, and ibr.control_profile.
  • Each replacement is reported as EMIT.DSS.VALUE_SUBSTITUTED: "line code cable type a, 4x70: name holds characters dss cannot carry in a token; written as Cable_type_A__4x70".
  • A network whose names are already safe is written from the original, with no copy.
  • validate_emission checks the network as written, so a bus id like Node 1 is no longer refused.

Native objects and extras are not rewritten. They carry dss text from a dss source, whose names are safe already. The model keeps its original names; only the deck changes.

Tests

  • free_text_names_write_a_dss_deck_that_reads_back (powerio-dist/tests/cim.rs) writes a synthetic CIM feeder with free text bus, line, line code, load, and source names to OpenDSS. It checks each replacement finding, reads the deck back with every element connected, and confirms a second write replaces nothing. It fails on main at the bus id refusal.
  • The writer's unit test unrepresentable_names_are_reported becomes unrepresentable_names_are_replaced_and_reported and pins the replacements in the deck text.
  • Two unit tests in safe_names.rs cover the substitution alphabet and suffixes on collision.
  • cargo test: 3404 passed, 0 failed. The conversion matrix baseline is unchanged: its fixtures have safe names.
  • cargo clippy -p powerio-dist --all-targets --all-features -- -D warnings: clean.

This is independent of #768 and #769. All three add tests at the end of powerio-dist/tests/cim.rs, so whichever merges later needs a one-line conflict resolution there.

… verbatim

Names from other formats can be free text (a CIM `IdentifiedObject.name`
such as `Cable type A`). OpenDSS output refused a network whose bus id held
a character the dss tokenizer splits on, and wrote any other such name
verbatim with a warning, into a deck that did not parse back: a line code
`Cable type A` became `linecode=Cable type A`.

The writer now works on a copy of the network in which each such name is
replaced before writing. Each character `name_breaks_dss` rejects becomes
`_`, with a numeric suffix when the result is already taken in the same
dss class (lines and switches share `Line`, shunts and capacitors share
`Capacitor`), in element, line code, bus, and circuit names and in every
typed reference: bus fields, `linecode`, and an IBR's control profile.
Each replacement is an `EMIT.DSS.VALUE_SUBSTITUTED` finding. A network
whose names are all safe is written from the original, without a copy.
The pre-emission validation checks the network as written.

A new test writes a CIM feeder with free text bus, line, line code, load,
and source names to OpenDSS, reads the deck back with every element
connected, and checks that a second write replaces nothing. The writer's
unit test for unrepresentable names now pins the replacements.

@frederikgeth frederikgeth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes on reviewed head a9785bf44d17a18db0b68ff41ceebeae239d3540 for one P2 collision in the new name allocation, attached inline. Fixed-dispatch IBRs emit into the same OpenDSS Generator class as ordinary generators, so they need shared name reservations.

Validation: 300 distribution unit tests passed (12 existing ignores), and all 45 CIM integration tests passed. A supplemental round-trip regression with a generator named a_b and a fixed-dispatch IBR named a b fails on this head: both emit as Generator.a_b, and reading the deck back returns one generator instead of two. The regression passes with shared generator/IBR name reservations. That local proof change was not committed or pushed.

Current hosted CI also has inherited BMOPF validation failures (PMD profile fields and unsupported network time series emission) and a stale Julia companion coverage failure for AC OTS entry points. Refresh and rerun the affected checks after the dependency repairs land. No other actionable code finding in this review's scope. No merge was performed.

samtalki added a commit that referenced this pull request Nov 9, 2026
The OpenDSS helper line nodes (#765), absent line ampacity (#762), names
OpenDSS cannot carry (#770), BMOPF provenance (#763), the libsqlite3-sys
advisory fix with the Rust 1.89 MSRV, and the dependency bumps ship in
0.11.10 before this candidate. The candidate section refers to that
release instead of restating them, and the 0.11.10 section is the one
main carries.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017y9wBpFumRrmQLvdxnVwZG
samtalki pushed a commit that referenced this pull request Nov 9, 2026
samtalki pushed a commit that referenced this pull request Nov 9, 2026
A fixed dispatch IBR writes as a dss Generator, so a renamed IBR could
take a generator's name and one of them would be lost (review of #770).
samtalki added a commit that referenced this pull request Nov 9, 2026
The OpenDSS helper line nodes (#765), absent line ampacity (#762), names
OpenDSS cannot carry (#770), BMOPF provenance (#763), the libsqlite3-sys
advisory fix with the Rust 1.89 MSRV, and the dependency bumps ship in
0.11.10 before this candidate. The candidate section refers to that
release instead of restating them, and the 0.11.10 section is the one
main carries.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017y9wBpFumRrmQLvdxnVwZG

samtalki commented Nov 9, 2026

Copy link
Copy Markdown
Member

This PR is folded into #821 through a9785bf44d17. The original commits and author attribution are retained; @MohamedNumair is credited in the RC description and changelog. It now targets main and will auto-close as merged when that included head reaches main through the release integration (some fixes land with #823 first). Please preserve a merge commit rather than squash/rebase. The RC ledger records scope and merge order; any later push here needs another ancestry check.

@samtalki
samtalki merged commit 32bb299 into eigenergy:main Nov 10, 2026
40 of 42 checks passed
samtalki added a commit that referenced this pull request Nov 11, 2026
samtalki added a commit that referenced this pull request Nov 11, 2026
A fixed dispatch IBR writes as a dss Generator, so a renamed IBR could
take a generator's name and one of them would be lost (review of #770).
samtalki added a commit that referenced this pull request Nov 11, 2026
The OpenDSS helper line nodes (#765), absent line ampacity (#762), names
OpenDSS cannot carry (#770), BMOPF provenance (#763), the libsqlite3-sys
advisory fix with the Rust 1.89 MSRV, and the dependency bumps ship in
0.11.10 before this candidate. The candidate section refers to that
release instead of restating them, and the 0.11.10 section is the one
main carries.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017y9wBpFumRrmQLvdxnVwZG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants