Constitutional AI Governance Framework - Grounded in Socratic Philosophy
Project description
Socratic Morality
Constitutional AI Governance Framework - Building trustworthy, accountable multi-agent systems grounded in Socratic philosophy.
"It is better to suffer injustice than to commit it." — Plato's Gorgias
Quick Start
pip install socratic-morality
from socratic_morality import Governor
governor = Governor(constitution="constitution.yaml", llm_provider="anthropic")
decision = await governor.evaluate(
action="Access user's private data",
purpose="Personalization",
actor="recommendation_agent",
context={"user_id": "user_123"}
)
Documentation
Complete Module Architecture (7 Modules)
Phase 1 - Foundation (3 modules)
-
Governor - Core decision-making engine
- Constraint checking and validation
- Decision tracking with audit trails
- Multi-dimensional decision analysis
-
Constitution Framework - YAML-based governance
- Supreme principles and axioms
- Named principles with severity levels
- Agent capabilities and permissions
- Action policies and constraints
- Escalation rules and approval workflows
-
CapabilityToken System - Fine-grained access control
- Token-based permissions
- Resource authorization
- Capability validation
- Storage backends (SQLite, PostgreSQL)
Phase 2 - Ethical Reasoning (3 modules)
-
Multi-Framework Ethical Analysis
- Kantian deontological analysis (duty, dignity, universality)
- Utilitarian consequentialist analysis (benefit/harm, extremes)
- Virtue ethics analysis (virtues, vices, flourishing)
- Rights-based analysis (fundamental rights, consent)
- LLM integration with keyword analysis fallback
-
Moral Precedent Engine - Case-based reasoning
- Decision storage and retrieval
- Similarity-based matching
- Consistency analysis
- Precedent clustering and history
-
Explanation Generation - Transparent reasoning
- Reasoning artifact export
- Decision justification
- Explanation reports
- Framework analysis summaries
Phase 3 - Advanced Governance (4 modules - NEW ✨)
-
Constitutional Enforcer - Active principle enforcement
- Real-time principle verification
- Principle violation detection with severity levels
- Agent capability validation
- Constitutional reasoning generation
-
Unified Governance API - Single entry point for all decisions
evaluate(action, context, actor)- Main interface- Constitutional checks (first gate)
- Integrated ethical deliberation (4 frameworks)
- Precedent analysis with semantic similarity
- Threat detection and anomaly analysis
- Optional interactive Socratic dialogue
- Complete decision history and explanation reports
- Batch evaluation support
-
Socratic Dialogue Engine - Interactive ethical reasoning
- 8 Socratic approaches (exposing contradictions, testing universality, examining assumptions, probing consequences, inviting counterarguments, clarifying definitions)
- 7 question categories (stakeholder, consequence, principle, alternative, assumption, vulnerability, outcome)
- 40+ built-in Socratic questions
- Interactive dialogue with Claude LLM
- Dialogue synthesis and insight extraction
- Dialogue history tracking
-
Semantic Precedent Matching - Advanced similarity search
- Sentence-transformer embeddings (semantic matching)
- Combined lexical + semantic similarity (40/60 blend)
- Embedding caching for performance
- Precedent clustering by conclusion type
- Context-aware relevance scoring
Phase 3 Extensions (3 modules - NEW ✨)
-
Care Ethics Framework - Relational moral analysis
- Relationship mapping and analysis
- Vulnerability assessment
- Care response adequacy evaluation
- Care violation detection
- Emphasis on interdependence and caring
-
Remediation Engine - Constraint violation handling
- 5 remediation strategies:
- MODIFY_ACTION: Adjust action parameters
- ADD_SAFEGUARDS: Add protective measures
- REJECT_AND_PROPOSE_ALTERNATIVE: Suggest better approach
- ESCALATE_WITH_CONSTRAINTS: Allow with restrictions
- ROLLBACK: Reverse decisions
- Intelligent suggestion generation
- Auto-remediation for safe violations
- Decision rollback capability
- Complete audit trail
- 5 remediation strategies:
-
Resource Monitor - Real-time resource enforcement
- CPU, memory, file descriptor, process monitoring
- Soft and hard limit enforcement
- Violation detection and escalation
- Comprehensive usage reporting
- Session-based monitoring lifecycle
- Integration with sandbox execution
Release Status
v0.0.5 - COMPLETE ✅ (May 2026)
All 13 modules fully implemented, tested, and documented:
- Phase 1: 3 foundation modules ✅
- Phase 2: 3 ethical reasoning modules ✅
- Phase 3: 4 advanced governance modules ✅
- Phase 3 Extensions: 3 specialized modules ✅
Available on PyPI:
pip install socratic-morality==0.0.5
Test Coverage: 100% (71/71 tests passing) Code Quality: All linting and type checks passing Documentation: Complete API docs and examples included
License
MIT License - See LICENSE for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file socratic_morality-0.0.6.tar.gz.
File metadata
- Download URL: socratic_morality-0.0.6.tar.gz
- Upload date:
- Size: 60.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
785ea8bf33edee369b0eddba4e8d62c3c43e61ee866e623c15a65cc673b430c6
|
|
| MD5 |
39da3e7ed29da07c21562b9a12cce2b3
|
|
| BLAKE2b-256 |
a6c9b80a2dff1ee4095385c8f52f2ea2e39b4c1611c87309d4d25154a0d9a88d
|
File details
Details for the file socratic_morality-0.0.6-py3-none-any.whl.
File metadata
- Download URL: socratic_morality-0.0.6-py3-none-any.whl
- Upload date:
- Size: 56.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c87742072f998385c4bffeaffb73f2d0245c720db5f2df7383c760faac060f5
|
|
| MD5 |
efdb2b60f5597992ab972b1d135176b6
|
|
| BLAKE2b-256 |
69a9805aa175464ae12c2c41c4408716924e6cb1d533fe3a8f8be26bda8a1937
|