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.2.0.tar.gz (25.7 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.2.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cmvk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7749fc5e73c04636629bf17867b5d4750c1ba606ca9f380492f6e16cbca233a8
MD5 57474b715686fbf756911d0a363840c4
BLAKE2b-256 b9bf524d47d3abb7cba21030409cad32a32ab8b4ebcc28d1be6d366ba88a0372

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cmvk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb12d5a649c1e79acb4fd2d683a52c86ee90734be4acd30f5126e798578b3352
MD5 a5f990f5be431aaedc06d7f0b8b6129e
BLAKE2b-256 675ef2944f93a1d13afc801d86303b9928e212bc6e43a41f6816af6f98c8dd07

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