# Batch 24 Leaf Nodes Implementation Plan

> **For Codex:** REQUIRED SUB-SKILL: Use `executeplan` to implement this plan task-by-task.

**Goal:** Port and verify Batch 24 (`Leaf Nodes`) by implementing 67 deferred leaf-node features from `server/leafnode.go` and implementing/verifying the 2 mapped tests with real behavioral coverage.

**Architecture:** Implement leaf-node behavior in domain-focused partials for `ClientConnection` and `NatsServer`, plus helper logic in `LeafNodeHandler`/`LeafNodeCfg` and account propagation updates in `Account`. Execute in four feature groups (18/18/14/17 IDs), each with a strict per-feature verification loop and hard gates. Only promote `complete -> verified` after both mapped tests and all related regression 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-24-leaf-nodes-design.md`

---

## Batch 24 Scope

- Batch ID: `24`
- Name: `Leaf Nodes`
- Dependencies: `19`, `23`
- Go source: `golang/nats-server/server/leafnode.go`
- Features: `67`
- Tests: `2`

Reference commands:

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 24 --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
```

If `dotnet` is not on `PATH` in your shell, use `/usr/local/share/dotnet/dotnet` in the same commands.

Primary production files:

- Create: `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.LeafNodes.cs`
- Create: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.ConfigAndConnect.cs`
- Create: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.Subscriptions.cs`
- Create: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeHandler.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeTypes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Protocol/ProtocolParser.cs`
- Modify (as needed): `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Lifecycle.cs`

Mapped test files:

- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs`
- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs`

Related regression test files:

- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Protocol/ProtocolParserTests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Accounts/ResolverDefaultsOpsTests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ClientTests.cs`

---

## MANDATORY VERIFICATION PROTOCOL

> **NON-NEGOTIABLE:** Every Batch 24 feature/test update must follow this protocol.

### Per-Feature Verification Loop (REQUIRED for every feature ID)

1. Read tracked metadata and Go source before coding:

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature show <feature_id> --db porting.db
# then open golang/nats-server/server/leafnode.go at go_line_number..(go_line_number + go_line_count)
```

2. Write/adjust C# implementation for that specific feature.
3. Build immediately after each feature (or tightly coupled pair):

```bash
dotnet build dotnet/
```

4. Run the smallest related tests immediately (feature-local gate):

```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ \
  --filter "FullyQualifiedName~ProtocolParserTests|FullyQualifiedName~ResolverDefaultsOpsTests|FullyQualifiedName~ClientTests|FullyQualifiedName~LeafNodeHandlerTests|FullyQualifiedName~RouteHandlerTests"
```

5. Record evidence per feature ID: Go line(s) read, files touched, build status, test command, test summary.
6. If any command is red, fix before moving to the next ID.

### Stub Detection Check (REQUIRED after every feature group and test wave)

Run before any status promotion:

```bash
# 1) Forbidden markers in mapped production and test files
grep -R -n -E "(NotImplementedException|TODO|PLACEHOLDER)" \
  dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Protocol/ProtocolParser.cs \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs

# 2) Empty method bodies in mapped production files
grep -R -n -E "^[[:space:]]*(public|internal|private|protected)[^{;=]*\\)[[:space:]]*\\{[[:space:]]*\\}$" \
  dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Protocol/ProtocolParser.cs
```

Any hit must be fixed or deferred with a reason. Do not promote status with unresolved hits.

### Build Gate (REQUIRED after each feature group)

```bash
dotnet build dotnet/
```

`Build succeeded` is mandatory before any `stub -> complete` update.

### Test Gate (REQUIRED before any `complete -> verified` promotion)

All related tests must pass:

```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.Protocol.ProtocolParserTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.Accounts.ResolverDefaultsOpsTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ClientTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~LeafNodeHandlerTests.LeafNodeRoutedSubKeyDifferentBetweenLeafSubAndRoutedSub_ShouldSucceed"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~RouteHandlerTests.ClusterQueueGroupWeightTrackingLeak_ShouldSucceed"
```

No Batch 24 feature may be marked `verified` until both mapped tests and this regression gate are green.

### Status Update Protocol (REQUIRED)

- Never include more than `15` IDs in a single `feature batch-update` or `test batch-update`.
- Required progression:
  - `deferred -> stub` when active work begins.
  - `stub -> complete` only after clean stub checks + build gate.
  - `complete -> verified` only after full Test Gate passes.
- Evidence is required for each update chunk:
  - build output summary,
  - related test output summary,
  - clean stub scan output,
  - explicit IDs being promoted and why.

Command templates:

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "<max 15 ids>" --set-status <stub|complete|verified> --db porting.db --execute

dotnet run --project tools/NatsNet.PortTracker -- \
  test batch-update --ids "<max 15 ids>" --set-status <stub|complete|verified> --db porting.db --execute
```

### Checkpoint Protocol Between Tasks (REQUIRED)

After each task (feature group or test wave), before starting the next task:

```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 "<batch24 checkpoint message>"
```

Do not continue if checkpoint gates fail.

### If You Get Stuck (REQUIRED)

1. Stop on the blocked ID.
2. Remove partial placeholders; do not leave stubs in-tree.
3. Mark the blocked item `deferred` with a specific 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. Move to next unblocked ID.
5. Do not create fake-pass code/tests to force progress.

---

## ANTI-STUB GUARDRAILS (NON-NEGOTIABLE)

### Forbidden Patterns

The following are forbidden in Batch 24 feature and test work:

- `throw new NotImplementedException()` in mapped feature methods
- Empty method bodies for mapped features
- `// TODO` or `// PLACEHOLDER` in mapped code paths
- Non-semantic default placeholders (`return null;`, `return false;`, `return 0;`, `return string.Empty;`) for non-trivial methods
- ImplBacklog fake assertions such as `"...".ShouldContain("Should")`
- Tests that do not call production code
- Tests with no meaningful assertions on behavior under test

### Hard Limits

- Maximum `20` features per feature task
- Maximum `15` IDs per status-update command
- One feature group active at a time
- Zero unresolved stub-scan hits before any promotion
- Mandatory checkpoint (full build + full tests + commit) between tasks

---

## Feature Groups (<=20 IDs each)

### Group 1 (18 IDs): Identity, validation, and remote-config bootstrap

IDs:

`1979,1980,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997`

Focus:

- Leaf role identity checks (`solicited`, `spoke`, `isolated`)
- Remote solicitation validity checks and TLS config updates
- Leaf config construction and URL/delay helpers
- Validation helpers (`validateLeafNode*`) and proxy tunnel setup

### Group 2 (18 IDs): Connect loop, listener, CONNECT/INFO foundation

IDs:

`1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015`

Focus:

- Outbound connect/reconnect and observer/migration timer handling
- Listener accept loop and leaf client creation path
- Leaf CONNECT payload generation and INFO handling
- Compression negotiation and server leaf-info broadcast helpers

### Group 3 (14 IDs): Connection registration and account/smap propagation

IDs:

`2016,2017,2018,2019,2021,2022,2024,2025,2026,2027,2029,2030,2031,2032`

Focus:

- Remote URL update flow and host/port/IP advertisement
- Leaf connection registration and inbound CONNECT processing
- Account permission and subscription map initialization
- Gateway interest update and account leaf propagation (`UpdateLeafNodesEx`)

### Group 4 (17 IDs): Sub keys, sub/unsub and inbound message pipeline

IDs:

`2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049`

Focus:

- Routed-sub key generation (`keyFromSub`, `keyFromSubWithOrigin`)
- Leaf sub protocol serialization and sub/unsub handlers
- Leaf MSG/HMSG arg parsing and inbound message processing
- Permission violation/error paths
- TLS/ws solicit helpers and resume/finish connect process

---

## Mapped Test Wave (2 IDs)

IDs:

`1966,2825`

Target methods:

- `LeafNodeHandlerTests.LeafNodeRoutedSubKeyDifferentBetweenLeafSubAndRoutedSub_ShouldSucceed`
- `RouteHandlerTests.ClusterQueueGroupWeightTrackingLeak_ShouldSucceed`

Target files:

- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs`

---

## Task 1: Preflight and Dependency Gate

**Files:**

- Read: `docs/standards/dotnet-standards.md`
- Read: `docs/plans/2026-02-27-batch-24-leaf-nodes-design.md`
- Read: `golang/nats-server/server/leafnode.go`

**Step 1: Confirm batch context**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 24 --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: Verify dependency readiness**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch ready --db porting.db
```

Expected: Batch `24` is listed as ready. If not, stop implementation and keep planning-only state.

**Step 3: Start batch and run baseline gate**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch start 24 --db porting.db
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/
```

**Step 4: Checkpoint commit**

```bash
git add porting.db
git commit -m "chore(batch24): start leaf nodes batch"
```

---

## Task 2: Implement Feature Group 1 (18 IDs)

**Files:**

- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeHandler.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.ConfigAndConnect.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeTypes.cs`
- Modify (as needed): `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.cs`

**Step 1: Move Group 1 to `stub` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1979,1980,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1995,1996,1997" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Feature Verification Loop for all 18 IDs**

**Step 3: Run mandatory stub checks + build gate + related tests**

```bash
# run stub detection check from protocol section
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ProtocolParserTests|FullyQualifiedName~ClientTests"
```

**Step 4: Move Group 1 to `complete` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1979,1980,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1995,1996,1997" --set-status complete --db porting.db --execute
```

**Step 5: Run Checkpoint Protocol and commit**

```bash
git commit -m "feat(batch24): implement leaf validation and remote config bootstrap"
```

---

## Task 3: Implement Feature Group 2 (18 IDs)

**Files:**

- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.LeafNodes.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.ConfigAndConnect.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Lifecycle.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeTypes.cs`

**Step 1: Move Group 2 to `stub` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2013,2014,2015" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Feature Verification Loop for all 18 IDs**

**Step 3: Run mandatory stub checks + build gate + related tests**

```bash
# run stub detection check from protocol section
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ProtocolParserTests|FullyQualifiedName~ClientTests"
```

**Step 4: Move Group 2 to `complete` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2013,2014,2015" --set-status complete --db porting.db --execute
```

**Step 5: Run Checkpoint Protocol and commit**

```bash
git commit -m "feat(batch24): implement leaf connect lifecycle and handshake foundation"
```

---

## Task 4: Implement Feature Group 3 (14 IDs)

**Files:**

- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.Subscriptions.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.LeafNodes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`

**Step 1: Move Group 3 to `stub`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2016,2017,2018,2019,2021,2022,2024,2025,2026,2027,2029,2030,2031,2032" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Feature Verification Loop for all 14 IDs**

**Step 3: Run mandatory stub checks + build gate + related tests**

```bash
# run stub detection check from protocol section
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ResolverDefaultsOpsTests|FullyQualifiedName~ClientTests|FullyQualifiedName~ProtocolParserTests"
```

**Step 4: Move Group 3 to `complete`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2016,2017,2018,2019,2021,2022,2024,2025,2026,2027,2029,2030,2031,2032" --set-status complete --db porting.db --execute
```

**Step 5: Run Checkpoint Protocol and commit**

```bash
git commit -m "feat(batch24): implement leaf registration and account interest propagation"
```

---

## Task 5: Implement Feature Group 4 (17 IDs)

**Files:**

- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.LeafNodes.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Protocol/ProtocolParser.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/LeafNodeHandler.cs`
- Create/Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.LeafNodes.ConfigAndConnect.cs`

**Step 1: Move Group 4 to `stub` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2048,2049" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Feature Verification Loop for all 17 IDs**

**Step 3: Run mandatory stub checks + build gate + related tests**

```bash
# run stub detection check from protocol section
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ProtocolParserTests|FullyQualifiedName~ResolverDefaultsOpsTests|FullyQualifiedName~ClientTests"
```

**Step 4: Move Group 4 to `complete` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2048,2049" --set-status complete --db porting.db --execute
```

**Step 5: Run Checkpoint Protocol and commit**

```bash
git commit -m "feat(batch24): implement leaf sub and inbound message pipeline"
```

---

## Task 6: Implement and Verify the 2 Mapped Tests

**Files:**

- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs`
- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs`

**Step 1: Move tests to `stub`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  test batch-update --ids "1966,2825" --set-status stub --db porting.db --execute
```

**Step 2: Per-test loop for each ID**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test show 1966 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- test show 2825 --db porting.db

dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ \
  --filter "FullyQualifiedName~LeafNodeHandlerTests.LeafNodeRoutedSubKeyDifferentBetweenLeafSubAndRoutedSub_ShouldSucceed"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ \
  --filter "FullyQualifiedName~RouteHandlerTests.ClusterQueueGroupWeightTrackingLeak_ShouldSucceed"
```

**Step 3: Mandatory stub scan on test files + class-level run**

```bash
grep -n -E "(NotImplementedException|Assert\\.True\\(true\\)|TODO|PLACEHOLDER|ShouldContain\\(\"Should\"\\))" \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs

dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~LeafNodeHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~RouteHandlerTests"
```

**Step 4: Move tests to `complete`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  test batch-update --ids "1966,2825" --set-status complete --db porting.db --execute
```

**Step 5: Run Checkpoint Protocol and commit**

```bash
git commit -m "test(batch24): port mapped leaf-node tests"
```

---

## Task 7: Verification Gate and Promote to `verified`

**Files:**

- Modify: `porting.db`

**Step 1: Run full Batch 24 test gate**

```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.Protocol.ProtocolParserTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.Accounts.ResolverDefaultsOpsTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ClientTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~LeafNodeHandlerTests.LeafNodeRoutedSubKeyDifferentBetweenLeafSubAndRoutedSub_ShouldSucceed"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~RouteHandlerTests.ClusterQueueGroupWeightTrackingLeak_ShouldSucceed"
```

**Step 2: Promote tests to `verified`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  test batch-update --ids "1966,2825" --set-status verified --db porting.db --execute
```

**Step 3: Promote all features to `verified` in chunks <=15**

```bash
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1979,1980,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2021,2022,2024,2025,2026" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2027,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- \
  feature batch-update --ids "2043,2044,2045,2046,2047,2048,2049" --set-status verified --db porting.db --execute
```

**Step 4: Run Checkpoint Protocol and commit**

```bash
git commit -m "feat(batch24): verify all leaf-node features and mapped tests"
```

---

## Task 8: Batch Closure and Reporting

**Files:**

- Modify: `porting.db`
- Generate: `reports/current.md`

**Step 1: Final build/test sweep**

```bash
dotnet build dotnet/
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/
```

**Step 2: Final Batch 24 stub audit**

```bash
grep -R -n -E "(NotImplementedException|TODO|PLACEHOLDER)" \
  dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/LeafNode/*.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs \
  dotnet/src/ZB.MOM.NatsNet.Server/Protocol/ProtocolParser.cs \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/LeafNodeHandlerTests.Impltests.cs \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs
```

**Step 3: Verify batch closure**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 24 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch complete 24 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db
```

**Step 4: Generate report and final 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(batch24): complete leaf nodes implementation and verification"
```

