Skip to main content

DBL Gateway

Project description

DBL Gateway

Tests Python License PyPI version

DBL Gateway is a deterministic execution boundary for LLM calls.

It enforces explicit intent, policy decisions, and execution as an auditable, replayable event stream.

This is not:

  • a RAG pipeline
  • a workflow engine
  • a UI product

The gateway does not decide what to do. It decides whether an explicitly declared action may execute.

Supported Providers (v0.4.x)

The gateway supports multiple LLM providers through a unified execution contract.

Currently supported:

  • OpenAI (cloud)
  • Anthropic (cloud)
  • Ollama (local or remote)

Providers are discovered at runtime via capabilities introspection.


Repository Landscape

The gateway is part of a small toolchain:

dbl-gateway (this repository)

Authoritative execution boundary and event log. The gateway is authoritative for execution, but not for interpretation. It emits facts, not narratives.

  • Accepts explicit intents.
  • Applies policy.
  • Executes provider calls.
  • Emits canonical events (INTENT, DECISION, EXECUTION).
  • Persists an append-only event trail.
  • Exposes read-only observation surfaces (/snapshot, /tail).

dbl-operator

Observer and intervention client. Used for rendering timelines, audits, and decision views. Does not evaluate policy or store authoritative state.

dbl-chat-cli

Minimal interactive CLI client for smoke testing and quick interaction via terminal.

dbl-chat-client

Pure event-projection UI. Real-time visualization of the gateway event stream and identity anchor management.


Interaction Model

Every interaction follows the same sequence:

  1. INTENT – explicit request with identity anchors (thread_id, turn_id).
  2. DECISION – policy outcome (ALLOW/DENY).
  3. EXECUTION – provider call and result.
  4. OBSERVATION – read-only access via snapshot or tail.

Only DECISION events are normative. EXECUTION events are observational and cannot influence policy or state.

No step is implicit; every event is linked via a stable correlation_id.


Design Principles

  • Explicit boundaries: Strict separation between core logic, policy, and execution.
  • Append-only records: Immutable event trail for audit and replay.
  • No hidden state: No heuristics or internal memory beyond the event stream.
  • Observer-safe: Clients may observe and project state, but cannot affect policy, execution, or event ordering.

Context System (v0.4.0+)

The gateway supports explicit context declaration for multi-turn conversations.

declared_refs

Clients can reference prior events as context via IntentEnvelope.payload.declared_refs:

{
  "declared_refs": [
    {"ref_type": "event", "ref_id": "correlation-id-1"},
    {"ref_type": "event", "ref_id": "turn-id-2"}
  ]
}

These references are resolved by the gateway and injected into the LLM context as a deterministic system block. This allows for multi-turn conversations without the gateway implicitly managing history.

I_context / O_context Split

Type Admitted For Digest Scope Policy Access
INTENT events governance ✅ Included ✅ Yes
EXECUTION events execution_only ✅ Included (audit) ❌ No

This ensures observations never influence governance decisions (DBL Claim 4).

Configuration

Context behavior is controlled by config/context.json:

{
  "max_refs": 50,
  "empty_refs_policy": "DENY",
  "canonical_sort": "event_index_asc",
  "enforce_scope_bound": true
}

The config digest is pinned in every DECISION event for replay verification.

See docs/CONTEXT.md for the full specification.


Installation

Local Install

Create a virtual environment and install the gateway:

pip install .

Docker (Quick Start)

The gateway can be started in observer mode without executing any LLM calls:

docker run -p 8010:8010 dbl-gateway

This allows inspecting capabilities, snapshots, and event streams.

To enable execution, provide a policy and at least one provider:

docker run -p 8010:8010 \
  -e DBL_GATEWAY_POLICY_MODULE="dbl_policy.allow_all" \
  -e OPENAI_API_KEY="sk-..." \
  lukaspfister/dbl-gateway:0.4.2

Running the Gateway

Environment Variables

Required for execution

Variable Description
DBL_GATEWAY_POLICY_MODULE Policy module path
OPENAI_API_KEY Or another provider

Optional

Variable Description
DBL_GATEWAY_POLICY_OBJECT Default: policy
OLLAMA_HOST Remote Ollama endpoint

Start Command

dbl-gateway serve --host 127.0.0.1 --port 8010

Observation Surfaces

Snapshot (/snapshot)

Returns a point-in-time state of the event log. Suitable for audits and offline inspection.

Tail (/tail)

A live SSE stream of events.

  • since: Start streaming from a specific event index.
  • backlog: Number of recent events to emit on connect (default: 20).

Integration Examples

Using the Operator

$env:DBL_GATEWAY_BASE_URL = "http://127.0.0.1:8010"
dbl-operator thread-view --thread-id t-1

Using the Chat CLI

dbl-chat-cli --base-url http://127.0.0.1:8010 --principal-id user-1

Using the Chat Client

# In the dbl-chat-client repository:
npm install && npm run dev

Status

Early, but operational. Core execution, policy gating, and auditing are stable. Current focus: surface stabilization and contract clarity.

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

dbl_gateway-0.4.2.tar.gz (63.1 kB view details)

Uploaded Source

Built Distribution

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

dbl_gateway-0.4.2-py3-none-any.whl (56.3 kB view details)

Uploaded Python 3

File details

Details for the file dbl_gateway-0.4.2.tar.gz.

File metadata

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

File hashes

Hashes for dbl_gateway-0.4.2.tar.gz
Algorithm Hash digest
SHA256 fc27f550779c89b5ac27e8e8a0ace99e35a21c1c6f4b6cb38235870fad81d7d6
MD5 cfadeb9e5377c0f8920dd953a7298fc1
BLAKE2b-256 44e208e8ab3bc1f8d105e164b70bb5ccc137e91ba182a44be526ac00db6f8c14

See more details on using hashes here.

File details

Details for the file dbl_gateway-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: dbl_gateway-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 56.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for dbl_gateway-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5fe9c87b4b40231a15f46d49afc888ba4faf2a7c39ede3f35c60e4e1bdba2b39
MD5 abb7ee32787c03a2e9c3fff4c0da17e7
BLAKE2b-256 2c4023fd63539b5004609fd7d357eaec3f9a6afc4a054178c4f9e3799e12a8b0

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