Skip to content

NRP Test Documentation

The NRP tests are grouped under tests/NRP. They protect the mesh resolver, scoring engine, observability loop, and the parser compatibility fixes that make the bridge work with cleaker v3.

This document mirrors the exported NRP_TEST_CATALOG, so TypeDoc also includes the test taxonomy.


Test Groups

FileCategoryPurpose
tests/NRP/bridge.parse.test.tsparsingVerifies me:// parsing through cleaker v3 __ptr.target, including dot paths like .mesh/monads
tests/NRP/monadIndex.test.tsindexVerifies local monad index read/write/list, claimed namespace lookup, name lookup, and ordering
tests/NRP/meshSelect.test.tsselectionVerifies selector matching, stale filtering, self-exclusion, runner-up tracking, and exploration
tests/NRP/scoring.test.tsscoringVerifies score invariants, learning loop, introspection breakdowns, and scoring integration
tests/NRP/decisionLog.test.tsobservabilityVerifies decisionId correlation, reward calculation, JSONL output, and failure isolation
tests/NRP/adaptiveWeights.test.tslearningVerifies global/namespace weight updates, maturity blending, and learning-loop integration

Hard Invariants

The scoring suite explicitly protects these invariants:

  • normalized scores stay in [0, 1]
  • identical inputs produce identical scores
  • NaN and Infinity do not propagate
  • scaling all weights by the same constant does not change the score
  • computeScore and computeScoreDetailed.total stay identical
  • runner-up is present only when more than one claimant exists
  • decision correlation uses decisionId, not monadId:namespace
  • reward stays in [-0.7, 1]
  • namespace weights are not created on read
  • namespace maturity reaches 70% blend at 140 samples
  • global prior still receives 5% background learning at full maturity

Why Tests Are Also in TypeDoc

Runtime test files are not exported as public API. Instead, the production module exports NRP_TEST_CATALOG, a typed catalog of the NRP test groups. This keeps the package runtime clean while letting generated API docs show the coverage map.

See:

ts
import { NRP_TEST_CATALOG } from "monad.ai";

Commands

bash
# Full suite
npm test

# Focus a test group
npx vitest run tests/NRP/scoring.test.ts
npx vitest run tests/NRP/decisionLog.test.ts
npx vitest run tests/NRP/adaptiveWeights.test.ts

# Build docs API
npm run docs:api

Legacy/Non-NRP Tests

The older tests are still relevant. They protect the base semantic runtime:

FileArea
appFactory.test.tsapp bootstrap and env isolation
claimSemanticSeeds.test.tsclaim semantic seeding
claimsOpenProfile.test.tsopened claim profile hydration
commitsync.test.tsmemory ledger and replay smoke tests
hostProjection.test.tshost memory projection
hostResolver.test.tscanonical host-to-namespace projection
observerRelation.test.tsobserver relation and disclosure envelopes
persistentClaim.test.tsclaim persistence and verification
replayCanonicalization.test.tsreplay payload normalization
rootUsersProjection.test.tsroot namespace user projection
selfMapping.test.tsself identity, selector parsing, and surface entries
semanticBootstrap.test.tssemantic bootstrap idempotency
semanticBranchReader.test.tssemantic branch prefix isolation

tests/claim_test_verification.ts remains a manual script invoked by npm run test:claims.