Files
natsnet/docs/plans/2026-02-27-batch-22-monitoring-implementation-plan.md
Joseph Doherty dc3e162608 Add batch plans for batches 13-15, 18-22 (rounds 8-11)
Generated design docs and implementation plans via Codex for:
- Batch 13: FileStore Read/Query
- Batch 14: FileStore Write/Lifecycle
- Batch 15: MsgBlock + ConsumerFileStore
- Batch 18: Server Core
- Batch 19: Accounts Core
- Batch 20: Accounts Resolvers
- Batch 21: Events + MsgTrace
- Batch 22: Monitoring

All plans include mandatory verification protocol and anti-stub guardrails.
Updated batches.md with file paths and planned status.
2026-02-27 15:43:14 -05:00

633 lines
24 KiB
Markdown

# Batch 22 Monitoring Implementation Plan
> **For Codex:** REQUIRED SUB-SKILL: Use `executeplan` to implement this plan task-by-task.
**Goal:** Port and verify Batch 22 (`Monitoring`) by implementing 70 deferred monitoring features from `server/monitor.go` and replacing/validating 29 mapped deferred tests with real behavioral assertions.
**Architecture:** Implement monitoring runtime in domain-focused `NatsServer` partial files (`Connz`, `Route/Sub`, `Varz`, `Gateway/Leaf`, `Account/JSz`, `Health/Raft`) and keep monitor DTO/sort/query helpers in `Monitor/*`. Execute in six feature groups (each <=20 IDs), then run mapped test waves and only promote `complete -> verified` once all related tests pass.
**Tech Stack:** .NET 10, C# latest, xUnit 3, Shouldly, NSubstitute, PortTracker CLI, SQLite (`porting.db`)
**Design doc:** `docs/plans/2026-02-27-batch-22-monitoring-design.md`
---
## Batch 22 Scope
- Batch ID: `22`
- Name: `Monitoring`
- Dependencies: `18`, `19`
- Go source: `golang/nats-server/server/monitor.go`
- Features: `70`
- Tests: `29`
Reference commands (run before starting work):
```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 22 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch list --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db
```
Primary production files:
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.Connz.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.RouteSub.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.Varz.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.GatewayLeaf.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.AccountJsz.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.HealthRaft.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorSortOptions.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/ClientTypes.cs`
Primary mapped test files:
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/AccountTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/EventsHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamJwtTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/ConfigReloaderTests.Impltests.cs`
---
## MANDATORY VERIFICATION PROTOCOL
> **NON-NEGOTIABLE:** Every Batch 22 feature and mapped test must follow this protocol.
### Per-Feature Verification Loop (REQUIRED for every feature ID)
1. Read feature metadata and Go implementation first:
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature show <feature_id> --db porting.db
# then inspect monitor.go around go_line_number/go_line_count
```
2. Write the mapped C# behavior in the target file only (no placeholders).
3. Build immediately after each feature (or tight pair of coupled features):
```bash
dotnet build dotnet/
```
4. Run the smallest related test filter immediately:
```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ \
--filter "FullyQualifiedName~MonitoringHandlerTests|FullyQualifiedName~RouteHandlerTests|FullyQualifiedName~LeafNodeHandlerTests|FullyQualifiedName~AccountTests|FullyQualifiedName~EventsHandlerTests|FullyQualifiedName~JetStreamJwtTests|FullyQualifiedName~ConfigReloaderTests"
```
5. Keep feature ID in `complete-candidate` only if build and related tests are green.
6. If red, fix before moving on. Do not stack unresolved failures.
### Stub Detection Check (REQUIRED after every feature group and test wave)
Run these checks before any status promotion:
```bash
# Feature/test placeholder detector
grep -R -n -E "(NotImplementedException|TODO|PLACEHOLDER|Assert\.True\(true\)|throw new Exception\(\"TODO\"\))" \
dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring*.cs \
dotnet/src/ZB.MOM.NatsNet.Server/Monitor/*.cs \
dotnet/src/ZB.MOM.NatsNet.Server/ClientTypes.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/AccountTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/EventsHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamJwtTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/ConfigReloaderTests.Impltests.cs
# Empty-body detector (features)
grep -R -n -E "^[[:space:]]*(public|internal|private|protected)[^{;=]*\)[[:space:]]*\{[[:space:]]*\}$" \
dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring*.cs \
dotnet/src/ZB.MOM.NatsNet.Server/Monitor/*.cs
# Fake-test detector for known placeholder pattern in ImplBacklog files
grep -R -n -E "var goFile = \"server/|ShouldContain\(\"Should\"\)|ShouldNotBeNullOrWhiteSpace\(\);[[:space:]]*$" \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/AccountTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/EventsHandlerTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamJwtTests.Impltests.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/ConfigReloaderTests.Impltests.cs
```
Any new hit must be fixed or deferred with explicit reason.
### Build Gate (REQUIRED after each feature group)
```bash
dotnet build dotnet/
```
`Build succeeded` is mandatory before moving any feature IDs in that group to `complete`.
### Test Gate (REQUIRED before marking any features verified)
All related test classes must pass before any Batch 22 feature moves `complete -> verified`:
```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.MonitoringHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.RouteHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.LeafNodeHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.AccountTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.EventsHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.JetStreamJwtTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.ConfigReloaderTests"
```
No feature may be `verified` while these related tests fail or remain placeholder-style.
### Status Update Protocol (REQUIRED)
- Max `15` IDs per `feature batch-update` or `test batch-update` command.
- Required progression:
- `deferred/not_started -> stub` when active work starts.
- `stub -> complete` only after stub checks + group build gate.
- `complete -> verified` only after full related test gate passes.
- Evidence required before each status chunk:
- successful build output,
- successful related test output,
- clean stub scan output,
- explicit list of IDs being updated.
Example (feature chunk <=15):
```bash
dotnet run --project tools/NatsNet.PortTracker -- \
feature batch-update --ids "2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178" \
--set-status complete --db porting.db --execute
```
### Checkpoint Protocol Between Tasks (REQUIRED)
After each major task (every feature group and every test wave):
```bash
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/
git add dotnet/src/ZB.MOM.NatsNet.Server dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db
git commit -m "<task checkpoint message>"
```
---
## ANTI-STUB GUARDRAILS (NON-NEGOTIABLE)
### Forbidden Patterns
For Batch 22 mapped features and tests, these are forbidden:
- `throw new NotImplementedException()`
- Empty method bodies for mapped features
- `// TODO`, `// PLACEHOLDER`, or temporary fake logic in mapped methods
- Trivial default-return stubs for non-trivial behavior (`return null`, `return 0`, `return false`, `return string.Empty`)
- Placeholder test bodies that do not execute Batch 22 production code
- Literal/self assertions used as fake test pass criteria (for example `"...".ShouldContain("Should")`)
- Placeholder signature pattern `var goFile = "server/..."` without real Arrange/Act/Assert on production code
### Hard Limits
- Maximum `~20` features per implementation task group
- Maximum `15` IDs per status-update command
- One active feature-group status cycle at a time (start, implement, gate, update)
- Zero tolerance for unresolved stub-scan hits in touched files
- Mandatory checkpoint (build + test + commit) between tasks
### If You Get Stuck (REQUIRED)
1. Stop on the blocked feature/test ID immediately.
2. Remove any partial placeholder code; do not keep a stub.
3. Mark as deferred with explicit blocker reason:
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature update <id> --status deferred --override "blocked: <specific reason>" --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- test update <id> --status deferred --override "blocked: <specific reason>" --db porting.db
```
4. Continue with next unblocked ID.
5. Do not write fake-pass tests to bypass blockers.
---
## Feature Groups (<=20 IDs each)
### Group 1 (13 IDs): Connz foundations and query decode
`2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178`
Scope focus:
- `newSubsDetailList`, `newSubsList`
- `Connz` core + `ConnInfo.fill`
- query decode helpers (`decodeBool`, `decodeUint64`, `decodeInt`, `decodeState`, `decodeSubs`)
- `/connz` handler
### Group 2 (9 IDs): Route/Sub/stack/ipqueue monitoring
`2179,2180,2181,2182,2183,2184,2185,2186,2187`
Scope focus:
- `Routez`, `Subsz`, sub detail projections
- `/routez`, `/subsz`, `/stacksz`, `/ipqueuesz` handlers
### Group 3 (11 IDs): Varz core and root-level metadata
`2188,2189,2190,2191,2192,2193,2194,2195,2196,2197,2198`
Scope focus:
- uptime and TLS helper projections
- root endpoint output
- varz creation and reload/runtime update paths
- `/varz` handler
### Group 4 (10 IDs): Gateway monitor projections and handlers
`2199,2200,2201,2202,2203,2204,2205,2206,2207,2208`
Scope focus:
- gateway monitor options and inbound/outbound projections
- `/gatewayz` handler
### Group 5 (13 IDs): Leaf/Account monitor surfaces and detail projections
`2209,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221`
Scope focus:
- `Leafz`, `AccountStatz`, `Accountz`
- response helper wrappers (`ResponseHandler`, `handleResponse`)
- `ClosedState.String`
- account import/export/detail projections (`newExtServiceLatency`, `newExtImport`, `accountInfo`, `accountDetail`)
### Group 6 (14 IDs): JSz, healthz, expvar/profile, raftz
`2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235`
Scope focus:
- `JszAccount`, `Jsz`, `/jsz`
- health type serialization and `/healthz` internals
- `/debug/vars` and profile reporting
- `/raftz` endpoint and aggregation
---
## Mapped Test Waves (29 IDs)
### Wave 1 (13 IDs): MonitoringHandlerTests
`2064,2087,2090,2092,2093,2112,2117,2120,2121,2143,2150,2157,2165`
Target file:
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs`
Execution notes:
- Replace placeholder methods with real endpoint behavior assertions.
- `Benchmark_*` mapped entries must still assert measurable behavior in deterministic unit-test style if kept as tests; if they must remain benchmark-only, keep deferred with explicit reason.
### Wave 2 (16 IDs): Cross-class monitor dependencies
`89,318,1393,1394,1930,1964,1980,1981,1982,2004,2772,2815,2831,2837,2851,2857`
Target files:
- `AccountTests.Impltests.cs`
- `EventsHandlerTests.Impltests.cs`
- `JetStreamJwtTests.Impltests.cs`
- `LeafNodeHandlerTests.Impltests.cs`
- `ConfigReloaderTests.Impltests.cs`
- `RouteHandlerTests.Impltests.cs`
Execution notes:
- Validate each test still maps to Batch 22 features (`Connz`, `Routez`, `Subsz`, `Varz`, `Leafz`, `Accountz`, `Jsz`, `profilez`) and rewrite assertions around those paths.
---
## Task 1: Preflight and Batch Start
**Files:**
- Read: `docs/standards/dotnet-standards.md`
- Read: `docs/plans/2026-02-27-batch-22-monitoring-design.md`
- Read: `golang/nats-server/server/monitor.go`
**Step 1: Confirm scope and dependencies**
```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 22 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch list --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db
```
**Step 2: Start batch**
```bash
dotnet run --project tools/NatsNet.PortTracker -- batch start 22 --db porting.db
```
**Step 3: Baseline gate**
```bash
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/
```
**Step 4: Commit checkpoint**
```bash
git add porting.db
git commit -m "chore(batch22): start monitoring batch"
```
---
## Task 2: Implement Feature Group 1 (13 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.Connz.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorSortOptions.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 13 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 3: Implement Feature Group 2 (9 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.RouteSub.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2179,2180,2181,2182,2183,2184,2185,2186,2187" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 9 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2179,2180,2181,2182,2183,2184,2185,2186,2187" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 4: Implement Feature Group 3 (11 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.Varz.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2188,2189,2190,2191,2192,2193,2194,2195,2196,2197,2198" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 11 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2188,2189,2190,2191,2192,2193,2194,2195,2196,2197,2198" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 5: Implement Feature Group 4 (10 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.GatewayLeaf.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2199,2200,2201,2202,2203,2204,2205,2206,2207,2208" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 10 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2199,2200,2201,2202,2203,2204,2205,2206,2207,2208" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 6: Implement Feature Group 5 (13 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.AccountJsz.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/ClientTypes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2209,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 13 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2209,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 7: Implement Feature Group 6 (14 IDs)
**Files:**
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring.HealthRaft.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Monitor/MonitorTypes.cs`
**Step 1: Move IDs to `stub`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235" --set-status stub --db porting.db --execute
```
**Step 2: Execute Per-Feature Verification Loop for all 14 IDs**
**Step 3: Run Stub Detection Check + Build Gate**
**Step 4: Move IDs to `complete`**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235" --set-status complete --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 8: Implement Test Wave 1 (MonitoringHandler class)
**Files:**
- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs`
**Mapped IDs:**
- `2064,2087,2090,2092,2093,2112,2117,2120,2121,2143,2150,2157,2165`
**Step 1: Move IDs to `stub` (max 15, one command valid)**
```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2064,2087,2090,2092,2093,2112,2117,2120,2121,2143,2150,2157,2165" --set-status stub --db porting.db --execute
```
**Step 2: Rewrite each mapped test with real Arrange/Act/Assert behavior**
**Step 3: Run class filter and stub checks**
```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.MonitoringHandlerTests"
```
**Step 4: Move passing IDs to `verified`; keep blocked IDs deferred with reason**
```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "<passing IDs, max 15>" --set-status verified --db porting.db --execute
# for blocked IDs:
dotnet run --project tools/NatsNet.PortTracker -- test update <id> --status deferred --override "blocked: <reason>" --db porting.db
```
**Step 5: Run Checkpoint Protocol**
---
## Task 9: Implement Test Wave 2 (Cross-class mapped tests)
**Files:**
- Modify: `AccountTests.Impltests.cs`
- Modify: `EventsHandlerTests.Impltests.cs`
- Modify: `JetStreamJwtTests.Impltests.cs`
- Modify: `LeafNodeHandlerTests.Impltests.cs`
- Modify: `ConfigReloaderTests.Impltests.cs`
- Modify: `RouteHandlerTests.Impltests.cs`
**Mapped IDs:**
- `89,318,1393,1394,1930,1964,1980,1981,1982,2004,2772,2815,2831,2837,2851,2857`
**Step 1: Move IDs to `stub` in chunks <=15**
```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "89,318,1393,1394,1930,1964,1980,1981,1982,2004,2772,2815,2831,2837,2851" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2857" --set-status stub --db porting.db --execute
```
**Step 2: Rewrite mapped tests with real production assertions**
**Step 3: Run per-class filters + related endpoint filters**
```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~AccountTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~EventsHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~JetStreamJwtTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~LeafNodeHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ConfigReloaderTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~RouteHandlerTests"
```
**Step 4: Move passing IDs to `verified`, defer blocked IDs with reason**
```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "<passing IDs chunk 1, max 15>" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "<passing IDs chunk 2, max 15>" --set-status verified --db porting.db --execute
```
**Step 5: Run Checkpoint Protocol**
---
## Task 10: Promote Features to Verified (After Test Gate)
**Files:**
- Modify: `porting.db`
**Step 1: Run full related test gate (all seven classes)**
**Step 2: Promote features `2166-2235` from `complete` to `verified` in chunks <=15**
```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2179,2180" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2181,2182,2183,2184,2185,2186,2187,2188,2189,2190,2191,2192,2193,2194,2195" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2196,2197,2198,2199,2200,2201,2202,2203,2204,2205,2206,2207,2208,2209,2210" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "2226,2227,2228,2229,2230,2231,2232,2233,2234,2235" --set-status verified --db porting.db --execute
```
**Step 3: Checkpoint Protocol**
---
## Task 11: Final Batch 22 Closure
**Files:**
- Modify: `porting.db`
- Generate: `reports/current.md` (via script)
**Step 1: Full regression and final stub audit**
```bash
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/
grep -R -n -E "(NotImplementedException|TODO|PLACEHOLDER|Assert\.True\(true\)|var goFile = \"server/|ShouldContain\(\"Should\"\))" \
dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Monitoring*.cs \
dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog
```
**Step 2: Validate tracker state**
```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 22 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch complete 22 --db porting.db
```
**Step 3: Generate report and commit**
```bash
./reports/generate-report.sh
git add dotnet/src/ZB.MOM.NatsNet.Server dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db reports/
git commit -m "feat(batch22): complete monitoring endpoints and mapped tests"
```