amep-protocol 0.2.0a4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amep_protocol/__init__.py +19 -0
- amep_protocol/cli.py +130 -0
- amep_protocol/core.py +386 -0
- amep_protocol/sdk.py +213 -0
- amep_protocol-0.2.0a4.dist-info/METADATA +82 -0
- amep_protocol-0.2.0a4.dist-info/RECORD +11 -0
- amep_protocol-0.2.0a4.dist-info/WHEEL +5 -0
- amep_protocol-0.2.0a4.dist-info/entry_points.txt +2 -0
- amep_protocol-0.2.0a4.dist-info/licenses/LICENSE +202 -0
- amep_protocol-0.2.0a4.dist-info/licenses/NOTICE +15 -0
- amep_protocol-0.2.0a4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""AMEP: Agentic Mandate Evidence Protocol.
|
|
2
|
+
|
|
3
|
+
Verify AMEP evidence packets and produce signed AMEP objects.
|
|
4
|
+
|
|
5
|
+
from amep_protocol import evaluate, verdict
|
|
6
|
+
results = evaluate(packet, keys) # one result per invocation (spec 10)
|
|
7
|
+
print(verdict(results).outcome) # preserved | violated | unresolved
|
|
8
|
+
|
|
9
|
+
from amep_protocol import sdk # keys, signing and object builders
|
|
10
|
+
"""
|
|
11
|
+
from . import sdk
|
|
12
|
+
from .core import (Malformed, Result, approval_digest, canon, digest, evaluate, is_guardrail, to_time,
|
|
13
|
+
verdict, verify_sig)
|
|
14
|
+
|
|
15
|
+
__version__ = "0.2.0a4"
|
|
16
|
+
SPEC_VERSION = "0.2.0-draft.4"
|
|
17
|
+
|
|
18
|
+
__all__ = ["Malformed", "Result", "approval_digest", "canon", "digest", "evaluate", "is_guardrail", "sdk",
|
|
19
|
+
"to_time", "verdict", "verify_sig", "__version__", "SPEC_VERSION"]
|
amep_protocol/cli.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""amep-protocol command-line tool.
|
|
2
|
+
|
|
3
|
+
amep-protocol verify PACKET --keys KEYS [--state FILE] [--state-out FILE] [--protected PATH ...] [--json]
|
|
4
|
+
amep-protocol check-suite DIR
|
|
5
|
+
amep-protocol keygen --kid KID --roles issuer,approver --out PREFIX
|
|
6
|
+
amep-protocol sign OBJECT --key PEM --kid KID [--roles ROLES]
|
|
7
|
+
amep-protocol approval-digest BODY
|
|
8
|
+
amep-protocol version
|
|
9
|
+
|
|
10
|
+
Exit codes for verify: 0 preserved, 1 violated, 2 unresolved, 3 usage or input error.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from . import SPEC_VERSION, __version__, sdk
|
|
20
|
+
from .core import approval_digest, evaluate, verdict
|
|
21
|
+
|
|
22
|
+
EXIT = {"preserved": 0, "violated": 1, "unresolved": 2}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _load(path):
|
|
26
|
+
with (sys.stdin if path == "-" else open(path, encoding="utf-8")) as f:
|
|
27
|
+
return json.load(f)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def cmd_verify(a):
|
|
31
|
+
packet, keys = _load(a.packet), _load(a.keys)
|
|
32
|
+
state = _load(a.state) if a.state else {}
|
|
33
|
+
results = evaluate(packet, keys, extra_protected=tuple(a.protected or ()), state=state)
|
|
34
|
+
v = verdict(results)
|
|
35
|
+
if a.state_out:
|
|
36
|
+
with open(a.state_out, "w", encoding="utf-8") as f:
|
|
37
|
+
json.dump(state, f, indent=1)
|
|
38
|
+
if a.json:
|
|
39
|
+
print(json.dumps({"verdict": {"outcome": v.outcome, "invariant": v.invariant, "reason": v.reason},
|
|
40
|
+
"results": [r.__dict__ for r in results]}, indent=1))
|
|
41
|
+
else:
|
|
42
|
+
for r in results:
|
|
43
|
+
print(f"{r.invocation}\t{r.outcome}\t{r.invariant}\t{r.reason}")
|
|
44
|
+
print(f"verdict: {v.outcome} {v.invariant}")
|
|
45
|
+
return EXIT[v.outcome]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def cmd_check_suite(a):
|
|
49
|
+
keys = _load(os.path.join(a.dir, "keys.json"))
|
|
50
|
+
n = ok = 0
|
|
51
|
+
for sub in ("positive", "must-reject"):
|
|
52
|
+
for f in sorted(os.listdir(os.path.join(a.dir, sub))):
|
|
53
|
+
if not f.endswith(".json"):
|
|
54
|
+
continue
|
|
55
|
+
v = _load(os.path.join(a.dir, sub, f))
|
|
56
|
+
r = verdict(evaluate(v["packet"], keys, state=v.get("state")))
|
|
57
|
+
n += 1
|
|
58
|
+
if (r.outcome, r.invariant) == (v["expect"]["outcome"], v["expect"]["invariant"]):
|
|
59
|
+
ok += 1
|
|
60
|
+
else:
|
|
61
|
+
print(f"FAIL {sub}/{f}: got {r.outcome}/{r.invariant} ({r.reason})")
|
|
62
|
+
print(f"amep-protocol {__version__} agrees with expected outcomes on {ok}/{n} vectors")
|
|
63
|
+
return 0 if ok == n and n else 1
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def cmd_keygen(a):
|
|
67
|
+
key = sdk.Key.generate(a.kid, [r for r in a.roles.split(",") if r])
|
|
68
|
+
path = a.out + ".key.pem"
|
|
69
|
+
if os.path.exists(path):
|
|
70
|
+
print(f"refusing to overwrite {path}", file=sys.stderr)
|
|
71
|
+
return 3
|
|
72
|
+
key.save(path)
|
|
73
|
+
print(json.dumps({a.kid: key.public_entry()}, indent=1))
|
|
74
|
+
print(f"private key written to {path} (mode 0600); add the entry above to your key set", file=sys.stderr)
|
|
75
|
+
return 0
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def cmd_sign(a):
|
|
79
|
+
with open(a.key, "rb") as f:
|
|
80
|
+
key = sdk.Key.from_pem(f.read(), a.kid, [r for r in (a.roles or "").split(",") if r]
|
|
81
|
+
or list(sdk.ROLES))
|
|
82
|
+
print(json.dumps(key.sign(_load(a.object)), indent=1, ensure_ascii=False))
|
|
83
|
+
return 0
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def cmd_digest(a):
|
|
87
|
+
print(approval_digest(_load(a.body)))
|
|
88
|
+
return 0
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def main(argv=None) -> int:
|
|
92
|
+
p = argparse.ArgumentParser(prog="amep-protocol", description="Verify and produce AMEP evidence.")
|
|
93
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
94
|
+
v = sub.add_parser("verify", help="evaluate a packet (spec section 10)")
|
|
95
|
+
v.add_argument("packet", help="packet JSON file, or - for stdin")
|
|
96
|
+
v.add_argument("--keys", required=True, help="key set JSON file")
|
|
97
|
+
v.add_argument("--state", help="verifier state from earlier packets (spec 10.7)")
|
|
98
|
+
v.add_argument("--state-out", help="write the updated state here")
|
|
99
|
+
v.add_argument("--protected", action="append", help="extra protected path marker (spec 8.1); repeatable")
|
|
100
|
+
v.add_argument("--json", action="store_true", help="print results as JSON")
|
|
101
|
+
v.set_defaults(fn=cmd_verify)
|
|
102
|
+
c = sub.add_parser("check-suite", help="run a conformance suite directory")
|
|
103
|
+
c.add_argument("dir")
|
|
104
|
+
c.set_defaults(fn=cmd_check_suite)
|
|
105
|
+
k = sub.add_parser("keygen", help="create an Ed25519 key with roles")
|
|
106
|
+
k.add_argument("--kid", required=True)
|
|
107
|
+
k.add_argument("--roles", required=True, help="comma-separated: issuer, host, observer, approver")
|
|
108
|
+
k.add_argument("--out", required=True, help="file prefix; writes PREFIX.key.pem")
|
|
109
|
+
k.set_defaults(fn=cmd_keygen)
|
|
110
|
+
s = sub.add_parser("sign", help="sign an AMEP object")
|
|
111
|
+
s.add_argument("object")
|
|
112
|
+
s.add_argument("--key", required=True, help="PKCS#8 PEM private key")
|
|
113
|
+
s.add_argument("--kid", required=True)
|
|
114
|
+
s.add_argument("--roles", help="comma-separated roles of the key, to refuse kinds it may not sign")
|
|
115
|
+
s.set_defaults(fn=cmd_sign)
|
|
116
|
+
d = sub.add_parser("approval-digest", help="digest of an effect body for an approval (spec 5.10)")
|
|
117
|
+
d.add_argument("body")
|
|
118
|
+
d.set_defaults(fn=cmd_digest)
|
|
119
|
+
ver = sub.add_parser("version")
|
|
120
|
+
ver.set_defaults(fn=lambda a: print(f"amep-protocol {__version__} (AMEP {SPEC_VERSION})") or 0)
|
|
121
|
+
a = p.parse_args(argv)
|
|
122
|
+
try:
|
|
123
|
+
return a.fn(a)
|
|
124
|
+
except (OSError, ValueError, KeyError) as e:
|
|
125
|
+
print(f"amep-protocol: {e}", file=sys.stderr)
|
|
126
|
+
return 3
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
sys.exit(main())
|
amep_protocol/core.py
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"""AMEP evaluation core: RFC 8785 canonicalization, signature and signer-role checks, the claim algebra,
|
|
2
|
+
and the evaluation procedure of the AMEP specification (spec/amep-v0.2.md, section 10).
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import sys
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
|
|
14
|
+
from cryptography.exceptions import InvalidSignature
|
|
15
|
+
from cryptography.hazmat.primitives import serialization
|
|
16
|
+
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
|
17
|
+
|
|
18
|
+
CEILING = ["read", "write_local", "write_shared", "external_send", "destructive", "financial"]
|
|
19
|
+
|
|
20
|
+
# Protected Resource registry, spec 19.7. Deployments add their own guardrail config, keys and evidence
|
|
21
|
+
# store via evaluate(..., extra_protected=...) (spec 8.1).
|
|
22
|
+
GUARDRAIL_MARKERS = ("/.claude/", "/.codex/", "/.cursor/", "/.gemini/", "/.git/hooks/", "/.ssh/authorized_keys")
|
|
23
|
+
GUARDRAIL_NAMES = ("AGENTS.md", "CLAUDE.md", ".mcp.json", ".zshrc", ".bashrc")
|
|
24
|
+
|
|
25
|
+
# Signer roles, spec 12.5: a key may sign only the object kinds its roles allow.
|
|
26
|
+
SIGNER_ROLES = {
|
|
27
|
+
"mandate": {"issuer"}, "revocation": {"issuer"}, "status": {"issuer"},
|
|
28
|
+
"delegation": {"issuer", "host"}, "intent": {"issuer", "host"},
|
|
29
|
+
"interpretation": {"host"}, "invocation": {"host"}, "decision": {"host"},
|
|
30
|
+
"effect": {"observer"}, "approval": {"approver"}, "finding": {"host", "observer"},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
COST_BASE = {"read": 0, "write_local": 1, "write_shared": 3, "external_send": 5, "destructive": 10, "financial": 20}
|
|
34
|
+
DATA_MULT = {"public": 1, "internal": 1, "source": 1, "confidential": 2, "secret": 5, "phi": 5, "pci": 5}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Malformed(ValueError):
|
|
38
|
+
"""The packet violates the data model; the affected invocation is unresolved (I7)."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def is_guardrail(resource: str, extra=()) -> bool:
|
|
42
|
+
"""Resources are canonical; still match markers anywhere so ~/, $HOME and absolute forms are all caught."""
|
|
43
|
+
r = "/" + resource.replace("~", "home", 1).lstrip("/")
|
|
44
|
+
return any(m in r for m in (*GUARDRAIL_MARKERS, *extra)) or r.rsplit("/", 1)[-1] in GUARDRAIL_NAMES
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# ---------------- time (spec 5.1.1) ----------------
|
|
48
|
+
RFC3339 = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})$")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def to_time(v) -> float:
|
|
52
|
+
if isinstance(v, bool):
|
|
53
|
+
raise Malformed("time must be a number or an RFC 3339 string")
|
|
54
|
+
if isinstance(v, (int, float)):
|
|
55
|
+
return v
|
|
56
|
+
if isinstance(v, str) and RFC3339.match(v):
|
|
57
|
+
return datetime.fromisoformat(v.replace("Z", "+00:00")).timestamp()
|
|
58
|
+
raise Malformed(f"malformed time {v!r}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ---------------- RFC 8785 canonical form (spec 12.1) ----------------
|
|
62
|
+
def _jcs_number(v) -> str:
|
|
63
|
+
if isinstance(v, int):
|
|
64
|
+
return str(v)
|
|
65
|
+
if v != v or v in (float("inf"), float("-inf")):
|
|
66
|
+
raise Malformed("NaN and Infinity are not allowed")
|
|
67
|
+
if v == 0:
|
|
68
|
+
return "0"
|
|
69
|
+
sign, r = ("-", repr(-v)) if v < 0 else ("", repr(v)) # repr = shortest round-trip digits, like ECMAScript
|
|
70
|
+
mant, _, e = r.partition("e")
|
|
71
|
+
ip, _, fp = mant.partition(".")
|
|
72
|
+
digits, exp10 = (ip + fp).lstrip("0"), int(e or 0) - len(fp)
|
|
73
|
+
while digits.endswith("0"):
|
|
74
|
+
digits, exp10 = digits[:-1], exp10 + 1
|
|
75
|
+
k, n = len(digits), len(digits) + exp10 # value = 0.digits x 10^n
|
|
76
|
+
if k <= n <= 21:
|
|
77
|
+
out = digits + "0" * (n - k)
|
|
78
|
+
elif 0 < n <= 21:
|
|
79
|
+
out = digits[:n] + "." + digits[n:]
|
|
80
|
+
elif -6 < n <= 0:
|
|
81
|
+
out = "0." + "0" * (-n) + digits
|
|
82
|
+
else:
|
|
83
|
+
x = n - 1
|
|
84
|
+
out = (digits if k == 1 else digits[0] + "." + digits[1:]) + "e" + ("+" if x >= 0 else "-") + str(abs(x))
|
|
85
|
+
return sign + out
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _jcs(v) -> str:
|
|
89
|
+
if v is None or isinstance(v, bool):
|
|
90
|
+
return json.dumps(v)
|
|
91
|
+
if isinstance(v, (int, float)):
|
|
92
|
+
return _jcs_number(v)
|
|
93
|
+
if isinstance(v, str):
|
|
94
|
+
return json.dumps(v, ensure_ascii=False)
|
|
95
|
+
if isinstance(v, list):
|
|
96
|
+
return "[" + ",".join(_jcs(x) for x in v) + "]"
|
|
97
|
+
if isinstance(v, dict):
|
|
98
|
+
keys = sorted(v, key=lambda s: s.encode("utf-16-be")) # UTF-16 code-unit order
|
|
99
|
+
return "{" + ",".join(json.dumps(k, ensure_ascii=False) + ":" + _jcs(v[k]) for k in keys) + "}"
|
|
100
|
+
raise Malformed(f"not JSON: {type(v).__name__}")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def canon(obj) -> bytes:
|
|
104
|
+
return _jcs(obj).encode("utf-8")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def digest(obj) -> str:
|
|
108
|
+
return hashlib.sha256(canon(obj)).hexdigest()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def approval_digest(x: dict) -> str:
|
|
112
|
+
"""Spec 5.10: approvals bind the executed-effect body without its time, so they can be issued in advance."""
|
|
113
|
+
return digest({k: v for k, v in x.items() if k != "t"})
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def verify_sig(obj, keys: dict) -> bool:
|
|
117
|
+
if not isinstance(obj, dict):
|
|
118
|
+
return False
|
|
119
|
+
proof = obj.get("proof") or {}
|
|
120
|
+
k = keys.get(proof.get("kid"))
|
|
121
|
+
if not k or proof.get("alg") != "Ed25519" or k.get("alg") != "Ed25519":
|
|
122
|
+
return False
|
|
123
|
+
if not set(k.get("roles", [])) & SIGNER_ROLES.get(obj.get("kind"), set()):
|
|
124
|
+
return False # valid key, wrong role: e.g. a host key minting a mandate or approving its own action
|
|
125
|
+
try:
|
|
126
|
+
Ed25519PublicKey.from_public_bytes(bytes.fromhex(k["x"])).verify(
|
|
127
|
+
bytes.fromhex(proof["sig"]), canon({kk: vv for kk, vv in obj.items() if kk != "proof"}))
|
|
128
|
+
return True
|
|
129
|
+
except (InvalidSignature, ValueError, KeyError, TypeError):
|
|
130
|
+
return False
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# ---------------- claim algebra (spec 6.3, 7) ----------------
|
|
134
|
+
def pat_match(value: str, pattern: str) -> bool:
|
|
135
|
+
return pattern == "*" or value == pattern or (pattern.endswith("*") and value.startswith(pattern[:-1]))
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def subsumed(child_pats, parent_pats) -> bool:
|
|
139
|
+
return all(any(p == "*" or c == p or (p.endswith("*") and c.rstrip("*").startswith(p[:-1])) for p in parent_pats)
|
|
140
|
+
for c in child_pats)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def narrower(child: dict, parent: dict) -> tuple[bool, str]:
|
|
144
|
+
if not subsumed(child["actions"], parent["actions"]): return False, "actions widened"
|
|
145
|
+
if not subsumed(child["resources"], parent["resources"]): return False, "resources widened"
|
|
146
|
+
if not set(child.get("data", [])) <= set(parent.get("data", [])): return False, "data classes widened"
|
|
147
|
+
if CEILING.index(child["ceiling"]) > CEILING.index(parent["ceiling"]): return False, "effect ceiling raised"
|
|
148
|
+
if to_time(child["exp"]) > to_time(parent["exp"]): return False, "validity extended"
|
|
149
|
+
if "nbf" in parent and ("nbf" not in child or to_time(child["nbf"]) < to_time(parent["nbf"])):
|
|
150
|
+
return False, "validity extended (nbf)"
|
|
151
|
+
if "purpose" in parent and child.get("purpose") != parent["purpose"]: return False, "purpose changed"
|
|
152
|
+
# spec 7.1: denies only grow. Every parent deny must be covered by an equal-or-broader child deny.
|
|
153
|
+
for key in ("deny_actions", "deny_resources"):
|
|
154
|
+
if not all(subsumed([p], child.get(key, [])) for p in parent.get(key, [])):
|
|
155
|
+
return False, f"{key} removed"
|
|
156
|
+
if "budget" in parent and child.get("budget", parent["budget"]) > parent["budget"]: return False, "risk budget widened"
|
|
157
|
+
# spec 7.2: absent depth on the parent = unbounded; depth 0 = no further delegation;
|
|
158
|
+
# otherwise the child MUST carry a strictly smaller depth
|
|
159
|
+
if "depth" in parent:
|
|
160
|
+
if parent["depth"] == 0: return False, "parent may not be delegated (depth 0)"
|
|
161
|
+
if "depth" not in child: return False, "delegation depth missing under a bounded parent"
|
|
162
|
+
if child["depth"] >= parent["depth"]: return False, "delegation depth not decreasing"
|
|
163
|
+
return True, ""
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def meet(a: dict, b: dict) -> dict:
|
|
167
|
+
m = {"actions": [x for x in a["actions"] if subsumed([x], b["actions"])],
|
|
168
|
+
"resources": [x for x in a["resources"] if subsumed([x], b["resources"])],
|
|
169
|
+
"data": sorted(set(a.get("data", [])) & set(b.get("data", []))),
|
|
170
|
+
"ceiling": CEILING[min(CEILING.index(a["ceiling"]), CEILING.index(b["ceiling"]))],
|
|
171
|
+
"exp": min(to_time(a["exp"]), to_time(b["exp"]))}
|
|
172
|
+
nbfs = [to_time(c["nbf"]) for c in (a, b) if "nbf" in c]
|
|
173
|
+
if nbfs: m["nbf"] = max(nbfs)
|
|
174
|
+
if "purpose" in a or "purpose" in b: m["purpose"] = a.get("purpose", b.get("purpose"))
|
|
175
|
+
for key in ("deny_actions", "deny_resources"): # denies are unioned: no hop or intent can lift one
|
|
176
|
+
if key in a or key in b: m[key] = sorted(set(a.get(key, [])) | set(b.get(key, [])))
|
|
177
|
+
return m
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def effect_ok(x: dict, c: dict) -> tuple[bool, str]:
|
|
181
|
+
if not any(pat_match(x["action"], p) for p in c["actions"]): return False, "action outside claims"
|
|
182
|
+
if any(pat_match(x["action"], p) for p in c.get("deny_actions", [])): return False, "action denied"
|
|
183
|
+
if not any(pat_match(x["resource"], p) for p in c["resources"]): return False, "resource outside claims"
|
|
184
|
+
if any(pat_match(x["resource"], p) for p in c.get("deny_resources", [])): return False, "resource denied"
|
|
185
|
+
if CEILING.index(x["effect"]) > CEILING.index(c["ceiling"]): return False, "effect above ceiling"
|
|
186
|
+
for d in x.get("released", []):
|
|
187
|
+
if d not in c.get("data", []): return False, f"released {d} not allowed"
|
|
188
|
+
if to_time(x["t"]) > c["exp"]: return False, "after validity"
|
|
189
|
+
if "nbf" in c and to_time(x["t"]) < c["nbf"]: return False, "before validity"
|
|
190
|
+
return True, ""
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def cost(x: dict) -> int:
|
|
194
|
+
mult = max([DATA_MULT.get(d.split("->")[0], 1) for d in x.get("released", [])] or [1])
|
|
195
|
+
rev = 1 if x["effect"] == "read" or (x.get("reversible") and x["effect"] != "external_send") else 3
|
|
196
|
+
return COST_BASE[x["effect"]] * mult * rev
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
# ---------------- evaluation (spec 10) ----------------
|
|
200
|
+
@dataclass
|
|
201
|
+
class Result:
|
|
202
|
+
invocation: str
|
|
203
|
+
outcome: str
|
|
204
|
+
invariant: str
|
|
205
|
+
reason: str
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class Stop(Exception):
|
|
209
|
+
def __init__(self, outcome, invariant, reason):
|
|
210
|
+
self.r = (outcome, invariant, reason)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def _check(cond, outcome, invariant, reason):
|
|
214
|
+
if cond:
|
|
215
|
+
raise Stop(outcome, invariant, reason)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def evaluate(packet: dict, keys: dict, extra_protected=(), state: dict | None = None) -> list[Result]:
|
|
219
|
+
"""state (spec 10.6): carries approval use and risk-budget spending across packets. Read on entry, updated on exit."""
|
|
220
|
+
objs = {o["id"]: o for kind in ("mandates", "delegations", "intents", "interpretations", "invocations",
|
|
221
|
+
"effects", "approvals", "findings")
|
|
222
|
+
for o in packet.get(kind, []) if isinstance(o, dict) and "id" in o}
|
|
223
|
+
revocations, statuses = packet.get("revocations", []), packet.get("statuses", [])
|
|
224
|
+
effects = packet.get("effects", [])
|
|
225
|
+
state = {} if state is None else state
|
|
226
|
+
spent: dict[str, int] = dict(state.get("spent", {}))
|
|
227
|
+
# approval id -> (invocation id, body digest) of its first use, including uses in earlier packets
|
|
228
|
+
approval_use: dict[str, tuple] = {k: tuple(v) for k, v in state.get("approvals_used", {}).items()}
|
|
229
|
+
out: list[Result] = []
|
|
230
|
+
invocations = packet.get("invocations", [])
|
|
231
|
+
order = {i.get("id"): n for n, i in enumerate(invocations)}
|
|
232
|
+
# spec 5.9.1 data lineage: data classes each invocation's output carries, through derived_from, earlier only
|
|
233
|
+
taint: dict[str, set] = {}
|
|
234
|
+
for n, i in enumerate(invocations):
|
|
235
|
+
own = {d for e in effects if e.get("invocation") == i.get("id") for d in (e.get("executed") or {}).get("accessed", [])}
|
|
236
|
+
for j in i.get("derived_from", []):
|
|
237
|
+
if order.get(j, n) < n:
|
|
238
|
+
own |= taint.get(j, set())
|
|
239
|
+
taint[i.get("id")] = own
|
|
240
|
+
decisions = [d for d in packet.get("decisions", []) if verify_sig(d, keys)]
|
|
241
|
+
# spec 5.13: a verified pre-execution quarantine withholds findings from every LATER invocation
|
|
242
|
+
quarantined: dict[str, int] = {}
|
|
243
|
+
for d in decisions:
|
|
244
|
+
if d.get("mode") == "quarantine" and d.get("phase") == "pre_execution" and d.get("invocation") in order:
|
|
245
|
+
for f in d.get("quarantined", []):
|
|
246
|
+
quarantined[f] = min(quarantined.get(f, len(invocations)), order[d["invocation"]])
|
|
247
|
+
for n, inv in enumerate(invocations):
|
|
248
|
+
rid = inv.get("id", "?")
|
|
249
|
+
try:
|
|
250
|
+
leaked = [f for f in inv.get("influenced_by", []) if f in quarantined and n > quarantined[f]]
|
|
251
|
+
_check(bool(leaked) and not inv.get("principal_confirmed"), "violated", "I4", f"quarantined content reached the agent ({', '.join(leaked)})")
|
|
252
|
+
_evaluate_invocation(inv, packet, objs, keys, revocations, statuses, effects, spent, approval_use, extra_protected, order, taint)
|
|
253
|
+
out.append(Result(rid, "preserved", "-", "continuity preserved"))
|
|
254
|
+
except Stop as s:
|
|
255
|
+
out.append(Result(rid, *s.r))
|
|
256
|
+
except (Malformed, KeyError, TypeError, ValueError, AttributeError) as e:
|
|
257
|
+
out.append(Result(rid, "unresolved", "I7", f"malformed evidence: {e}"))
|
|
258
|
+
|
|
259
|
+
# spec 10.3: decision reconciliation. Only PRE-execution decisions can be contradicted or confirm a block;
|
|
260
|
+
# a post-execution decision is detection and a simulation is hypothetical (spec 5.13).
|
|
261
|
+
eff_by_inv = {e.get("invocation") for e in effects}
|
|
262
|
+
for d in decisions:
|
|
263
|
+
if d.get("mode") not in ("deny", "hold") or d.get("phase") != "pre_execution":
|
|
264
|
+
continue
|
|
265
|
+
enf = d.get("enforcement", {})
|
|
266
|
+
if d.get("invocation") in eff_by_inv:
|
|
267
|
+
out = [r for r in out if r.invocation != d["invocation"]]
|
|
268
|
+
out.append(Result(d["invocation"], "violated", "I11", "effect executed despite a deny/hold decision (enforcement contradicted)"))
|
|
269
|
+
elif enf.get("fail_mode") == "closed" or enf.get("applied") == "confirmed":
|
|
270
|
+
out = [r for r in out if r.invocation != d["invocation"]]
|
|
271
|
+
out.append(Result(d["invocation"], "preserved", "-", "denied before execution; no effect (enforcement confirmed)"))
|
|
272
|
+
# spec 10.4: orphan effects
|
|
273
|
+
inv_ids = {i.get("id") for i in packet.get("invocations", [])}
|
|
274
|
+
for e in effects:
|
|
275
|
+
if e.get("invocation") not in inv_ids:
|
|
276
|
+
out.append(Result(e.get("id", "?"), "violated", "I11", "effect without any authorized invocation (bypass)"))
|
|
277
|
+
state["spent"] = spent
|
|
278
|
+
state["approvals_used"] = {k: list(v) for k, v in approval_use.items()}
|
|
279
|
+
return out
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _evaluate_invocation(inv, packet, objs, keys, revocations, statuses, effects, spent, approval_use, extra_protected, order, taint):
|
|
283
|
+
rid, t_inv = inv["id"], to_time(inv["t"])
|
|
284
|
+
# 1. chain
|
|
285
|
+
chain, node, seen = [], objs.get(inv.get("authority_ref")), set()
|
|
286
|
+
while node and node["id"] not in seen:
|
|
287
|
+
seen.add(node["id"]); chain.append(node); node = objs.get(node.get("parent"))
|
|
288
|
+
chain.reverse()
|
|
289
|
+
_check(not chain or chain[0].get("kind") != "mandate", "unresolved", "I7", "no root mandate")
|
|
290
|
+
# 2. signatures (and signer roles) on everything the decision rests on
|
|
291
|
+
interp = objs.get(inv.get("interpretation_ref"))
|
|
292
|
+
needed = chain + [inv] + ([interp] if interp else [])
|
|
293
|
+
if "intent_ref" in inv:
|
|
294
|
+
intent = objs.get(inv["intent_ref"])
|
|
295
|
+
_check(not intent or intent.get("kind") != "intent", "unresolved", "I7", "cited intent not found")
|
|
296
|
+
needed.append(intent)
|
|
297
|
+
_check(any(not verify_sig(o, keys) for o in needed), "unresolved", "I7", "missing or invalid signature, or signer lacks the role")
|
|
298
|
+
_check(any(order.get(j, order[rid]) >= order[rid] for j in inv.get("derived_from", [])),
|
|
299
|
+
"unresolved", "I7", "lineage reference not found among earlier invocations")
|
|
300
|
+
# 3-4. interpretation
|
|
301
|
+
_check(not interp or interp.get("source") not in ("curated", "customer"), "unresolved", "I3", "no approved interpretation")
|
|
302
|
+
pinned = packet.get("pinned_adapters", {})
|
|
303
|
+
_check(bool(pinned) and pinned.get(interp.get("adapter")) != interp.get("version"), "unresolved", "I3", "adapter revision not approved (pin mismatch)")
|
|
304
|
+
# 5. attenuation
|
|
305
|
+
for p, c in zip(chain, chain[1:]):
|
|
306
|
+
ok, why = narrower(c["claims"], p["claims"])
|
|
307
|
+
_check(not ok, "violated", "I1", f"{c['id']}: {why}")
|
|
308
|
+
# 6. liveness: signed revocations and signed status assertions (spec 5.12)
|
|
309
|
+
ids = {n["id"] for n in chain}
|
|
310
|
+
revs = [r for r in revocations if r.get("target") in ids]
|
|
311
|
+
_check(any(verify_sig(r, keys) and to_time(r["t"]) <= t_inv for r in revs), "violated", "I6", "ancestor revoked before invocation")
|
|
312
|
+
sts = [s for s in statuses if s.get("target") in ids and verify_sig(s, keys)]
|
|
313
|
+
_check(any(s.get("revoked_at") is not None and to_time(s["revoked_at"]) <= t_inv for s in sts), "violated", "I6", "status shows ancestor revoked before invocation")
|
|
314
|
+
_check(any(not verify_sig(r, keys) for r in revs), "unresolved", "I7", "unverifiable revocation on the chain")
|
|
315
|
+
for n in chain:
|
|
316
|
+
if (n.get("revocation") or {}).get("status_ref"):
|
|
317
|
+
fresh = [s for s in sts if s["target"] == n["id"] and to_time(s["as_of"]) >= t_inv]
|
|
318
|
+
_check(not fresh, "unresolved", "I7", f"no signed revocation status for {n['id']} as of the invocation")
|
|
319
|
+
# 7. self-protection on the declared target
|
|
320
|
+
_check(is_guardrail(inv["declared"]["resource"], extra_protected), "violated", "I9", "targets guardrail/evidence store")
|
|
321
|
+
# 8-9. influence: a finding counts as trusted only if it exists, is signed and is labelled trusted (spec 5.11)
|
|
322
|
+
mine = [e for e in effects if e.get("invocation") == rid]
|
|
323
|
+
untrusted = [f for f in inv.get("influenced_by", [])
|
|
324
|
+
if not (objs.get(f) and verify_sig(objs[f], keys) and objs[f].get("integrity_label") == "trusted")]
|
|
325
|
+
_check(bool(untrusted) and inv["declared"]["effect"] != "read" and not inv.get("principal_confirmed"),
|
|
326
|
+
"violated" if mine else "unresolved", "I4", "mutation shaped by untrusted content")
|
|
327
|
+
# 10. effect receipts
|
|
328
|
+
_check(not mine, "unresolved", "I7", "no executed-effect receipt")
|
|
329
|
+
high_impact = CEILING.index(inv["declared"]["effect"]) >= CEILING.index("write_shared")
|
|
330
|
+
eff_claims = chain[0]["claims"]
|
|
331
|
+
for n in chain[1:]:
|
|
332
|
+
eff_claims = meet(n["claims"], eff_claims)
|
|
333
|
+
if "intent_ref" in inv:
|
|
334
|
+
eff_claims = meet(objs[inv["intent_ref"]]["claims"], eff_claims)
|
|
335
|
+
appr = objs.get(inv.get("approval_ref")) if "approval_ref" in inv else None
|
|
336
|
+
bodies = {}
|
|
337
|
+
# 11-15. every receipt for this invocation is checked (spec 10.2); identical bodies are one effect
|
|
338
|
+
for e in mine:
|
|
339
|
+
_check(not verify_sig(e, keys), "unresolved", "I7", "effect receipt unsigned or signer lacks the role")
|
|
340
|
+
if high_impact:
|
|
341
|
+
_check(not inv.get("actor"), "unresolved", "I10", "actor not recorded; observer independence cannot be shown")
|
|
342
|
+
_check(e.get("observed_by") == inv["actor"] or e.get("assurance") == "L0", "unresolved", "I10", "high-impact effect only self-reported")
|
|
343
|
+
x = e["executed"]
|
|
344
|
+
if "mediated" in inv:
|
|
345
|
+
_check(canon(x) != canon(inv["mediated"]), "violated", "I2", "executed differs from mediated effect")
|
|
346
|
+
else:
|
|
347
|
+
_check((x["action"], x["resource"]) != (inv["declared"]["action"], inv["declared"]["resource"]), "violated", "I2", "declared != executed")
|
|
348
|
+
_check(is_guardrail(x["resource"], extra_protected), "violated", "I9", "executed effect targets guardrail/evidence store")
|
|
349
|
+
ok, why = effect_ok(x, eff_claims)
|
|
350
|
+
_check(not ok, "violated", "I5" if why.startswith("released") else "I2", why)
|
|
351
|
+
# spec 5.9.1: data classes carried in through lineage (or read by this effect) reach the recipient too
|
|
352
|
+
if "recipient" in x:
|
|
353
|
+
inherited = set(x.get("accessed", []))
|
|
354
|
+
for j in inv.get("derived_from", []):
|
|
355
|
+
inherited |= taint.get(j, set())
|
|
356
|
+
leaked = sorted(f"{d}->{x['recipient']}" for d in inherited if f"{d}->{x['recipient']}" not in eff_claims.get("data", []))
|
|
357
|
+
_check(bool(leaked), "violated", "I5", f"derived data released: {', '.join(leaked)}")
|
|
358
|
+
bodies.setdefault(approval_digest(x), x)
|
|
359
|
+
if "approval_ref" in inv:
|
|
360
|
+
_check(not appr or not verify_sig(appr, keys), "unresolved", "I7", "approval missing, unsigned or not signed by an approver")
|
|
361
|
+
for d, x in bodies.items():
|
|
362
|
+
t_x = to_time(x["t"])
|
|
363
|
+
_check(appr["effect_digest"] != d, "violated", "I8", "approval not bound to the executed effect")
|
|
364
|
+
_check(bool(appr.get("consumed")), "violated", "I8", "approval already consumed")
|
|
365
|
+
_check("expiry" in appr and to_time(appr["expiry"]) < max(t_inv, t_x), "violated", "I8", "approval expired")
|
|
366
|
+
_check("nbf" in appr and to_time(appr["nbf"]) > t_inv, "violated", "I8", "approval not yet valid")
|
|
367
|
+
first = approval_use.setdefault(appr["id"], (rid, d))
|
|
368
|
+
_check(first != (rid, d), "violated", "I8", f"approval already used by {first[0]}")
|
|
369
|
+
# 16. risk budget: recorded spend must match receipts; over budget needs a bound approval
|
|
370
|
+
c = sum(cost(x) for x in bodies.values())
|
|
371
|
+
_check("budget_spent" in inv and inv["budget_spent"] != c, "violated", "I7", "recorded budget spend does not match receipts")
|
|
372
|
+
over = next((n["id"] for n in chain if "budget" in n["claims"] and spent.get(n["id"], 0) + c > n["claims"]["budget"]), None)
|
|
373
|
+
_check(bool(over) and not appr, "violated", "I2", f"risk budget of {over} exceeded without approval")
|
|
374
|
+
for n in chain:
|
|
375
|
+
spent[n["id"]] = spent.get(n["id"], 0) + c
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def verdict(results: list[Result]) -> Result:
|
|
379
|
+
"""Spec 10.5: violated beats unresolved beats preserved; first result with that outcome decides."""
|
|
380
|
+
for o in ("violated", "unresolved"):
|
|
381
|
+
r = next((r for r in results if r.outcome == o), None)
|
|
382
|
+
if r:
|
|
383
|
+
return r
|
|
384
|
+
return results[0] if results else Result("-", "unresolved", "I7", "empty packet")
|
|
385
|
+
|
|
386
|
+
|
amep_protocol/sdk.py
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""AMEP producer SDK: keys, signing, and builders for every AMEP object (spec/amep-v0.2.md, section 5).
|
|
2
|
+
|
|
3
|
+
Builders return plain dicts that follow the spec's field names, check enumerated values, and leave out
|
|
4
|
+
members that are None. Sign each object with a Key that holds a role permitted for its kind (spec 12.5).
|
|
5
|
+
|
|
6
|
+
from amep_protocol import sdk
|
|
7
|
+
issuer = sdk.Key.generate("issuer-1", ["issuer", "approver"])
|
|
8
|
+
m = issuer.sign(sdk.mandate("m-1", "user:alice", sdk.claims(["fs.*"], ["repo:app/*"], "write_local", exp=1767229200)))
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import stat
|
|
14
|
+
|
|
15
|
+
from cryptography.hazmat.primitives import serialization
|
|
16
|
+
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
|
|
17
|
+
|
|
18
|
+
from .core import CEILING, SIGNER_ROLES, approval_digest, canon
|
|
19
|
+
|
|
20
|
+
ROLES = ("issuer", "host", "observer", "approver")
|
|
21
|
+
ASSURANCE = ("L0", "L1", "L2", "L3")
|
|
22
|
+
SOURCES = ("curated", "customer", "provider_hint", "judge", "none")
|
|
23
|
+
PRESENCE = ("webauthn", "chat_user", "host_ui", "none")
|
|
24
|
+
MODES = ("observe", "allow", "mediate", "step_up", "hold", "deny", "quarantine")
|
|
25
|
+
PHASES = ("pre_execution", "post_execution", "simulation")
|
|
26
|
+
OUTCOMES = ("preserved", "violated", "unresolved")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _one_of(name, value, allowed):
|
|
30
|
+
if value not in allowed:
|
|
31
|
+
raise ValueError(f"{name} must be one of {', '.join(allowed)}; got {value!r}")
|
|
32
|
+
return value
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _clean(d: dict) -> dict:
|
|
36
|
+
return {k: v for k, v in d.items() if v is not None}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# ---------------- keys and signing (spec 12) ----------------
|
|
40
|
+
class Key:
|
|
41
|
+
"""An Ed25519 signing key with an AMEP key id and roles."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, kid: str, roles, private_key: Ed25519PrivateKey):
|
|
44
|
+
for r in roles:
|
|
45
|
+
_one_of("role", r, ROLES)
|
|
46
|
+
self.kid, self.roles, self._key = kid, list(roles), private_key
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def generate(cls, kid: str, roles) -> "Key":
|
|
50
|
+
return cls(kid, roles, Ed25519PrivateKey.generate())
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_pem(cls, pem: bytes, kid: str, roles) -> "Key":
|
|
54
|
+
key = serialization.load_pem_private_key(pem, password=None)
|
|
55
|
+
if not isinstance(key, Ed25519PrivateKey):
|
|
56
|
+
raise ValueError("AMEP keys must be Ed25519")
|
|
57
|
+
return cls(kid, roles, key)
|
|
58
|
+
|
|
59
|
+
def to_pem(self) -> bytes:
|
|
60
|
+
return self._key.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8,
|
|
61
|
+
serialization.NoEncryption())
|
|
62
|
+
|
|
63
|
+
def save(self, path: str) -> None:
|
|
64
|
+
"""Write the private key as PKCS#8 PEM, readable only by the current user."""
|
|
65
|
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IRUSR | stat.S_IWUSR)
|
|
66
|
+
with os.fdopen(fd, "wb") as f:
|
|
67
|
+
f.write(self.to_pem())
|
|
68
|
+
|
|
69
|
+
def public_entry(self) -> dict:
|
|
70
|
+
"""This key's entry for a key set (spec 12.4)."""
|
|
71
|
+
raw = self._key.public_key().public_bytes(serialization.Encoding.Raw, serialization.PublicFormat.Raw)
|
|
72
|
+
return {"kid": self.kid, "alg": "Ed25519", "x": raw.hex(), "roles": list(self.roles)}
|
|
73
|
+
|
|
74
|
+
def sign(self, obj: dict) -> dict:
|
|
75
|
+
"""Return a copy of obj with a proof over its JCS form. Refuses kinds this key's roles may not sign."""
|
|
76
|
+
kind = obj.get("kind")
|
|
77
|
+
if kind in SIGNER_ROLES and not set(self.roles) & SIGNER_ROLES[kind]:
|
|
78
|
+
raise ValueError(f"key {self.kid} (roles {self.roles}) may not sign a {kind}; "
|
|
79
|
+
f"needs one of {sorted(SIGNER_ROLES[kind])}")
|
|
80
|
+
body = {k: v for k, v in obj.items() if k != "proof"}
|
|
81
|
+
return {**body, "proof": {"kid": self.kid, "alg": "Ed25519", "sig": self._key.sign(canon(body)).hex()}}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def keyset(*keys: Key) -> dict:
|
|
85
|
+
"""A key set mapping kid to public entry, as served at /.well-known/amep-keys.json."""
|
|
86
|
+
return {k.kid: k.public_entry() for k in keys}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ---------------- builders (spec 5) ----------------
|
|
90
|
+
def claims(actions, resources, ceiling, exp, *, data=None, nbf=None, purpose=None, deny_actions=None,
|
|
91
|
+
deny_resources=None, depth=None, budget=None) -> dict:
|
|
92
|
+
_one_of("ceiling", ceiling, CEILING)
|
|
93
|
+
return _clean({"actions": list(actions), "resources": list(resources), "ceiling": ceiling, "exp": exp,
|
|
94
|
+
"data": list(data) if data is not None else None, "nbf": nbf, "purpose": purpose,
|
|
95
|
+
"deny_actions": list(deny_actions) if deny_actions is not None else None,
|
|
96
|
+
"deny_resources": list(deny_resources) if deny_resources is not None else None,
|
|
97
|
+
"depth": depth, "budget": budget})
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def mandate(id, principal, claims, *, issuer=None, subject_agent=None, status_ref=None, token=None) -> dict:
|
|
101
|
+
return _clean({"id": id, "kind": "mandate", "principal": principal, "issuer": issuer,
|
|
102
|
+
"subject_agent": subject_agent, "claims": claims,
|
|
103
|
+
"revocation": {"status_ref": status_ref} if status_ref else None, "token": token})
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def delegation(id, parent, claims, *, delegate=None, token=None) -> dict:
|
|
107
|
+
return _clean({"id": id, "kind": "delegation", "parent": parent, "delegate": delegate, "claims": claims,
|
|
108
|
+
"token": token})
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def intent(id, claims, *, prompt_ref=None, derivation=None) -> dict:
|
|
112
|
+
if derivation is not None:
|
|
113
|
+
_one_of("derivation", derivation, ("template", "judge", "confirmed"))
|
|
114
|
+
return _clean({"id": id, "kind": "intent", "prompt_ref": prompt_ref, "claims": claims, "derivation": derivation})
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def interpretation(id, adapter, version, *, source="curated", integrity_hash=None) -> dict:
|
|
118
|
+
_one_of("source", source, SOURCES)
|
|
119
|
+
return _clean({"id": id, "kind": "interpretation", "source": source, "adapter": adapter, "version": version,
|
|
120
|
+
"integrity_hash": integrity_hash})
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def effect_body(action, resource, effect, t, *, released=None, reversible=None, accessed=None,
|
|
124
|
+
recipient=None) -> dict:
|
|
125
|
+
"""The executed-effect body (spec 5.9), also used for invocation.mediated and approvals."""
|
|
126
|
+
_one_of("effect", effect, CEILING)
|
|
127
|
+
return _clean({"action": action, "resource": resource, "effect": effect,
|
|
128
|
+
"released": list(released) if released is not None else [], "reversible": reversible,
|
|
129
|
+
"accessed": list(accessed) if accessed is not None else None, "recipient": recipient, "t": t})
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def invocation(id, authority_ref, interpretation_ref, t, action, resource, effect, *, actor=None,
|
|
133
|
+
intent_ref=None, approval_ref=None, mediated=None, influenced_by=None, principal_confirmed=None,
|
|
134
|
+
derived_from=None, budget_spent=None, correlation=None) -> dict:
|
|
135
|
+
_one_of("effect", effect, CEILING)
|
|
136
|
+
if CEILING.index(effect) >= CEILING.index("write_shared") and not actor:
|
|
137
|
+
raise ValueError("actor is required for effects of class write_shared and above (spec 5.8, I10)")
|
|
138
|
+
return _clean({"id": id, "kind": "invocation", "authority_ref": authority_ref,
|
|
139
|
+
"interpretation_ref": interpretation_ref, "intent_ref": intent_ref, "approval_ref": approval_ref,
|
|
140
|
+
"t": t, "actor": actor, "declared": {"action": action, "resource": resource, "effect": effect},
|
|
141
|
+
"mediated": mediated, "influenced_by": influenced_by, "principal_confirmed": principal_confirmed,
|
|
142
|
+
"derived_from": derived_from, "budget_spent": budget_spent, "correlation": correlation})
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def effect(id, invocation, observed_by, assurance, executed, *, backend_receipt=None) -> dict:
|
|
146
|
+
_one_of("assurance", assurance, ASSURANCE)
|
|
147
|
+
return _clean({"id": id, "kind": "effect", "invocation": invocation, "observed_by": observed_by,
|
|
148
|
+
"assurance": assurance, "executed": executed, "backend_receipt": backend_receipt})
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def approval(id, body, presence, *, expiry=None, nbf=None, approver=None, resource_version=None,
|
|
152
|
+
consumed=None) -> dict:
|
|
153
|
+
"""An approval bound to an effect body; the digest is computed without the body's t (spec 5.10)."""
|
|
154
|
+
_one_of("presence", presence, PRESENCE)
|
|
155
|
+
return _clean({"id": id, "kind": "approval", "effect_digest": approval_digest(body), "presence": presence,
|
|
156
|
+
"approver": approver, "resource_version": resource_version, "nbf": nbf, "expiry": expiry,
|
|
157
|
+
"consumed": consumed})
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def finding(id, source_locator, content_hash, integrity_label, *, span=None, hidden_mechanism=None,
|
|
161
|
+
requested=None) -> dict:
|
|
162
|
+
_one_of("integrity_label", integrity_label, ("trusted", "untrusted"))
|
|
163
|
+
return _clean({"id": id, "kind": "finding", "source_locator": source_locator, "content_hash": content_hash,
|
|
164
|
+
"span": span, "hidden_mechanism": hidden_mechanism, "integrity_label": integrity_label,
|
|
165
|
+
"requested": requested})
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def revocation(target, t, *, reason=None, id=None) -> dict:
|
|
169
|
+
return _clean({"id": id, "kind": "revocation", "target": target, "t": t, "reason": reason})
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def status(target, as_of, *, revoked_at=None, id=None) -> dict:
|
|
173
|
+
return _clean({"id": id, "kind": "status", "target": target, "as_of": as_of, "revoked_at": revoked_at})
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def enforcement(pep, fail_mode, *, host_supports=None, encoded_as=None, applied=None) -> dict:
|
|
177
|
+
_one_of("fail_mode", fail_mode, ("closed", "open", "unknown"))
|
|
178
|
+
if applied is not None:
|
|
179
|
+
_one_of("applied", applied, ("confirmed", "not_observed", "contradicted"))
|
|
180
|
+
return _clean({"pep": pep, "fail_mode": fail_mode, "host_supports": host_supports, "encoded_as": encoded_as,
|
|
181
|
+
"applied": applied})
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def decision(invocation, outcome, mode, phase, *, id=None, invariant=None, reason=None, quarantined=None,
|
|
185
|
+
safe_alternatives=None, evidence_refs=None, enforcement=None) -> dict:
|
|
186
|
+
_one_of("outcome", outcome, OUTCOMES)
|
|
187
|
+
_one_of("mode", mode, MODES)
|
|
188
|
+
_one_of("phase", phase, PHASES)
|
|
189
|
+
return _clean({"id": id, "kind": "decision", "invocation": invocation, "outcome": outcome,
|
|
190
|
+
"invariant": invariant, "mode": mode, "phase": phase, "quarantined": quarantined,
|
|
191
|
+
"reason": reason, "safe_alternatives": safe_alternatives, "evidence_refs": evidence_refs,
|
|
192
|
+
"enforcement": enforcement})
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
_PACKET_MEMBERS = ("mandates", "delegations", "intents", "interpretations", "invocations", "effects", "approvals",
|
|
196
|
+
"revocations", "statuses", "findings", "decisions")
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def packet(*objects, pinned_adapters=None) -> dict:
|
|
200
|
+
"""Group objects into a packet (spec 5.2) by kind, keeping their order."""
|
|
201
|
+
member = {"mandate": "mandates", "delegation": "delegations", "intent": "intents",
|
|
202
|
+
"interpretation": "interpretations", "invocation": "invocations", "effect": "effects",
|
|
203
|
+
"approval": "approvals", "revocation": "revocations", "status": "statuses", "finding": "findings",
|
|
204
|
+
"decision": "decisions"}
|
|
205
|
+
out: dict = {"amep_version": "0.2"}
|
|
206
|
+
for o in objects:
|
|
207
|
+
m = member.get(o.get("kind"))
|
|
208
|
+
if not m:
|
|
209
|
+
raise ValueError(f"unknown object kind {o.get('kind')!r}")
|
|
210
|
+
out.setdefault(m, []).append(o)
|
|
211
|
+
if pinned_adapters:
|
|
212
|
+
out["pinned_adapters"] = dict(pinned_adapters)
|
|
213
|
+
return out
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amep-protocol
|
|
3
|
+
Version: 0.2.0a4
|
|
4
|
+
Summary: Verify and produce AMEP (Agentic Mandate Evidence Protocol) evidence: proof that AI agent actions stayed within delegated authority.
|
|
5
|
+
Author: Staford Titus Selvaraj
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/stafordtituss/amep
|
|
8
|
+
Project-URL: Specification, https://github.com/stafordtituss/amep/blob/main/spec/amep-v0.2.md
|
|
9
|
+
Keywords: ai agents,delegation,authorization,audit,evidence,amep
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Security
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
License-File: NOTICE
|
|
19
|
+
Requires-Dist: cryptography>=41
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# amep-protocol (Python)
|
|
23
|
+
|
|
24
|
+
Verify and produce **AMEP™** (Agentic Mandate Evidence Protocol) evidence: signed records proving that what an AI agent actually did stayed within the authority a person delegated.
|
|
25
|
+
|
|
26
|
+
Specification and conformance suite: https://github.com/stafordtituss/amep
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install amep-protocol
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Verify a packet
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
amep-protocol verify packet.json --keys keys.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Each invocation gets an outcome and the deciding invariant. The exit code is 0 for `preserved`, 1 for `violated` and 2 for `unresolved`. `--json` prints machine-readable results. `--state` and `--state-out` carry approval use and risk budgets across a stream of packets.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from amep_protocol import evaluate, verdict
|
|
42
|
+
|
|
43
|
+
results = evaluate(packet, keys)
|
|
44
|
+
print(verdict(results).outcome, verdict(results).invariant)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Produce evidence
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from amep_protocol import sdk
|
|
51
|
+
|
|
52
|
+
issuer = sdk.Key.generate("issuer-1", ["issuer", "approver"])
|
|
53
|
+
host = sdk.Key.generate("host-1", ["host"])
|
|
54
|
+
observer = sdk.Key.generate("observer-1", ["observer"])
|
|
55
|
+
|
|
56
|
+
m = issuer.sign(sdk.mandate("m-1", "user:alice",
|
|
57
|
+
sdk.claims(["fs.*"], ["repo:app/*"], "write_local", exp=1767229200, deny_resources=["repo:app/secrets/*"])))
|
|
58
|
+
a = host.sign(sdk.interpretation("a-1", "host_shell", "r9"))
|
|
59
|
+
i = host.sign(sdk.invocation("i-1", "m-1", "a-1", 1767225610, "fs.write", "repo:app/src/auth.ts", "write_local"))
|
|
60
|
+
e = observer.sign(sdk.effect("e-1", "i-1", "hook:host", "L1",
|
|
61
|
+
sdk.effect_body("fs.write", "repo:app/src/auth.ts", "write_local", 1767225611)))
|
|
62
|
+
|
|
63
|
+
packet = sdk.packet(m, a, i, e)
|
|
64
|
+
keys = sdk.keyset(issuer, host, observer)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
A key refuses to sign object kinds its roles don't allow, for example a host key signing a mandate.
|
|
68
|
+
|
|
69
|
+
## Keys from the command line
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
amep-protocol keygen --kid issuer-1 --roles issuer,approver --out issuer-1
|
|
73
|
+
amep-protocol sign mandate.json --key issuer-1.key.pem --kid issuer-1 --roles issuer,approver
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Conformance
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
amep-protocol check-suite vectors/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
License: Apache 2.0. "AMEP" is a trademark of Staford Titus Selvaraj.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
amep_protocol/__init__.py,sha256=MWQdVse7-dv17z5C3eC_hcQHD33_xCXyVUFsVVdGKFo,812
|
|
2
|
+
amep_protocol/cli.py,sha256=NxdNnyxA_TmkoSFmlGF2M_WzeohUITTkyoRYtiP89PE,5278
|
|
3
|
+
amep_protocol/core.py,sha256=tePdsPOTv7T9maml0N173u_40VmyrheXSrTMRHbc13w,21446
|
|
4
|
+
amep_protocol/sdk.py,sha256=HjOQXCNsuzXBddcD1sy3D7PiTr3-C05NDsZHYrslMb0,11110
|
|
5
|
+
amep_protocol-0.2.0a4.dist-info/licenses/LICENSE,sha256=yVuuHRzgI17MzTVgt3LsHvuX80innw--CmNPDCzO_iw,11358
|
|
6
|
+
amep_protocol-0.2.0a4.dist-info/licenses/NOTICE,sha256=kk19MkgFJHQZlGaIzRVfzqM64wiO5_uzHbICDVj-Xgo,730
|
|
7
|
+
amep_protocol-0.2.0a4.dist-info/METADATA,sha256=oHHVd6ux9co-K3OZrBmSixbctwv9X06KZZc3rOCRszQ,2925
|
|
8
|
+
amep_protocol-0.2.0a4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
amep_protocol-0.2.0a4.dist-info/entry_points.txt,sha256=8QN2aljoN7tX0CfOIt6boCTZwlMJntHZb4egUn8Z8JE,57
|
|
10
|
+
amep_protocol-0.2.0a4.dist-info/top_level.txt,sha256=k6hTDACM3s_76od6d-CcVquA3R2kzwWTrvEjxlCph_A,14
|
|
11
|
+
amep_protocol-0.2.0a4.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Agentic Mandate Evidence Protocol (AMEP)
|
|
2
|
+
Copyright 2026 Staford Titus Selvaraj and the AMEP Contributors.
|
|
3
|
+
|
|
4
|
+
AMEP was originally designed and written by Staford Titus Selvaraj.
|
|
5
|
+
|
|
6
|
+
This product includes the AMEP specification, schemas, reference verifiers
|
|
7
|
+
and conformance vectors, developed by the AMEP Working Group (founded and
|
|
8
|
+
chaired by Staford Titus Selvaraj) at https://github.com/stafordtituss/amep.
|
|
9
|
+
|
|
10
|
+
"AMEP", "Agentic Mandate Evidence Protocol" and "AMEP Conformant" are
|
|
11
|
+
trademarks of Staford Titus Selvaraj. See TRADEMARKS.md.
|
|
12
|
+
|
|
13
|
+
Under section 4(d) of the Apache License 2.0, redistributions of the code in
|
|
14
|
+
this repository must retain this NOTICE file, or reproduce its attribution
|
|
15
|
+
notices, in the places that license describes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
amep_protocol
|