Skip to main content

SluiceGate Open Core

Project description

SluiceGate Open Core

This directory contains the SluiceGate Open Core: a pure, deterministic policy engine for governing actions taken by autonomous systems (AI agents, services, workflows, humans-in-the-loop).

The Open Core is intentionally side-effect free. It evaluates requests against policy, returns decisions and obligations, and emits audit events — but it does not execute actions, send emails, or integrate with vendors.

Those behaviors belong in adapters (demos, SDKs, enterprise deployments).


WHAT THE OPEN CORE IS

  • A policy evaluation engine
  • A decision point for agent actions
  • A governance control plane, not an approval workflow
  • A library, not a service

Given a request, the core returns:

  • a decision: ALLOW, PAUSE, or BLOCK
  • a policy provenance hash
  • zero or more structured obligations (e.g. require_approval)
  • optional audit events (via a callback)

WHAT THE OPEN CORE IS NOT

  • Not an email system
  • Not a workflow engine
  • Not a UI
  • Not tied to HTTP, REST, or any transport
  • Not opinionated about how obligations are enforced

Those concerns are deliberately kept outside the core.


REPOSITORY STRUCTURE

open-core/ ├── pyproject.toml ├── README.md ├── src/ │ └── sg_core/ │ ├── init.py │ ├── adapters.py │ ├── decision_loop.py │ ├── models.py │ ├── obligation_adapter.py │ ├── pause_api.py │ ├── policy.py │ └── py.typed ├── examples/ │ └── run_local_decision.py ├── policies/ │ └── example-policy.yml └── tests/ (future pytest tests)


PUBLIC API (BETA-STABLE)

The primary entrypoint is the Gate object.

Import pattern:

from sg_core import Gate, PolicyEngine, GateRequest

Key methods:

  • Gate.evaluate(request) Returns a GateDecision (decision + obligations + policy hash)

  • Gate.explain(request) Returns an ExplainResult (decision + obligations + full trace) This is a pure simulation with no side effects.

The core never performs execution or notification.


DEVELOPMENT SETUP (USING UV)

Prerequisites:

Setup steps:

cd open-core uv sync uv pip install -e .

Sanity check:

uv run python -c "import sg_core; print('sg_core import ok')"


RUNNING THE EXAMPLE HARNESS

The example harness runs a set of policy test cases entirely in-process.

It demonstrates:

  • rule matching
  • ALLOW vs PAUSE decisions
  • default fallback behavior
  • obligation generation
  • policy provenance hashing
  • explain / trace output per request

Run it with:

uv run -m examples.run_local_decision

The harness prints both the decision and the explain trace for each test.


POLICY DSL

Policies are defined as YAML files under the policies/ directory.

They operate over four top-level request domains:

  • actor
  • action
  • target
  • context

Rules are evaluated top-to-bottom. All conditions within a rule must match (AND-only in Beta). The first matching rule wins; otherwise the policy default applies.

See docs/Policy_DSL.md at the repo root for the full DSL specification.


EXPLAIN MODE (POLICY SIMULATION)

Gate.explain() provides a pure, side-effect-free evaluation trace, including:

  • which rule matched (or default)
  • which conditions passed or failed
  • actual vs expected values
  • resulting decision and obligations

Explain mode is intended for:

  • policy authoring
  • debugging
  • audit review
  • UI visualization
  • dry-run simulations

Explain mode does not emit audit events or execute anything.


OBLIGATIONS AND ADAPTERS

The Open Core returns obligations as data:

Obligation(type="require_approval", data={...})

How those obligations are enforced is left to adapters.

A minimal adapter interface (ObligationAdapter) is defined, but the core never invokes it automatically. This preserves purity and extensibility.


AGENT ADAPTERS / WEBSOCKETS / FASTAPI ENDPOINTS

-PollingPauseAdapter (sync) -AsyncPollingPauseAdapter (async)

They implement the “if PAUSE → wait → resume with ALLOW or BLOCK” pattern in one reusable component (so PAUSE is not treated as an error.)

“Wait” without polling: SSE + WebSocket

-SSE: GET /pause/{token}/events Streams event: pause messages with JSON payloads; auto-closes when resolved/expired.

-WebSocket: WS /ws/pause/{token} Sends initial state then pushes updates; closes on resolved/expired.

FastAPI endpoints

GET /pause/{token} → returns { pause: ..., decision: ... } GET /pause/{token}/decision → returns the current decision (PAUSE|ALLOW|BLOCK) POST /pause/{token}/approve body: { "approver": "...", "comment": "..." } POST /pause/{token}/deny body: { "approver": "...", "comment": "..." }


DESIGN PRINCIPLES

  • Deterministic
  • Declarative
  • Transport-agnostic
  • Side-effect free
  • Explicit separation of decision and execution
  • Extensible without modifying core logic

LICENSE

See LICENSE.md at the repo root.


STATUS

Beta.

The core API and Policy DSL are considered stable for experimentation and early adoption. Future versions may add features in a backward-compatible manner.

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

sg_core-0.1.2.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

sg_core-0.1.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file sg_core-0.1.2.tar.gz.

File metadata

  • Download URL: sg_core-0.1.2.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for sg_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 218b3542c42ef3fe1695d5c35ab04bfb65d624e3ba1e15976e3943a4b2aa5f59
MD5 1039705a028e7cc0f2643e0dd656441c
BLAKE2b-256 4a29b244dfd84a8e0b89cc71b5dae17d15493c9824c8cbb42655b97497382db5

See more details on using hashes here.

File details

Details for the file sg_core-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sg_core-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for sg_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1651fc546cdf40534415c34467e949f389e9ab3a18918b277303a785fada643
MD5 6e74cda326fe946fba006c97e1711fe6
BLAKE2b-256 012c89828c0e7e1eb7ac646fe1cc5a45da8dc2980f00bdff0d9a68e5c43511e3

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