E4: AccountImportExport with DFS cycle detection for service imports,
RemoveServiceImport/RemoveStreamImport, and ValidateImport authorization.
E5: AccountLimits record with MaxStorage/MaxConsumers/MaxAckPending,
TryReserveConsumer/ReleaseConsumer, TrackStorageDelta on Account.
20 new tests, all passing.
- Consumer priority groups and pull timeout/filter mappings
- Route pool accounting and S2 compression mappings
- MQTT session persistence, QoS 2, and retained message mappings
- Total mapped: 924 → 938 of 2,937
Add MqttSessionStore with save/load/delete/list operations, flapper
detection (backoff on rapid reconnects), and TimeProvider-based testing.
Add MqttRetainedStore for per-topic retained messages with MQTT wildcard
matching (+/# filters). Add MqttQos2StateMachine tracking the full
PUBREC/PUBREL/PUBCOMP flow with duplicate rejection and timeout detection.
19 new tests: 9 session persistence, 10 QoS/retained message tests.
D2: Add FNV-1a-based ComputeRoutePoolIdx to RouteManager matching Go's
route.go:533-545, with PoolIndex on RouteConnection and account-aware
ForwardRoutedMessageAsync that routes to the correct pool connection.
D3: Replace DeflateStream with IronSnappy in RouteCompressionCodec, add
RouteCompressionLevel enum, NegotiateCompression, and IsCompressed
detection. 17 new tests (6 pool + 11 compression), all passing.
Ports the gateway interest-only mode from Go (gateway.go:100-150, 1500-1600):
- Add GatewayInterestTracker with Optimistic/Transitioning/InterestOnly modes
- In Optimistic mode, track no-interest set; switch to InterestOnly when set
exceeds threshold (default 1000, matching Go defaultGatewayMaxRUnsubThreshold)
- In InterestOnly mode, only forward subjects with tracked RS+ interest;
use SubjectMatch.MatchLiteral for wildcard pattern support
- Integrate tracker into GatewayConnection: A+/A- messages update tracker,
SendMessageAsync skips send when ShouldForward returns false
- Expose InterestTracker property on GatewayConnection for observability
- Add 13 unit tests covering all 8 specified behaviors plus edge cases
Adds OptsGoParityTests.cs with 49 tests porting 15 unmapped Go test
functions from server/opts_test.go: random port semantics, listen port
config variants, multiple users, authorization block parsing, options
defaults (TestDefaultSentinel), write_deadline parsing, path handling,
variable/env-var substitution chains, and unknown field tolerance.
Add MsgBlock write cache (mirrors Go's msgBlock.cache) to serve reads
for recently-written records without disk I/O; cleared on block seal via
RotateBlock. Add HashWheel-based TTL expiry in FileStore (ExpireFromWheel /
RegisterTtl), replacing the O(n) linear scan on every append with an
O(expired) wheel scan. Implement StoreMsg sync method with per-message TTL
override support. Add 10 tests covering cache hits/eviction, wheel expiry,
retention, StoreMsg seq/ts, per-msg TTL, and recovery re-registration.
Implement PurgeEx, Compact, Truncate, FilteredState, SubjectsState,
SubjectsTotals, State, FastState, GetSeqFromTime on FileStore. Add
MsgBlock.IsDeleted, DeletedSequences, EnumerateNonDeleted. Includes
wildcard subject support via SubjectMatch for all filtered operations.
Replace JSONL persistence with real MsgBlock-based block files (.blk).
FileStore now acts as a block manager that creates, seals, and rotates
MsgBlocks while maintaining an in-memory cache for fast reads/queries.
Key changes:
- AppendAsync writes transformed payloads to MsgBlock via WriteAt
- Block rotation occurs when active block reaches size limit
- Recovery scans .blk files and rebuilds in-memory state from records
- Legacy JSONL migration: existing messages.jsonl data is automatically
converted to block files on first open, then JSONL is deleted
- PurgeAsync disposes and deletes all block files
- RewriteBlocks rebuilds blocks from cache (used by trim/restore)
- InvalidDataException propagates during recovery (wrong encryption key)
MsgBlock.WriteAt added to support explicit sequence numbers and timestamps,
needed when rewriting blocks with non-contiguous sequences (after removes).
Tests updated:
- New FileStoreBlockTests.cs with 9 tests for block-specific behavior
- JetStreamFileStoreCompressionEncryptionParityTests updated to read
FSV1 magic from .blk files instead of messages.jsonl
- JetStreamFileStoreDurabilityParityTests updated to verify .blk files
instead of index.manifest.json
All 3,562 tests pass (3,535 passed + 27 skipped, 0 failures).
MsgBlock is the unit of storage in the file store — a single append-only
block file containing sequentially written binary message records. Blocks
are sealed (read-only) when they reach a configurable byte-size limit.
Key features:
- Write: appends MessageRecord-encoded messages with auto-incrementing
sequence numbers and configurable first sequence offset
- Read: positional I/O via RandomAccess.Read for concurrent reader safety
- Delete: soft-delete with on-disk persistence (re-encodes flags byte +
checksum so deletions survive recovery)
- Recovery: rebuilds in-memory index by scanning block file using
MessageRecord.MeasureRecord for record boundary detection
- Thread safety: ReaderWriterLockSlim allows concurrent reads during writes
Also adds MessageRecord.MeasureRecord() — computes a record's byte length
by parsing varint field headers without full decode, needed for sequential
record scanning during block recovery.
Reference: golang/nats-server/server/filestore.go:217-267 (msgBlock struct)
12 tests covering write, read, delete, seal, recovery, concurrency,
and custom sequence offsets.
Add MessageRecord class with Encode/Decode for the binary wire format
used in JetStream file store blocks. Uses varint-encoded lengths,
XxHash64 checksums, and a flags byte for deletion markers.
Go reference: filestore.go:6720-6724, 8180-8250, 8770-8777
13 tests covering round-trip, headers, checksum validation, corruption
detection, varint encoding, deleted flag, empty/large payloads.
50 tasks across 5 parallel tracks (A-E) with full TDD steps,
Go reference citations, file paths, and test_parity.db update
protocol. Task persistence file for session resumption.
test_parity.db contains go_tests (2,937 rows) and dotnet_tests
(2,966 rows) tables for querying Go-to-.NET test mapping across
Claude sessions. 857 mapped, 2,080 unmapped.
Research documents covering implementation gaps (structuregaps.md)
and full test function mapping (testmapping.md + CSV files) between
the Go NATS server and .NET port. 857/2937 Go tests mapped (29.2%),
2080 unmatched, 2966 .NET-only tests.
Adds 55 new tests across three files in a new Stress/ directory,
covering concurrent pub/sub SubList thread safety, slow consumer
detection under real NatsServer connections, and clustered JetStream
operations under concurrency. All tests carry [Trait("Category",
"Stress")] for selective execution. Go ref: norace_1_test.go,
norace_2_test.go.
Add 60 tests in JsClusterConsumerReplicationTests covering consumer
creation, fetch/delivery, ack tracking, leader failover, state
consistency, and edge cases. Ported from Go jetstream_cluster_2_test.go.
Adds two new test files covering Task 10 of the full Go parity plan:
JsClusterAdvancedTests.cs (27 tests):
- Large 7-node cluster with R5 stream
- Stream with 20+ subjects and wildcard '>' subject
- 1000-message publish to R3 and R1 streams
- Stream state accuracy after 1000 messages
- 10 streams with mixed replica counts
- Create/publish/delete/recreate cycle (3x)
- Consumer on 1000-message stream with batch fetch
- AckAll for all 1000 messages
- Stream info consistency after 50 interleaved ops
- Meta state after creating and deleting 10 streams
- 5 independent consumers with correct pending counts
- Consumer with wildcard filter subject
- Stream update adding subjects after publishes
- Stream purge then republish
- Fetch empty after purge
- Stream delete cascades consumer removal
- Node removal preserves data reads
- Node restart lifecycle markers
- Leader stepdown with monotonic sequence verification
- Stream info after stepdown with 1000 messages
JsClusterLongRunningTests.cs (15 tests, [Trait("Category", "LongRunning")]):
- 5000 messages in R3 stream maintain consistency
- 100 sequential fetches of 50 messages each
- 50 consumers on same stream all see all messages
- 20 streams in 5-node cluster all independent
- Publish-ack-fetch cycle 100 times
- 10 stepdowns during continuous publishing
- Alternating publish and stepdown (20 iterations)
- Create-publish-delete 20 streams sequentially
- Consumer ack tracking after 10 leader failovers
- Fetch with batch=1 iterated 500 times
- Mixed operations across 5 streams
- Rapid meta stepdowns (20) with version verification
- 10000 small messages in R1 stream
- Stream with max_messages=100 enforces limit after 1000 publishes
- Consumer on max-messages stream tracks correct pending
All 42 tests pass (27 advanced + 15 long-running).
Adds 97 tests across two new files covering stream replication semantics
(R1/R3 creation, replica group size, publish preservation, state accuracy,
purge, update, delete, max limits, subjects, wildcards, storage type) and
placement semantics (replica caps at cluster size, various cluster sizes,
concurrent creation, stepdown resilience, long names, re-create after delete).
Adds a unified JetStreamClusterFixture consolidating the capabilities of all 7
per-suite fixtures (ClusterFormationFixture, ClusterStreamFixture, LeaderFailoverFixture, etc.)
into a single reusable helper for Tasks 6-10. Includes new Go-parity helpers
(WaitOnStreamLeaderAsync, WaitOnConsumerLeaderAsync, GetConsumerLeaderId,
StepDownMetaLeader, SimulateNodeRestart, RemoveNode) matching jetstream_helpers_test.go.
27 smoke tests verify all capabilities pass.
Implements RaftSubjects static class with Go's $NRG.* subject constants
and NatsRaftTransport which routes RAFT RPCs over those subjects using
RaftAppendEntryWire / RaftVoteRequestWire encoding. 43 tests cover all
subject patterns, wire encoding fidelity, and transport construction.
Replace Deflate+XOR with IronSnappy S2 block compression and ChaCha20-Poly1305 / AES-256-GCM
AEAD encryption, matching golang/nats-server/server/filestore.go. Introduces FSV2 envelope
format alongside existing FSV1 for backward compatibility. Adds 55 new tests across
S2CodecTests, AeadEncryptorTests, and FileStoreV2Tests covering all 6 cipher×compression
permutations, tamper detection, and legacy format round-trips.
Bottom-up layered approach: implementation gaps first (RAFT transport,
JetStream orchestration, FileStore S2/crypto), then test ports across
3 phases targeting ~445 new tests for full Go behavioral parity.