Skip to main content

Deterministic pre-execution authority layer for AI agents.

Project description

predicate-authority

predicate-authority is a deterministic pre-execution authority layer for AI agents. It binds identity, policy, and runtime evidence so risky actions are authorized before execution and denied fail-closed when checks do not pass.

Docs: https://www.PredicateSystems.ai/docs Github Repo: https://github.com/PredicateSystems/predicate-authority

Core pieces:

  • PolicyEngine for allow/deny + required verification labels,
  • ActionGuard for pre-action authorize / enforce,
  • LocalMandateSigner for signed short-lived mandates,
  • InMemoryProofLedger and optional OpenTelemetryTraceEmitter,
  • typed integration adapters (including sdk-python mapping helpers),
  • control-plane client primitives for shipping proof and usage batches to hosted APIs,
  • local identity registry primitives (ephemeral task identities + local flush queue).

Quick usage example

from predicate_authority import ActionGuard, InMemoryProofLedger, LocalMandateSigner, PolicyEngine
from predicate_contracts import (
    ActionRequest,
    ActionSpec,
    PolicyEffect,
    PolicyRule,
    PrincipalRef,
    StateEvidence,
    VerificationEvidence,
)

guard = ActionGuard(
    policy_engine=PolicyEngine(
        rules=(
            PolicyRule(
                name="allow-orders",
                effect=PolicyEffect.ALLOW,
                principals=("agent:orders",),
                actions=("http.post",),
                resources=("https://api.vendor.com/orders",),
            ),
        )
    ),
    mandate_signer=LocalMandateSigner(secret_key="replace-with-strong-secret"),
    proof_ledger=InMemoryProofLedger(),
)

request = ActionRequest(
    principal=PrincipalRef(principal_id="agent:orders", tenant_id="tenant-a"),
    action_spec=ActionSpec(
        action="http.post",
        resource="https://api.vendor.com/orders",
        intent="create order",
    ),
    state_evidence=StateEvidence(source="backend", state_hash="sha256:example"),
    verification_evidence=VerificationEvidence(),
)

decision = guard.authorize(request)
print("allowed=", decision.allowed, "reason=", decision.reason.value)

Entra compatibility demo (capability-gated OBO)

python examples/delegation/entra_obo_compat_demo.py \
  --tenant-id "$ENTRA_TENANT_ID" \
  --client-id "$ENTRA_CLIENT_ID" \
  --client-secret "$ENTRA_CLIENT_SECRET" \
  --scope "${ENTRA_SCOPE:-api://predicate-authority/.default}"

OIDC compatibility demo (capability-gated token exchange)

python examples/delegation/oidc_compat_demo.py \
  --issuer "$OIDC_ISSUER" \
  --client-id "$OIDC_CLIENT_ID" \
  --client-secret "$OIDC_CLIENT_SECRET" \
  --audience "$OIDC_AUDIENCE" \
  --scope "${OIDC_SCOPE:-authority:check}"

If your provider supports token exchange and you have a subject token:

python examples/delegation/oidc_compat_demo.py \
  --issuer "$OIDC_ISSUER" \
  --client-id "$OIDC_CLIENT_ID" \
  --client-secret "$OIDC_CLIENT_SECRET" \
  --audience "$OIDC_AUDIENCE" \
  --scope "${OIDC_SCOPE:-authority:check}" \
  --subject-token "$OIDC_SUBJECT_TOKEN" \
  --supports-token-exchange

Local IdP quick example

from predicate_authority import LocalIdPBridge, LocalIdPBridgeConfig
from predicate_contracts import PrincipalRef, StateEvidence

bridge = LocalIdPBridge(
    LocalIdPBridgeConfig(
        issuer="http://localhost/predicate-local-idp",
        audience="api://predicate-authority",
        signing_key="replace-with-strong-secret",
        token_ttl_seconds=300,
    )
)

token = bridge.exchange_token(
    PrincipalRef(principal_id="agent:local", tenant_id="tenant-a"),
    StateEvidence(source="backend", state_hash="sha256:local-state"),
)
print(token.provider.value, token.access_token[:24] + "...")

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

predicate_authority-0.4.0.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

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

predicate_authority-0.4.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for predicate_authority-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3f5fe08adf7ce2227c7cc924a71f46e841d99a3b32996f5936dd5dde39ab2fb1
MD5 9b296e8f0ac10efe0a37760a8c58654e
BLAKE2b-256 8c0a3b85f29e1a41b11a1bc0f0f4d9f174bf70e32a39a4e0d17cf611b1d9ee77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for predicate_authority-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7642381bbc521c471aebe38648bff5f9e4ccc60058f56de3d885a2a84a958745
MD5 9e9eff9f0812cd5d464b1322714fb8a4
BLAKE2b-256 5dbc55095f39c894be94e00ce2767d8819823b4c8077437182ff9c36c7830190

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