Skip to main content

Local enforcement SDK and simulation environment for AI governance.

Project description

Waveframe Guard

Stop unsafe AI and automated actions before they execute.

Waveframe Guard enforces governance at the execution boundary. If an action violates policy, it never runs.

Example

This example assumes a published contract artifact exists at contracts/finance-core-0.3.1.contract.json. In your application, point contract_path at the contract published by your governance workflow.

from pathlib import Path

from waveframe_guard import install_guard, guard

install_guard(
    actor={"id": "user-1", "type": "human", "role": "intern"},
    contract_path=Path("contracts") / "finance-core-0.3.1.contract.json"
)

@guard
def transfer(amount):
    print(f"Transferred ${amount}")

transfer(100)
Execution blocked: required role not satisfied: manager

Governed Runtime

For applications that want to resolve published contracts from a registry, use GovernedRuntime:

from waveframe_guard import GovernedRuntime

runtime = GovernedRuntime(
    registry_path="contracts/index.json"
)

runtime.execute(
    actor={"id": "user-1", "type": "human", "role": "intern"},
    contract_id="finance-policy",
    fn=transfer,
    args=(1250000,),
)

By default, blocked execution raises GovernanceError. To observe the decision without raising, pass raise_on_block=False:

result = runtime.execute(
    actor={"id": "user-1", "type": "human", "role": "intern"},
    contract_id="finance-policy",
    fn=transfer,
    args=(1250000,),
    raise_on_block=False,
)

print(result.allowed)
print(result.reason)
print(result.contract_hash)

Allowed executions return GovernedExecutionResult(allowed=True, reason="execution allowed", value=<function return value>, ...). Blocked executions return GovernedExecutionResult(allowed=False, reason=<policy reason>, error=<block error>, ...).

The registry can map contract IDs to published contract artifacts:

{
  "contracts": {
    "finance-policy": "finance-core-0.3.1.contract.json"
  }
}

Runtime execution is intentionally small in v1: registry lookup, load the published contract, install the Guard context, execute the guarded function, then allow or block.

You can also bind runtime context once and omit it from each execution:

runtime = GovernedRuntime(registry_path="contracts/index.json")
runtime.install_actor({"id": "user-1", "type": "human", "role": "manager"})
runtime.bind_contract("finance-policy")

result = runtime.execute(
    fn=transfer,
    args=(1250000,),
    raise_on_block=False,
)

Per-call actor and contract_id values still work and override the bound context for that call.

For proposal-bound execution, pass a normalized proposal directly:

result = runtime.execute_proposal(
    proposal,
    raise_on_block=False,
)

execute_proposal evaluates the proposal against the bound or supplied contract and returns the same GovernedExecutionResult shape.

Each runtime execution also emits a structured SDK-local audit event. Events are kept in memory on the runtime and attached to non-raising results:

result = runtime.execute(
    fn=transfer,
    args=(1250000,),
    raise_on_block=False,
)

print(result.event)
print(runtime.last_event)
print(runtime.audit_events)

Example event:

{
    "event_type": "governed_execution",
    "execution_type": "function",
    "allowed": False,
    "reason": "required role not satisfied: manager",
    "error": "Execution blocked: required role not satisfied: manager",
    "contract_id": "finance-policy",
    "contract_version": "0.3.1",
    "contract_hash": "...",
    "actor": {"id": "user-1", "type": "human", "role": "intern"},
    "target": "transfer",
    "timestamp": "2026-05-12T12:00:00+00:00",
}

To append events locally as JSON lines:

runtime = GovernedRuntime(
    registry_path="contracts/index.json",
    audit_path="runtime-audit.jsonl",
)

What Waveframe Guard Does

  • Intercepts function execution
  • Loads published contract artifacts
  • Evaluates governance rules before execution
  • Blocks invalid actions deterministically
  • Continues enforcement even if Cloud is unavailable

Local vs Cloud

Mode Behavior
Local Fast, local enforcement
Cloud Policy sync, audit, and attestation

Guard enforces locally. Cloud provides authority, audit, and verification.

Fail Modes

Mode Behavior
cache (default) Use cached policy if Cloud is unavailable
closed Block if Cloud is unavailable and no cached policy exists
open Allow execution if policy is unavailable and mark the decision unverified

Install

pip install waveframe-guard cricore-contract-compiler cricore-proposal-normalizer

Live Demo

python examples/live_enforcement_demo.py

The demo shows:

  • an intern blocked by policy
  • a manager allowed by policy
  • cached local enforcement during a simulated Cloud outage

Published Contracts

Guard runtime consumes published governance authority artifacts:

from pathlib import Path

install_guard(
    actor={"id": "user-1", "type": "human", "role": "manager"},
    contract_path=Path("contracts") / "finance-core-0.3.1.contract.json"
)

Inline policy dictionaries are authored and compiled before runtime. Guard loads the compiled contract artifact and enforces against it locally.

Guard also records contract metadata in runtime context for audit and telemetry:

{
    "contract_id": "finance-core",
    "contract_version": "0.3.1",
    "contract_hash": "..."
}

Why This Exists

Most AI systems can suggest, warn, or log.

Waveframe Guard is the layer that can stop execution.

Architecture Note

The Waveframe Guard SDK operates independently and does not require Cloud components to enforce governance locally.

The cloud directory contains experimental Cloud control plane components and is not required for SDK operation.

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

waveframe_guard-0.4.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

waveframe_guard-0.4.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file waveframe_guard-0.4.0.tar.gz.

File metadata

  • Download URL: waveframe_guard-0.4.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for waveframe_guard-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2e0fdef7ee427736a053c3564b2226e16d032a816e2c2da9ea4593e3fb89a6ae
MD5 aabe9f9f1b3b8764ce47c6609a9a20da
BLAKE2b-256 2bd3c29d643ef16042b3b85a0659e640eac0fa772ab1d424fb42dd126a496c31

See more details on using hashes here.

File details

Details for the file waveframe_guard-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for waveframe_guard-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f86c6b1dad3ca7c0ed73a4cd80236aa7fab38a9f18799fbf068df39287d3381f
MD5 04681c930ac72e6fedf451ffc3c7cb18
BLAKE2b-256 783cfec61f7d9d69e752ca55f61dd1b17852721f3695248fe14bcf6ce3d461b9

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