feat: port session 07 — Protocol Parser, Auth extras (TPM/certidp/certstore), Internal utilities & data structures

Session 07 scope (5 features, 17 tests, ~1165 Go LOC):
- Protocol/ParserTypes.cs: ParserState enum (79 states), PublishArgument, ParseContext
- Protocol/IProtocolHandler.cs: handler interface decoupling parser from client
- Protocol/ProtocolParser.cs: Parse(), ProtoSnippet(), OverMaxControlLineLimit(),
  ProcessPub/HeaderPub/RoutedMsgArgs/RoutedHeaderMsgArgs, ClonePubArg(), GetHeader()
- tests/Protocol/ProtocolParserTests.cs: 17 tests via TestProtocolHandler stub

Auth extras from session 06 (committed separately):
- Auth/TpmKeyProvider.cs, Auth/CertificateIdentityProvider/, Auth/CertificateStore/

Internal utilities & data structures (session 06 overflow):
- Internal/AccessTimeService.cs, ElasticPointer.cs, SystemMemory.cs, ProcessStatsProvider.cs
- Internal/DataStructures/GenericSublist.cs, HashWheel.cs
- Internal/DataStructures/SubjectTree.cs, SubjectTreeNode.cs, SubjectTreeParts.cs

All 461 tests pass (460 unit + 1 integration). DB updated for features 2588-2592 and tests 2598-2614.
This commit is contained in:
Joseph Doherty
2026-02-26 13:16:56 -05:00
parent 0a54d342ba
commit 88b1391ef0
56 changed files with 9006 additions and 6 deletions

View File

@@ -0,0 +1,50 @@
# Session 18: File Store
## Summary
The persistent file-based storage engine for JetStream. Handles message persistence, compaction, encryption, compression, and recovery. This is the largest single-file session.
## Scope
| Go File | Features | Feature IDs | Go LOC |
|---------|----------|-------------|--------|
| server/filestore.go | 312 | 9511262 | 11,421 |
| **Total** | **312** | | **11,421** |
## .NET Classes
- `JetStreamFileStore` — file-based stream store (174 features, 7,255 LOC)
- `MessageBlock` — individual message block on disk (95 features, 3,314 LOC)
- `ConsumerFileStore` — file-based consumer store (33 features, 700 LOC)
- `CompressionInfo` — compression metadata
- `ErrBadMsg` — bad message error type
## Test Files
| Test File | Tests | Test IDs |
|-----------|-------|----------|
| server/filestore_test.go | 249 | 351599 |
| **Total** | **249** | |
## Dependencies
- Session 01 (Foundation Types)
- Session 02 (Utilities)
- Session 17 (Store Interfaces)
## .NET Target Location
- `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/Storage/`
## Notes
- **This is a multi-sitting session** — 11.4K Go LOC and 249 tests
- Suggested sub-batching:
- **18a**: `MessageBlock` (95 features, 3.3K LOC) — the on-disk block format
- **18b**: `JetStreamFileStore` core (load, store, recover, compact) — ~90 features
- **18c**: `JetStreamFileStore` remaining (snapshots, encryption, purge) — ~84 features
- **18d**: `ConsumerFileStore` (33 features, 700 LOC)
- **18e**: Tests (249 tests)
- File I/O should use `FileStream` with `RandomAccess` APIs for .NET 10
- Encryption maps to `System.Security.Cryptography`
- S2/Snappy compression maps to existing NuGet packages