7.0 KiB
NATS Strict Full Go Parity Design
Date: 2026-02-23
Status: Approved
Scope: Identify and close all remaining NATS functionality gaps between Go and .NET using behavior-level parity (not limited to existing parity-table status), with required unit/integration test coverage and parity-doc synchronization.
1. Architecture and Scope Boundary
Closure model
Each parity capability closes only when all three are complete:
-
Behavior
The .NET runtime behavior matches Go contract semantics at protocol and subsystem level. -
Tests
Positive and edge/failure tests exist and fail on regression. -
Docs
differences.mdand parity artifacts reflect the validated behavior state.
Scope interpretation
This cycle treats remaining parity as capability-level and code-backed, not as a direct read of current table status alone. Existing contradictions between prose claims and observable implementation are treated as parity debt and are in scope.
Execution order
- Inter-server fabric semantics (routes/gateway/leaf, account-scoped interest/delivery)
- Auth/account/config/monitor operational semantics
- JetStream runtime state machines
- JetStream storage durability + RAFT/cluster governance
- MQTT protocol/transport parity beyond current baseline
- Documentation and evidence synchronization
2. Component Plan
A. Inter-server fabric parity
Primary files:
src/NATS.Server/NatsServer.cssrc/NATS.Server/Routes/RouteConnection.cssrc/NATS.Server/Routes/RouteManager.cssrc/NATS.Server/Gateways/GatewayConnection.cssrc/NATS.Server/Gateways/GatewayManager.cssrc/NATS.Server/LeafNodes/LeafConnection.cssrc/NATS.Server/LeafNodes/LeafNodeManager.cssrc/NATS.Server/Subscriptions/SubList.cs
Focus:
- account-correct remote delivery path (not global-only shortcuts)
- idempotent remote interest propagation under reconnect/duplicates
- durable reply-remap and loop-marker transparency rules
B. MQTT protocol parity
Primary files:
src/NATS.Server/Mqtt/MqttProtocolParser.cssrc/NATS.Server/Mqtt/MqttConnection.cssrc/NATS.Server/Mqtt/MqttListener.cssrc/NATS.Server/MqttOptions.cssrc/NATS.Server/Configuration/ConfigProcessor.cs
Focus:
- replace line-oriented pseudo protocol with byte-level MQTT packet parsing/writing
- implement connection/session/subscribe/publish acknowledgement contracts
- align MQTT auth/TLS/keepalive behavior with configured options
C. JetStream runtime parity
Primary files:
src/NATS.Server/JetStream/JetStreamService.cssrc/NATS.Server/JetStream/StreamManager.cssrc/NATS.Server/JetStream/ConsumerManager.cssrc/NATS.Server/JetStream/Consumers/AckProcessor.cssrc/NATS.Server/JetStream/Consumers/PullConsumerEngine.cssrc/NATS.Server/JetStream/Consumers/PushConsumerEngine.cssrc/NATS.Server/JetStream/MirrorSource/*
Focus:
- policy-divergent retention runtime behavior (
Limits/Interest/WorkQueue) - deterministic delivery/ack/backoff/replay/flow-control state-machine transitions
- mirror/source behavior under filters, transform, and cross-account paths
D. Storage + RAFT + governance parity
Primary files:
src/NATS.Server/JetStream/Storage/FileStore.cssrc/NATS.Server/JetStream/Storage/MemStore.cssrc/NATS.Server/Raft/RaftNode.cssrc/NATS.Server/Raft/RaftReplicator.cssrc/NATS.Server/Raft/RaftTransport.cssrc/NATS.Server/Raft/RaftSnapshotStore.cssrc/NATS.Server/JetStream/Cluster/JetStreamMetaGroup.cssrc/NATS.Server/JetStream/Cluster/StreamReplicaGroup.cs
Focus:
- durability invariants across restart/prune/recovery cycles
- term/quorum/next-index/snapshot/membership semantics with convergence behavior
- meta/replica governance actions reflected in committed state and routing outcomes
E. Operational parity surfaces
Primary files:
src/NATS.Server/Monitoring/MonitorServer.cssrc/NATS.Server/Monitoring/PprofHandler.cssrc/NATS.Server/Configuration/ConfigReloader.cssrc/NATS.Server/NatsOptions.cssrc/NATS.Server/Events/InternalEventSystem.cs
Focus:
- replace synthetic profiling behavior with parity-meaningful runtime profiling outputs
- close option-surface vs runtime-semantics drift for key advanced options
- align event/monitor behavior with capability claims
F. Documentation and evidence
Primary files:
differences.mddocs/plans/2026-02-23-jetstream-remaining-parity-map.mddocs/plans/2026-02-23-jetstream-remaining-parity-verification.md
Focus:
- remove contradictory parity claims
- ensure every claimed closure maps to concrete behavior and test evidence
3. Data Flow and Behavioral Contracts
- Inter-server delivery contract
- route/gateway/leaf inbound delivery resolves with correct account scope and permissions
- reply-remap and leaf-loop markers remain transport-internal and reversible
- remote interest convergence stays idempotent across reconnect churn
- MQTT protocol contract
- fixed-header/remaining-length packet framing must be valid on read/write paths
- QoS/session/ack transitions must be deterministic and stateful
- auth and account association must fail closed on invalid credentials or malformed packets
- JetStream stream contract
- retention modes diverge by runtime behavior, not only config parsing
- preconditions and policy guards execute before irreversible storage changes
- max-age/per-subject/dedupe behavior remains consistent under load and restart
- JetStream consumer contract
- deliver policy cursor initialization and progression are deterministic
- ack/redelivery/backoff/max-deliver transitions preserve monotonic pending/floor invariants
- push/pull flows maintain consistent flow-control and replay timing contracts
- Storage/RAFT/governance contract
- stream/store state invariants remain stable after prune/recovery/snapshot cycles
- commit visibility is quorum-gated with stale-term and mismatch handling
- governance actions (stepdown/placement/cluster forwarding) reflect committed consensus state
4. Error Handling, Testing Strategy, and Completion Gates
Error handling
- Preserve protocol-specific error surfaces across NATS, JetStream, and MQTT.
- Fail closed on account-scoping, authorization, and consensus-precondition violations.
- Prevent partial mutation on multi-step operations (publish+replicate, control+governance).
Testing strategy
- Test-first per capability batch (failing test first, then minimal implementation).
- Each capability requires positive + edge/failure coverage.
- Multi-node, transport, RAFT, and MQTT protocol semantics use integration tests; low-level state transitions use focused unit tests.
- No parity claim is accepted from docs-only or hook-only evidence.
Completion gates
- Capability closes only with Behavior + Tests + Docs complete.
- Full verification gate must pass:
- focused suites for each completed batch
dotnet test -v minimal
differences.mdmay only claim closure where behavior is demonstrably ported.- Deferred parity items are allowed only with explicit blocker rationale and observable evidence.