Skip to content

P3-H P1: separate SV sampling and Ethernet frame cadence - #142

Merged
masarray merged 3 commits into
mainfrom
hardening/smv-p1-timing-semantics
Oct 6, 2026
Merged

masarray merged 3 commits into
mainfrom
hardening/smv-p1-timing-semantics

Conversation

@masarray

@masarray masarray commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Tracks #139 after merged #140 and #141.

Base: main@f3a107ec4cc4eca553ee467911c979afd057ce4d
Head: 213d31235b665556e339af82c147daa1ab4100b3

Purpose

Remove the remaining semantic ambiguity between sampling cadence and Ethernet publication cadence.

IEC 61850 SCL gives smpRate, smpMod and nofASDU; these are not one interchangeable "publisher rate". A stream may carry multiple consecutive ASDUs per Ethernet publication, so sample cadence and frame cadence must be represented independently.

Model

New SvPublicationTiming authority contains:

  • configured sampling basis: SmpPerSec / SmpPerPeriod / SecPerSample;
  • configured smpRate;
  • ASDUs per Ethernet frame;
  • optional nominal system frequency context;
  • rational samples/s;
  • rational frames/s;
  • explicit resolution state.

Rates remain exact rational values; no floating point or truncating scheduler inference is used in the engineering model.

Standards / interoperability behavior

  • omitted SCL smpMod compiles as the SCL default SmpPerPeriod;
  • SmpPerPeriod remains Class B until nominal frequency is explicitly supplied;
  • 80 samples/period + 50 Hz resolves to 4000 sample/s;
  • 80 samples/period + 60 Hz resolves to 4800 sample/s;
  • 256 samples/period + 8 ASDUs/frame @ 50 Hz resolves to 12800 sample/s and 1600 frames/s;
  • 4800 sample/s + 2 ASDUs/frame resolves to 2400 frames/s;
  • 14400 sample/s + 6 ASDUs/frame resolves to 2400 frames/s;
  • SecPerSample is represented as a rational cadence rather than guessed or rejected by the host semantic model.

Device boundary remains narrow

This does not expand the ESP32-P4 runtime claim.

classify_esp32p4_sv_profile() still requires:

  • SmpPerSec;
  • one ASDU/frame;
  • integral bounded frame rate;
  • current proven 4I+4V / 64-byte layout;
  • explicit counter modulus.

Thus host semantics become broader while deployment remains fail-closed.

Compatibility

Studio and the CLI preserve the existing publisherRate / publisherRateHz compatibility key, but it is now derived from frame cadence, not copied from smpRate.

The profile/inspection schema moves to v2 and additionally exposes rational sample/frame-rate metadata.

Explicit resolution path

Class B is no longer treated as synonymous with an unresolved counter.

  • Studio exposes nominal system frequency only when an SmpPerPeriod profile has unresolved timing.
  • Counter-modulus confirmation remains a separate control and appears only when counter policy is unresolved.
  • The CLI accepts --nominal-frequency-hz N; no 50/60 Hz value is inferred from a vendor, filename, or profile shape.
  • Studio displays configured Sampling and derived Frames separately so engineers can see ASDUs/frame instead of one ambiguous rate.

Tests

Regression coverage includes:

  • 4800 / 1 ASDU;
  • 4800 / 2 ASDU;
  • 14400 / 6 ASDU;
  • explicit and omitted SmpPerPeriod;
  • 50/60 Hz nominal-frequency resolution;
  • 256 SPC / 8 ASDU legacy measurement shape;
  • SecPerSample rational cadence.

Non-goals

No multi-ASDU ESP packet builder, no multi-stream scheduler, no new IEC 61869-9 conformance claim, and no runtime wire protocol change in this PR.

Next node after this is accepted: profile-family authority + explicit device compilation from the timing model.

Introduce an explicit rational timing model for sampling basis, configured sample rate, ASDUs per Ethernet frame, samples/s and frames/s. Honor SmpPerPeriod as the SCL default, represent SecPerSample without guessing, keep legacy Studio bridge keys derived from the new authority, and keep the current ESP32-P4 target fail-closed to its proven SmpPerSec/one-ASDU boundary. Tracks #139.
Allow Studio and the inspector CLI to supply nominal system frequency explicitly, keep counter confirmation independent, surface sample/frame cadence separately in the UI, and add explicit sampleRateHz/frameRateHz outputs while preserving publisherRate compatibility aliases. Tracks #139.
Accept both current SecPerSample and legacy SecPerSmp engineering tokens as the same seconds-per-sample semantic, add regression coverage, and keep CLI fatal-error JSON on schema v2. Tracks #139.
@masarray
masarray marked this pull request as ready for review October 6, 2026 14:11
@masarray
masarray merged commit 67cf57e into main Oct 6, 2026
37 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T14:12:50.730213Z 175de44 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant