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
Part of Socrates AI Ecosystem
This package is a component of Socrates AI, a production-ready platform for building intelligent multi-agent systems with constitutional governance.
Use This Package Standalone:
pip install socratic-morality
Or As Part of Socrates Platform:
pip install socrates-ai # Includes 37+ modules + all 11 packages
Integration Example:
See the Socrates ECOSYSTEM.md for detailed integration examples showing how to use socratic-morality with other Socratic packages.
Related packages you might use together:
More Information:
Metadata
Release files for socratic-morality 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| socratic_morality-0.0.7.tar.gz | 61.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| socratic_morality-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 117.7 kB
Release files / socratic_morality-0.0.7.tar.gz
| Download URL | socratic_morality-0.0.7.tar.gz |
|---|---|
| Size | 61.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a5dbe773014d732aba4b7cee495212d6981b150a1309f46adae3e0311cdcf54
|
|
BLAKE2b-256 checksum How to use checksums |
0740a663264818b29640f001f571dd787fdc9ef4b76bc2a7d8a6522b556ef0af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / socratic_morality-0.0.7-py3-none-any.whl
| Download URL | socratic_morality-0.0.7-py3-none-any.whl |
|---|---|
| Size | 56.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35bcd9b49108898b8f7de5d67911d2d97c59984781e286eaa82f569b9bab3e2d
|
|
BLAKE2b-256 checksum How to use checksums |
05ee59bef1f96e9c688ac16bf491c5b6e93c697619352750eabca864b0374a20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|