Skip to main content

langchain-nobulex

Compliance middleware for LangChain agents with hash-chained audit trails.

Enforce covenant rules on agent tool calls, block forbidden actions, and maintain a tamper-proof audit log — ready for EU AI Act compliance requirements.

Installation

pip install langchain-nobulex

Quick Start

from langchain_nobulex import create_agent, NobulexComplianceMiddleware

agent = create_agent(
    model="gpt-4.1",
    tools=tools,
    middleware=[
        NobulexComplianceMiddleware(
            rules="permit read; forbid transfer where amount > 500; require log_all;"
        )
    ]
)

How It Works

Define rules using a simple covenant DSL:

  • permit <action> — explicitly allow a tool/action
  • forbid <action> [where <condition>] — block a tool/action, optionally with conditions
  • require <behavior> — declare required behaviors (e.g., log_all)

The middleware:

  1. Intercepts every tool call from the model
  2. Matches it against your covenant rules
  3. Blocks forbidden actions before they execute
  4. Logs every action (allowed and blocked) in a SHA-256 hash-chained audit trail

Verify integrity independently:

from langchain_nobulex import verify

log = agent.get_audit_log()
assert verify(log)  # True if chain is intact, False if tampered

Audit Trail

Every entry in the audit log contains:

Field Description
timestamp ISO 8601 UTC timestamp
action Tool/action name
params Tool arguments
allowed Whether the action was permitted
matching_rule The rule that matched
prev_hash SHA-256 hash of the previous entry
hash SHA-256 hash of this entry

Each hash links to the previous entry, forming a tamper-evident chain. Use verify() to independently validate the entire chain.

EU AI Act Compliance

This middleware supports EU AI Act (Regulation 2024/1689) requirements for high-risk AI systems:

  • Article 14 — Human oversight: Rules let operators define boundaries before deployment
  • Article 12 — Record-keeping: Hash-chained audit logs provide tamper-proof records of all AI actions
  • Article 9 — Risk management: Forbidden rules act as runtime guardrails against identified risks
  • Independent verification: The verify() function enables third-party audit of the action log

API Reference

NobulexComplianceMiddleware(rules: str)

Main middleware class. Pass a covenant rules string.

  • after_model(response) — intercepts and filters tool calls
  • wrap_tool_call(tool_call) — hook for per-execution logging
  • after_agent(state) — attaches audit log to final agent state
  • get_audit_log() — returns the full audit trail as a list of dicts
  • get_audit_log_json() — returns the audit trail as formatted JSON

verify(audit_log)

Independently validates a hash-chained audit log. Returns True if intact.

create_agent(model, tools, middleware)

Creates a middleware-aware agent wrapper.

License

MIT

Metadata

Release files for langchain-nobulex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-nobulex 0.1.0
File Size Uploaded Provenance Actions
langchain_nobulex-0.1.0.tar.gz 12.3 kB Without provenance Details for langchain_nobulex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-nobulex 0.1.0
File Interpreter ABI Platform Actions
langchain_nobulex-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_nobulex-0.1.0-py3-none-any.whl

Total release size: 22.9 kB

Release files / langchain_nobulex-0.1.0.tar.gz

Download URL langchain_nobulex-0.1.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7dba54975fab39780e0dfe715c96c2f99b35460eed73c2fa674720659a108c13
BLAKE2b-256 checksum
How to use checksums
03fcaa704755fd2849656edf7b5f0504e2f2f15b410d59a9afe0908de0b97bdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / langchain_nobulex-0.1.0-py3-none-any.whl

Download URL langchain_nobulex-0.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbde218bf64836114d5fe3bbd03f16964a5af2b724521867954ae66dc684cb29
BLAKE2b-256 checksum
How to use checksums
8ba7c4f8f031fd0ba708c0f56144f96087ead969e015ab29d4ce816ca936b701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for langchain-nobulex 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page