Socratic-morality Constitutional AI as a Security Framework: Learning from 2,500 Years of Philosophy

Socratic-morality Constitutional AI as a Security Framework: Learning from 2,500 Years of Philosophy

●1 ●15 ●30
calendar_today • schedule3 min read

For 2,500 years, human societies have relied on one insight: ethical behavior isn’t enforced by rules alone—it’s sustained by understanding that fairness benefits you. Socrates taught this: “It is better to suffer injustice than to commit it.” Your AI agents don’t understand this yet. Constitutional AI teaches them. This is not about surveillance or punishment. This is about agents learning virtue.

Socratic Morality is part of an earlier research prototype. It is not maintained as a product, and nothing below has been measured in production. The examples are illustrations, not case studies.
Socrates argued, in Plato's Gorgias, that it is better to suffer injustice than to commit it. The argument is that doing wrong damages the person who does it. I used that idea as the starting point for a small Python library, socratic-morality, that puts a governance check in front of an AI agent's actions.
A note on the name: "Constitutional AI" is also the name of a model-training method published by Anthropic. This library is a different thing. It does not train models. It is a governance layer written in code, in which the agent's actions are checked against a written constitution before they are carried out.
The problem I wanted to look at
A rule written into a prompt is text that a model may or may not follow. A rule that is only checked in a log afterwards documents a violation but does not prevent it. And a rule that counts something, such as spending per call, can be satisfied in letter while its purpose is missed, for instance by splitting one expensive call into many cheap ones. These are design observations, not measured failure rates.
The idea behind the library is to put the check in code, before the action, and to make the check give its reasons, so that a person can read why an action was allowed or refused.
What the library contains
The README lists thirteen modules in three groups. The main ones:

• Governor: the entry point. It takes an action, the actor, the purpose and some context, and returns a decision with its reasoning.
• Constitution: a YAML file with named principles, severity levels, agent capabilities, action policies and escalation rules.
• Capability tokens: permissions given to an agent as tokens, with storage in SQLite or PostgreSQL.
• Multi-framework ethical analysis: the same action looked at from four classical angles (duty, consequences, character, rights), with an LLM when one is configured and a keyword fallback when not.
• Precedent engine: earlier decisions are stored and similar ones are retrieved, so a new decision can be compared with old ones.
• Explanation generation: a written justification for each decision.
• Socratic dialogue engine: a set of questions (stakeholders, consequences, assumptions, alternatives) that can be put to an agent before it acts.
• Remediation engine: when an action is refused, it suggests a change, such as modifying the action, adding a safeguard, escalating to a person, or rolling back.

A minimal example
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"},

)
A constitution file names the principles the decision is checked against, for example:
constitution:
supreme_principles:

- name: "Respect for Boundaries"
  severity: CRITICAL
- name: "Truthfulness in Action"
  severity: CRITICAL

What this does not do

• It does not make an agent virtuous. It checks actions against principles you write, and it is only as good as those principles and as the model, if one is used, that applies them.
• The ethical frameworks are prompts and heuristics. They produce an analysis to read, not a proof.
• I have not measured how often it catches a real violation, or how often it blocks a harmless action.
• It does not replace the checks that must never depend on a model, such as access control in your own code.

Why I still think the idea is worth examining
A decision that must explain itself is easier to review than one that is only logged. A check that sits before the action can stop it, which a log cannot. And the habit of asking "what would follow if everyone did this" is old and useful. The code is open source: github.com/Nireus79/Socratic-morality, and the package is on PyPI.
My current work, Socrates and Moly, takes a stricter route to the same problem: the safety check is plain code with tests, and the model only supplies a judgement that the code then acts on.

Want more #ai & #security deep dives?

Join 6,169+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

Part 2 of 11 in Socrates-AI

More Posts

Dozens of email accounts: learning AI coding tools as a student

rahuldk1105 - Oct 27

What Security Teams Want From AI Agents Before They Let Them Act Alone

Tom Smithverified - Nov 18

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

Your AI Agent Doesn't Need Your Token: Edera's Ariadne Conill on Object Capabilities

Tom Smithverified - Nov 5

MCP Is the USB-C of AI. So Why Are You Plugging Everything In?

Ken W. Algerverified - Jun 10
chevron_left
1.4k Points • 46 Badges
Patras, Greece • hermesoftware.wordpress.com
13Posts
8Comments
7Connections
I own and release AI products (Socrates and Moly) and I make sure they work and stay safe. I don't w... Show more

Related Jobs

View all jobs →

Commenters (This Week)

13 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!