# Batch 27 JetStream Core Implementation Plan

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

**Goal:** Port and verify Batch 27 JetStream core behavior (82 features, 77 tests) from `server/jetstream.go` into .NET without stubs, with evidence-based status updates.

**Architecture:** Implement JetStream core behavior in grouped waves across `NatsServer`, `Account`, `JetStream`, and `JsAccount` code paths, then port mapped tests by class waves with strict per-test verification evidence. Promote status only through `stub -> complete -> verified` after mandatory build/test/stub gates.

**Tech Stack:** .NET 10, C# latest, xUnit 3, Shouldly, NSubstitute, PortTracker CLI, SQLite (`porting.db`)

**Design doc:** `docs/plans/2026-02-27-batch-27-jetstream-core-design.md`

---

## Batch 27 Scope

- Batch ID: `27`
- Dependencies: `5`, `8`, `19`
- Go source: `golang/nats-server/server/jetstream.go`
- Feature count: `82`
- Test count: `77`

Primary source targets:

- `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.cs`
- `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer.Lifecycle.cs`
- `dotnet/src/ZB.MOM.NatsNet.Server/NatsServerTypes.cs`
- `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/JetStreamTypes.cs`
- `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs` (new or existing core behavior files)

Primary test targets:

- `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/JetStreamFileStoreTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsConsumerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamEngineTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamVersioningTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MqttHandlerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MessageTracerTests.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/ConcurrencyTests1.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/ConcurrencyTests2.Impltests.cs`
- `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsServerTests.Impltests.cs`

---

## MANDATORY VERIFICATION PROTOCOL

> **NON-NEGOTIABLE:** every feature and test in Batch 27 must follow this protocol. No exceptions.

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

1. Read mapping and Go span:
   ```bash
   dotnet run --project tools/NatsNet.PortTracker -- feature show <feature_id> --db porting.db
   sed -n '<start_line>,<end_line>p' golang/nats-server/server/jetstream.go
   ```
2. Implement exactly one feature behavior in mapped C# target.
3. Build immediately:
   ```bash
   dotnet build dotnet/
   ```
4. Run smallest related test filter (feature-local) and confirm discovery:
   ```bash
   dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~<RelatedClass>"
   ```
5. If green, add feature ID to the current `complete-candidate` list.
6. If red, fix before touching the next feature ID.

### Per-Test Verification Loop (REQUIRED for each test ID)

1. Read mapping and Go span:
   ```bash
   dotnet run --project tools/NatsNet.PortTracker -- test show <test_id> --db porting.db
   ```
2. Port one test method (Arrange/Act/Assert, calls production code).
3. Run single-test filter and capture output:
   ```bash
   dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ \
     --filter "FullyQualifiedName~ZB.MOM.NatsNet.Server.Tests.ImplBacklog.<ClassName>.<MethodName>" \
     --verbosity normal
   ```
4. Verify output includes `Passed: 1, Failed: 0` (not `Passed: 0`).
5. Only then add test ID to `verified-candidate` list.

### Stub Detection Check (REQUIRED after each feature group and test class)

```bash
rg -n "(NotImplementedException|Assert\.True\(true\)|Assert\.Pass|// TODO|// PLACEHOLDER|throw new Exception\(\"TODO\"\))" \
  dotnet/src/ZB.MOM.NatsNet.Server \
  dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog

rg -n "^\s*(public|internal|private)\s+.*\)\s*\{\s*\}$" \
  dotnet/src/ZB.MOM.NatsNet.Server
```

Any new match in touched files blocks status promotion.

### Build Gate (REQUIRED)

- Required after every feature group and before every status promotion:
  ```bash
  dotnet build dotnet/
  ```
- `Build succeeded` is mandatory.

### Test Gate (REQUIRED)

Before setting any feature to `verified`, all relevant Batch 27 backlog classes touched in the current wave must pass.

Minimum gate commands:

```bash
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.AccountTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.EventsHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.JetStreamFileStoreTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.NatsConsumerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.JetStreamEngineTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.JetStreamVersioningTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.MonitoringHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.MqttHandlerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.MessageTracerTests"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.ConcurrencyTests1"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.ConcurrencyTests2"
dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --filter "FullyQualifiedName~ImplBacklog.NatsServerTests"
```

### Status Update Protocol (REQUIRED, hard limit enforced)

- **Max 15 IDs per `feature batch-update` or `test batch-update` command.**
- Status progression:
  - Start work: `deferred/not_started -> stub`
  - After feature/test evidence: `stub -> complete`
  - After full gate evidence: `complete -> verified`
- Evidence required per update chunk:
  - latest build success output
  - latest relevant test success output
  - latest stub-scan output (no unresolved new matches)

Command template:

```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)

At end of every task (before next task):

1. Run build gate:
   ```bash
   dotnet build dotnet/
   ```
2. Run test checkpoint:
   ```bash
   dotnet test dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ --verbosity normal
   ```
3. Record checkpoint summary (pass/fail/skip, stub scan result, updated IDs).
4. Commit checkpoint before next task.

---

## ANTI-STUB GUARDRAILS (NON-NEGOTIABLE)

### Forbidden Patterns

The following indicate fake progress and are forbidden in Batch 27 feature/test code:

- `throw new NotImplementedException()`
- Empty feature method body (`{ }`) for mapped methods
- `Assert.True(true)` / equivalent trivial pass assertion
- `Assert.Pass()`
- `// TODO` or `// PLACEHOLDER` in newly ported feature/test method bodies
- Returning trivial constants (`null`, `0`, `false`, `string.Empty`) where Go behavior is non-trivial
- Test methods that do not invoke production code

### Hard Limits

- Max `~20` features per feature task group.
- Max `15` IDs per status update command.
- One test class at a time for test verification/status promotion.
- No `verified` updates when any touched file still contains unresolved stub-pattern matches.
- No cross-group status promotion; only update IDs in the active task group.

### If You Get Stuck (MANDATORY)

1. Stop the current ID immediately.
2. Do **not** leave placeholder code/tests behind.
3. Mark blocked item as `deferred` with explicit 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. Deferred with reason is correct; stubbing is not.

---

## Feature Group Map (Max ~20 Features Each)

### Group 1 (20 IDs): Server Enable/Disable Bootstrap and Account Wiring

`1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387`

### Group 2 (19 IDs): Engine State/Getters and Account Enable Core

`1388,1389,1390,1391,1392,1394,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408`

### Group 3 (18 IDs): Usage Foundations and Limits Helpers

`1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425,1426`

### Group 4 (17 IDs): jsAccount Limits Enforcement and Resource Accounting

`1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443`

### Group 5 (8 IDs): Dynamic Config/Validation/Error Tail

`1444,1445,1446,1447,1448,1449,1450,1451`

---

## Test Wave Map

### Wave A (19 IDs): Cross-Module Small/Medium Classes

`100,101,102,314,345,1804,1806,2160,2161,2243,2244,2245,2248,2259,2343,2345,2346,2478,2890`

### Wave B (17 IDs): Storage/Consumer/Concurrency Support

`356,379,389,390,391,392,463,1295,1302,1308,1314,1336,2397,2403,2409,2424,2430`

### Wave C (41 IDs): JetStreamEngine Heavy Class

`1466,1467,1529,1548,1549,1550,1581,1583,1584,1589,1595,1600,1604,1608,1609,1617,1620,1621,1629,1631,1632,1648,1649,1650,1651,1654,1666,1672,1673,1675,1683,1684,1689,1721,1723,1724,1732,1739,1740,1744,1780`

---

## Task 1: Preflight, Dependency Gate, and Batch Start

**Files:**
- Read: `docs/standards/dotnet-standards.md`
- Read: `docs/plans/2026-02-27-batch-27-jetstream-core-design.md`
- Read: `golang/nats-server/server/jetstream.go`

**Step 1: Verify dependency batches are complete**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch show 5 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch show 8 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch show 19 --db porting.db
```

Expected: all required predecessor work for Batch 27 is complete/verified enough to start.

**Step 2: Start Batch 27**

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

**Step 3: Capture baseline health**

```bash
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(batch27): start jetstream core batch"
```

---

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

**Files:**
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs` (JetStream lifecycle/config methods)
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- Modify/create as needed: `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs`

**Step 1: Mark Group 1 IDs as `stub` (max 15 per call)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1383,1384,1385,1386,1387" --set-status stub --db porting.db --execute
```

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

**Step 3: Run mandatory stub scan + build gate + targeted test gate**

**Step 4: Mark Group 1 as `complete` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1383,1384,1385,1386,1387" --set-status complete --db porting.db --execute
```

**Step 5: Run checkpoint protocol and commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server porting.db
git commit -m "feat(batch27): implement jetstream bootstrap and account wiring"
```

---

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

**Files:**
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs`

**Step 1: Mark Group 2 IDs as `stub` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1388,1389,1390,1391,1392,1394,1396,1397,1398,1399,1400,1401,1402,1403,1404" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1405,1406,1407,1408" --set-status stub --db porting.db --execute
```

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

**Step 3: Run mandatory stub scan + build gate + targeted test gate**

**Step 4: Mark Group 2 as `complete` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1388,1389,1390,1391,1392,1394,1396,1397,1398,1399,1400,1401,1402,1403,1404" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1405,1406,1407,1408" --set-status complete --db porting.db --execute
```

**Step 5: Run checkpoint protocol and commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server porting.db
git commit -m "feat(batch27): implement jetstream engine state and account enable core"
```

---

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

**Files:**
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs`

**Step 1: Mark Group 3 IDs as `stub` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1424,1425,1426" --set-status stub --db porting.db --execute
```

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

**Step 3: Run mandatory stub scan + build gate + targeted test gate**

**Step 4: Mark Group 3 as `complete` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1424,1425,1426" --set-status complete --db porting.db --execute
```

**Step 5: Run checkpoint protocol and commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server porting.db
git commit -m "feat(batch27): implement jetstream usage foundations and limit helpers"
```

---

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

**Files:**
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`

**Step 1: Mark Group 4 IDs as `stub` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1442,1443" --set-status stub --db porting.db --execute
```

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

**Step 3: Run mandatory stub scan + build gate + targeted test gate**

**Step 4: Mark Group 4 as `complete` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441" --set-status complete --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1442,1443" --set-status complete --db porting.db --execute
```

**Step 5: Run checkpoint protocol and commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server porting.db
git commit -m "feat(batch27): implement jsaccount limit checks and resource accounting"
```

---

## Task 6: Implement Feature Group 5 (8 IDs)

**Files:**
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/NatsServer*.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/Accounts/Account.cs`
- Modify: `dotnet/src/ZB.MOM.NatsNet.Server/JetStream/*.cs`

**Step 1: Mark Group 5 IDs as `stub`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1444,1445,1446,1447,1448,1449,1450,1451" --set-status stub --db porting.db --execute
```

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

**Step 3: Run mandatory stub scan + build gate + targeted test gate**

**Step 4: Mark Group 5 as `complete`**

```bash
dotnet run --project tools/NatsNet.PortTracker -- feature batch-update --ids "1444,1445,1446,1447,1448,1449,1450,1451" --set-status complete --db porting.db --execute
```

**Step 5: Run checkpoint protocol and commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server porting.db
git commit -m "feat(batch27): implement jetstream config validation and error tail"
```

---

## Task 7: Port Test Wave A (19 IDs)

**Files:**
- Modify backlog class files for: `AccountTests`, `EventsHandlerTests`, `MonitoringHandlerTests`, `JetStreamVersioningTests`, `MqttHandlerTests`, `MessageTracerTests`, `ConcurrencyTests2`, `NatsServerTests`

**Step 1: Mark Wave A tests as `stub` (max 15 IDs)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "100,101,102,314,345,1804,1806,2160,2161,2243,2244,2245,2248,2259,2343" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2345,2346,2478,2890" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Test Verification Loop for each ID**

**Step 3: Class-level gates + stub scans for each touched class**

**Step 4: Mark Wave A tests `verified` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "100,101,102,314,345,1804,1806,2160,2161,2243,2244,2245,2248,2259,2343" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2345,2346,2478,2890" --set-status verified --db porting.db --execute
```

**Step 5: Checkpoint protocol and commit**

```bash
git add dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db
git commit -m "test(batch27): port wave-a cross-module jetstream tests"
```

---

## Task 8: Port Test Wave B (17 IDs)

**Files:**
- Modify backlog class files: `JetStreamFileStoreTests`, `NatsConsumerTests`, `ConcurrencyTests1`

**Step 1: Mark Wave B tests as `stub` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "356,379,389,390,391,392,463,1295,1302,1308,1314,1336,2397,2403,2409" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2424,2430" --set-status stub --db porting.db --execute
```

**Step 2: Execute Per-Test Verification Loop for each ID**

**Step 3: Class-level gates + stub scans for each touched class**

**Step 4: Mark Wave B tests `verified` (chunked)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "356,379,389,390,391,392,463,1295,1302,1308,1314,1336,2397,2403,2409" --set-status verified --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "2424,2430" --set-status verified --db porting.db --execute
```

**Step 5: Checkpoint protocol and commit**

```bash
git add dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db
git commit -m "test(batch27): port wave-b filestore-consumer-concurrency tests"
```

---

## Task 9: Port Test Wave C (JetStreamEngineTests, 41 IDs)

**Files:**
- Modify: `dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamEngineTests.Impltests.cs`

**Step 1: Mark Wave C tests as `stub` (3 chunks)**

```bash
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "1466,1467,1529,1548,1549,1550,1581,1583,1584,1589,1595,1600,1604,1608,1609" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "1617,1620,1621,1629,1631,1632,1648,1649,1650,1651,1654,1666,1672,1673,1675" --set-status stub --db porting.db --execute
dotnet run --project tools/NatsNet.PortTracker -- test batch-update --ids "1683,1684,1689,1721,1723,1724,1732,1739,1740,1744,1780" --set-status stub --db porting.db --execute
```

**Step 2: Port in sub-batches of 8-10 tests**

For each sub-batch:

1. Run per-test verification loop for each method.
2. Run class gate for `JetStreamEngineTests`.
3. Run stub scan and assertion-density check.
4. If unsupported benchmark/perf/runtime behavior is encountered, defer with reason immediately.

**Step 3: Mark verified/deferred with evidence (max 15 IDs per call)**

**Step 4: Checkpoint protocol and commit**

```bash
git add dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db
git commit -m "test(batch27): port jetstream engine heavy test wave"
```

---

## Task 10: Final Verification, Status Closure, and Batch Completion

**Files:**
- Modify: `porting.db`
- Generate: `reports/current.md` (via report script)

**Step 1: Final feature verification promotion (chunked max 15 IDs)**

Promote each feature group from `complete -> verified` only after all relevant tests are green.

**Step 2: Final test status reconciliation**

- Ensure every Batch 27 test ID is `verified` or `deferred` with explicit reason.

**Step 3: Full repo verification gates**

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

**Step 4: Complete batch + summary checks**

```bash
dotnet run --project tools/NatsNet.PortTracker -- batch complete 27 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- batch show 27 --db porting.db
dotnet run --project tools/NatsNet.PortTracker -- report summary --db porting.db
./reports/generate-report.sh
```

**Step 5: Final commit**

```bash
git add dotnet/src/ZB.MOM.NatsNet.Server dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog porting.db reports/
git commit -m "feat(batch27): complete jetstream core features and mapped tests"
```

---

## Execution Notes

- Do not execute this plan while dependencies (`5`,`8`,`19`) are still blocked.
- Do not bypass verification protocol for speed.
- Deferred-with-reason is acceptable; stubbed code/tests are not.
