Skip to main content
Glama
README.md
# ZNKernel-II open tooling: MCP server, HTTP bridge, public benchmark

**A three-valued geometry judge for AI agents.** ZNKernel-II answers geometric and
manufacturing questions with `allow`, `reject`, or `cannot_judge` — and `cannot_judge`
is *undecided*, never a pass. Every judgement carries a rule id, a rule version and
replayable evidence.

This repository is the open-source tool layer around the kernel:

| Component | What it is |
|---|---|
| [`mcp/`](mcp/) | `znk-mcp`, a **zero-dependency** MCP stdio server exposing **10 tools** (create / boolean / describe / import / export / adjudicate / adjudicate_rules / topology / capabilities / sketch_solve) |
| [`mcp/http-bridge/`](mcp/http-bridge/) | optional stdio → Streamable HTTP bridge for clients that only speak HTTP (loopback only) |
| [`bench/`](bench/) | **6 public, self-built benchmark cases** with inputs, expected verdicts and a recompute script |
| [`docs/`](docs/) | API quickstart, error-code reference and C ABI integration guide |
| [`examples/`](mcp/examples/) | JSONL MCP transcripts and a small agent example |

The **ZNKernel-II kernel itself is not part of this repository** and is not open
source. The tools call a separately licensed `znk2_cli` binary; without a valid
license every geometry operation returns error `1004` by design.

## Three commands

```bash
# 1) Start the server in demo mode: no kernel binary, no license, 3 recorded samples
ZNK_DEMO=1 node mcp/server.cjs

# 2) Run the CI smoke test (Node.js >= 18, zero npm dependencies)
node mcp/test/smoke.cjs

# 3) Recompute the public benchmark (needs your own ZNKernel-II 2.40 CLI + license)
python bench/verify.py --cli /path/to/znk2_cli.exe --license /path/to/your.lic
```

Windows PowerShell equivalents:

```powershell
$env:ZNK_DEMO=1; node mcp/server.cjs
node mcp/test/smoke.cjs
python bench/verify.py --cli C:\path\to\znk2_cli.exe --license C:\path\to\your.lic
```

The full self-test (`node mcp/test/selftest.cjs`, 28 assertions) additionally needs
`ZNK2_CLI` and `ZNK2_LICENSE_FILE` and exercises real kernel round-trips.

### What "demo mode" is

`ZNK_DEMO=1` replays **3 recorded, self-built sample verdicts** (C01/C05/C06). It is
a contract demo, not a geometry engine: it never spawns `znk2_cli` and never reads a
license file. All three verdicts appear in the samples, including `cannot_judge`.

## Public benchmark

Six self-built cases, no customer data:

| id | part | rule | expected |
|---|---|---|---|
| NA01 | 0.5° draft | `manufacturing/draft_angle` | reject |
| NA02 | interference pair | `assembly/interference` | reject |
| NA03 | blind hole L/D 7.5 | `manufacturing/hole_depth_ratio` | reject |
| NA04 | uneven wall | `manufacturing/wall_thickness_uniformity` | reject |
| NA05 | tiny opening radius | `quality/opening_radius` | reject |
| C01 | flange, all 20 rules | — | allow 15 / reject 0 / cannot_judge 5 |

Start at [`bench/README.md`](bench/README.md); machine-readable expectations and
input SHA-256 are in [`bench/expected.json`](bench/expected.json). Recompute with
`python bench/verify.py --cli <znk2_cli.exe> --license <your.lic>`. An input whose
SHA-256 no longer matches is a broken baseline, not a passing one.

## Boundaries (please read before adopting)

- **Analytic solids only.** The kernel is an analytic solid modeler (box, cylinder,
  sphere, cone, torus and analytic booleans). It does **not** implement a general
  NURBS B-rep boolean; imported STEP geometry is handled where it reduces to
  analytic faces, and unsupported configurations fail explicitly instead of
  returning a guessed result.
- **`cannot_judge` is not a pass.** It means the engine lacks evidence or the
  configuration is out of the supported envelope. Timeouts and non-zero exits are
  also not passes. Do not fold `cannot_judge` into `allow` (or into `reject`) in
  your product.
- **No kernel source or binary here.** Kernel licensing, activation and revocation
  are proprietary. This repository ships the MCP wrapper, docs, examples and the
  public benchmark only.
- **HTTP bridge is loopback-only.** No TLS, auth or multi-tenancy; put it behind a
  reverse proxy if you expose it.
- **Verified environment:** Windows x64 + MinGW/GCC. Linux/macOS/ARM/MSVC are
  untested; see [`docs/INTEGRATION-GUIDE.md`](docs/INTEGRATION-GUIDE.md).

## License

Apache License 2.0 — see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE). The license
covers the wrapper, docs, examples and benchmark; it grants **no** rights to the
ZNKernel-II kernel, the ZNGL licensing logic or any customer license file.

The names and logos are trademarks of the project owner. Apache-2.0 does not grant
trademark rights; factual references are welcome. See [`TRADEMARK.md`](TRADEMARK.md).

Commercial kernel licensing, support and certified rule packs are separate and are
not sold under the open-source license: see [`COMMERCIAL.md`](COMMERCIAL.md).

## Contributing

DCO sign-off (`git commit -s`), no CLA. See [`CONTRIBUTING.md`](CONTRIBUTING.md).
Security reports: [`SECURITY.md`](SECURITY.md). Please never paste a `.lic` file,
a key or customer geometry into an issue or pull request.