Decision-first Python SDK for policy-aware agent action control
Project description
Xenovia SDK for Python
Decision-first control hook for agent actions.
Full documentation:
docs/SDK_REFERENCE.md(complete API and mode behavior)
Core Model
Xenovia decides. Your code executes.
- The SDK sends action intent to Xenovia for policy decisioning.
- The SDK returns a typed response with decision and trace context.
- Local execution stays in your environment, never in Xenovia.
Installation
pip install xenovia-sdk
For local development:
pip install -e ".[dev]"
Quick Start
from xenovia_sdk import Xenovia
xenovia = Xenovia(
api_key="xv_...",
endpoint="https://api.xenovia.io",
default_env="prod",
auto_session=True,
)
decision = xenovia.execute(
capability="k8s.deploy",
payload={"service": "checkout", "version": "v2"},
)
if decision.is_blocked():
print("Blocked:", decision.decision.get("reason"))
elif decision.is_success():
print("Allowed:", decision.trace_id)
else:
print("Failed:", decision.error)
Guard Modes
guard() wraps existing tool functions with decision-aware control.
@xenovia.guard("k8s.deploy", mode="enforce")
def deploy(payload):
return kubectl_apply(payload)
Supported modes:
enforce(recommended): execute local function only when decision outcome isallow.observe: always execute local function, but still return Xenovia's decision for visibility.
Migration pattern:
- Start with
observe. - Review would-have-blocked events.
- Move sensitive capabilities to
enforce.
API Surface
Xenovia(
api_key: str,
endpoint: str = "https://api.xenovia.io",
default_env: str = "prod",
raise_on_block: bool = False,
timeout: int = 5,
auto_session: bool = False,
debug: bool = False,
identity_id: str | None = None,
identity_type: str = "agent",
unreachable_mode: str = "error",
allow_insecure_http: bool = False,
)
Primary methods:
execute(capability, payload, session_id=None, env=None) -> XenoviaResponseguard(capability, mode="enforce") -> decorator
XenoviaResponse fields:
status:success|blocked|failedresult: local function output (if executed viaguard) or backend-provided resulterror: string error when presentdecision: decision payload (outcome,rule_id,reason, ...)trace_id: request trace identifier
Wire Contract
SDK request envelope:
{
"capability": "k8s.deploy",
"payload": { "...": "..." },
"session_id": "sess_123",
"identity": { "type": "agent", "id": "agent_7" },
"env": "prod",
"sdk": { "version": "0.1.0", "language": "python" }
}
Typical response shape:
{
"status": "blocked",
"result": null,
"error": "policy_violation",
"decision": {
"outcome": "deny",
"rule_id": "SEQ_001",
"reason": "unsafe_sequence"
},
"trace_id": "xnv_123"
}
Security Defaults
The SDK ships with opinionated safety defaults:
- HTTPS endpoint enforcement by default (
allow_insecure_http=False). - If
allow_insecure_http=True, only localhost/loopback HTTP endpoints are permitted. - No secret or payload logging in normal operation.
- Explicit fail-mode for Xenovia outages:
unreachable_mode="error"(default)unreachable_mode="allow"(fail-open)unreachable_mode="block"(fail-closed)
- Structured identity metadata on every request.
- Timeout required and validated.
Production Configuration Example
import os
from xenovia_sdk import Xenovia
xenovia = Xenovia(
api_key=os.environ["XENOVIA_API_KEY"],
endpoint=os.environ.get("XENOVIA_ENDPOINT", "https://api.xenovia.io"),
default_env=os.environ.get("XENOVIA_ENV", "prod"),
identity_id=os.environ.get("XENOVIA_AGENT_ID", "payments-agent"),
auto_session=True,
raise_on_block=False,
unreachable_mode="block", # fail closed for sensitive environments
)
Development
Run tests:
python -m unittest discover -s tests -v
Publishing and Security Docs
- See
PUBLISHING.mdfor release workflow and publishing checklist. - See
SECURITY.mdfor vulnerability reporting and operational controls. - See
CHANGELOG.mdfor release history. - See
docs/SDK_REFERENCE.mdfor full mode matrix and behavior reference.
CI and Release Automation
.github/workflows/ci.ymlruns tests, builds the package, and checks metadata..github/workflows/publish.ymlis manual (workflow_dispatch) and supports separate targets:testpypiandpypi..github/dependabot.ymlkeeps dependencies and GitHub Actions updated weekly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xenovia_sdk-0.1.1.tar.gz.
File metadata
- Download URL: xenovia_sdk-0.1.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
774dd393c60cb88e80eb1281fe6cf04c4c3a07875374a327cc3d880f13a70d21
|
|
| MD5 |
22403e89865d5e3bfbf53074734edeee
|
|
| BLAKE2b-256 |
715979e93d328eb1e52b7ab392b686f4bdd035765e960c05dd630cb3a60d53d8
|
File details
Details for the file xenovia_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: xenovia_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d86962a8f3f6173221f60601da628178fbaca9c30755f32fcaf4a5b346bf51d7
|
|
| MD5 |
7d69a26cfccd4c9ba3caac69d75820e1
|
|
| BLAKE2b-256 |
326e4efd70aafad39dafc8432399c1deeee209bb286dd37edd46c2375fdb7edc
|