Automated tests for text

Type: types/note.md · Tags: document-system, evaluation, type-system

Text artifacts can be tested like software once contracts are declared per document type. Checks separate along two orthogonal dimensions—method (deterministic script vs. LLM semantic judgment) and scope (single document vs. cross-document corpus)—producing a practical testing pyramid:

  • Deterministic structural checks (hard oracle, cheap and repeatable) — valid frontmatter schema, required fields and sections, enum values, link resolution, and citation bounds. These run in milliseconds as scripts across one note or an entire corpus.
  • Semantic rubric checks (soft oracle, judgment-based) — clarity, single clear thesis, grounding alignment, internal consistency, and claim-scope boundaries. Even a single paragraph can require an LLM or human reviewer when the property cannot be checked mechanically.
  • Cross-document corpus checks — contradiction detection against neighboring claims, terminology consistency, and duplicate detection. Scope alone does not fix cost: link resolution is corpus-wide yet deterministic, while contradiction detection requires semantic comparison.

Since document types should be verifiable, each type and trait asserts a checkable property—and those properties are what testing contracts verify. The type system and the testing stack are two sides of the same coin: types define what to check, and validators and review gates do the checking.

Build contracts from observed failures rather than from an abstract taxonomy of possible checks: add a check when a recurring failure would have been caught by it, not before.

A knowledge base retains LLM-generated notes selected for reuse. Selecting an LLM output fixes a result, not its interpretation, making each accepted note a stable artifact-testing target even when its language remains open to interpretation. Artifact testing is distinct from generator testing: generators and their artifacts are separate testing targets, including when generation is deterministic. An acceptable note does not establish that its generator reliably produces acceptable notes, and confidence in a generator does not certify every output.


Relevant Notes: