Skip to content

Add MMS association and report subscription runtime - #13

Merged
masarray merged 1 commit into
mainfrom
agent/mms-association-subscriptions
Aug 6, 2026
Merged

masarray merged 1 commit into
mainfrom
agent/mms-association-subscriptions

Conversation

@masarray

@masarray masarray commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Supersedes #12 after Phase 4A was squash-merged to main. This PR contains the same validated Phase 4B tree, rebuilt as one clean commit directly on top of the new main.

Scope

Phase 4B adds an application-injected MMS association lifecycle and IEC 61850 report subscription runtime above the merged Phase 4A offline reporting layer.

Association lifecycle

  • Add an MmsByteTransport abstraction with connection, send, receive, close, deadline, and cancellation semantics.
  • Establish TPKT/COTP CR/CC, negotiate TPDU size, then establish ISO Session, Presentation, ACSE, and MMS Initiate.
  • Track explicit disconnected, transport, COTP, ACSE, associated, closing, and faulted states with bounded event history.
  • Segment outgoing COTP data and perform bounded TPKT/COTP receive and reassembly.
  • Allocate monotonic invoke IDs and route confirmed responses/errors through the existing invoke router.
  • Preserve interleaved unconfirmed InformationReports while a confirmed request is pending.
  • Distinguish timeout and cancellation; timeout faults the association while cancellation remains caller-controlled.
  • Support explicit reconnect after disconnect or failure and best-effort lifecycle cleanup.

Report subscription runtime

  • Re-probe the target RCB immediately before any write.
  • Reject takeover when an RCB is enabled, reserved, caller-incompatible, or otherwise in use.
  • Reserve URCBs with Resv=true when required.
  • Optionally configure DatSet, TrgOps, and OptFlds before enabling.
  • Enable with RptEna=true and optionally issue GI.
  • Poll or run persistently with std::stop_token, feeding report bytes through the Phase 4A decoder and bounded monitor.
  • Stop by disabling RptEna and releasing only reservations acquired by this runtime.
  • Record cleanup_required when the association disappears before cleanup and support retry after reconnect.

Validation

  • Repository total: 16 CTest entries.
  • Local GCC and Clang warnings-as-errors: 16/16 passed.
  • Local Clang ASan/UBSan: 16/16 passed.
  • Previous stacked PR final-head GCC/Clang/MSVC, ASan/UBSan, and ten-corpus libFuzzer runs passed; this main-based PR reruns all gates on the cleaned history.

Safety boundary

The core library does not provide or automatically create a TCP socket backend. Live network and IED access is possible only when an application deliberately supplies an MmsByteTransport implementation. IEC 61850 control services, BRCB EntryID resume, purge, replay, and overflow recovery remain outside Phase 4B.

@masarray
masarray marked this pull request as ready for review August 6, 2026 10:01
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@masarray
masarray merged commit 73cb85c into main Aug 6, 2026
10 checks passed
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