Skip to content

[Server] Add live NodeManager lifecycle support#4015

Closed
marcschier wants to merge 13 commits into
OPCFoundation:masterfrom
marcschier:copilot/3993-live-node-manager-lifecycle
Closed

[Server] Add live NodeManager lifecycle support#4015
marcschier wants to merge 13 commits into
OPCFoundation:masterfrom
marcschier:copilot/3993-live-node-manager-lifecycle

Conversation

@marcschier

@marcschier marcschier commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds supported live add, reload, and remove lifecycle operations for NodeManager instances on a running server.

The change introduces a DI-backed INodeManagerLifecycle service with direct StandardServer access, generation-aware registration handles, copy-on-write routing, transactional prepare/commit/rollback, runtime NodeSet convenience APIs, append-only namespace updates, model and semantic change notifications, additive-compatible complex type priming, and complete teardown behavior.

Lifecycle publication is coordinated with requests, sessions, subscriptions, monitored items, continuation points, and shutdown so retired managers cannot remain reachable or be disposed while still in use. Compatible monitored items transfer to replacement generations without a transient bad status. Removed or incompatible Nodes publish BadNodeIdUnknown as required by OPC UA Part 4 §5.8.4.1, retain their MonitoredItem identity, and automatically recover when a compatible Node with the same NodeId returns.

Validation

  • Full Opc.Ua.Server.Tests on net10.0: 3,666 passed, 5 skipped.
  • Monitored-item and lifecycle focused suites: 148 passed on net10.0 and 148 passed on net48.
  • NativeAOT publish and execution: 115 passed.
  • Changed-line patch coverage: 80.31%.
  • Server builds complete with zero warnings or errors.

Related Issues

Checklist

  • I have signed the CLA and read the CONTRIBUTING doc.
  • 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.
  • 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.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.07035% with 1091 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.56%. Comparing base (16dd14f) to head (b177a09).

Files with missing lines Patch % Lines
...rver/NodeManager/Lifecycle/NodeManagerLifecycle.cs 74.79% 284 Missing and 54 partials ⚠️
src/Opc.Ua.Server/NodeManager/MasterNodeManager.cs 76.59% 140 Missing and 29 partials ⚠️
src/Opc.Ua.Server/NodeManager/CustomNodeManager.cs 63.55% 103 Missing and 26 partials ⚠️
...pc.Ua.Server/NodeManager/AsyncCustomNodeManager.cs 76.13% 86 Missing and 30 partials ⚠️
.../Opc.Ua.Server/Subscription/SubscriptionManager.cs 80.10% 59 Missing and 15 partials ⚠️
...MonitoredItem/MonitoredNodeMonitoredItemManager.cs 64.56% 26 Missing and 19 partials ⚠️
src/Opc.Ua.Server/Subscription/Subscription.cs 71.33% 32 Missing and 11 partials ⚠️
...nitoredItem/QueueHandler/DataChangeQueueHandler.cs 80.31% 29 Missing and 8 partials ⚠️
...MonitoredItem/SamplingGroupMonitoredItemManager.cs 70.75% 16 Missing and 15 partials ⚠️
...Server/Subscription/MonitoredItem/MonitoredItem.cs 87.68% 11 Missing and 14 partials ⚠️
... and 10 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4015      +/-   ##
==========================================
- Coverage   79.93%   79.56%   -0.38%     
==========================================
  Files        1472     1479       +7     
  Lines      199317   203958    +4641     
  Branches    34537    35273     +736     
==========================================
+ Hits       159330   162283    +2953     
- Misses      27849    29348    +1499     
- Partials    12138    12327     +189     
Files with missing lines Coverage Δ
...er/ComplexTypes/AddressSpaceComplexTypeResolver.cs 94.81% <100.00%> (+0.32%) ⬆️
...pc.Ua.Server/Hosting/HostedNodeManagerLifecycle.cs 100.00% <100.00%> (ø)
....Ua.Server/Hosting/OpcUaServerBuilderExtensions.cs 70.58% <100.00%> (+0.11%) ⬆️
...r/NodeManager/Lifecycle/IDynamicNodeManagerHost.cs 100.00% <100.00%> (ø)
...r/NodeManager/Lifecycle/NodeManagerRegistration.cs 100.00% <100.00%> (ø)
...untimeNodeSet/RuntimeNodeSetLifecycleExtensions.cs 100.00% <100.00%> (ø)
src/Opc.Ua.Server/Session/Session.cs 74.23% <100.00%> (+0.09%) ⬆️
...Opc.Ua.Server/Session/SessionContinuationPoints.cs 98.62% <100.00%> (+0.19%) ⬆️
src/Opc.Ua.Types/Nodes/TypeTable.cs 98.55% <100.00%> (+0.38%) ⬆️
.../Opc.Ua.Server/Hosting/OpcUaServerHostedService.cs 76.92% <87.50%> (+0.35%) ⬆️
... and 19 more

... and 50 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
marcschier force-pushed the copilot/3993-live-node-manager-lifecycle branch from 6f48473 to a2f1ee8 Compare July 18, 2026 13:33
@marcschier
marcschier requested a review from Copilot July 19, 2026 04:46

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

Adds first-class, supported runtime lifecycle operations for server NodeManagers (add/reload/remove) and integrates them with request tracking, session/subscription safety, continuation points, and runtime NodeSet + complex-type refresh paths.

Changes:

  • Introduces INodeManagerLifecycle plus supporting host/registration/routing infrastructure to safely publish, replace, and retire NodeManagers at runtime.
  • Coordinates live mutations with request execution, session closing, subscription deletion, monitored-item ownership checks, and continuation-point invalidation.
  • Expands runtime NodeSet support (including live reload/remove) and updates tests + docs to cover the new behavior.

Reviewed changes

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

Show a summary per file
File Description
tests/Opc.Ua.Types.Tests/Nodes/TypeTableTests.cs Adds coverage for TypeTable subtype reparenting behavior.
tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Adds lifecycle-focused subscription tests (session closing / deletion / ownership).
tests/Opc.Ua.Server.Tests/RuntimeNodeSet/RuntimeNodeSetTestServer.cs Exposes NodeSet test stream helper for wider test reuse.
tests/Opc.Ua.Server.Tests/RequestManagerTests.cs Adds tests for request snapshot draining semantics.
tests/Opc.Ua.Server.Tests/NodeManager/NodeManagerRoutingTableTests.cs New concurrency/snapshot tests for copy-on-write routing table.
tests/Opc.Ua.Server.Tests/Hosting/OpcUaServerHostedServiceCoverageTests.cs Updates coverage tests for hosted lifecycle dependency.
tests/Opc.Ua.Aot.Tests/HostingAotTests.cs Ensures INodeManagerLifecycle resolves in AOT scenarios.
src/Opc.Ua.Types/Nodes/TypeTable.cs Fixes subtype reparenting + encoding bookkeeping when updating entries.
src/Opc.Ua.Server/Subscription/SubscriptionManager.cs Adds deletion/closing coordination to support safe live NodeManager mutations.
src/Opc.Ua.Server/Subscription/Subscription.cs Adds monitored-item ownership tracking and mutation coordination hooks.
src/Opc.Ua.Server/Subscription/ISubscriptionDeletionRegistry.cs New internal contract for “subscription is deleting” checks.
src/Opc.Ua.Server/Session/SessionContinuationPoints.cs Adds targeted continuation-point invalidation for a NodeManager.
src/Opc.Ua.Server/Session/Session.cs Implements continuation-point invalidation hook for lifecycle.
src/Opc.Ua.Server/Session/ISessionClosingRegistry.cs New internal contract to reject work during session closing.
src/Opc.Ua.Server/Server/StandardServer.cs Wires lifecycle provider + request scoping + complex-type refresh path.
src/Opc.Ua.Server/Server/ServerInternalData.cs Tracks closing sessions and exposes registry to other components.
src/Opc.Ua.Server/Server/RequestManager.cs Adds validation/request scopes and snapshot draining for safe teardown.
src/Opc.Ua.Server/RuntimeNodeSet/RuntimeNodeSetNodeManager.cs Adds reload participation and reference retention for runtime NodeSets.
src/Opc.Ua.Server/RuntimeNodeSet/RuntimeNodeSetLifecycleExtensions.cs Adds convenience lifecycle extensions for runtime NodeSets.
src/Opc.Ua.Server/NugetREADME.md Documents live add/reload/remove usage via lifecycle API.
src/Opc.Ua.Server/NodeManager/MasterNodeManager.cs Implements dynamic NodeManager hosting + mutation coordination.
src/Opc.Ua.Server/NodeManager/Lifecycle/NodeManagerRoutingTable.cs New copy-on-write routing + visibility snapshots for manager dispatch.
src/Opc.Ua.Server/NodeManager/Lifecycle/NodeManagerRegistration.cs Adds generation-aware registration handle type.
src/Opc.Ua.Server/NodeManager/Lifecycle/INodeManagerReloadParticipant.cs Defines reload participant contract for safe replacement.
src/Opc.Ua.Server/NodeManager/Lifecycle/INodeManagerMutationCoordinator.cs Adds coordinator interface for mutation serialization.
src/Opc.Ua.Server/NodeManager/Lifecycle/INodeManagerMonitoredItemTracker.cs Adds contract to detect monitored-item ownership by manager.
src/Opc.Ua.Server/NodeManager/Lifecycle/INodeManagerLifecycle.cs Public API for add/reload/remove + registration snapshot.
src/Opc.Ua.Server/NodeManager/Lifecycle/INodeManagerContinuationPointTracker.cs Adds contract to invalidate manager-owned continuation points.
src/Opc.Ua.Server/NodeManager/Lifecycle/IDynamicNodeManagerHost.cs Internal host contract for staged prepare/commit/rollback lifecycle.
src/Opc.Ua.Server/NodeManager/CustomNodeManager.cs Improves teardown bookkeeping (type ownership, external refs, events).
src/Opc.Ua.Server/NodeManager/AsyncCustomNodeManager.cs Async counterpart teardown bookkeeping improvements.
src/Opc.Ua.Server/Hosting/OpcUaServerHostedService.cs Attaches/detaches hosted lifecycle to server instance.
src/Opc.Ua.Server/Hosting/OpcUaServerBuilderExtensions.cs Registers hosted lifecycle provider in DI.
src/Opc.Ua.Server/Hosting/HostedNodeManagerLifecycle.cs Adds DI-facing forwarding lifecycle implementation.
src/Opc.Ua.Server/ComplexTypes/ServerComplexTypeSystem.cs Adds “additional NodeManager” complex-type load path for pre-publish.
src/Opc.Ua.Server/ComplexTypes/AddressSpaceComplexTypeResolver.cs Allows resolving types from a prepared (not-yet-published) manager.
docs/SourceGeneratedNodeManagers.md Updates runtime NodeSet guidance to include live lifecycle.
docs/RuntimeNodeSets.md Documents live lifecycle semantics and APIs for runtime NodeSets.
docs/DependencyInjection.md Documents INodeManagerLifecycle DI surface and usage.
docs/ComplexTypes.md Updates complex-type documentation for live lifecycle behavior.

Comment thread src/Opc.Ua.Server/Subscription/SubscriptionManager.cs Outdated
@marcschier
marcschier force-pushed the copilot/3993-live-node-manager-lifecycle branch from a2f1ee8 to 2afe352 Compare July 19, 2026 21:39
@marcschier
marcschier marked this pull request as ready for review July 21, 2026 09:17
@marcschier marcschier added the needs changes PR needs more changes label Jul 23, 2026
…ode-manager-lifecycle

# Conflicts:
#	src/Opc.Ua.Server/NodeManager/MasterNodeManager.cs
@marcschier marcschier removed the needs changes PR needs more changes label Jul 23, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29378426-2a98-41ee-9a6d-050af5b1141f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29378426-2a98-41ee-9a6d-050af5b1141f
@marcschier

Copy link
Copy Markdown
Collaborator Author

Superseded by #4094 after migrating the head branch into the OPCFoundation upstream repository. The upstream branch is commit-for-commit and tree-identical to this PR head at \�177a094ef.

@marcschier marcschier closed this Jul 25, 2026
@marcschier
marcschier deleted the copilot/3993-live-node-manager-lifecycle branch July 25, 2026 07:12
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.

[Server] Runtime NodeSet: add/reload/remove NodeManager instances on a running server

2 participants