Skip to main content

LockStock compliance runtime integrations for AI Agent SDKs - thin SaaS client with idempotency

Project description

LockStock Integrations

Universal compliance runtime for AI Agent SDKs. LockStock provides cryptographic identity, capability authorization, and audit trails for agents running on any framework.

What's New in 2.0.0

  • Thin SaaS Client: No local crypto, no Guard daemon required
  • Built-in Idempotency: Safe retries on network failures without double-advancing the chain
  • Automatic Retry: Exponential backoff for transient errors (502, 503, 504, timeouts)
  • Sequence Tracking: Detects stale clients and provides resync diagnostics

Supported Frameworks

Integration Framework Status
lockstock_fastapi FastAPI (Thin Middleware) Stable
lockstock_claude Claude Agent SDK Alpha
lockstock_openai OpenAI Agents SDK Alpha
lockstock_langgraph LangGraph Alpha
lockstock_a2a A2A Protocol Alpha
lockstock_adk Google ADK Planned
lockstock_crewai CrewAI Planned

Installation

# FastAPI thin middleware (recommended for SaaS)
pip install lockstock-integrations[fastapi]

# Install with specific framework support
pip install lockstock-integrations[claude]
pip install lockstock-integrations[openai]
pip install lockstock-integrations[langgraph]

# Install with all frameworks
pip install lockstock-integrations[all]

Quick Start

FastAPI Inference Servers (Recommended)

The thin middleware stamps every request and response via the /v1/stamp API with zero local crypto. Supports SSE streaming for LLM responses. Fail-closed by default (no stamp = no action).

from fastapi import FastAPI
from lockstock_fastapi import LockStockThinMiddleware

app = FastAPI()

app.add_middleware(
    LockStockThinMiddleware,
    agent_id="agent_xxx_name",
    api_key="lsk_admin_...",
    path_tasks={
        "/v1/chat/completions": "chatcompletion",
        "/v1/models": "network",
        "/health": None,  # Excluded from stamping
    },
    # Defaults (no configuration needed):
    # - response_tasks auto-inferred: chatcompletion -> chatcompletionRESPONSE
    # - block_on_rejection=True: fail-closed, 503 if stamp fails
)

Install with:

pip install lockstock-integrations[fastapi]

Claude Agent SDK

from lockstock_claude import LockStockHook

# Create hook with your agent credentials
hook = LockStockHook(
    agent_id="agent_abc123",
    api_key="lsk_admin_...",
    endpoint="https://lockstock-api-i9kp.onrender.com"
)

# Use as pre-tool-execution hook
# The hook will verify capabilities before each tool call

OpenAI Agents SDK

from lockstock_openai import LockStockGuardrail

guardrail = LockStockGuardrail(agent_id="agent_abc123")

# Add to your agent's guardrails
agent = Agent(
    name="my-agent",
    guardrails=[guardrail]
)

LangGraph

from lockstock_langgraph import lockstock_middleware

# Wrap your graph with LockStock middleware
app = lockstock_middleware(
    graph=your_graph,
    agent_id="agent_abc123"
)

Direct API Usage

For custom integrations, use the core client directly:

from lockstock_core import LockStockClient

async with LockStockClient(
    agent_id="agent_xxx",
    api_key="lsk_admin_...",
) as client:
    # Stamp a capability (with automatic retry and idempotency)
    result = await client.stamp("chatcompletion")

    if result.authorized:
        print(f"Authorized! Sequence: {result.sequence}")
    else:
        print(f"Denied: {result.reason}")

Idempotency Guarantees

Every stamp() call automatically:

  1. Generates a unique idempotency key (UUID)
  2. Retries on transient failures (timeouts, 502/503/504)
  3. Returns cached response on retry if server already processed
  4. Never double-advances the chain on network failures
# Safe to retry - same logical request
result = await client.stamp("deploy")  # Network timeout
result = await client.stamp("deploy")  # Returns cached response, chain at same position

Architecture

Thin Middleware (SaaS)

┌─────────────────────────────────────────────────────────────────┐
│                     YOUR FASTAPI SERVER                         │
│              (LLM inference, chat completions, etc.)            │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│               LOCKSTOCK THIN MIDDLEWARE                         │
│                                                                  │
│  • Pure ASGI (no buffering - supports SSE streaming)           │
│  • Calls /v1/stamp API (server does all crypto)                │
│  • Injects X-LockStock-* headers into response                 │
│  • Auto response stamping (fire-and-forget, non-blocking)      │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                     LOCKSTOCK CORE API                          │
│                                                                  │
│  • /v1/stamp - Request stamping (thin clients)                 │
│  • /verify - Full verification (fat clients)                   │
│  • /bootstrap - Agent identity initialization                   │
│  • Hash chain - Cryptographic audit trail                       │
└─────────────────────────────────────────────────────────────────┘

Agent SDK Integrations

┌─────────────────────────────────────────────────────────────────┐
│                     YOUR AGENT RUNTIME                          │
│  (Claude Agent SDK / OpenAI / LangGraph / CrewAI / ADK)        │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                   LOCKSTOCK INTEGRATION                         │
│                                                                  │
│  • Pre-tool-execution hooks                                     │
│  • Capability verification                                       │
│  • Audit trail logging                                          │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                     LOCKSTOCK CORE API                          │
│                                                                  │
│  • /verify - Capability authorization                           │
│  • /bootstrap - Agent identity initialization                   │
│  • Hash chain - Cryptographic audit trail                       │
└─────────────────────────────────────────────────────────────────┘

License

MIT License - See LICENSE file for details.

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

lockstock_integrations-2.0.0rc5.tar.gz (82.4 kB view details)

Uploaded Source

Built Distribution

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

lockstock_integrations-2.0.0rc5-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file lockstock_integrations-2.0.0rc5.tar.gz.

File metadata

File hashes

Hashes for lockstock_integrations-2.0.0rc5.tar.gz
Algorithm Hash digest
SHA256 5cd31cef4de8be74e2cedb22c9bbccfd6b2262912844666d9e95f425bc723ae9
MD5 16aebd068474fcf6a4f61ae42b0364c1
BLAKE2b-256 94dfdd0ba48e76a602845fe74a0eae1a068f76c4e2aa09ee7bc16bbdbed0afc3

See more details on using hashes here.

File details

Details for the file lockstock_integrations-2.0.0rc5-py3-none-any.whl.

File metadata

File hashes

Hashes for lockstock_integrations-2.0.0rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 4372e00e5dcb3a7ddcf1837da22f705a482dfdb677ba18eab49c49aeefbf07bc
MD5 34b9543530ccd2cc9700e90f58661a29
BLAKE2b-256 00656e39f8d432750d19ddff0e8e6697d1feb2db08cd8c0880595684e830c2be

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