Bring deterministic verification into your workflow.

Use Verify to check an AI-transformed batch and Infer to turn validated examples into a reusable rule. For repositories, CI pipelines, scripts, and agents, the same deterministic engine is available through the hosted MCP/HTTP endpoint. The npm package, local MCP server, and CLI are implemented in the repo and clearly labeled below as release targets.

Every interface runs the same deterministic program synthesis engine. No LLM. Same input, same rule, same result.

Availability: the hosted MCP/HTTP endpoint is live today. The npm package, local MCP package, and CLI are implemented and verified in the repo; the commands below are the public release target and will work after the npm packages are published.


npm package

Availability: implemented and prepared for npm publishing. Use the hosted MCP/HTTP endpoint below until @latentmachine/verify is available on npm.

@latentmachine/verify is a zero-dependency, ESM-only Node.js package. It exposes verify, infer, transform, the complete Transformation Contract v1 API, fingerprint, canonicalize, structuralDiff, and profileStructure, plus format utilities for JSON, CSV, YAML, TOML, XML, .env, and SQL INSERT input.

Install

npm install @latentmachine/verify

Verify a batch

Pass the original records and the AI-generated output. The engine infers the majority transformation rule and flags every row that does not follow it.

import { verify } from "@latentmachine/verify";

const result = verify({
  original: [
    { first: "Ana", last: "Meyer", joined: "2026-03-02" },
    { first: "Bo", last: "Singh", joined: "2026-03-04" },
    { first: "Clara", last: "Diaz", joined: "2026-03-05" },
  ],
  transformed: [
    { name: "Ana Meyer", joinedDate: "2026-03-02" },
    { name: "Bo Singh", joinedDate: "March 4, 2026" },
    { name: "Clara Diaz", joinedDate: "2026-03-05" },
  ],
});

console.log(result.verdict);
// "inconsistent"

console.log(result.flaggedRows);
// [{ index: 1, input: {...}, expected: {...}, actual: {...} }]

Infer a rule

Show input/output pairs. The engine infers the simplest deterministic rule that explains the examples, or reports ambiguity, contradictions, or insufficient evidence.

import { infer } from "@latentmachine/verify";

const result = infer({
  examples: [
    { input: { first: "Ana", last: "Meyer" }, output: { name: "Ana Meyer" } },
    { input: { first: "Bo", last: "Singh" }, output: { name: "Bo Singh" } },
  ],
});

console.log(result.status);
// "safe"

Apply a rule

Once you have a safe rule, apply it to new input. The transformation is deterministic: same input, same rule, same output.

import { infer, transform } from "@latentmachine/verify";

const { rule } = infer({
  examples: [
    { input: { first: "Ana", last: "Meyer" }, output: { name: "Ana Meyer" } },
    { input: { first: "Bo", last: "Singh" }, output: { name: "Bo Singh" } },
  ],
});

const output = transform({
  rule,
  input: { first: "Clara", last: "Diaz" },
});

console.log(output);
// { name: "Clara Diaz" }

Inference guardrails

Reusable percentage rules expose their rounding mode and evaluation order in each numericFormula step. Signed magnitude and zero-comparison rules require evidence on both sides of zero. Global stringReplace steps are limited to identifier-like fields and literal delimiters proven by repeated occurrences in the examples.

Learn and enforce a Transformation Contract

A contract binds examples, a deterministic program, runtime policy, and deliberate approval to one behavioral fingerprint. Runtime use fails closed when approval is missing or the contract is invalid.

import {
  approveContract,
  checkContract,
  learnContract,
  runContract,
} from "@latentmachine/verify";

const learned = learnContract({
  examples: [
    {
      input: { id: "evt_1", status: "created" },
      output: { eventId: "evt_1", state: "NEW" },
    },
    {
      input: { id: "evt_2", status: "paid" },
      output: { eventId: "evt_2", state: "READY" },
    },
  ],
});

const approved = approveContract(learned, {
  coreFingerprint: learned.identity.coreFingerprint,
  acknowledgedChallenges: learned.challenges
    .filter((challenge) => challenge.severity === "advisory")
    .map((challenge) => challenge.id),
});

const input = [{ id: "evt_3", status: "paid" }];
const run = runContract({ contract: approved, input });
const check = checkContract({
  contract: approved,
  input,
  output: run.records.map((record) => record.output),
});

Contract APIs are also available from the @latentmachine/verify/contracts export.

Fingerprint data

Compute a deterministic, non-cryptographic identity hash for parsed data, profile its structure, or compare two values path by path. Object key order is ignored; array order is significant.

import { fingerprint, structuralDiff } from "@latentmachine/verify";

const left = { a: 1, b: [2, 3] };
const right = { b: [2, 4], a: 1 };

console.log(fingerprint(left).hex);
console.log(structuralDiff(left, right).counts);
// { added: 0, changed: 1, removed: 0, same: 1 }

Trace analysis contracts

The stable Trace product uses deterministic analyzeTrace(value, options) and compareTrace(baseline, candidate, options) contracts for field profiles, ranked evidence, sampling, and single or compound keyed row comparison. These website-source contracts are versioned but are not exported by @latentmachine/verify yet. The package's existing fingerprint exports above remain stable and unchanged.

String input and formats

verify also accepts raw strings. The format can be auto-detected, and the package exposes the same parsers used by the browser tool.

import { detectFormat, parseWithFormat, serializeWithFormat } from "@latentmachine/verify";

detectFormat('[{"id": 1}]');    // "json"
detectFormat('id,name\n1,Ada'); // "csv"
detectFormat('key: value');     // "yaml"

const data = parseWithFormat('[{"id": 1}]', "auto");
const csv = serializeWithFormat(data, "csv");
// "id\n1"

Return values

verify() returns:

  • verdict: "consistent", "inconsistent", or "unverifiable" when the evidence cannot establish one reusable majority rule.
  • totalRows: number of rows checked.
  • matchedRows: rows that followed the majority rule.
  • flaggedRows: { index, input, expected, actual } for rows that broke the pattern.
  • clusters: up to three coherent alternative rules with a result-local label, privacy-safe source-to-target signature, support, and batch share. Equal splits are unverifiable and do not accuse individual rows.
  • unexplained: bounded row indices not covered by the reported clusters.
  • inference: the bounded evidence strategy, maximum evidence rows, whether sampling occurred, and the number of rows fully validated.
  • ruleStatus: safe, unverified, ambiguous, contradictory, unsafe, or insufficient.
  • confidence: the evidence label, checks, and reasons; memorised lookups never receive proven.
  • nearFit: the strongest lower-support candidate from the initial full-batch fit. Verify may refit a safe candidate on conforming evidence and replay it against every row before classifying a majority and its exceptions.
  • memorisation: lookup ratios, full support counts, repeated-source consistency counts, ruleDemotions with exact contradicting row indices, all nearFits, ruleVerifiedTargets, unchanged passthroughTargets, memorisedTargets, insufficientSupportTargets, incompleteLookupTargets, and the combined unverifiableTargets. Optional fields are checked only inside their inferred source domain, and unverifiable fields cannot contribute row flags.
  • summary: a human-readable, field-attributed verdict explanation.

Executable rules retain lookup bodies. Use compactVerificationResult() or compactRuleArtifact() before logging or serialising diagnostics; compact rules are explicitly marked executable: false.

infer() returns:

  • status: the evidence state for the inferred rule.
  • rule: the symbolic program to pass to transform().
  • confidence: evidentiary confidence assessment.
  • diagnosis: contradictions, ambiguities, guardrails, and suggested examples.
  • warnings: runtime or inference risks.

MCP server

The Latentmachine engine is available as a Model Context Protocol server. When connected, AI assistants can call the verification engine directly inside a conversation: the AI transforms data, then Latentmachine checks whether every row is consistent.

Remote server

Connect any MCP client that supports remote HTTP MCP servers to the hosted endpoint. No install required.

Remote MCP config for clients that accept a URL:

{
  "mcpServers": {
    "latentmachine": {
      "url": "https://www.latentmachine.com/api/mcp"
    }
  }
}

Claude Code when HTTP transport is enabled:

claude mcp add --transport http latentmachine https://www.latentmachine.com/api/mcp

Workspace config for clients that read .cursor/mcp.json-style files:

{
  "mcpServers": {
    "latentmachine": {
      "url": "https://www.latentmachine.com/api/mcp"
    }
  }
}

Local server

Availability: implemented and prepared for npm publishing. Use the remote MCP server above until @latentmachine/mcp is available on npm.

Run the MCP server locally over stdio. Data stays on your machine.

npm install -g @latentmachine/mcp

Then add to your MCP client config:

{
  "mcpServers": {
    "latentmachine": {
      "command": "latentmachine-mcp"
    }
  }
}

Or without a global install:

{
  "mcpServers": {
    "latentmachine": {
      "command": "npx",
      "args": ["@latentmachine/mcp"]
    }
  }
}

Available tools

  • verify_data_transformation: check whether a batch of transformed rows all follow one rule.
  • infer_transformation_rule: infer a rule from input/output examples.
  • apply_transformation_rule: apply a previously inferred rule to new data.
  • detect_data_format: detect JSON, CSV, YAML, TOML, XML, .env, SQL INSERT, or unknown data.
  • fingerprint_data: compute a deterministic structural fingerprint, or compare two datasets path by path.
  • learn_transformation_contract: learn an explicitly unapproved or review-required contract from examples.
  • get_contract_challenges: surface unresolved review questions without answering them.
  • test_transformation_contract: mutation-test protected behavior and disclose visible gaps.
  • run_transformation_contract: run an already-approved contract.
  • check_transformation_contract: check external output against an already-approved contract.
  • compare_transformation_contracts: classify behavioral, evidence, policy, review, and metadata changes.

Local stdio calls allow at most 500,000 characters per text argument and 1,000,000 characters for the complete JSON-RPC line. Audited rich fixtures fit roughly 900–1,200 rows per call depending on schema width, but clients should batch by serialised size.

Candidate inference uses at most 200 deterministic, output-diverse examples; the selected rule is still validated against every supplied row.

MCP can prepare a contract for review, but it cannot create local-human-review approval. Run and check fail closed until an approved artifact is supplied from Contract Studio or the CLI. Contract tools return concise, capped summaries unless a full report is explicitly requested.

Example conversation

You: I asked ChatGPT to transform these customer records. Can you check
     if it got every row right?

     [paste original + transformed data]

Claude: I checked 200 rows against the majority rule. 197 followed
        the pattern, but 3 rows have inconsistencies: rows 44, 89,
        and 156 show date format drift. The rule expects ISO dates,
        but those rows switched to US format.

CLI

Availability: implemented, pack-tested in a clean consumer project, and awaiting explicit npm release approval. The commands below will work after @latentmachine/verify is published.

Learn, inspect, approve, run, and check contracts from the command line. The existing verification and fingerprint commands remain available.

Contract workflow

npx @latentmachine/verify contract learn examples.json --out contract.json
npx @latentmachine/verify contract inspect contract.json
npx @latentmachine/verify contract challenge contract.json --inputs candidates.json
npx @latentmachine/verify contract test contract.json
npx @latentmachine/verify contract approve contract.json \
  --fingerprint <exact-core-fingerprint> \
  --acknowledge-all-advisory \
  --out approved.contract.json
npx @latentmachine/verify contract run approved.contract.json \
  --input input.json \
  --out output.json \
  --report run-report.json
npx @latentmachine/verify contract check approved.contract.json \
  --input input.json \
  --output output.json
npx @latentmachine/verify contract diff contract-v1.json contract-v2.json

Commands print structured JSON to stdout by default and diagnostics to stderr. Use --format human for concise terminal output.

  • 0: pass or successful command.
  • 1: runtime, mutation-test, or contract-check violation.
  • 2: invalid input, contract, version, or usage.
  • 3: approval required or blocking review state.

The installed primary binary is latentmachine. latentmachine-verify remains a compatibility alias during v0.x.

Existing commands

npx @latentmachine/verify original.json transformed.json
npx @latentmachine/verify fingerprint data.json
npx @latentmachine/verify fingerprint before.json after.json

Verification results remain JSON and exit 0 when consistent or 1 when inconsistent. Fingerprint comparison exits 1 when the files differ.

In CI

# GitHub Actions example
- name: Verify data transformation
  run: npx @latentmachine/verify fixtures/input.json fixtures/expected.json

The step fails if any row breaks the pattern.


HTTP API

The MCP endpoint at https://www.latentmachine.com/api/mcp also works as a standard JSON-RPC API. You can call it from any HTTP client.

List available tools

curl -X POST https://www.latentmachine.com/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Verify a batch

curl -X POST https://www.latentmachine.com/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "verify_data_transformation",
      "arguments": {
        "original": "[{\"id\":1,\"date\":\"2026-01-01\"},{\"id\":2,\"date\":\"2026-01-02\"}]",
        "transformed": "[{\"id\":1,\"date\":\"2026-01-01\"},{\"id\":2,\"date\":\"01/02/2026\"}]"
      }
    }
  }'

Fingerprint data

curl -X POST https://www.latentmachine.com/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "fingerprint_data",
      "arguments": {
        "data": "{\"a\":1,\"b\":[2,3]}",
        "compare_to": "{\"b\":[2,4],\"a\":1}"
      }
    }
  }'

Server info

curl https://www.latentmachine.com/api/mcp

Returns the server name, version, and list of available tool names.


Privacy

The browser tools process data entirely on your device. Nothing is uploaded. This is an architectural decision, not a policy.

The local MCP server (@latentmachine/mcp via stdio) and the npm package also process data locally. Your data never leaves your machine.

The remote MCP endpoint and HTTP API at latentmachine.com/api/mcp process data on Vercel infrastructure. No data is stored, logged, or persisted by the function. It is stateless and returns the result immediately, but the data does travel over the network. If that matters for your use case, use the local MCP server or the npm package instead.

Contract learning sends both examples and generated contract evidence through the selected transport. Remote contract run/check defaults to privacy-safe response shaping, which redacts raw values from returned diagnostics; it does not remove the network transfer itself.


Links