Skip to main content

crux-sdk

Python SDK for Crux -- agentic knowledge versioning.

Crux tracks what an AI agent believes about the world and tells it when those beliefs go stale. This SDK connects to the Crux daemon over a Unix socket.

Install

pip install crux-sdk

Quick start

from crux import WorldModel, CruxInterceptor

world = WorldModel(socket_path="/tmp/crux.sock")
tools = CruxInterceptor(world)

# These automatically register beliefs
content = tools.read_file("config.json")
tools.write_file("output.py", "print('hello')")
stdout, code = tools.run_shell("git status")

# Query a belief
belief = world.query("file", path="/absolute/path/to/config.json")
print(belief.status)      # "valid", "uncertain", or "invalidated"
print(belief.confidence)   # 0.0 to 1.0

# Check for pending invalidations
diff = world.diff()
if not diff.is_empty():
    print(f"{len(diff.invalidated)} beliefs invalidated")

# Plans as beliefs -- fence pattern
world.create_plan("refactor-auth", goal="Refactor auth module")
# Plan auto-depends on all beliefs read since the last plan

world.close()

Claude Code integration

Add hooks to .claude/settings.json to auto-register every Read/Write/Edit/Bash tool call. A PreToolUse hook surfaces stale beliefs before each tool call, and a PostToolUse hook records observations after. See the full README for setup.

Features

  • Typed belief graph with causal dependency edges
  • Convention-based auto-edges (writes depend on recent reads)
  • Plans as first-class beliefs with fence-pattern auto-edges
  • TTL-based belief expiry (shell: 30s, file: 60s, http: 2min, env: 5min)
  • Stability filter for oscillating beliefs
  • Field-level edge filtering for selective invalidation
  • Schema evolution detection
  • Append-only event log with crash recovery
  • Branching for speculative agent work
  • Historical queries (query_at)

Links

Metadata

Release files for crux-sdk 0.3.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 crux-sdk 0.3.0
File Size Uploaded
crux_sdk-0.3.0.tar.gz 20.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crux-sdk 0.3.0
File Interpreter ABI Platform
crux_sdk-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.9 kB

Release files / crux_sdk-0.3.0.tar.gz

Download URL crux_sdk-0.3.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0260df163702c146b96f441097ba1684ee9fc6f3ebd1f54b500af8f61e9dc7f2
BLAKE2b-256 checksum
How to use checksums
942720057633cee9979e815d9a2312afff40bf975a74daf32abd4e37eb6119ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.5

Release files / crux_sdk-0.3.0-py3-none-any.whl

Download URL crux_sdk-0.3.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
877d1ca49bed8b39a87e1dca62471142821f39d8c771adfb76a4974bfe66398a
BLAKE2b-256 checksum
How to use checksums
bf159fe5f2c7490ddeca5ec1375eb2113c8a3b7b777d7e7baae05b653fbee936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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