Skip to content

CTT follow-up: monitored items, alarms, codecs, history, and model validation#4002

Merged
marcschier merged 28 commits into
masterfrom
copilot/ctt-run16-fixes
Jul 18, 2026
Merged

CTT follow-up: monitored items, alarms, codecs, history, and model validation#4002
marcschier merged 28 commits into
masterfrom
copilot/ctt-run16-fixes

Conversation

@marcschier

@marcschier marcschier commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #3978 based on the latest OPC UA CTT aggregate, matrix, Historical Access, Attribute, and Node Management runs.

Aggregate run 16

  • Ignore synthetic BadBoundNotFound raw-bound markers when feeding aggregate calculators.
  • Add direct and live historian regression coverage.

Multi-dimensional Variant matrices

  • Fix Variant.Copy() so rank-2 Variant matrices preserve their payload and dimensions.
  • Enforce valid Variant matrix dimensions consistently across Binary, JSON, XML stream, and XML parser codecs.
  • Encoders return BadEncodingError; decoders return BadDecodingError for malformed matrix dimensions.
  • Add cross-codec valid/null/empty/malformed tests and a batched ReferenceServer Read regression.
  • Correct the previous CTT issue attribution: the invalid Scalar_Static_Arrays2D_Variant server encoding poisoned the batched CTT Read.

Node Management AddNodes

  • Return BadNodeIdRejected for unsupported requested-NodeId namespaces.
  • Validate hierarchical ReferenceType source/target NodeClass constraints.
  • Document run-18 confirmation that all remaining 15 AddNodes errors are CTT project/script configuration issues.

Historical Access and Attribute Services run 18

  • Reject whitespace in NumericRange syntax with BadIndexRangeInvalid.
  • Add HistoryRead tests for operation-level invalid syntax and per-DataValue BadIndexRangeNoData.
  • Document CTT defects:
    • 012.js expects BadIndexRangeNoData at the operation level instead of on returned DataValues;
    • Err-012.js uses a non-historizing node for an access-denied test;
    • generic Attribute array helpers omit NodeId[] and StatusCode[] conversion paths.

Base Information model validation run 19

  • Run the CTT main session as sysadmin over Basic256Sha256 SignAndEncrypt so SecurityAdmin RolePermissions and EncryptionRequired restrictions are both satisfied without weakening the server model.
  • Preserve predefined well-known NodeIds while making generated dynamic type and optional-child factories allocate compatible per-instance NodeIds, remap internal references, and update references from the owning subtree.
  • Materialize dynamic RoleType properties through generated helpers and keep role-child string NodeIds disjoint from numeric RoleManager root IDs.
  • Add net48/net10 regressions for generator output, NodeId allocation/reference remapping, DI mandatory children, dynamic roles, and low-privilege versus SecurityAdmin Browse visibility.
  • Document CTT defects for permission-unaware mandatory-child validation, the UA 1.04 reference model used against a UA 1.05 server, stale ServerDiagnostics cache, and the ConformanceUnits scalar/array mismatch.

Related Issues

Checklist

  • I have signed the CLA and read the CONTRIBUTING document.
  • Tests prove the fixes and improve coverage.
  • Required CTT documentation is updated.
  • Focused builds/tests introduce no warnings.
  • Affected tests pass on .NET Framework and .NET 10.
  • CI and CodeQL are green.
  • All PR feedback is addressed.

Latest CTT full run and A&C run 20

  • Fix Monitor Value Change V2 036.js: an ambiguous DataValue(StatusCode) call encoded BadIndexRangeNoData as a Good value.
  • Prove all 19 configured matrix monitored items notify when the selected value actually changes; document the independent 042.js script defects.
  • Rebase dynamic CertificateExpired / TrustListOutOfDate alarm roots and descendants, restore standard type declarations and ModellingRules, and expose the cross-node-manager references.
  • Deliver method-triggered events to every authorized Session, fixing the two-Session Confirm scenario.
  • Preserve locale-only LocalizedText values consistently across Binary, JSON, and XML and align Acknowledge/Confirm comment behavior and tests.
  • Document the remaining proven CTT defects for TransactionDiagnostics, SemanticChange, History 013, PolicyId scope, A&C, durable subscriptions, and Subscription Minimum events.

Base synchronization

Merged master through 007cfaf90 (#4010, repository layout consolidation) and retained the matrix regression tests at their new tests/ locations.

Latest validation

  • Focused merged-tree tests pass on net10 and net48.
  • Opc.Ua.Server and Quickstarts.Servers Release builds complete with 0 warnings and 0 errors on net10 and net48.
  • The existing DisableEnableViaTypeAndInstanceMethodNoEventsDuringDisabledAsync timing test took its documented inconclusive timeout path after the layout merge; no test failure was reported.

marcschier and others added 7 commits July 13, 2026 21:24
Use the matrix accessor for Variant, Number, Integer, and UInteger matrix copies so the payload remains a shaped MatrixOf<Variant> instead of becoming a null ArrayOf<Variant> under matrix TypeInfo.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the server Variant copy corruption as the root cause of the batched CTT BadDecodingError and remove the unproven symmetric CTT codec claim.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record the D8, null-array, rank-one zero-dimension wire shape produced by the pre-fix Variant copy path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reject malformed Variant matrix dimensions consistently across binary, JSON, streaming XML, and XmlParser paths while preserving valid inline binary empty matrices. Add encoder/decoder regressions and net48-compatible cross-codec tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier marcschier changed the title CTT follow-up: aggregate bounds, matrix variants, and AddNodes validation CTT follow-up: aggregate bounds, matrix codecs, and AddNodes validation Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.98361% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.52%. Comparing base (007cfaf) to head (18d4b35).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/Opc.Ua.Server/NodeManager/MasterNodeManager.cs 73.33% 5 Missing and 7 partials ⚠️
...pc.Ua.Server/NodeManager/AsyncCustomNodeManager.cs 90.41% 2 Missing and 5 partials ⚠️
...Server/RoleBasedUserManagement/RoleStateBinding.cs 91.11% 1 Missing and 3 partials ⚠️
src/Opc.Ua.Types/State/NodeInstanceExtensions.cs 89.47% 1 Missing and 3 partials ⚠️
...rc/Opc.Ua.Server/Aggregates/AggregateCalculator.cs 66.66% 0 Missing and 2 partials ⚠️
...c.Ua.Server/Aggregates/CountAggregateCalculator.cs 88.88% 0 Missing and 1 partial ⚠️
...pc.Ua.Server/Diagnostics/DiagnosticsNodeManager.cs 0.00% 1 Missing ⚠️
src/Opc.Ua.Types/Encoders/BinaryDecoder.cs 85.71% 0 Missing and 1 partial ⚠️
src/Opc.Ua.Types/Encoders/XmlEncoder.cs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4002      +/-   ##
==========================================
- Coverage   73.72%   73.52%   -0.20%     
==========================================
  Files        1340     1345       +5     
  Lines      179309   179988     +679     
  Branches    31541    31668     +127     
==========================================
+ Hits       132188   132332     +144     
- Misses      36385    36955     +570     
+ Partials    10736    10701      -35     
Files with missing lines Coverage Δ
...a.Server/Configuration/ConfigurationNodeManager.cs 80.81% <100.00%> (+0.10%) ⬆️
....Server/NodeManager/MonitoredItem/MonitoredNode.cs 76.58% <100.00%> (+0.86%) ⬆️
src/Opc.Ua.Types/BuiltIn/DataValue.cs 98.19% <100.00%> (+0.21%) ⬆️
src/Opc.Ua.Types/BuiltIn/MatrixOf.cs 78.26% <100.00%> (+1.51%) ⬆️
src/Opc.Ua.Types/BuiltIn/NumericRange.cs 70.83% <100.00%> (-0.20%) ⬇️
src/Opc.Ua.Types/BuiltIn/Variant.cs 80.16% <100.00%> (-0.28%) ⬇️
src/Opc.Ua.Types/Encoders/BinaryEncoder.cs 92.62% <100.00%> (+0.05%) ⬆️
src/Opc.Ua.Types/Encoders/JsonDecoder.cs 83.38% <100.00%> (+0.04%) ⬆️
src/Opc.Ua.Types/Encoders/JsonEncoder.cs 84.51% <100.00%> (+0.09%) ⬆️
src/Opc.Ua.Types/Encoders/XmlDecoder.cs 72.60% <100.00%> (+0.48%) ⬆️
... and 11 more

... and 64 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

marcschier and others added 2 commits July 14, 2026 02:52
Cover the in-memory XmlParser decoder alongside the streaming XmlDecoder for malformed multi-dimensional Variant matrices (zero dimension and dimension/length product mismatch) plus a valid round-trip, and extract the shared malformed XML payloads into constants.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise the same decode path as the cross-codec conformance suite (DataValue-wrapped Variant matrix, streaming XmlParser constructor, ReadDataValue, XDocument dimension mutation) to prove XmlParser rejects malformed matrix dimensions with BadDecodingError in parity with XmlDecoder.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI requested a review from romanett July 14, 2026 04:15
Copilot stopped work on behalf of romanett due to an error July 14, 2026 04:15
…t root (#4001)

# Description

The CTT reference server config was incomplete for Historical Access of
array nodes and NodeManagement. This wires up historizing for
one-dimensional array nodes, fills in the corresponding CTT config
slots, and sets the NodeManagement root node.

## Changes

- **Historize array nodes** (`ReferenceNodeManager`): added
`HistoricalArrayNodeNames` (14 `Scalar_Static_Arrays_*` types matching
the historized scalar element types) to the
`EnableHistoryArchivingAsync` loop, so array nodes get `Historizing`,
HistoryRead/HistoryWrite access levels, a registered historian, seeded
history, and a `HistoricalDataConfigurationType` companion.
- **Array-aware seeding**: `SeedHistoricalNodeAsync` now branches on
`ValueRank`. Scalar seeding is factored into
`CreateHistoricalScalarValue` (behaviour unchanged, preserving
aggregate/CTT oracles); arrays use `CreateHistoricalArrayValue` to emit
per-sample typed arrays.
- **CTT config** (`UAReferenceServer.ctt.xml`):
- `HA Profile > Arrays` — populated Bool…UInt64 with their
`ns=2;s=Scalar_Static_Arrays_*` ids.
- `HA Profile > AccessRights` — mapped the six slots to non-historizing
`AccessRights_AccessAll_*` nodes.
  - `NodeManagement > RootNode` — set to `ns=2;s=CTT`.
- **New address-space node**: `AccessRights_AccessAll_NoAccess`
(`AccessLevel = None`) to back the `AccessLevel_None` access-rights
slot, which had no existing counterpart.
- **Tests**: added
`HistoryReadRawDataForArrayTypeReturnsSeededValuesAsync` covering raw
history reads across all historized array types, asserting Good status,
seeded values, and array-typed results.

## Related Issues

## Checklist

_Put an `x` in the boxes that apply. You can complete these step by step
after opening the PR._

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [ ] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <romanett98@gmail.com>
@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ marcschier
✅ romanett
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@marcschier
marcschier marked this pull request as ready for review July 14, 2026 06:36
Copilot AI review requested due to automatic review settings July 14, 2026 06:36

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.

Pull request overview

This PR is a CTT-driven conformance follow-up that hardens history aggregate behavior, multi-dimensional Variant (matrix) encoding/decoding across codecs, and AddNodes validation/routing, with accompanying regression tests and updated CTT project/documentation artifacts.

Changes:

  • Fix Variant matrix copying and enforce consistent matrix-dimension validation/BadEncodingError+BadDecodingError handling across Binary/JSON/XML codecs.
  • Treat BadBoundNotFound as a synthetic placeholder (not aggregate input) and add direct + live-historian regression tests.
  • Tighten AddNodes routing/status codes and reference NodeClass validation; expand ReferenceServer historized nodes and update CTT findings/config.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Tests/Opc.Ua.Types.Tests/Encoders/MatrixVariantCodecValidationTests.cs New targeted tests for matrix-dimension validation behavior across codecs.
Tests/Opc.Ua.Types.Tests/BuiltIn/VariantCoverageTests.cs Regression test ensuring Variant.Copy() preserves MatrixOf<Variant> shape/content.
Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs Batched Read regression ensuring a Variant matrix doesn’t break neighboring DataValues during binary encoding.
Tests/Opc.Ua.Server.Tests/NodeManager/MasterNodeManagerNodeManagementTests.cs AddNodes routing/validation regression coverage for requested NodeIds and reference constraints.
Tests/Opc.Ua.Server.Tests/NodeManager/AsyncCustomNodeManagerNodeManagementTests.cs Validates requested NodeId behavior when using an explicit namespace URI.
Tests/Opc.Ua.Server.Tests/AggregateRun14ResidualOracleTests.cs Adds oracle tests asserting BadBoundNotFound markers don’t affect key aggregates.
Tests/Opc.Ua.History.Tests/HistoricalAccessTests.cs Expands raw-history coverage to arrays/matrices/structures and validates mixed-quality seeding.
Tests/Opc.Ua.Core.Encoders.Tests/VariantMatrixConformanceTests.cs New cross-codec conformance tests for valid/empty/null/invalid matrix encodings.
Stack/Opc.Ua.Types/Encoders/XmlParser.cs Reject invalid matrix dimensions during XML parsing with BadDecodingError.
Stack/Opc.Ua.Types/Encoders/XmlEncoder.cs Prevent encoding invalid matrix dimensions (fail fast with BadEncodingError).
Stack/Opc.Ua.Types/Encoders/XmlDecoder.cs Enforce matrix-dimension validation and normalize invalid payloads to BadDecodingError.
Stack/Opc.Ua.Types/Encoders/JsonEncoder.cs Prevent encoding invalid matrix dimensions in UA JSON.
Stack/Opc.Ua.Types/Encoders/JsonDecoder.cs Validate matrix dimensions and normalize malformed matrices to BadDecodingError.
Stack/Opc.Ua.Types/Encoders/BinaryEncoder.cs Add matrix-dimension validation for Variant encoding (not raw-value encoding).
Stack/Opc.Ua.Types/Encoders/BinaryDecoder.cs Validate Variant matrix dimensions during binary decoding and reject malformed payloads.
Stack/Opc.Ua.Types/BuiltIn/Variant.cs Fix Variant.Copy() for Variant/Number/Integer/UInteger matrices to preserve matrix payload.
Stack/Opc.Ua.Types/BuiltIn/MatrixOf.cs Introduce shared IsValidMatrix helper for dimension validation.
plans/ctt-issues.md Update findings to reflect corrected root cause and reclassify remaining items pending rerun/evidence.
Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs Return BadNodeIdRejected for disallowed requested NodeIds; validate reference/nodeclass constraints; adjust owner selection.
Libraries/Opc.Ua.Server/Aggregates/AggregateCalculator.cs Ignore BadBoundNotFound placeholders when queuing aggregate raw input.
Applications/UAReferenceServer.ctt.xml Populate missing HA/access-rights node ids and RootNode slot for CTT project.
Applications/Quickstarts.Servers/ReferenceServer/ReferenceNodeManager.cs Historize array/matrix/structure nodes and seed deterministic mixed-quality history values.

Comment thread src/Opc.Ua.Types/Encoders/JsonDecoder.cs
Comment thread samples/Quickstarts.Servers/ReferenceServer/ReferenceNodeManager.cs
Comment thread Applications/Quickstarts.Servers/ReferenceServer/ReferenceNodeManager.cs Outdated
marcschier and others added 2 commits July 14, 2026 09:02
Make NumericRange parsing conform to the no-whitespace grammar and add HistoryRead regressions for invalid and out-of-range index ranges.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier marcschier changed the title CTT follow-up: aggregate bounds, matrix codecs, and AddNodes validation CTT follow-up: aggregates, matrix codecs, AddNodes, and history ranges Jul 14, 2026
@marcschier marcschier changed the title CTT follow-up: aggregates, matrix codecs, AddNodes, and history ranges CTT follow-up: aggregates, codecs, history, and model validation Jul 16, 2026
Comment thread src/Opc.Ua.Server/RoleBasedUserManagement/RoleStateBinding.cs
@marcschier marcschier added the ready Ready to merge once CI Passes label Jul 16, 2026
…ixes

# Conflicts:
#	tests/Opc.Ua.Core.Encoders.Tests/VariantMatrixConformanceTests.cs
#	tests/Opc.Ua.Types.Tests/Encoders/MatrixVariantCodecValidationTests.cs
@marcschier marcschier changed the title CTT follow-up: aggregates, codecs, history, and model validation CTT follow-up: monitored items, alarms, codecs, history, and model validation Jul 17, 2026
Comment thread src/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs Outdated
@romanett romanett removed the ready Ready to merge once CI Passes label Jul 17, 2026
@romanett romanett added the ready Ready to merge once CI Passes label Jul 17, 2026
@marcschier
marcschier merged commit 84fa8e8 into master Jul 18, 2026
163 checks passed
@marcschier
marcschier deleted the copilot/ctt-run16-fixes branch July 18, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants