Skip to main content

Mathematical and adversarial verification library for calculating drift/hallucination scores between outputs

Project description

CMVK - Cross-Model Verification Kernel

PyPI version License: MIT Build Status

Mathematical drift detection between outputsโ€”pure functions, zero dependencies on agent logic. Part of the Agent OS ecosystem.


๐Ÿง  Why CMVK?

Agent systems fail when they cannot measure semantic drift. LLMs hallucinate, models diverge, and outputs degrade without quantifiable verification. The naive approach couples verification logic directly into agent control loops, creating brittle, untestable architectures.

CMVK exists because verification is a primitive, not a feature. We subtract LLM calls, agent orchestration, and correction loops from the verification layer. What remains is a pure mathematical kernel: verify(a, b) -> score. This separation enables compositionโ€”verification becomes a reusable building block across the Agent OS stack.

Scale by Subtraction: Remove dependencies on external services. CMVK uses only numpy (and optionally scipy). No API keys. No network calls. No side effects. Just deterministic drift calculation.


๐Ÿ“ฆ Installation

pip install cmvk

For enhanced statistical functions:

pip install cmvk[scipy]

โšก Quick Start

from cmvk import verify

score = verify("def add(a, b): return a + b", "def add(x, y): return x + y")
print(f"Drift: {score.drift_score:.3f}")  # 0.0 = identical

That's it. Five lines, zero configuration. verify() returns a VerificationScore with drift magnitude (0.0-1.0), confidence, and classification (semantic, structural, numerical, or lexical).


๐Ÿ—๏ธ Architecture

CMVK sits at Layer 1 (Primitives) of the Agent OS. It provides low-level mathematical operations that higher layers depend on:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Layer 3: Framework (agent-control-plane)โ”‚
โ”‚  โ”œโ”€ Self-Correction Loop (scak)         โ”‚
โ”‚  โ””โ”€ Orchestration Logic                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ–ฒ
              โ”‚ uses verification scores
              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Layer 2: Infrastructure                โ”‚
โ”‚  โ”œโ”€ iatp: Trust Protocol                โ”‚
โ”‚  โ”œโ”€ amb: Message Bus                    โ”‚
โ”‚  โ””โ”€ atr: Tool Registry                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ–ฒ
              โ”‚ composes primitives
              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Layer 1: Primitives (THIS LAYER)       โ”‚
โ”‚  โ”œโ”€ cmvk: Verification (THIS PROJECT) * โ”‚
โ”‚  โ”œโ”€ caas: Context-as-a-Service          โ”‚
โ”‚  โ””โ”€ emk: Episodic Memory Kernel         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Design Principle: CMVK never calls external services. Higher layers (like scak) orchestrate correction loops using CMVK's verification scores. This inverted dependency enables testing, composability, and deterministic behavior.

API Surface:

  • verify(a, b) โ€” High-level text comparison
  • verify_embeddings(emb_a, emb_b) โ€” Vector comparison (cosine, euclidean)
  • verify_distributions(dist_a, dist_b) โ€” Distribution comparison (KL divergence, JS divergence)
  • verify_sequences(seq_a, seq_b) โ€” Sequence comparison (edit distance, LCS)
  • verify_batch(...) โ€” Batch operations with aggregation

All functions return immutable VerificationScore objects:

@dataclass(frozen=True)
class VerificationScore:
    drift_score: float      # 0.0 (identical) to 1.0 (completely different)
    confidence: float       # 0.0 to 1.0
    drift_type: DriftType   # SEMANTIC | STRUCTURAL | NUMERICAL | LEXICAL
    details: dict           # Component scores and metadata

๐Ÿ—บ๏ธ Agent OS Ecosystem

CMVK is one component of a modular Agent Operating System. Each project solves a single problem without assuming the existence of others.

Layer 1: Primitives

  • caas โ€” Context-as-a-Service: Efficient context window management
  • cmvk (this project) โ€” Verification: Drift detection between outputs
  • emk โ€” Episodic Memory Kernel: Long-term memory for agents

Layer 2: Infrastructure

  • iatp โ€” Inter-Agent Trust Protocol: Cryptographic verification of agent messages
  • amb โ€” Agent Message Bus: Decoupled communication between agents
  • atr โ€” Agent Tool Registry: Dynamic tool discovery and invocation

Layer 3: Framework

  • agent-control-plane โ€” The Core: Orchestrates primitives and infrastructure
  • scak โ€” Self-Correction Agent Kernel: Verification-driven correction loops

Philosophy: Each layer subtracts complexity from the layer above. Primitives have zero cross-dependencies. Infrastructure composes primitives. Framework orchestrates infrastructure.


๐Ÿ“š Citation

If you use CMVK in research or production systems, please cite:

@software{cmvk2024,
  author = {Siddique, Imran},
  title = {CMVK: Cross-Model Verification Kernel},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/imran-siddique/cross-model-verification-kernel},
  note = {Part of the Agent OS ecosystem}
}

๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿ”— Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmvk-0.3.0.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmvk-0.3.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file cmvk-0.3.0.tar.gz.

File metadata

  • Download URL: cmvk-0.3.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cmvk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4bc4f9e1ccb78929a3c0200ed67f146debbfc77ff0091e2e0bd34acfaa80c865
MD5 1242565f286f4469e5bdcd402364c533
BLAKE2b-256 070b6612528129ecbadb060e3a46a611ae4fca384d3bdf29822bf561ecb06c34

See more details on using hashes here.

File details

Details for the file cmvk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cmvk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cmvk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a52303f302174a9d017aa652feca897a07014b010e54ffeae1c80641715a269b
MD5 0425ff2992226825387a844575649bc3
BLAKE2b-256 bc6625c25bb18bea666e9215db9e8af1862b89f7b6c993c3fa3c1c8c6f60d1f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page