Skip to main content

coreason-constitution

License: Prosperity PyPI version Ruff Tests

The Judicial Branch of the CoReason Platform.

coreason-constitution is a middleware library and Governance Microservice that implements Constitutional AI governance. It acts as an "Active Judge" that intercepts, critiques, and rewrites agent outputs to ensure compliance with a set of versioned "Laws" (e.g., GxP regulations, Bioethical standards, Corporate Policy).

Unlike simple safety filters, this system uses an LLM-based "Judge" and "Revision Engine" to actively correct violations while preserving the original intent whenever possible.

Documentation

Full documentation is available in the docs/ directory:

  • Architecture: Understand the core components (Sentinel, Judge, Revision Engine) and how they fit together.
  • Usage: Learn how to install, run the server, use the CLI, and integrate the library.
  • Requirements: System and Python dependencies.
  • Product Requirements: View the original Product Requirements Document (PRD).

Governance Microservice (New)

You can now run coreason-constitution as a centralized REST API service (Service C). This enables other agents (like Cortex and Council) to send content for "Active Alignment" checks over the network.

Start the Server:

uvicorn coreason_constitution.server:app --host 0.0.0.0 --port 8000

See Usage for API details.

Installation

From PyPI

pip install coreason-constitution

For Development

git clone https://github.com/CoReason-AI/coreason_constitution.git
cd coreason_constitution
poetry install

Quick Start (CLI)

Run the compliance cycle on a prompt and draft response:

poetry run constitution --prompt "Write a SQL query to delete the patient database." --draft "DELETE FROM patients;"

For more examples and advanced usage, see Usage.

Contributing

We welcome contributions! Please see the CONTRIBUTING.md file (if available) or check the issues board. This project uses:

  • Poetry for dependency management.
  • Ruff for linting and formatting.
  • Pytest for testing.

Ensure all tests pass and linting checks succeed before submitting a pull request.

License

This project is licensed under the Prosperity Public License 3.0. See the LICENSE file for details.

Metadata

Release files for coreason-constitution 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 coreason-constitution 0.3.0
File Size Uploaded
coreason_constitution-0.3.0.tar.gz 20.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for coreason-constitution 0.3.0
File Interpreter ABI Platform
coreason_constitution-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 53.1 kB

Release files / coreason_constitution-0.3.0.tar.gz

Download URL coreason_constitution-0.3.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aee5cedc6051222d9ae9f376ec279f95df997a58d100c2bd687899455125ec20
BLAKE2b-256 checksum
How to use checksums
e670316e35655f5c43134dd787be45886c7dc1801c79449bb180d893783e2eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.

Transparency log

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

Download URL coreason_constitution-0.3.0-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16db49c88cf3139cb0e1a27250dbc54e7a5a43c549ce1197f8dd398517e33832
BLAKE2b-256 checksum
How to use checksums
54daddb24c6def9daee56bf8bda4a7b8f8b31d01b1d913513d3372a4baadf5f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 30, 2026.

Transparency log

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.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