Joseph Doherty
09252b8c79
feat(storage): add MsgBlock block-based message storage unit
...
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.
2026-02-24 12:21:33 -05:00
Joseph Doherty
17731e2af5
feat(storage): add binary message record encoding (Go parity)
...
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.
2026-02-24 12:12:15 -05:00
Joseph Doherty
3e972f217e
feat: add FileStore 6-way permutation tests (Go testFileStoreAllPermutations parity)
...
Port 20 tests across the {NoCipher, ChaCha, Aes} x {NoCompression, S2Compression}
matrix from Go's testFileStoreAllPermutations (filestore_test.go:55), yielding 120
total Theory executions in FileStorePermutationTests.cs.
Also fix PushFrame.Subject property missing compilation error that was blocking
the test build (JetStreamConsumerDeliveryEdgeTests.cs:119).
Tests covered (each runs 6x):
Store_and_load_basic TestFileStoreBasics:86
Store_multiple_messages_load_by_sequence TestFileStoreBasics:86
LoadLastBySubject_returns_most_recent_for_subject
Remove_single_message_updates_state TestFileStoreBasics:129
Purge_clears_all_messages TestFileStorePurge:710
TrimToMaxMessages_enforces_limit TestFileStoreMsgLimitBug:518
Block_rotation_when_exceeding_block_size TestFileStoreAndRetrieveMultiBlock:1527
GetState_returns_correct_counts TestFileStoreBasics:104
Snapshot_and_restore_round_trip TestFileStoreSnapshot:1799
ListAsync_returns_ordered_messages TestFileStoreTimeStamps:683
MaxAge_prunes_expired_messages TestFileStoreAgeLimit:616
Recovery_after_reopen_preserves_messages TestFileStoreBasicWriteMsgsAndRestore:181
Large_payload_store_and_load 64 KiB random payload variant
Multiple_subjects_filter_by_subject TestFileStoreBasics multi-subject
Sequential_writes_maintain_ordering TestFileStoreSelectNextFirst:304
Store_creates_files_on_disk disk-presence variant
Write_and_read_same_block TestFileStoreWriteAndReadSameBlock:1510
Stored_messages_have_non_decreasing_timestamps TestFileStoreTimeStamps:683
Remove_out_of_order_collapses_first_seq TestFileStoreCollapseDmap:1561
Snapshot_after_removes_preserves_remaining TestFileStoreSnapshot:1904
2026-02-24 06:43:48 -05:00
Joseph Doherty
9cc9888bb4
feat: add S2 compression and AEAD encryption for FileStore (Go parity)
...
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.
2026-02-24 06:29:34 -05:00
Joseph Doherty
2c9683e7aa
feat: upgrade JetStreamService to lifecycle orchestrator
...
Implements enableJetStream() semantics from golang/nats-server/server/jetstream.go:414-523.
- JetStreamService.StartAsync(): validates config, creates store directory
(including nested paths via Directory.CreateDirectory), registers all
$JS.API.> subjects, logs startup stats; idempotent on double-start
- JetStreamService.DisposeAsync(): clears registered subjects, marks not running
- New properties: RegisteredApiSubjects, MaxStreams, MaxConsumers, MaxMemory, MaxStore
- JetStreamOptions: adds MaxStreams and MaxConsumers limits (0 = unlimited)
- FileStoreConfig: removes duplicate StoreCipher/StoreCompression enum declarations
now that AeadEncryptor.cs owns them; updates defaults to NoCipher/NoCompression
- FileStoreOptions/FileStore: align enum member names with AeadEncryptor.cs
(NoCipher, NoCompression, S2Compression) to fix cross-task naming conflict
- 13 new tests in JetStreamServiceOrchestrationTests covering all lifecycle paths
2026-02-24 06:03:46 -05:00
Joseph Doherty
921554f410
feat: define StreamStore/ConsumerStore interfaces from Go store.go
...
Port IStreamStore, IConsumerStore, StoreMsg, StreamState, SimpleState,
ConsumerState, FileStoreConfig, StoreCipher, StoreCompression types.
Rename Models.StreamState → ApiStreamState to avoid namespace conflict.
2026-02-23 21:06:16 -05:00
Joseph Doherty
61b1a00800
feat: phase C jetstream depth test parity — 34 new tests across 7 subsystems
...
Stream lifecycle, publish/ack, consumer delivery, retention policy,
API endpoints, cluster formation, and leader failover tests ported
from Go nats-server reference. 1006 total tests passing.
2026-02-23 19:55:31 -05:00
Joseph Doherty
081ff1b0db
docs: synchronize strict full go parity evidence and status
2026-02-23 15:03:35 -05:00
Joseph Doherty
148ff9ebb6
feat: implement jetstream governance runtime parity semantics
2026-02-23 14:54:30 -05:00
Joseph Doherty
56177a7099
feat: enforce filestore durability and recovery invariants
2026-02-23 14:51:30 -05:00
Joseph Doherty
3896512f84
feat: complete jetstream mirror source strict runtime parity
2026-02-23 14:50:18 -05:00
Joseph Doherty
7bea35aaa8
feat: harden jetstream consumer state machine parity
2026-02-23 14:48:47 -05:00
Joseph Doherty
cdde3c7a1d
feat: implement strict retention runtime parity for jetstream
2026-02-23 14:47:24 -05:00
Joseph Doherty
377ad4a299
feat: complete jetstream deep operational parity closure
2026-02-23 13:43:14 -05:00
Joseph Doherty
2b64d762f6
feat: execute full-repo remaining parity closure plan
2026-02-23 13:08:52 -05:00
Joseph Doherty
b41e6ff320
feat: execute post-baseline jetstream parity plan
2026-02-23 12:11:19 -05:00
Joseph Doherty
8bce096f55
feat: complete final jetstream parity transport and runtime baselines
2026-02-23 11:04:43 -05:00
Joseph Doherty
f46b331921
feat: complete remaining jetstream parity implementation plan
2026-02-23 10:16:16 -05:00
Joseph Doherty
2aa7265db1
feat: enforce account jetstream limits and jwt tiers
2026-02-23 06:21:51 -05:00
Joseph Doherty
c87661800d
feat: add stream replica groups and leader stepdown
2026-02-23 06:17:30 -05:00
Joseph Doherty
23216d0a48
feat: integrate jetstream meta-group placement
2026-02-23 06:16:01 -05:00
Joseph Doherty
f1d3c19594
feat: add jetstream mirror and source orchestration
2026-02-23 06:10:41 -05:00
Joseph Doherty
d3aad48096
feat: enforce jetstream ack and redelivery semantics
2026-02-23 06:09:26 -05:00
Joseph Doherty
fecb51095f
feat: implement jetstream push delivery and heartbeat
2026-02-23 06:08:14 -05:00
Joseph Doherty
9a0de19c2d
feat: implement jetstream pull consumer fetch
2026-02-23 06:07:02 -05:00
Joseph Doherty
40b940b1fd
feat: add jetstream consumer api lifecycle
2026-02-23 06:06:02 -05:00
Joseph Doherty
6825839191
feat: add jetstream publish preconditions and dedupe
2026-02-23 06:05:01 -05:00
Joseph Doherty
d73e7e2f88
feat: enforce jetstream retention and limits
2026-02-23 06:04:23 -05:00
Joseph Doherty
95691fa9e7
feat: route publishes to jetstream with puback
2026-02-23 06:03:24 -05:00
Joseph Doherty
5f530de2e4
feat: add jetstream stream lifecycle api
2026-02-23 06:02:07 -05:00
Joseph Doherty
788f4254b0
feat: implement jetstream filestore recovery baseline
2026-02-23 06:00:42 -05:00
Joseph Doherty
64e3b1bd49
feat: implement jetstream memstore core behavior
2026-02-23 06:00:10 -05:00
Joseph Doherty
cae09f9091
feat: define jetstream storage interfaces
2026-02-23 05:59:39 -05:00
Joseph Doherty
d1935bc9ec
feat: add jetstream config validation models
2026-02-23 05:59:03 -05:00
Joseph Doherty
6d23e89fe8
feat: add jetstream api router and error envelope
2026-02-23 05:58:34 -05:00
Joseph Doherty
7fe15d7ce1
feat: add route propagation and bootstrap js gateway leaf services
2026-02-23 05:55:45 -05:00