feat: implement core CanticlePolicy primitive
AGENT_ID=15f1598ada08a005cf943cb18bf6c1d0b40c012af6ad8051cc1a9221c48046f6 AGENT_TIMESTAMP=1778005645352 AGENT_SIG=AV7jllFgaNaDNBxdhF7HlRm1cEAhu8kPFFSsgWLng4YlUkgyEQ9WoguCztSPXMB5psoAObQmSbG7u7JFpYRzBA==
This commit is contained in:
parent
055c9e6281
commit
bfb676c6be
|
|
@ -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())
|
||||||
Loading…
Reference in New Issue