Skip to main content

Execution gateway and policy layer on top of KL Kernel Logic.

Project description

KL Exec Gateway

A small execution layer that lets you see and govern what an LLM actually does.

Most LLM calls are a black box: you send a prompt, something happens in between, and a result appears.

You don't see the steps, the decisions, or the filters.

KL Exec Gateway makes the entire process visible.

It runs each request through a deterministic pipeline:

LLM → Policy → Sanitization → Formatting → Trace

Every step recorded.
Local. Reproducible. Inspectable.


Try it in 10 seconds

pip install kl-exec-gateway
kl-gateway-web
# On first launch, the Browser will prompt you to enter your OpenAI API key.

Opens automatically at http://localhost:8787

You immediately see:

  • Live pipeline execution with animation
  • what you sent to the model
  • what the model returned
  • which rules were applied
  • what was removed or transformed
  • the final output
  • the full step-by-step trace

KL Exec Gateway Pipeline

Alternative: CLI mode

kl-gateway --key "sk-..."

Interactive terminal chat with full trace logging.


Examples

1. Allowed

A normal request flows through the entire pipeline:

hello

Result:

LLM → policy → sanitize → format → done

2. Denied after LLM (length limit)

tell me a love story

This usually produces a long answer that exceeds the default 500-character length policy:

LLM → policy (DENY_LENGTH) → done

3. Denied before LLM (forbidden pattern)

If a request contains a forbidden pattern (configured in the policy engine), it is blocked before the model is even called:

my secret code

Result:

policy (DENY_PATTERN) → done

The LLM step is skipped entirely.


Use cases

  • enforce policies on LLM output
  • remove or mask sensitive data
  • analyse model behaviour
  • build safe internal tools
  • reproduce responses
  • explain decisions to auditors or teams

Simple building blocks. All deterministic (except the LLM call).


Configuration

Default limits: 500 characters, basic pattern blocking.

To adjust:

  • Edit policy.config.json (policy limits)
  • Edit pipeline.config.json (pipeline steps, logging, trace)
  • Use templates: configs/production.config.json, configs/compliance-gdpr.config.json

Documentation


About the KL Execution Model

This project demonstrates how deterministic execution, policy evaluation and step-level traces can be composed into a practical LLM gateway.

It uses KL Kernel Logic as its underlying execution substrate.

For details on how the gateway maps to the execution axioms, see docs/THEORY_ALIGNMENT.md.


License

MIT

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

kl_exec_gateway-0.3.1.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

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

kl_exec_gateway-0.3.1-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

Details for the file kl_exec_gateway-0.3.1.tar.gz.

File metadata

  • Download URL: kl_exec_gateway-0.3.1.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for kl_exec_gateway-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e4f9d5c3d06101bd9ed914064cff8ccbc6e51b8922bbaffa2799fc984f52fdc1
MD5 154edc1d83f1d3f86dcaf749555aa521
BLAKE2b-256 ad10efee63dd83fd939b366c5e004cc9c971eeb2b020cf9f6c1e9748b7581d21

See more details on using hashes here.

File details

Details for the file kl_exec_gateway-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kl_exec_gateway-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6363967713a68f6a5e08770c23cd75558ea045e854325ca0d280def884cfe78
MD5 9fcc1a4d31345c6fff7511bada116382
BLAKE2b-256 d045685d835daa15cfdd0594bb42cbc88251144856b1385b1e26c14996ad59c8

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