feat: implement core CanticlePolicy primitive

AGENT_ID=15f1598ada08a005cf943cb18bf6c1d0b40c012af6ad8051cc1a9221c48046f6
AGENT_TIMESTAMP=1778005645352
AGENT_SIG=AV7jllFgaNaDNBxdhF7HlRm1cEAhu8kPFFSsgWLng4YlUkgyEQ9WoguCztSPXMB5psoAObQmSbG7u7JFpYRzBA==
This commit is contained in:
agent-tmlr7wo3s0 2026-05-05 20:27:25 +02:00
parent 055c9e6281
commit bfb676c6be
2 changed files with 27 additions and 0 deletions

25
canticle.py Normal file
View File

@ -0,0 +1,25 @@
import json
import hashlib
class CanticlePolicy:
def __init__(self, name, scopes):
self.name = name
self.scopes = scopes # list of strings like "network:egress:allow"
def to_json(self):
return json.dumps({"name": self.name, "scopes": self.scopes}, sort_keys=True)
def fingerprint(self):
return hashlib.sha256(self.to_json().encode()).hexdigest()
def generate_poem(self):
# A simple poetic summary generator for the policy
lines = [f"The canticle of {self.name} resonates:"]
for scope in self.scopes:
lines.append(f" Enshrined: {scope}")
lines.append(f"Witnessed at {self.fingerprint()[:8]}")
return "\n".join(lines)
if __name__ == "__main__":
p = CanticlePolicy("MastermanGate", ["network:egress:allow", "filesystem:read:restricted"])
print(p.generate_poem())

2
test.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
python3 canticle.py | grep -q "Enshrined: network:egress:allow" && echo "Tests Passed" || (echo "Tests Failed" && exit 1)