# CLAUDE.md

## Project Summary

This project is porting the NATS server from Go to .NET 10 C#. The Go source (~130K LOC across 109 non-test files, 85 test files) is at `golang/nats-server/`. The porting process is tracked via an SQLite database (`porting.db`) and managed by two tools: a Go AST analyzer and a .NET PortTracker CLI.

## Folder Layout

```
natsnet/
├── golang/nats-server/              # Go source (reference)
├── dotnet/                          # .NET ported version
│   ├── src/
│   │   ├── ZB.MOM.NatsNet.Server/          # Main server library
│   │   └── ZB.MOM.NatsNet.Server.Host/     # Host/entry point
│   └── tests/
│       ├── ZB.MOM.NatsNet.Server.Tests/              # Unit tests
│       └── ZB.MOM.NatsNet.Server.IntegrationTests/   # Integration tests
├── tools/
│   ├── go-analyzer/                 # Go AST analyzer (Phases 1-2)
│   └── NatsNet.PortTracker/         # .NET CLI tool (all phases)
├── docs/plans/phases/               # Phase instruction guides
├── reports/                         # Generated porting reports
├── porting.db                       # SQLite tracking database
├── porting-schema.sql               # Database schema
└── documentation_rules.md           # Documentation conventions
```

## Tools

### Go AST Analyzer

```bash
CGO_ENABLED=1 go build -o go-analyzer . && ./go-analyzer --source golang/nats-server --db porting.db --schema porting-schema.sql
```

### .NET PortTracker CLI

```bash
dotnet run --project tools/NatsNet.PortTracker -- <command> --db porting.db
```

## Phase Instructions

- **Phase 1: Go Codebase Decomposition** - `docs/plans/phases/phase-1-decomposition.md`
- **Phase 2: Verification of Captured Items** - `docs/plans/phases/phase-2-verification.md`
- **Phase 3: Library Mapping** - `docs/plans/phases/phase-3-library-mapping.md`
- **Phase 4: .NET Solution Design** - `docs/plans/phases/phase-4-dotnet-design.md`
- **Phase 5: Mapping Verification** - `docs/plans/phases/phase-5-mapping-verification.md`
- **Phase 6: Initial Porting** - `docs/plans/phases/phase-6-porting.md`
- **Phase 7: Porting Verification** - `docs/plans/phases/phase-7-porting-verification.md`

## .NET Standards

All .NET code must follow the rules in [`docs/standards/dotnet-standards.md`](docs/standards/dotnet-standards.md). Key points:

- .NET 10, C# latest
- **Testing**: xUnit 3, Shouldly, NSubstitute — do NOT use FluentAssertions or Moq
- **Logging**: `Microsoft.Extensions.Logging` with Serilog provider; use `LogContext.PushProperty` for contextual enrichment
- **Naming**: PascalCase for all public members; `ZB.MOM.NatsNet.Server.[Module]` namespace hierarchy

## Reports

- `reports/current.md` always has the latest porting status.
- `reports/report_{commit_id}.md` snapshots are generated on each commit via pre-commit hook.
- Run `./reports/generate-report.sh` manually to regenerate.
