Python SDK for KyroDB, the freshness-aware context runtime for AI systems.
Project description
KyroDB Python SDK
Typed Python client for KyroDB, the freshness-aware context runtime for AI systems.
KyroDB fixes stale agent context by serving retrieval through an explicit freshness, invalidation, trace, proof, and replay contract. This SDK is intentionally only a client for a running KyroDB Runtime. It does not implement vector search, local caching, freshness proofs, or planner logic in Python.
Install
pip install kyrodb
For local development from this repository:
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
Quickstart
from kyrodb import KyroDBClient, Scope
client = KyroDBClient(
base_url="https://runtime.example.com",
data_plane_token="data-plane-token",
observability_token="observability-token",
)
packet = client.retrieve(
query_embedding=[1.0, 0.0, 0.0, 0.0],
scope=Scope(tenant_id="acme", namespace="kb"),
top_k=3,
freshness_mode="balanced",
)
trace = client.observability.get_trace(packet.trace_id)
diagnosis = client.observability.diagnose_trace(packet.trace_id)
For production apps that load credentials from environment variables:
client = KyroDBClient.from_env()
from_env() reads KYRO_RUNTIME_URL, KYRO_DATA_PLANE_TOKEN, optional
KYRO_OBSERVABILITY_TOKEN, and optional KYRO_SHADOW_SESSION_ID.
Security Defaults
- HTTPS is required for non-loopback hosts unless
allow_insecure_http=Trueis explicit. - Redirects are disabled by default to prevent replaying captured documents or bearer tokens to another origin.
- Data-plane and observability/admin tokens are separate by default.
- Tokens are never included in
repr, logs, or SDK exceptions. - Data-plane-only clients cannot access
client.observabilityorclient.adminuntil an observability token is configured. - Side-effecting calls are not retried automatically because retrieval and mutations write trace, replay, and freshness evidence.
- Responses are read through a bounded stream to protect callers from unbounded memory use.
- Requests are preflighted against the runtime's default body,
top_k, embedding, metadata, filter, replay, andrecentlimits before they leave the process. - Shadow-session IDs are validated before being sent as
kyro-shadow-session-id.
API Shape
Data-plane methods live on KyroDBClient:
retrieveinvalidateingest_change_eventupsert_documentdelete_documentrecord_feedback
Observability methods live under client.observability:
get_feedbackget_tracediagnose_tracehealthcontext_proof_report
Admin/evidence methods live under client.admin:
build_proof_bundlebuild_root_cause_reportdiff_replay_runsrun_counterfactual_replaycreate_shadow_sessionexport_replay_capture
Async parity is available through AsyncKyroDBClient.
Counterfactual replay and replay diff calls use typed request models at the SDK boundary while keeping replay artifacts as forward-compatible JSON objects:
from kyrodb import CounterfactualIntervention, CounterfactualReplayScenario
capture = client.admin.export_replay_capture(recent=50)
scenario = CounterfactualReplayScenario(
name="drop retry noise",
interventions=[CounterfactualIntervention.drop_step(0)],
)
summary = client.admin.run_counterfactual_replay(capture=capture, scenario=scenario)
Shadow replay workflows can pass the server-returned session ID explicitly:
shadow = KyroDBClient(
base_url="https://candidate-runtime.example.com",
data_plane_token="candidate-data-token",
observability_token="candidate-observability-token",
shadow_session_id="session-id-from-create-shadow-session",
)
Development
python -m pytest
python -m ruff format .
python -m ruff check .
python -m mypy src/kyrodb
python scripts/check_release.py --no-build
Optional live tests should be wired to a running KyroDB Runtime with:
KYRO_RUNTIME_URLKYRO_DATA_PLANE_TOKENKYRO_OBSERVABILITY_TOKENKYRO_LIVE_TESTS=1
KYRO_LIVE_TESTS=1 python -m pytest -m live
You can point the live tests at a seeded fixture with KYRO_TEST_TENANT_ID,
KYRO_TEST_NAMESPACE, and KYRO_TEST_QUERY_EMBEDDING.
Examples
The examples/ directory contains small production-shaped flows:
retrieve.py: retrieve fresh context and print trace evidence identifiers.trace_diagnosis.py: inspect why a trace was stale, degraded, or fresh.proof_bundle.py: build a redacted proof bundle from retained replay evidence.design_partner_shadow.py: create a candidate shadow session from replay primer state.
Release
Release candidates must pass the full local gate in RELEASE.md, including build artifact
validation and the optional runtime-dependency audit via python -m pip_audit ..
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
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 kyrodb-1.0.0.tar.gz.
File metadata
- Download URL: kyrodb-1.0.0.tar.gz
- Upload date:
- Size: 44.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a9ae60b1a6eaff47acfe1449ef3e0099292be789aa397f02767003d78982fb4
|
|
| MD5 |
e05175118a1584ac536f3e7873b377d5
|
|
| BLAKE2b-256 |
3ee2b3d6562d4eeab20217c4eb362ec0342620a1dd1983c5ddfca15fb62e74be
|
Provenance
The following attestation bundles were made for kyrodb-1.0.0.tar.gz:
Publisher:
publish.yml on KyroDB/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kyrodb-1.0.0.tar.gz -
Subject digest:
5a9ae60b1a6eaff47acfe1449ef3e0099292be789aa397f02767003d78982fb4 - Sigstore transparency entry: 1405037253
- Sigstore integration time:
-
Permalink:
KyroDB/python-sdk@c65618ab27278859be87c7ed8cc82484c14db233 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyroDB
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c65618ab27278859be87c7ed8cc82484c14db233 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file kyrodb-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kyrodb-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a13da31a287926936cc3953345238a21acd2698b710bd3cb4b6062f4fab132f3
|
|
| MD5 |
78caf87d1e8163da1151a55ef70f2f6b
|
|
| BLAKE2b-256 |
2e57d94018d4eb0cf5fc55a54c3f687abe941b2a5473dd19e7e7b4ec13a39ec1
|
Provenance
The following attestation bundles were made for kyrodb-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on KyroDB/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kyrodb-1.0.0-py3-none-any.whl -
Subject digest:
a13da31a287926936cc3953345238a21acd2698b710bd3cb4b6062f4fab132f3 - Sigstore transparency entry: 1405037340
- Sigstore integration time:
-
Permalink:
KyroDB/python-sdk@c65618ab27278859be87c7ed8cc82484c14db233 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyroDB
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c65618ab27278859be87c7ed8cc82484c14db233 -
Trigger Event:
workflow_dispatch
-
Statement type: