Edictum
Python SDK

Python Server SDK

Connect Python agents to edictum-api for rulesets, approvals, session state, SSE updates, and the decision log.

AI Assistance

Right page if: you want `Edictum.from_server()` options, the Python server SDK components, or the exact edictum-api integration points. Wrong page if: you only need local YAML rulesets. See https://docs.edictum.ai/docs/python. Gotcha: in M1, server-backed rules and Workflow Gates stay explicit. The API provides rulesets and runtime services; you attach the workflow locally with `workflow_path` or `workflow_content`.

Use the Python server SDK when you want remote rulesets, human approval, shared session state, SSE hot reload, and decision log delivery through edictum-api.

Quick Start

Install

pip install edictum[yaml,server]

Add verified if you want Ed25519 signature checks:

pip install edictum[yaml,server,verified]

Create a server-backed guard

import os

from edictum import Edictum

guard = await Edictum.from_server(
    url="https://api.example.com",
    api_key=os.environ["EDICTUM_API_KEY"],
    agent_id="docs-agent",
    env="production",
    bundle_name="production-rules",
)

Use it like any other guard

async def read_file(path: str) -> str:
    return f"contents of {path}"


result = await guard.run("read_file", {"path": "README.md"}, read_file)
print(result)

Close it on shutdown

await guard.close()

Edictum.from_server() Options

OptionTypeWhat it does
urlstrBase URL for edictum-api
api_keystrBearer credential used for every API call
agent_idstrStable agent identity for rulesets, session state, and approvals
envstr | NoneEnvironment name. Defaults to "production"
bundle_namestr | NoneNamed ruleset to fetch immediately. Leave None for server-assigned mode
tagsdict[str, str] | NoneTags used by server-side assignment rules
modestrRuntime mode override
audit_sinkAuditSink | NoneOverride the default ServerAuditSink
approval_backendApprovalBackend | NoneOverride the default ServerApprovalBackend
storage_backendStorageBackend | NoneOverride the default ServerBackend
auto_watchboolStart the SSE watcher. Required for server-assigned mode
allow_insecureboolAllow plain HTTP to non-loopback hosts. Local-only
verify_signaturesboolVerify Ed25519 ruleset signatures
signing_public_keystr | NoneHex-encoded Ed25519 public key
workflow_runtimeWorkflowRuntime | NoneAttach a prebuilt local workflow runtime
workflow_pathstr | Path | NoneLoad the local workflow from disk
workflow_contentstr | bytes | NoneLoad the local workflow from inline YAML
workflow_exec_evaluator_enabledboolEnable trusted exec(...) workflow conditions

If bundle_name is omitted, the guard starts empty, opens the SSE stream, and waits up to 30 seconds for a server assignment.

Server SDK Components

These are lazy-imported from edictum.server:

from edictum.server import (
    EdictumServerClient,
    ServerAuditSink,
    ServerBackend,
    ServerApprovalBackend,
    ServerContractSource,
    verify_bundle_signature,
)
ComponentPurpose
EdictumServerClientLow-level async HTTP client with auth, retries, and TLS checks
ServerAuditSinkBuffers and sends decision-log events to the API
ServerBackendShared session storage for counts and workflow state
ServerApprovalBackendHuman approval requests and polling
ServerContractSourceSSE client for live ruleset updates
verify_bundle_signatureEd25519 verification helper for raw YAML bytes

edictum-api Integration

These integration points are source-backed in the Python SDK:

  • Rulesets: GET /v1/rulesets/{bundle_name}/current
  • Live updates: GET /v1/stream
  • Session state: /v1/sessions/*
  • Approvals: /v1/approvals
  • Decision log ingestion: POST /v1/events

That means Edictum.from_server() is not a separate control plane. It is the Python client for the same API surface that ruleset delivery, approvals, state, and SSE all use.

Workflow Gates With Server-Backed Rules

In M1, the API provides rulesets and runtime services. The workflow stays local and explicit:

guard = await Edictum.from_server(
    url="https://api.example.com",
    api_key=os.environ["EDICTUM_API_KEY"],
    agent_id="docs-agent",
    bundle_name="production-rules",
    workflow_path="workflow.yaml",
    workflow_exec_evaluator_enabled=True,
)

That split is deliberate:

  • Rulesets are remote and hot-reloadable.
  • Workflow Gates are attached locally.
  • The same session can emit workflow snapshots into the decision log.

Low-Level Client Example

from edictum.server import EdictumServerClient

client = EdictumServerClient(
    "https://api.example.com",
    api_key=os.environ["EDICTUM_API_KEY"],
    agent_id="docs-agent",
    env="production",
    bundle_name="production-rules",
)

payload = await client.get("/v1/rulesets/production-rules/current", env="production")

Use the low-level client only when you need to manage transport yourself. For most applications, Edictum.from_server() is the right entry point.

Last updated on

On this page