Repository avatar
AI Tools
v2.2.4
active

sva-gate

io.github.eyeoverthink/sva-gate

Zero-dependency 3-layer AI verification SDK, PII sealer, and Ed25519 receipt MCP server.

Documentation

@eyeoverthink/sva-gate (v2.2.4)

CI: Node + MCP + Python npm version MCP Registry Glama Score License: Apache-2.0

Redact streaming API keys & PII, block prompt injections, and sign/verify AI agent tool calls with pinned Ed25519 receipts — in 0 dependencies.

npm install @eyeoverthink/sva-gate

30-Second Quickstart: Catch Split-Token Secrets & Sign Agent Outputs

import { StreamSealGuard, mintSvaEr1, evaluateSvaEr1 } from '@eyeoverthink/sva-gate';

// 1. Catch secrets even when an LLM stream splits them across chunks ("sk-ant-" + "api03-...")
const guard = new StreamSealGuard();
const safeOut =
  guard.push('Send token sk-ant-') +
  guard.push('api03-secretkey1234567890abcdef to alice@example.com') +
  guard.flush();
// -> "Send token ⟦SECRET_1⟧ to ⟦EMAIL_1⟧" (0 raw secrets leaked)
const restored = guard.session.unseal(safeOut, { strict: true });

// 2. Sign & verify an agent deliverable against a caller-pinned Ed25519 public key
const { receipt, deliverable, publicKeyHex } = mintSvaEr1({ rSan: { answer: 42 } });
const verdict = evaluateSvaEr1({ receipt, deliverable, expectedPublicKeys: [publicKeyHex] });
// -> { ok: true, outcome: 'verified', deliverable: 'verified', trust: 'pinned' }

Drop-In Framework Recipes

Streaming LLM Wrapper (OpenAI / Anthropic / Vercel AI SDK)

import { StreamSealGuard } from '@eyeoverthink/sva-gate/membrane';

export async function* guardTextStream(textChunks) {
  const guard = new StreamSealGuard();
  for await (const chunk of textChunks) {
    const out = guard.push(chunk);
    if (out) yield out;
  }
  const tail = guard.flush();
  if (tail) yield tail;
}

HTTP / Express / Hono Receipt-Verification Middleware

import { evaluateSvaEr1 } from '@eyeoverthink/sva-gate/receipt';

export function requirePinnedReceipt(trustedKeys) {
  return (req, res, next) => {
    const out = evaluateSvaEr1({
      receipt: req.body?.receipt,
      deliverable: req.body?.deliverable,
      expectedPublicKeys: trustedKeys,
    });
    if (!out.ok) return res.status(403).json({ error: out.outcome, reason: out.reason });
    req.verifiedReceipt = out;
    next();
  };
}

2.1.0 — privacy membrane and skill crystallizer fixes (synced with @eyeoverthink/privacy-membrane 1.4.0 and @eyeoverthink/skill-crystallizer 1.3.0). StreamSealGuard no longer leaks a JWT, PEM key, email, password or titled name whose fragment arrives as its own chunk; SealSession.unseal(text, { strict: true }) restores only the exact ⟦TYPE_n⟧ placeholders the session issued; detection is linear on adversarial input. The skill binder now refuses quantity and negation words its examples never used ("Two $240 coats…", "…is not 25% off…") and tasks on which two rules that both fit the examples disagree; explainApply says why. MCP serverInfo.version now reports the package version.

2.0.0 — breaking: verification now asks whose signature counts. A receipt is ok only when it is intact and signed by a key you name in expectedPublicKeys (CLI: --key <hex>). Without it an intact receipt is outcome: 'integrity_only', because anyone can mint an intact receipt with their own key. Small-order Ed25519 keys (which verify any message with no private key) are refused. AER-1 v0.4 receipts carry no issuer signature and are reported as integrity_only; their deliverable is now checked against the outputs. The Merkle tree is now real RFC 6962 (raw digest bytes); receipts minted by 1.x still verify and report merkleEncoding: 'legacy-hex-text'. allowUnpinned: true (CLI --allow-unpinned) restores the 1.x behaviour for demos and migration.

Unifies the proven standards from eyeoverthink/sva-standard (v1.7.0, 106/106 tri-runtime conformance) and eyeoverthink/logic-chain-judge (v1.0.0, 321 tests) into one installable package with zero external runtime dependencies (Node 22+ ESM with TypeScript .d.ts definitions + pure Python 3.10+ stdlib companion in python/).


1. Drop Into Claude Code / Cursor / Codex / Any MCP Client (4 Lines)

{
  "mcpServers": {
    "sva-gate": {
      "command": "npx",
      "args": ["-y", "@eyeoverthink/sva-gate", "mcp"]
    }
  }
}

Gives any agent 6 deterministic verification tools over stdio JSON-RPC 2.0:

MCP ToolLayerWhat It Enforces
sva_seal_textLayer 2 (EMA/1)Seals PII/secrets (emails, SSNs, API keys, phones) into typed placeholders + StreamSealGuard cross-token split-secret sealing + keyword/zero-width prompt-injection scan
sva_mint_receiptLayer 1 (SVA-ER/1)Mints an Ed25519-signed, RFC 6962 0x00/0x01 Merkle-proven receipt + matching OPEG/1 S4_COMMIT envelope
sva_verify_receiptLayer 1 (SVA-ER/1 + AER-1)Verifies SVA-ER/1 receipts against a key you pin, and checks AER-1 v0.4 receipts (an individual Internet-Draft, draft-zambo-aer1-26, not an IETF standard) offline. AER-1 receipts carry no issuer signature, so they are reported as integrity_only
sva_check_opegLayer 2 (OPEG/1)Fail-closed pre-commit gate: blocks DIRECT_INFERENCE, tampered R_san digests, and invalid receipts (sva-er/1 or aer-1)
sva_judge_auditLayer 3 (SVA-JEV/1)Rule checks over judge results you supply (no model call): Wilson 95% CI > 2/3 on your counts, author self-vote exclusion, mandatory verbatim >= 12-char quotes, hidden planted-fake traps, and zero-LLM new_terms invention scanner
sva_crystallize_skillLayer 1 (VSC/1)Zero-LLM deterministic parameter binder induction with leave-one-out verification; refuses novel wording, unseen quantity/negation words and ambiguous rules (testResult.refused says why)

2. CLI Quick Start (10-Second Offline Self-Test)

# Run built-in 3-layer verification (receipts + OPEG tamper block + StreamSealGuard + SVA-JEV/1 + skill crystallizer)
npx @eyeoverthink/sva-gate self-test

# Seal secrets & scan for prompt injection
npx @eyeoverthink/sva-gate seal "Patient SSN 123-45-6789 key sk-ant-api03-abcdefghijklmnop1234567890"

# Demo cross-token split-secret streaming redaction
npx @eyeoverthink/sva-gate stream-demo

# Mint a signed SVA-ER/1 receipt + OPEG/1 envelope
npx @eyeoverthink/sva-gate mint '{"answer":42,"unit":"ms"}'

# Verify an SVA-ER/1 OR IETF AER-1 v0.4 receipt offline
npx @eyeoverthink/sva-gate verify receipt.json [deliverable.json]

# Evaluate an OPEG/1 gate or SVA-JEV/1 judge envelope fail-closed
npx @eyeoverthink/sva-gate gate opeg-envelope.json
npx @eyeoverthink/sva-gate judge jev-envelope.json

3. JS / TypeScript SDK (0 Dependencies)

import {
  mintSvaEr1,
  verifyAnyReceipt,
  evaluateOpeg1,
  evaluateSvaJev1,
  StreamSealGuard,
  JEV_SEMANTICS,
} from '@eyeoverthink/sva-gate';

// 1. Mint & verify an SVA-ER/1 receipt + OPEG/1 S4_COMMIT envelope
const { receipt, deliverable, opegEnvelope, publicKeyHex } = mintSvaEr1({ rSan: { ok: true, value: 42 } });
// Name the key you trust. The verifier never trusts the key inside the receipt by itself.
const trust = { expectedPublicKeys: [publicKeyHex] };
console.log(verifyAnyReceipt(receipt, { deliverable, ...trust })); // { format: 'sva-er/1', ok: true, outcome: 'verified', trust: 'pinned', ... }
console.log(evaluateOpeg1(opegEnvelope, trust));                // { ok: true, gate: 'pass', ... }
console.log(verifyAnyReceipt(receipt, { deliverable }));        // { ok: false, outcome: 'integrity_only', ... } — intact, signer not trusted

// 2. Seal split-token API keys across streaming chunks
const sg = new StreamSealGuard();
const safe = ['Key sk-', 'ant-api03-abcdefghijklmnop1234567890 ok'].map((c) => sg.push(c)).join('') + sg.flush();
// -> 'Key ⟦SECRET_1⟧ ok'. Put values back only in text a person you trust will read; strict ignores bare EMAIL_1 etc.
const restored = sg.session.unseal(modelReply, { strict: true });

// 3. Enforce SVA-JEV/1 epistemic judge gates
const verdict = evaluateSvaJev1({
  spec: 'sva-jev/1',
  semantics: JEV_SEMANTICS,
  mode: 'claim_trace',
  ledgerTexts: ['[stage 1] Enforce 80% quorum via verify_run.'],
  briefText: 'Enforce 80% quorum with 9999 retries via invented_helper_v2.',
  plantedFakes: [{ id: 'fake-1', verdict: 'unsupported' }],
});
// -> { ok: false, newTerms: ['9999', 'invented_helper_v2'], ... }

4. Pure Python 3.10+ Companion (python/)

Zero pip dependencies (standard library only):

pip install ./python
python -m unittest discover -s python/tests -v
from sva_gate import JEV_SEMANTICS, evaluate_sva_jev1
res = evaluate_sva_jev1({
    "spec": "sva-jev/1",
    "semantics": JEV_SEMANTICS,
    "mode": "calibration",
    "answered": 36, "total": 36, "right": 33, "realFound": 12, "realTotal": 12,
})

Honest Limits

  • The privacy membrane is regex-based. It misses IPv6 addresses, SSNs written without dashes and names without a title. Default (lenient) unseal also restores [EMAIL_1], <EMAIL_1> and the bare word EMAIL_1, so any text that names a placeholder receives the real value; use { strict: true } for text shown to others. The streaming guard emits each word when the next whitespace arrives, and only holds what a detector could recognise.

  • The skill binder gates a fixed list of quantity and negation words before numbers, not every meaning-changing phrase; treat a routed answer as a draft for templated tasks only.

  • The prompt-injection scan is a keyword list. Paraphrases, other languages and homoglyphs score 0.

  • Signatures prove post-signing integrity and key possession, not that a compromised host didn't fabricate data prior to signing. Local unsynced clocks are explicitly labeled unattested.

  • SVA-JEV/1 verdicts are stamped stability-signal-not-correctness — multi-model consensus is never proof of truth.

  • Deterministic new_terms catches invented numbers and code identifiers, not subtle semantic paraphrasing.

Related Repositories & Live Offline Playgrounds

License

Apache-2.0 — see LICENSE.

NPM
@eyeoverthink/sva-gate
Install Command
npm install @eyeoverthink/sva-gate