Skip to main content

Behavioral governance compiler for AI agents. Compile corrections into enforceable mechanisms over MCP.

Reason this release was yanked:

tombstone

Project description

Calx

Your AI agent keeps making the same mistakes. Calx captures corrections, detects recurrence, and compiles them into rules and hooks that stick.

pip install getcalx

Quickstart

pip install getcalx
calx init

That's it. calx init registers an MCP server in .claude/settings.json. Claude Code starts it automatically via stdio. Corrections, rules, and briefings flow over MCP backed by local SQLite. Built on FastMCP.

# Log a correction (your agent can do this too via the MCP log_correction tool)
calx correct "don't mock the database in integration tests"
# → Logged C014. Matches C007: "don't mock the database." (3rd occurrence — promotion eligible.)

# Promote to a rule
calx distill
# → Promoted to tests-R003. Available in every future briefing.

Not using Claude Code? Run calx serve and point your MCP client at it:

calx serve                          # streamable-http on 127.0.0.1:4195
calx serve --transport stdio        # for Claude Desktop, Cursor, etc.

Requires Python 3.10+. Works with anything MCP-compatible.

How it works

Capture -> Detect -> Promote -> Inject

  1. You correct your agent. Calx logs it to an append-only event log. Three capture layers ensure nothing is lost: explicit command, session-end prompt, and dirty-exit recovery. The agent can also capture corrections itself via calx correct or the MCP log_correction tool.
  2. Calx silently matches new corrections against existing ones using keyword similarity. When the same correction recurs 3+ times, it surfaces once at the end of your current task as a single yes/no. Never mid-flow.
  3. On approval, the correction graduates to a rule in .calx/rules/{domain}.md, written in your own words. The full temporal chain is preserved as provenance.
  4. At the start of every session, domain-specific rules are injected into the agent's context via hooks or MCP briefing. The agent reads and applies them before writing any code.

Each pass through this loop tightens the correction surface. Without intervention, you'll average ~2.9 corrections per task, every task, forever. With Calx, that number drops as rules compound.

MCP Server

Calx runs as an MCP server built on FastMCP with local SQLite storage. calx init registers it automatically for Claude Code. The server provides the correction lifecycle over MCP: any MCP-compatible client can read rules, log corrections, and fetch briefings.

Resources: calx://briefing/{surface}, calx://rules, calx://corrections Tools: log_correction, promote_correction, get_briefing

For editors other than Claude Code, connect manually:

# Claude Desktop: add to claude_desktop_config.json
calx serve --transport stdio

# Any MCP client: connect to HTTP endpoint
calx serve
# → http://127.0.0.1:4195/mcp (auth token in .calx/server.json)

Full reference: docs/mcp-reference.md

What this changes about how you work

Calx isn't just a correction logger. It encodes an orchestration methodology as automation so you stop managing your agent and start working with it.

Token discipline. Calx auto-detects your subscription tier and enforces context limits (Max: 200k soft / 250k ceiling, Pro: 80k / 100k). You never hit compaction, which means the correction signal, the thing that makes the learning loop work, is never destroyed by context summarization.

Session lifecycle runs itself. Session start injects rules, shows an effectiveness signal (corrections trending down per domain), and gates edits until rules are read. Session end captures uncommitted corrections, writes a clean-exit marker, and hands off state to the next session. If a session crashes, dirty-exit recovery prompts for anything that was lost.

MCP server as the integration layer. When calx serve is running, hooks fetch the briefing from the server instead of reading files directly. MCP clients get structured access to corrections, rules, and briefings. The server handles recurrence detection, quarantine scanning, and auto-promotion. Everything still works without the server (hooks fall back to file-based injection).

Scoped rules, scoped agents. Rules sync from .calx/rules/ to AGENTS.md files co-located in your source directories. When you dispatch a subagent to work on src/api/, it reads src/api/AGENTS.md and gets exactly the rules it needs, nothing more. Your main window coordinates. Subagents do focused deep work.

src/
├── api/
│   ├── AGENTS.md          <- rules for API work
│   └── routes.py
├── services/
│   ├── AGENTS.md          <- rules for service layer
│   └── auth.py
└── db/
    ├── AGENTS.md          <- rules for data access
    └── migrations/

Start in plan mode. For any real implementation work, start in plan mode first. The orchestrator reads your rules, scopes the work, and decides what gets dispatched to subagents vs spun up as agent teams based on how isolated the task is. This is where you get the most out of Calx -- the rules inform the plan, not just the execution.

Distillation runs in the background. Recurrence detection is silent. Promotion surfaces at task boundaries, not mid-flow. Weekly review is a PR-style diff of your rule set. The system learns while you work.

The evidence

We gave an AI agent 237 rules learned from another agent. It made 44 new mistakes, 13 in categories the rules explicitly covered. Process rules showed ~50% persistence. Architectural fixes had zero recurrence.

Rule text doesn't reliably transfer behavior. Compiled mechanisms can. Meta's HyperAgents (arXiv:2603.19461) showed that meta-level improvements transfer across domains when embodied in executable mechanisms, not rule text. Calx automates the path from correction to enforceable mechanism: capture, detect recurrence, promote to rules and hooks, inject with provenance.

The Behavioral Plane (paper) | Evidence repo

What Calx collects

All data stays local. SQLite on disk. Nothing leaves your machine.

  • Corrections: Stored in an append-only event log (.calx/corrections.jsonl) and SQLite (.calx/calx.db). Never transmitted.
  • Telemetry table: Logs MCP interactions when the server is running: event type, tool/resource name, latency. No correction text. No code. No content.
  • No analytics. No phone-home. No remote collection.
  • Team tier (future): opt-in Postgres backend for shared state. You choose what syncs.

Why Calx over alternatives?

Approach What it does What it misses
Editing CLAUDE.md by hand Works. Rules persist across sessions. No recurrence detection. No health tracking. No signal when rules conflict or go stale. Scales to ~20 rules before it becomes a wall of text agents skim.
Agent memory tools Store and retrieve information across sessions. Assumes corrections transfer as behavior. 30% of new corrections fell in categories with explicit rules. Memory is not mechanism.
Agent self-improvement Compile mechanisms that transfer across domains. Needs governance around it: who approved this mechanism? What's the provenance? Can it be rolled back? That's what Calx provides.
Doing nothing Zero overhead. ~2.9 corrections per task, every task, forever. That's the error floor without intervention.
Calx Captures corrections, detects recurrence, promotes to rules, injects via hooks or MCP, enforces token discipline, automates the session lifecycle, scopes rules to directories, tracks health. Accelerates behavioral formation within each agent relationship. Doesn't try to share raw rule text between agents.

Rule health

Not all rules age the same way. Architectural rules (structural fixes that eliminate an error class) don't decay from dormancy. Zero corrections means they're working. Process rules decay with age unless reinforced. Calx tracks the difference and surfaces when a recurring process rule should become an architectural fix instead.

Commands

Command What it does
calx init Initialize .calx/, detect domains, scaffold CLAUDE.md, install hooks
calx correct <text> Log a correction with automatic recurrence detection
calx distill Promote recurring corrections or run weekly review (--review)
calx status Corrections, rules, pending promotions at a glance
calx serve Start the MCP server (--host, --port, --transport)
calx sync Write AGENTS.md files to source directories from .calx/rules/
calx dispatch <domain> Generate scoped prompt with domain rules for a subagent or teammate
calx health <sub> Rule health: score, conflicts, staleness, coverage, dedup, conversion
calx config View or modify configuration
calx stats Local metrics: corrections by domain, recurrence rates, trends

Project structure

.calx/
├── calx.json              # Configuration (domains, token discipline, thresholds)
├── calx.db                # SQLite database (when serve is running)
├── server.json            # Server config and auth token
├── corrections.jsonl       # Append-only event log (gitignored)
├── rules/
│   └── {domain}.md         # Promoted rules per domain (committed)
├── health/
│   ├── state.json          # Health scores per rule
│   └── .last_clean_exit    # Session state marker
├── method/
│   ├── how-we-document.md  # Three-tier learning model
│   ├── orchestration.md    # Session lifecycle and hooks
│   ├── dispatch.md         # Agent dispatch scaffolding
│   └── review.md           # Foil review methodology
└── hooks/
    ├── session-start.sh
    ├── session-end.sh
    ├── orientation-gate.sh
    └── collapse-guard.sh

Development

pip install -e ".[serve,dev]"

pytest                    # 419 tests
ruff check src/ tests/    # Lint
mypy src/calx/            # Type check

Docs

  • Quickstart: Install to running MCP server in 2 minutes
  • MCP Reference: Every resource and tool with parameters and examples
  • Correction Workflow: Full capture-to-rule lifecycle
  • Hooks: What each hook does, how to configure and customize

Contributing

Contributions welcome. Please open an issue first for anything beyond small fixes so we can align before you invest time.

License

MIT. The complete learning loop ships free with no feature gates.

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

getcalx-0.5.1.tar.gz (75.5 kB view details)

Uploaded Source

Built Distribution

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

getcalx-0.5.1-py3-none-any.whl (94.3 kB view details)

Uploaded Python 3

File details

Details for the file getcalx-0.5.1.tar.gz.

File metadata

  • Download URL: getcalx-0.5.1.tar.gz
  • Upload date:
  • Size: 75.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for getcalx-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3f9b2841167cdeb66a4776e5cb9dbdd82c4e4a3f538e6d0f9517f89809a40c72
MD5 2664af33041866e416de4715dfa038eb
BLAKE2b-256 0a1ccc061754d21d85cf1d3c5f248240010df34d9b4ea33bd9b7555d8f2bd391

See more details on using hashes here.

File details

Details for the file getcalx-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: getcalx-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 94.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for getcalx-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f331ec976692bdaa13e83ace168bbf155d087b97afebe04a2e1e27f188eeda7
MD5 3fdf0eefaafbd3db95132be25c108429
BLAKE2b-256 4d9b10d411853de4077289b04890c4172682170ec0c2b2af77c20f71637db833

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