Skip to main content

Deterministic AST static analysis boundaries for LLM code execution.

Project description

VAREK

A statically-typed, LLVM-compiled gateway for deterministic AI execution.

What is VAREK?

VAREK is an open-source, strictly-typed AI infrastructure gateway compiled via LLVM. It is designed to physically prevent rogue AI execution and hallucinated payloads at the consequence boundary.

Where today's AI/ML workflows require stitching together probabilistic Python scripts, YAML configs, and dynamically-typed JSON payloads that fundamentally fail open, VAREK replaces them with a deterministic physics engine.

The Consequence Boundary Problem

Modern enterprise pipelines execute high-stakes actions (database writes, financial trades, medical telemetry) using probabilistic LLM outputs serialized into JSON. This is an engineering dead end. You cannot secure probabilistic models with more probabilistic "LLM-as-a-judge" wrapper scripts.

VAREK was built to enforce consequence boundaries. By utilizing strict Hindley-Milner type inference before the LLVM compilation step, VAREK mathematically validates AI payloads at the machine-code level. If an autonomous agent hallucinates a schema or a tensor shape, the circuit breaks.

Physics, not probabilities.

Core Design Principles

1. Speed by Default (Sub-50ms Latency)

VAREK compiles to native machine code via LLVM. Interpreted mode is available for rapid prototyping, but production pipelines run compiled. Benchmarks show 10–40x speedups over equivalent Python for data-heavy operations, ensuring boundary checks do not create pipeline bottlenecks.

2. Hindley-Milner Type Inference

Mathematically provable static typing without the syntactic bloat. Shape validation and memory safety are enforced before execution.

  • Memory safety enforced at compile time — no null pointer exceptions, no buffer overflows.
  • Immutability by default; mutability is explicit and intentional.
  • Checked error handling — errors cannot be silently ignored or dynamically bypassed.

3. Unified Boundary Syntax

VAREK syntax reads like structured English but compiles like C. The same file defines strict data schemas, pipeline logic, API contracts, and configuration. No context switching, no format translation, no JSON serialization vulnerabilities.

4. AI-Native Primitives

VAREK is the first compiled language designed with deterministic LLM collaboration in mind:

  • Unambiguous grammar (no parsing edge cases for agent generation).
  • Built-in tensor and matrix primitives.
  • Native async/await for model inference backpressure.
  • Pipeline operators (|>) for composing safe model chains.

Syntax at a Glance

-- VAREK Sample: Safe Image Classification Pipeline

schema ImageInput {
    path: str,
    label: str?,
    resolution: (int, int)
}

pipeline classify_images {
    source: ImageInput[]
    steps: [
        preprocess -> normalize -> infer -> postprocess
    ]
    output: ClassificationResult[]
}

fn preprocess(img: ImageInput) -> Tensor {
    load_image(img.path)
        |> resize(224, 224)
        |> normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
}

fn infer(tensor: Tensor) -> RawOutput {
    model := load_model("resnet50.var")
    model.forward(tensor)
}

fn postprocess(raw: RawOutput) -> ClassificationResult {
    ClassificationResult {
        label: raw.top_class(),
        confidence: raw.softmax().max()
    }
}

Compare this to the equivalent: a Python script, a YAML config, a JSON schema, and a shell script — VAREK replaces all four with mathematically provable boundaries.

Key Features

Feature Description
pipeline blocks First-class pipeline definitions with statically-typed stages
schema types Built-in data schema definitions (replaces JSON Schema, Pydantic)
|> operator Unix-style pipe chaining for data transformations
async inference Native async model calls with strict backpressure support
tensor primitives Built-in n-dimensional array type with shape validation
safe blocks Explicit unsafe escape hatches (like Rust)
Interop Import Python, C, and Rust libraries natively
REPL Full interactive shell for pipeline exploration

Why Now?

The AI/ML tooling landscape is paralyzed by design debt. Tools built before the deep learning era were retrofitted to handle autonomous model pipelines. We are trusting trillion-parameter models to dynamically-typed glue code.

JSON won because XML was bloated. Python won because C was inaccessible. VAREK wins because the current stack is a fail-open liability.

Roadmap & Status

659 tests passing • 13,006 lines of code • MIT License

  • v0.1 — Formal grammar spec + reference parser
  • v0.2 — Type system + Hindley-Milner inference engine
  • v0.3 — LLVM compilation backend + native code generation
  • v0.4 — Standard library (var::io, var::tensor, var::http, var::async, var::pipeline)
  • v1.0.0 — Stable release + varek package manager CLI + RFC governance process

Community

GitHub Discussions is the official space for VAREK conversation.


VAREK Security Command


🛡️ VAREK Guardrails (PyPI Package)

VAREK provides a defense-in-depth architecture for AI agents, utilizing both static AST boundaries and PEP 578 Runtime Audit Hooks to prevent Remote Code Execution (RCE).

Installation

Install the core engine directly via pip: ```bash pip install varek-guardrails ```

Quick Start

Wrap your agent's code execution in the VAREK boundary:

```python from varek import secure_exec import sys

1. (Optional) Arm the global runtime warden

from varek.engine import varek_runtime_monitor sys.addaudithook(varek_runtime_monitor)

2. Execute agent payloads through the AST Gate

agent_payload = "import os\nos.system('echo Vulnerable')"

try: secure_exec(agent_payload) except RuntimeError as e: print(f"Threat Neutralized: {e}") ```

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

varek_guardrails-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

varek_guardrails-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file varek_guardrails-0.1.0.tar.gz.

File metadata

  • Download URL: varek_guardrails-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for varek_guardrails-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9844a9505d4f8ea0b3df391c60652dcb6275d408e17d29e414709a67cf93fa88
MD5 db0ce4358fa18618e429492c01c2578a
BLAKE2b-256 83dda6e3438f2d24142e3f7731fe4389553b6d3d960f9fe64f3c5132ab2f70e3

See more details on using hashes here.

File details

Details for the file varek_guardrails-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for varek_guardrails-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7681530b964d327ede7ffae8141f7799784748b70b7b350fd5b1cc1fb36e2358
MD5 0033144d61e8c4661a69b5224c61df1c
BLAKE2b-256 87252a2dc0fc6931c75b5f5743ff45ebc27261f2d692ee7c4261b0cdd0a55065

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