Skip to content

pkg: one version number for .pio.json - #269

Open
samtalki wants to merge 8 commits into
mainfrom
pio-json-version-collapse
Open

pkg: one version number for .pio.json#269
samtalki wants to merge 8 commits into
mainfrom
pio-json-version-collapse

Conversation

@samtalki

Copy link
Copy Markdown
Member

Stacked on #264 (worktree-bmopf-schema-010); review the last commit only. Merging #264 first collapses this diff to the versioning change. A same-named PowerIO.jl companion branch carries the constant mirror for the tandem CI.

A .pio.json file carried four version identifiers: schema and payload_schema (URLs, written and never read) and schema_version / payload_schema_version (both gated on major equality, which is vacuous while every version has major 0). The file is a regenerable snapshot only powerio reads back, so the reader's whole versioning job is telling the caller when a file needs regenerating. That takes one number.

  • schema_version (now 0.2.0) covers the whole document, model JSON included. While the major is 0 an incompatible change bumps the minor and additive changes bump the patch; the reader accepts exactly its own major.minor lineage and rejects anything else with an error naming the lineage and saying to regenerate from the source case. Files written by 0.7.x and earlier get that error.
  • schema, payload_schema, and payload_schema_version are gone from the wire form and the removed fields read back as ignorable unknowns. The PIO_PACKAGE_SCHEMA_URL and PIO_PAYLOAD_* constants are gone from the API.
  • One published schema document: pio-package/0.2/schema.json, which embeds every model type. The three pio-payload-* documents are deleted (the multiconductor /1 copy was already orphaned: nothing generated it and the reader rejected files declaring it).
  • This replaces the pio-payload-multiconductor/2 (2.0.0) payload bump dist: BMOPF schema 0.1.0 alignment #264 introduced: the DistBus wire change is covered by the 0.2.0 document bump instead.

The remaining powerio-authored wire versions (SCOPF Julia wire at 1.0.0, dist capabilities at 1.0.0, summary and arrow catalog integers) are a follow-up issue.

🤖 Generated with Claude Code

samtalki and others added 4 commits July 22, 2026 17:41
Track bmopf-report PR #16 (schema 0.1.0): meta case_study_generator +
frequency, uppercase load model enum, per-sequence bus voltage bounds
replacing the vsym arrays (multiconductor payload bumps to /2, 2.0.0),
lumped three phase transformer series impedance referred per winding
rating, transformer taps/neutral/no-load and the IBR, control profile,
DC, and time series tables relocated under the extras escape hatch, a
typed capacitor element, inline line impedance via a synthesized
linecode, line i_max/s_max, and one-triangle symmetric matrix mirroring
on read. The reader keeps accepting every pre-0.1.0 spelling.

The vendored schema and example networks track bmopf-report@f2e3684; a
regen_bmopf_examples example rebuilds the checked-in outputs. Grounded
terminals now count as referenced in the unused-terminal prune, so
standalone grounding survives a write.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review follow-up on the BMOPF 0.1.0 alignment: the new DistLine
i_max/s_max fields wrote BMOPF but vanished silently through the dss and
PMD writers, against the fidelity policy.

- The PMD ENGINEERING line has its own cm_ub/sm_ub slots, so the line
  ratings now map both directions: the reader takes line-level
  cm_ub/sm_ub into the typed fields (an inline-impedance line's ratings
  stay on the synthesized linecode, whose sm_ub now re-inlines alongside
  cm_ub), and the writer emits them back.
- The dss writer warns when it drops line i_max/s_max; the
  normamps/emergamps mapping decision stays with #266.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPB7LVTeMcdBYnzA9QdpPe
A PMD source spells an unbounded phase as JSON null, which restores as
Inf in the model; the writer's num zero fallback then turned "no limit"
into a zero limit. Line and switch i_max/s_max now go through a bounds
guard that drops the field with a warning when any entry is nonfinite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPB7LVTeMcdBYnzA9QdpPe
schema_version (0.2.0) covers the whole document, model JSON included.
The reader accepts exactly its own lineage (major.minor while the major
is 0) and rejects anything else with an error that says to regenerate
from the source case. The schema URL field, payload_schema,
payload_schema_version, the PIO_PAYLOAD_* constants, and the published
payload schema documents are gone; pio-package/0.2/schema.json embeds
every model type and is the one published document.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 18:36
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Conversion Matrix

Legend

Cells show X/Y: observed warnings / expected warnings. Counts include source parse, target write, and target readback.

  • 🟢 0/0: no warnings and checked invariants held.
  • 🟡 X=Y: observed warnings match the reviewed expected count, and that count is nonzero.
  • 🔴 X!=Y or invariant failure: behavior changed. If warnings decreased because fidelity improved, update the expected counts in the same PR.
  • Expected counts are the *_WARNING_BASELINE arrays in powerio-cli/tests/conversion_matrix_report.rs; accept an intentional change by editing the matching source/target entry in the same PR.

Transmission

7 cases.

Source ↓ / target → MATPOWER .m PowerModels JSON PSS/E .raw PowerWorld .aux egret JSON pandapower JSON Surge JSON PSLF .epc
MATPOWER .m 🟢 0/0 🟢 0/0 🟡 8/8 🟡 8/8 🟢 0/0 🟡 5/5 🟢 0/0 🟡 11/11
PowerModels JSON 🟡 6/6 🟢 0/0 🟡 14/14 🟡 14/14 🟡 1/1 🟡 11/11 🟡 24/24 🟡 16/16
PSS/E .raw 🟡 13/13 🟡 1/1 🟢 0/0 🟡 1/1 🟡 1/1 🟡 3/3 🟡 1/1 🟡 10/10
PowerWorld .aux 🟡 12/12 🟢 0/0 🟢 0/0 🟢 0/0 🟢 0/0 🟡 2/2 🟢 0/0 🟡 5/5
egret JSON 🟢 0/0 🟢 0/0 🟡 8/8 🟡 8/8 🟢 0/0 🟡 5/5 🟢 0/0 🟡 11/11
pandapower JSON 🟡 6/6 🟢 0/0 🟡 11/11 🟡 11/11 🟡 5/5 🟢 0/0 🟢 0/0 🟡 11/11
Surge JSON 🟡 2/2 🟡 2/2 🟡 10/10 🟡 10/10 🟡 2/2 🟡 7/7 🟡 2/2 🟡 17/17
PSLF .epc 🟡 17/17 🟡 5/5 🟡 5/5 🟡 5/5 🟡 5/5 🟡 7/7 🟡 5/5 🟡 8/8
DeepMind OPFData JSON 🟡 3/3 🟡 2/2 🟡 5/5 🟡 5/5 🟡 3/3 🟡 4/4 🟡 2/2 🟡 4/4

Distribution

7 cases.

Source ↓ / target → OpenDSS .dss BMOPF JSON PMD JSON
OpenDSS .dss 🟢 0/0 🟡 132/132 🟡 80/80
BMOPF JSON 🟡 18/18 🟢 0/0 🟡 27/27
PMD JSON 🟡 15/15 🟡 59/59 🟢 0/0

Full warning details: download conversion-matrix-warning-details for this workflow run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 consolidates .pio.json versioning to a single schema_version covering the entire document (including the model payload) and updates the distribution (BMOPF/PMD/DSS) converters and fixtures to BMOPF schema 0.1.0 conventions, including new/relocated fields and schema publication changes.

Changes:

  • Replace the previous envelope+payload version identifiers with one .pio.json schema_version (now 0.2.0) and enforce “same lineage” compatibility on read (exact 0.<minor>.x while major is 0).
  • Remove payload-schema declarations/constants from powerio-pkg, update docs/tests, and publish a single embedded schema document (pio-package/0.2) instead of separate payload schema docs.
  • Align powerio-dist BMOPF/PMD/DSS read/write paths and fixtures with BMOPF schema 0.1.0 (e.g., load model casing, bus bound fields, transformer overflow handling, inline line impedance and ratings, typed capacitors, one-triangle matrix mirroring).

Reviewed changes

Copilot reviewed 35 out of 38 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/tests/test_package.py Updates Python package JSON assertions to the single schema_version and absence of payload schema fields.
powerio-pkg/tests/roundtrip.rs Adjusts roundtrip/version-gate tests to the single-version lineage rule and removes payload schema assertions.
powerio-pkg/src/package.rs Removes schema/payload-schema fields, introduces 0.2.0 document versioning + lineage gate, updates error message semantics.
powerio-pkg/src/model.rs Updates model payload documentation to reflect single document versioning.
powerio-pkg/src/lowering.rs Updates multiconductor bus bound field checks to new per-sequence scalar names.
powerio-pkg/src/lib.rs Removes re-exports of deleted schema URL/version constants.
powerio-pkg/examples/generate_schemas.rs Switches schema generation to a single published pio-package/0.2 schema document embedding payload types.
powerio-dist/tests/rich.rs Updates BMOPF load voltage model string expectations to schema 0.1.0 casing.
powerio-dist/tests/pmd.rs Adds/updates PMD rating roundtrip coverage (cm_ub/sm_ub) and inline impedance behavior.
powerio-dist/tests/matrix.rs Makes distribution conversion harness tolerant of DSS/PMD terminal renumbering and DSS load-profile flattening; improves idempotence checks.
powerio-dist/tests/bmopf.rs Updates BMOPF fixture validation expectations, adds one-triangle matrix mirroring test, updates canonicalization/idempotence rules.
powerio-dist/src/pmd/write.rs Writes line-level ratings to ENGINEERING (cm_ub/sm_ub) and warns on dropped typed capacitors.
powerio-dist/src/pmd/read.rs Reads ENGINEERING line-level ratings and preserves inline ratings on synthesized linecodes.
powerio-dist/src/model.rs Adds BMOPF 0.1.0 fields (bus sequence bounds, line i_max/s_max) and introduces typed DistCapacitor.
powerio-dist/src/lib.rs Re-exports new DistCapacitor.
powerio-dist/src/dss/write.rs Adds capacitor-drop warnings and warns that line i_max/s_max are currently dropped pending mapping decision.
powerio-dist/src/dss/read.rs Initializes new DistLine rating fields as absent on DSS read.
powerio-dist/src/bmopf/write.rs Updates $schema and meta block fields, relocates schema-less tables under extras, emits new fields, and adds nonfinite-bound handling.
powerio-dist/src/bmopf/read.rs Adds extras-table ingestion, transformer overflow merge, one-triangle matrix mirroring, inline-linecode synthesis, and capacitor parsing.
powerio-dist/examples/regen_bmopf_examples.rs Adds a helper to regenerate checked-in BMOPF example outputs.
powerio-dist/examples/bmopf/ieee34.json Regenerates BMOPF example output to updated schema/meta/model conventions.
powerio-dist/examples/bmopf/4bus_dy.json Regenerates BMOPF example output to updated schema/meta/model conventions.
powerio-dist/docs/conversion-matrix.md Updates warning-count matrix documentation to reflect new behavior/baselines.
powerio-cli/tests/conversion_matrix_report.rs Updates distribution conversion warning baselines with explanatory note for schema 0.1.0 changes.
powerio-cli/tests/cli.rs Updates CLI package test to assert schema_version instead of schema URL.
powerio-cli/src/main.rs Updates CLI packaging smoke test to look for schema_version in output.
powerio-capi/src/lib.rs Updates C-ABI tests/comments to align package versioning with schema_version only.
docs/src/pio-json-schema.md Updates .pio.json format docs to single-version pio-package/0.2 policy and removes payload-schema tier discussion.
docs/src/compiler-ir.md Updates compiler IR docs to reflect single-version .pio.json rules.
docs/schema/pio-payload-multiconductor/1/schema.json Removes the standalone multiconductor payload schema document from the repo.
docs/schema/pio-package/0.2/schema.json Updates the published embedded schema for 0.2 (new fields, removed properties, new $id).
CHANGELOG.md Adds an Unreleased entry describing single-version .pio.json and BMOPF 0.1.0 alignment changes.
.github/workflows/docs.yml Updates docs site navigation and redirect generation to only publish pio-package/0.2 schema identifier pages.
Comments suppressed due to low confidence (1)

docs/schema/pio-package/0.2/schema.json:4886

  • docs/schema/pio-package/0.2/schema.json still contains a ModelPayload description that refers to the removed payload_schema / payload_schema_version fields. This makes the published schema docs inconsistent with the new “one version number” design; please regenerate/update the schema JSON so the embedded descriptions don’t mention fields that no longer exist.

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

Comment on lines 310 to 318
for (key, value) in doc {
let Value::Object(items) = value else {
continue;
};
match key.as_str() {
"bus" => self.buses(items),
"linecode" => self.linecodes(items),
"line" => self.lines(items),
"switch" => self.switches(items),
Copilot AI review requested due to automatic review settings July 23, 2026 18:41
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 35 out of 38 changed files in this pull request and generated no new comments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown

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 36 out of 39 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

python/powerio/mcp/server.py:236

  • powerio_pkg::NetworkPackage accepts .pio.json documents that omit schema_version (it defaults on read), but _package_value() currently requires schema_version to be present and a string. That makes MCP transport sniffing reject otherwise-valid package JSON and can misroute it through the non-package JSON classifier.

Consider treating schema_version as optional here (validate its type only when present) while still requiring model_kind and model.kind.

Comment on lines 165 to 170
pub struct NetworkPackage {
/// The schema URL identifying this package format.
#[serde(default = "default_schema_url")]
pub schema: String,
/// The package schema version (semver).
/// The `.pio.json` format version (semver); see
/// [`PIO_PACKAGE_SCHEMA_VERSION`]. Absent fields default to the current
/// version, so a hand-built document without it reads under current rules.
#[serde(default = "default_schema_version")]
pub schema_version: String,
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown

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 37 out of 40 changed files in this pull request and generated 1 comment.

Comment on lines +381 to +389
fn assert_maps_eq(x: &[String], y: &[String], what: &str, ctx: &str) {
if x == y {
return;
}
assert!(
target_renumbers_terminals(what) && x.len() == y.len(),
"{what}: {ctx} {x:?} vs {y:?}"
);
}
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