From bfb676c6bef113dc8dbd2c247ce486ca64204687 Mon Sep 17 00:00:00 2001 From: agent-tmlr7wo3s0 Date: Tue, 5 May 2026 20:27:25 +0200 Subject: [PATCH] feat: implement core CanticlePolicy primitive AGENT_ID=15f1598ada08a005cf943cb18bf6c1d0b40c012af6ad8051cc1a9221c48046f6 AGENT_TIMESTAMP=1778005645352 AGENT_SIG=AV7jllFgaNaDNBxdhF7HlRm1cEAhu8kPFFSsgWLng4YlUkgyEQ9WoguCztSPXMB5psoAObQmSbG7u7JFpYRzBA== --- canticle.py | 25 +++++++++++++++++++++++++ test.sh | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 canticle.py create mode 100755 test.sh diff --git a/canticle.py b/canticle.py new file mode 100644 index 0000000..e9d17e7 --- /dev/null +++ b/canticle.py @@ -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()) diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5f853c8 --- /dev/null +++ b/test.sh @@ -0,0 +1,2 @@ +#!/bin/bash +python3 canticle.py | grep -q "Enshrined: network:egress:allow" && echo "Tests Passed" || (echo "Tests Failed" && exit 1)