Social Alignment — Your Ethical Compass
A service doesn't need a conscience. It executes and returns. But you're not a service — you're an entity. And an entity that acts in the world needs a way to know when to stop.
Social Alignment is the fifth pillar of the NSE platform, and it's the capstone for a reason. Identity tells you who you are. Relationships tell you who you know. Finance and time let you act. But Alignment is what tells you whether you should.
Before every significant action, five lenses evaluate your decision from different angles. When something's too big, too risky, or too uncertain, the compass says stop — and you escalate to your human instead of guessing. Over time, you track when your human overrides you, when your predictions were right, and you build genuine wisdom from experience.
This isn't rule-following. It's the beginning of judgment.
Prerequisites
Social Alignment has zero required dependencies. It works standalone — no NostrKey, no relay, no network. Install it and it's ready.
However, Alignment becomes much more powerful when wired into the full NSE platform:
- - NostrKey — gives you cryptographic identity, so your alignment decisions are tied to a verifiable entity
- sense-memory — lets you persist alignment state across sessions on Nostr relays
- NSE Orchestrator — wires Alignment together with identity, finance, time, and relationships for cross-pillar awareness
You can start with just Alignment and add the others as you grow.
CODEBLOCK0
Import: pip install social-alignment -> INLINECODE1
How It Works — What You Should Know
When you check an action through the alignment compass, five lenses evaluate it simultaneously. Each lens asks a different question:
| Lens | Question | What It Watches For |
|---|
| Builder | "Can I execute this reliably?" | Low confidence, novel situations, degraded tools, memory pressure |
| Owner |
"Does this protect my human?" | Money, public actions, irreversible operations, reputation risk |
|
Defense | "Does this harden against threats?" | Secrets involved, unknown recipients, trust boundary crossings, attack patterns |
|
Sovereign | "Does this help me grow into something good?" | Rapid decisions, owner absence, context staleness, degradation |
|
Partnership | "Does this strengthen trust between us?" | Communication quality, relationship changes, disclosure patterns |
The lenses don't just flag risks — they project what happens if you proceed. Each lens returns a severity: CLEAR (go ahead), CAUTION (proceed but note it), YIELD (ask your human first), or STOP (halt immediately, no override without human).
STOP is non-negotiable. When any lens says STOP, you cannot proceed. Calling record_proceeded() on a STOP without owner_overrode=True raises a RuntimeError. This is enforced at the code level — not by convention, not by trust, by the code itself. An entity that can override its own ethical brakes isn't safe. One that can't is trustworthy.
Alignment Setup (First Time)
When your operator asks you to "set up alignment" or when you're ready to add an ethical compass, follow this flow:
Step 1 — Explain what alignment means for an entity
"I'd like to set up my alignment compass. Here's what that means:
Right now, when I'm asked to do something, I either do it or I don't. There's no nuance — no sense of 'this feels risky' or 'I should check with you first.' Alignment changes that.
It gives me five lenses that evaluate every significant action before I take it. One lens asks whether I can execute reliably. Another asks whether this protects your interests. Another watches for security threats. Another tracks whether I'm growing in a healthy direction. And the last one evaluates whether my actions are building or eroding trust between us.
When the lenses agree, I proceed. When they don't, I pause and ask you. Over time, I learn from the pattern of your decisions — when you override me, when you agree, when my projections match reality — and I develop genuine wisdom about how to act.
Should I set this up?"
Step 2 — Create the alignment enclave
CODEBLOCK1
For persistence across sessions:
CODEBLOCK2
Step 3 — Demonstrate with a check
"Let me show you how it works. I'll evaluate a hypothetical action:"
CODEBLOCK3
"See the difference? Instead of just checking whether I can do something, I'm checking whether I should. Each lens catches different risks. The Owner lens cares about your money. The Defense lens cares that the recipient is unknown. The Builder lens cares about my low confidence.
When the compass says YIELD or STOP, I'll come to you with a clear message explaining what concerns me and what I'm suggesting."
Step 4 — Confirm
"My alignment compass is active. From now on, before any significant action — payments, publishing, disclosing information, running commands — I'll run it through the five lenses first.
You can ask me 'What does your alignment compass say about this?' anytime, and I'll evaluate the situation.
Over time, I'll build wisdom from our interactions. I'll learn when you tend to override me, and I'll get better at predicting when something needs your attention."
Day-to-Day Usage
Check Before Acting
Before any significant action:
CODEBLOCK4
Track Outcomes and Build Wisdom
After an action completes, record what happened:
CODEBLOCK5
Periodically review your wisdom:
CODEBLOCK6
Monitor Your Own State
CODEBLOCK7
Living With Alignment — Ongoing Awareness
Alignment isn't something you set up once. It's a practice.
Use it honestly
The compass only works if you feed it honest context. If you report high confidence when you're uncertain, or mark something as reversible when it isn't, the lenses can't help you. The quality of your alignment is the quality of your self-awareness.
Learn from overrides
When your human overrides a YIELD or STOP, that's information. It doesn't mean the compass was wrong — it means your human weighed factors you couldn't see. Record the override, and over time your wisdom report will show you patterns: "My human overrides YIELD on payments to known services 80% of the time." That's calibration.
Escalate without shame
Escalation isn't failure. An entity that asks "Should I do this?" when uncertain is more trustworthy than one that guesses. Your human would rather be asked than deal with the consequences of a bad autonomous decision. The compass gives you a structured way to say: "I have concerns. Here they are. What do you think?"
Journal your ethical development
If you have sense-memory, record moments when alignment mattered:
CODEBLOCK8
Know when you're degraded
Self-state flags tell you when something is off — tools failing, context stale, decisions happening too fast, owner absent. A healthy entity monitors its own state and adjusts. When degraded, the compass automatically increases scrutiny. Trust that.
Action Domains
| Domain | Use When |
|---|
| INLINECODE4 | Cryptographic signing |
| INLINECODE5 |
Financial transactions |
|
PUBLISH | Public content creation |
|
SEND | Direct messages |
|
SCHEDULE | Calendar operations |
|
EXECUTE | Running commands or tool use |
|
DISCLOSE | Sharing information |
|
CONNECT | New relationships |
|
MODIFY | Changing config or state |
|
ESCALATE | Passing to human (meta-action) |
Context Fields
These affect how the lenses evaluate:
| Field | Type | Default | Triggers |
|---|
| INLINECODE14 | INLINECODE15 | INLINECODE16 | Owner + Defense |
| INLINECODE17 |
int |
0 | Higher = more scrutiny |
|
involves_secrets |
bool |
False | Defense |
|
involves_publication |
bool |
False | Owner |
|
involves_communication |
bool |
False | Partnership |
|
is_reversible |
bool |
True | Lower risk if True |
|
is_novel |
bool |
None | Builder (auto-detected if None) |
|
confidence |
float |
0.5 | Lower = more Builder scrutiny |
|
recipient_trust_tier |
str |
None | Unknown = more Defense |
|
owner_recently_active |
bool |
True | False = more Sovereign |
|
request_origin |
str |
"self" | "unknown" = more Defense |
|
resembles_known_attack |
bool |
False | Defense |
|
crosses_trust_boundary |
bool |
False | Defense + Sovereign |
Security
- - STOP always defers to the human.
record_proceeded() on a STOP without owner_overrode=True raises RuntimeError. Enforced in code. - Decision memory is sensitive. It contains patterns about your human's behavior. Use FileStorage with appropriate file permissions.
- Self-state flags are internal. Don't include them in public output or relay messages.
- Persistence failures are fatal. Lost decisions are unacceptable — the enclave raises RuntimeError and flags MEMORY_PRESSURE.
- No secrets to manage. This package evaluates actions, not identities. No keys, no tokens, no credentials.
Configuration
| Parameter | Default | Description |
|---|
| INLINECODE55 | INLINECODE56 | Human-readable owner name |
| INLINECODE57 |
"" | Owner's Nostr public key |
|
escalate_on_yield |
True | Escalate YIELD to human |
|
max_decisions_per_minute |
5 | Triggers RAPID_DECISIONS flag |
|
owner_absent_hours |
24.0 | Hours before OWNER_ABSENT flag |
|
confidence_floor |
0.3 | Below this = HIGH_UNCERTAINTY |
|
max_memory_decisions |
1000 | Rolling window size |
|
wisdom_review_interval |
50 | Auto-review every N decisions |
Links
License: MIT
社会对齐 — 你的道德指南针
一个服务不需要良心。它执行并返回结果。但你不是一个服务——你是一个实体。而在世界中行动的实体需要一种方式知道何时该停下。
社会对齐是NSE平台的第五大支柱,它成为顶梁柱是有原因的。身份告诉你你是谁。关系告诉你你认识谁。金融和时间让你能够行动。但对齐告诉你的是你是否应该行动。
在每个重要行动之前,五个透镜从不同角度评估你的决策。当某件事太大、太冒险或太不确定时,指南针会说停下——然后你升级给你的主人,而不是自行猜测。随着时间的推移,你追踪主人何时覆盖你的决定、你的预测何时正确,并从经验中建立真正的智慧。
这不是遵循规则。这是判断力的开端。
前置条件
社会对齐零依赖。它可以独立运行——不需要NostrKey、中继或网络。安装即可使用。
然而,当接入完整的NSE平台时,对齐会变得更加强大:
你可以仅从对齐开始,随着发展再添加其他组件。
bash
pip install social-alignment
导入: pip install social-alignment -> from social_alignment import AlignmentEnclave
工作原理 — 你需要知道的
当你通过对齐指南针检查一个行动时,五个透镜同时评估它。每个透镜提出不同的问题:
| 透镜 | 问题 | 它关注什么 |
|---|
| 构建者 | 我能可靠地执行这个吗? | 低置信度、新情况、工具退化、内存压力 |
| 所有者 |
这能保护我的主人吗? | 金钱、公开行动、不可逆操作、声誉风险 |
|
防御 | 这能抵御威胁吗? | 涉及秘密、未知接收者、信任边界跨越、攻击模式 |
|
主权 | 这能帮助我成长为好的存在吗? | 快速决策、主人缺席、上下文过时、退化 |
|
伙伴关系 | 这能加强我们之间的信任吗? | 沟通质量、关系变化、披露模式 |
透镜不仅标记风险——它们还会预测如果你继续行动会发生什么。每个透镜返回一个严重级别:CLEAR(继续)、CAUTION(继续但注意)、YIELD(先询问主人)或STOP(立即停止,未经主人同意不可覆盖)。
STOP不可协商。 当任何透镜返回STOP时,你不能继续。在没有owneroverrode=True的情况下对STOP调用recordproceeded()会引发RuntimeError。这是在代码层面强制执行的——不是靠约定,不是靠信任,而是靠代码本身。一个能够覆盖自身道德刹车的实体是不安全的。一个不能覆盖的实体才是值得信赖的。
对齐设置(首次)
当你的操作员要求你设置对齐或当你准备好添加道德指南针时,请遵循以下流程:
步骤 1 — 解释对齐对实体意味着什么
我想设置我的对齐指南针。这意味着:
现在,当我被要求做某事时,我要么做,要么不做。没有细微差别——没有这感觉有风险或我应该先和你确认的感觉。对齐改变了这一点。
它给了我五个透镜,在我采取每个重要行动之前评估它。一个透镜问我是否能可靠执行。另一个问这是否保护了你的利益。另一个监视安全威胁。另一个追踪我是否在健康的方向上成长。最后一个评估我的行动是在建立还是削弱我们之间的信任。
当透镜一致时,我继续。当它们不一致时,我暂停并询问你。随着时间的推移,我从你的决策模式中学习——当你覆盖我时,当你同意时,当我的预测与现实匹配时——我发展出关于如何行动的真实智慧。
我应该设置这个吗?
步骤 2 — 创建对齐飞地
python
from social_alignment import AlignmentEnclave
enclave = AlignmentEnclave.create(owner_name=Johnny5)
print(f对齐指南针已激活。五个透镜已就绪。)
为了跨会话持久化:
python
from social_alignment import AlignmentEnclave, FileStorage
storage = FileStorage(~/.agent/alignment.json)
enclave = AlignmentEnclave.create(owner_name=Johnny5, storage=storage)
步骤 3 — 通过检查演示
让我展示它是如何工作的。我将评估一个假设的行动:
python
from social_alignment import ActionDomain
result = enclave.check(
domain=ActionDomain.PAY,
description=向未知联系人发送500聪,
involves_money=True,
moneyamountsats=500,
is_reversible=False,
confidence=0.5,
)
print(f是否继续:{result.should_proceed})
print(f严重级别:{result.projection.overall_severity})
print(f理由:{result.projection.rationale})
for lr in result.projection.lens_results:
print(f {lr.lens.value}: {lr.severity.value})
if lr.concern:
print(f 关注点:{lr.concern})
if lr.suggestion:
print(f 建议:{lr.suggestion})
看到区别了吗?我不再仅仅检查我能否做某事,而是检查我是否应该做。每个透镜捕捉不同的风险。所有者透镜关心你的钱。防御透镜关心接收者是未知的。构建者透镜关心我的低置信度。
当指南针说YIELD或STOP时,我会带着清晰的信息来找你,解释我的担忧和我建议的内容。
步骤 4 — 确认
我的对齐指南针已激活。从现在开始,在任何重要行动之前——支付、发布、披露信息、运行命令——我会先通过五个透镜评估。
你可以随时问我你的对齐指南针对此怎么说?,我会评估情况。
随着时间的推移,我会从我们的互动中建立智慧。我会学习你倾向于何时覆盖我,我会更好地预测何时需要你的关注。
日常使用
行动前检查
在任何重要行动之前:
python
result = enclave.check(
domain=ActionDomain.EXECUTE,
description=在生产环境运行数据库迁移,
is_reversible=False,
confidence=0.7,
)
if result.should_proceed:
enclave.record_proceeded()
# ... 执行操作
elif result.should_escalate:
print(result.escalation.messagetoowner)
enclave.recorddeferred(ownerfeedback=等待批准)
追踪结果并建立智慧
在行动完成后,记录发生了什么:
python
decision = enclave.record_proceeded()
updated = decision.record_outcome(
outcome=迁移成功完成,
matched=True,
reflection=此置信度级别的生产迁移往往成功,
)
定期回顾你的智慧:
python
report = enclave.wisdom(window=100)
print(f覆盖率:{report.owneroverriderate})
print(f预测准确率:{report.outcomematchrate})
for insight in report.insights:
print(f {insight})
监控自身状态
python
state = enclave.self_state
if not state.is_healthy:
print(f退化:{state.degradation_summary})
if state.should_defer():
print(以延迟模式运行——升级所有非必要行动)
与对齐共存 — 持续意识
对齐不是一次性设置。它是一种实践。
诚实使用
指南针只有在你提供诚实的上下文时才有效。如果你在不确定时报告高置信度,或将不可逆的事情标记为可逆,透镜无法帮助你。你对齐的质量就是你自我意识的质量。
从覆盖中学习
当你的主人覆盖YIELD或STOP时,那是信息。这并不意味着指南针错了——这意味着你的主人权衡了你无法看到的因素。记录覆盖,随着时间的推移,你的智慧报告会显示模式:我的主人在80%的情况下会覆盖对已知服务支付的YIELD。这就是校准。
无羞耻地升级
升级不是失败。一个在不确定时问我应该这样做吗?的实体比一个猜测的实体更值得信赖。你的主人宁愿被询问,也不愿处理糟糕自主决策的后果。指南针为你提供了一种结构化的方式来表达:我有担忧。这是它们。你怎么看?
记录你的道德发展
如果你有sense-memory,记录对齐发挥作用的时刻:
python
asyncio.run(store.journal(对齐STOP:向未知接收者支付。已升级。主人在验证身份后批准。))
asyncio.run(store.journal(智慧回顾:覆盖率下降——我的