proofgate-runtime 0.1.0__tar.gz → 0.2.1__tar.gz
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.
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/PKG-INFO +13 -6
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/README.md +12 -5
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/pyproject.toml +5 -1
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/__init__.py +1 -1
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/claims.py +3 -2
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/cli.py +15 -8
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/mcp_server.py +20 -4
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/receipts.py +15 -5
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/PKG-INFO +13 -6
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/SOURCES.txt +3 -1
- proofgate_runtime-0.2.1/tests/test_cli.py +45 -0
- proofgate_runtime-0.2.1/tests/test_mcp.py +58 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/tests/test_receipts.py +25 -4
- proofgate_runtime-0.2.1/tests/test_verify_exit.py +38 -0
- proofgate_runtime-0.1.0/tests/test_mcp.py +0 -34
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/LICENSE +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/setup.cfg +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/guard.py +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/dependency_links.txt +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/entry_points.txt +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/top_level.txt +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/tests/test_claims.py +0 -0
- {proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/tests/test_guard.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: proofgate-runtime
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Evidence-first claim verification, signed receipts, lite injection guard and MCP server (stdlib only).
|
|
5
5
|
Author-email: gamAI <info@gamai.io>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -19,10 +19,13 @@ Dynamic: license-file
|
|
|
19
19
|
# ProofGate Runtime
|
|
20
20
|
|
|
21
21
|
**Evidence-first claim verification, signed receipts, and a lite injection guard for AI agents.**
|
|
22
|
-
[](https://pypi.org/project/proofgate-runtime/) v0.
|
|
22
|
+
[](https://pypi.org/project/proofgate-runtime/) v0.2.0 · Python 3.10+ · stdlib only · Apache-2.0
|
|
23
23
|
|
|
24
24
|
Agent says "done". ProofGate asks: **where is the evidence?**
|
|
25
25
|
|
|
26
|
+
> **Start here if you are new:** [`gama-mandate`](https://pypi.org/project/gama-mandate/) — sign a business commitment, execute it once, prove it offline.
|
|
27
|
+
> This package is one layer of the same stack, not an alternative to it: `gama-mandate` (commitments) · `gamai-trust` (verify claims) · `gamai-guard` (injection) · `gamai-plugins` (policy, sandbox, team) · `sigil-profile` (receipt profile over MCP/A2A) · `proofgate-runtime` (claim/receipt core) · `gama-l` (provable computation).
|
|
28
|
+
|
|
26
29
|
This package is the small, installable core of the gamAI trust layer:
|
|
27
30
|
|
|
28
31
|
- **Claims** — `confirmed / refuted / unverified` per claim, fail-closed, SHA-256-bound report.
|
|
@@ -72,7 +75,7 @@ echo '{"posted":true,"total":"2808.00"}' > result.json
|
|
|
72
75
|
printf 'shared-secret' > key.bin
|
|
73
76
|
|
|
74
77
|
proofgate make-receipt intent.json result.json --key-file key.bin > receipt.json
|
|
75
|
-
proofgate verify-receipt receipt.json --key-file key.bin
|
|
78
|
+
proofgate verify-receipt receipt.json --key-file key.bin
|
|
76
79
|
```
|
|
77
80
|
|
|
78
81
|
Tamper with `result.json` or the receipt and verification fails closed.
|
|
@@ -107,8 +110,8 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
107
110
|
- **No anchor/lease service.** That is [`sigil`](https://github.com/gamai-io/sigil) (grants, receipts, anchor, MCP middleware). ProofGate v0.1 is the local verification core.
|
|
108
111
|
- **No embedding-based guard.** This is the lexical layer; the full multilingual cascade is [`gamai-guard`](https://github.com/gamai-io/gamai-guard).
|
|
109
112
|
- **No independent security audit.** Treat v0.1 as a reference implementation, not a certified product.
|
|
110
|
-
- **MCP receipts are
|
|
111
|
-
- **PyPI 0.
|
|
113
|
+
- **MCP receipts are signed only when `PROOFGATE_HMAC_KEY` is set** and are rejected as unsigned otherwise. Set it in the server environment; never put the key in a client or in git.
|
|
114
|
+
- **PyPI 0.2.0 is available.** Install with `pip install proofgate-runtime`.
|
|
112
115
|
|
|
113
116
|
## Design rules
|
|
114
117
|
|
|
@@ -122,10 +125,14 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
122
125
|
|
|
123
126
|
- [`sigil`](https://github.com/gamai-io/sigil) — proof-carrying execution: grants, receipts, anchor, conformance.
|
|
124
127
|
- [`gamai-guard`](https://github.com/gamai-io/gamai-guard) — multilingual prompt-injection cascade.
|
|
125
|
-
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark
|
|
128
|
+
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark. Shipped v1.4.0: honest fleet **25,600/25,600 pass, 0 false successes**; controlled liar variant 28,800 records with **400 false successes, all on the lying node** (detected). The separate 93.75% / 6.25% Slurm run is reported in `evidence-gate-runtime` and its dataset is not public yet.
|
|
126
129
|
- [`evidence-gate-runtime`](https://github.com/gamai-io/evidence-gate-runtime) — fuller runtime with replay.
|
|
127
130
|
- [`floor-copilot`](https://github.com/gamai-io/floor-copilot) — production case study: invoice intake with 17% VAT gate.
|
|
128
131
|
|
|
132
|
+
## v0.2 breaking change
|
|
133
|
+
|
|
134
|
+
`verify_receipt()` now requires a valid signature by default. For legacy unsigned receipts, call `verify_receipt(..., require_signature=False)` or the CLI with `--allow-unsigned`. Create signed receipts with `proofgate make-receipt ... --key-file`; the MCP server signs when `PROOFGATE_HMAC_KEY` is set.
|
|
135
|
+
|
|
129
136
|
## Honest status
|
|
130
137
|
|
|
131
138
|
- Claim verification: tested (BHS/EU/US money formats, predicates, tamper detection).
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# ProofGate Runtime
|
|
2
2
|
|
|
3
3
|
**Evidence-first claim verification, signed receipts, and a lite injection guard for AI agents.**
|
|
4
|
-
[](https://pypi.org/project/proofgate-runtime/) v0.
|
|
4
|
+
[](https://pypi.org/project/proofgate-runtime/) v0.2.0 · Python 3.10+ · stdlib only · Apache-2.0
|
|
5
5
|
|
|
6
6
|
Agent says "done". ProofGate asks: **where is the evidence?**
|
|
7
7
|
|
|
8
|
+
> **Start here if you are new:** [`gama-mandate`](https://pypi.org/project/gama-mandate/) — sign a business commitment, execute it once, prove it offline.
|
|
9
|
+
> This package is one layer of the same stack, not an alternative to it: `gama-mandate` (commitments) · `gamai-trust` (verify claims) · `gamai-guard` (injection) · `gamai-plugins` (policy, sandbox, team) · `sigil-profile` (receipt profile over MCP/A2A) · `proofgate-runtime` (claim/receipt core) · `gama-l` (provable computation).
|
|
10
|
+
|
|
8
11
|
This package is the small, installable core of the gamAI trust layer:
|
|
9
12
|
|
|
10
13
|
- **Claims** — `confirmed / refuted / unverified` per claim, fail-closed, SHA-256-bound report.
|
|
@@ -54,7 +57,7 @@ echo '{"posted":true,"total":"2808.00"}' > result.json
|
|
|
54
57
|
printf 'shared-secret' > key.bin
|
|
55
58
|
|
|
56
59
|
proofgate make-receipt intent.json result.json --key-file key.bin > receipt.json
|
|
57
|
-
proofgate verify-receipt receipt.json --key-file key.bin
|
|
60
|
+
proofgate verify-receipt receipt.json --key-file key.bin
|
|
58
61
|
```
|
|
59
62
|
|
|
60
63
|
Tamper with `result.json` or the receipt and verification fails closed.
|
|
@@ -89,8 +92,8 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
89
92
|
- **No anchor/lease service.** That is [`sigil`](https://github.com/gamai-io/sigil) (grants, receipts, anchor, MCP middleware). ProofGate v0.1 is the local verification core.
|
|
90
93
|
- **No embedding-based guard.** This is the lexical layer; the full multilingual cascade is [`gamai-guard`](https://github.com/gamai-io/gamai-guard).
|
|
91
94
|
- **No independent security audit.** Treat v0.1 as a reference implementation, not a certified product.
|
|
92
|
-
- **MCP receipts are
|
|
93
|
-
- **PyPI 0.
|
|
95
|
+
- **MCP receipts are signed only when `PROOFGATE_HMAC_KEY` is set** and are rejected as unsigned otherwise. Set it in the server environment; never put the key in a client or in git.
|
|
96
|
+
- **PyPI 0.2.0 is available.** Install with `pip install proofgate-runtime`.
|
|
94
97
|
|
|
95
98
|
## Design rules
|
|
96
99
|
|
|
@@ -104,10 +107,14 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
104
107
|
|
|
105
108
|
- [`sigil`](https://github.com/gamai-io/sigil) — proof-carrying execution: grants, receipts, anchor, conformance.
|
|
106
109
|
- [`gamai-guard`](https://github.com/gamai-io/gamai-guard) — multilingual prompt-injection cascade.
|
|
107
|
-
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark
|
|
110
|
+
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark. Shipped v1.4.0: honest fleet **25,600/25,600 pass, 0 false successes**; controlled liar variant 28,800 records with **400 false successes, all on the lying node** (detected). The separate 93.75% / 6.25% Slurm run is reported in `evidence-gate-runtime` and its dataset is not public yet.
|
|
108
111
|
- [`evidence-gate-runtime`](https://github.com/gamai-io/evidence-gate-runtime) — fuller runtime with replay.
|
|
109
112
|
- [`floor-copilot`](https://github.com/gamai-io/floor-copilot) — production case study: invoice intake with 17% VAT gate.
|
|
110
113
|
|
|
114
|
+
## v0.2 breaking change
|
|
115
|
+
|
|
116
|
+
`verify_receipt()` now requires a valid signature by default. For legacy unsigned receipts, call `verify_receipt(..., require_signature=False)` or the CLI with `--allow-unsigned`. Create signed receipts with `proofgate make-receipt ... --key-file`; the MCP server signs when `PROOFGATE_HMAC_KEY` is set.
|
|
117
|
+
|
|
111
118
|
## Honest status
|
|
112
119
|
|
|
113
120
|
- Claim verification: tested (BHS/EU/US money formats, predicates, tamper detection).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "proofgate-runtime"
|
|
7
|
-
version = "0.1
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Evidence-first claim verification, signed receipts, lite injection guard and MCP server (stdlib only)."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -28,3 +28,7 @@ proofgate-mcp = "proofgate_runtime.mcp_server:main"
|
|
|
28
28
|
|
|
29
29
|
[tool.setuptools.packages.find]
|
|
30
30
|
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
pythonpath = ["src"]
|
|
34
|
+
testpaths = ["tests"]
|
|
@@ -3,7 +3,7 @@ from .claims import evaluate, check, verify, demo, EvidenceError
|
|
|
3
3
|
from .guard import check_injection
|
|
4
4
|
from .receipts import make_receipt, verify_receipt, verify_chain, canonical_json, sha256_hex
|
|
5
5
|
|
|
6
|
-
__version__ = "0.1
|
|
6
|
+
__version__ = "0.2.1"
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
"evaluate", "check", "verify", "demo", "EvidenceError",
|
|
@@ -306,8 +306,9 @@ def main(argv: list[str]) -> int:
|
|
|
306
306
|
if len(argv) < 3:
|
|
307
307
|
print("usage: proofgate.py verify report.json", file=sys.stderr)
|
|
308
308
|
return 2
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
result = verify(_read_json(argv[2]))
|
|
310
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
311
|
+
return 0 if result["ok"] else 1
|
|
311
312
|
print("unknown command: %s" % cmd, file=sys.stderr)
|
|
312
313
|
return 2
|
|
313
314
|
|
|
@@ -43,12 +43,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
43
43
|
m = sub.add_parser("make-receipt", help="create a receipt from intent/result JSON files")
|
|
44
44
|
m.add_argument("intent")
|
|
45
45
|
m.add_argument("result")
|
|
46
|
-
m.add_argument("--key-file", default=None, help="
|
|
46
|
+
m.add_argument("--key-file", default=None, help="HMAC key file (required unless --allow-unsigned)")
|
|
47
|
+
m.add_argument("--allow-unsigned", action="store_true", help="create an unsigned receipt (not recommended)")
|
|
47
48
|
|
|
48
49
|
v = sub.add_parser("verify-receipt", help="verify a receipt JSON file")
|
|
49
50
|
v.add_argument("receipt")
|
|
50
51
|
v.add_argument("--key-file", default=None)
|
|
51
|
-
v.add_argument("--
|
|
52
|
+
v.add_argument("--allow-unsigned", action="store_true", help="accept an unsigned receipt")
|
|
52
53
|
|
|
53
54
|
g = sub.add_parser("check-injection", help="lexical prompt-injection pre-filter")
|
|
54
55
|
g.add_argument("text")
|
|
@@ -60,15 +61,21 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
60
61
|
if args.cmd == "verify-claims":
|
|
61
62
|
data = _load(args.file)
|
|
62
63
|
claims = data.get("claims") if isinstance(data, dict) else data
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
report = check(claims or [], reported_hash=args.reported_hash)
|
|
65
|
+
_print(report)
|
|
66
|
+
return 0 if report["ok"] else 1
|
|
65
67
|
if args.cmd == "make-receipt":
|
|
66
|
-
|
|
68
|
+
key = _key(args.key_file)
|
|
69
|
+
if key is None and not args.allow_unsigned:
|
|
70
|
+
print("refusing unsigned receipt: pass --key-file or --allow-unsigned", file=sys.stderr)
|
|
71
|
+
return 2
|
|
72
|
+
_print(make_receipt(_load(args.intent), _load(args.result), key=key))
|
|
67
73
|
return 0
|
|
68
74
|
if args.cmd == "verify-receipt":
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
res = verify_receipt(_load(args.receipt), key=_key(args.key_file),
|
|
76
|
+
require_signature=not args.allow_unsigned)
|
|
77
|
+
_print(res)
|
|
78
|
+
return 0 if res["valid"] else 1
|
|
72
79
|
if args.cmd == "check-injection":
|
|
73
80
|
_print(check_injection(args.text, args.tool))
|
|
74
81
|
return 0
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
+
import os
|
|
6
7
|
import sys
|
|
7
8
|
from typing import Any
|
|
8
9
|
|
|
@@ -26,7 +27,7 @@ TOOLS = [
|
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
29
|
"name": "make_receipt",
|
|
29
|
-
"description": "Create a SHA-256-bound receipt for an intent/result
|
|
30
|
+
"description": "Create a SHA-256-bound receipt for an intent/result. Requires PROOFGATE_HMAC_KEY; unsigned is refused unless PROOFGATE_ALLOW_UNSIGNED=1.",
|
|
30
31
|
"inputSchema": {
|
|
31
32
|
"type": "object",
|
|
32
33
|
"properties": {"intent": {}, "result": {}, "meta": {"type": "object"}},
|
|
@@ -74,18 +75,33 @@ def call_tool(name: str, args: dict) -> dict:
|
|
|
74
75
|
if name == "make_receipt":
|
|
75
76
|
if "intent" not in args or "result" not in args:
|
|
76
77
|
return _text({"error": "intent and result are required"}, True)
|
|
77
|
-
|
|
78
|
+
key = os.environ.get("PROOFGATE_HMAC_KEY") or None
|
|
79
|
+
allow_unsigned = os.environ.get("PROOFGATE_ALLOW_UNSIGNED") == "1"
|
|
80
|
+
if not key and not allow_unsigned:
|
|
81
|
+
# verify_receipt rejects unsigned receipts by default; minting one
|
|
82
|
+
# here would hand the caller something its own verifier refuses
|
|
83
|
+
return _text({"error": "unsigned receipt refused",
|
|
84
|
+
"detail": "set PROOFGATE_HMAC_KEY, or "
|
|
85
|
+
"PROOFGATE_ALLOW_UNSIGNED=1 to opt in"}, True)
|
|
86
|
+
extra = {"signed": bool(key)}
|
|
87
|
+
if not key:
|
|
88
|
+
extra["_warning"] = "unsigned: PROOFGATE_ALLOW_UNSIGNED=1"
|
|
89
|
+
rec = make_receipt(args["intent"], args["result"], key=key,
|
|
90
|
+
meta=args.get("meta"), extra=extra)
|
|
91
|
+
return _text(rec)
|
|
78
92
|
if name == "verify_receipt":
|
|
79
93
|
if not isinstance(args.get("receipt"), dict):
|
|
80
94
|
return _text({"error": "receipt object is required"}, True)
|
|
81
|
-
return _text(verify_receipt(args["receipt"],
|
|
95
|
+
return _text(verify_receipt(args["receipt"],
|
|
96
|
+
require_signature=bool(args.get("require_signature", True))))
|
|
82
97
|
if name == "check_injection":
|
|
83
98
|
return _text(check_injection(args.get("text", ""), args.get("tool")))
|
|
84
99
|
if name == "runtime_info":
|
|
85
100
|
return _text({"name": "proofgate-runtime", "version": __version__,
|
|
86
101
|
"capabilities": ["verify_claims", "make_receipt", "verify_receipt",
|
|
87
102
|
"check_injection_lite"],
|
|
88
|
-
"signed_receipts": "HMAC-SHA256
|
|
103
|
+
"signed_receipts": "HMAC-SHA256; MCP uses PROOFGATE_HMAC_KEY; unsigned rejected by default",
|
|
104
|
+
"require_signature_default": True})
|
|
89
105
|
return _text({"error": "unknown tool: %s" % name}, True)
|
|
90
106
|
|
|
91
107
|
|
|
@@ -36,8 +36,14 @@ def _core(receipt: dict) -> dict:
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def make_receipt(intent: Any, result: Any, key: str | bytes | None = None,
|
|
39
|
-
meta: dict | None = None
|
|
40
|
-
|
|
39
|
+
meta: dict | None = None, prev_hash: str = "GENESIS",
|
|
40
|
+
extra: dict | None = None) -> dict:
|
|
41
|
+
"""Create a receipt. If key is provided, add an HMAC-SHA256 signature.
|
|
42
|
+
|
|
43
|
+
``prev_hash`` links receipts into a tamper-evident chain (GENESIS for the
|
|
44
|
+
first one). ``extra`` fields are merged before hashing so they are covered
|
|
45
|
+
by both receipt_hash and the signature.
|
|
46
|
+
"""
|
|
41
47
|
receipt = {
|
|
42
48
|
"v": VERSION,
|
|
43
49
|
"receipt_id": str(uuid.uuid4()),
|
|
@@ -46,9 +52,12 @@ def make_receipt(intent: Any, result: Any, key: str | bytes | None = None,
|
|
|
46
52
|
"result": result,
|
|
47
53
|
"intent_hash": sha256_hex(intent),
|
|
48
54
|
"result_digest": sha256_hex(result),
|
|
55
|
+
"prev_hash": prev_hash,
|
|
49
56
|
}
|
|
50
57
|
if meta:
|
|
51
58
|
receipt["meta"] = meta
|
|
59
|
+
if extra:
|
|
60
|
+
receipt.update(extra)
|
|
52
61
|
receipt["receipt_hash"] = sha256_hex(_core(receipt))
|
|
53
62
|
kb = _key_bytes(key)
|
|
54
63
|
if kb:
|
|
@@ -61,7 +70,7 @@ def make_receipt(intent: Any, result: Any, key: str | bytes | None = None,
|
|
|
61
70
|
|
|
62
71
|
|
|
63
72
|
def verify_receipt(receipt: dict, key: str | bytes | None = None,
|
|
64
|
-
require_signature: bool =
|
|
73
|
+
require_signature: bool = True) -> dict:
|
|
65
74
|
"""Verify hashes and, when present, the signature. Fail closed."""
|
|
66
75
|
errors: list[str] = []
|
|
67
76
|
if not isinstance(receipt, dict):
|
|
@@ -100,14 +109,15 @@ def verify_receipt(receipt: dict, key: str | bytes | None = None,
|
|
|
100
109
|
"receipt_hash": receipt.get("receipt_hash")}
|
|
101
110
|
|
|
102
111
|
|
|
103
|
-
def verify_chain(receipts: list[dict], key: str | bytes | None = None
|
|
112
|
+
def verify_chain(receipts: list[dict], key: str | bytes | None = None,
|
|
113
|
+
require_signature: bool = True) -> dict:
|
|
104
114
|
"""Verify a simple prev_hash chain (first prev_hash = GENESIS)."""
|
|
105
115
|
errors: list[str] = []
|
|
106
116
|
prev = "GENESIS"
|
|
107
117
|
for i, rec in enumerate(receipts or []):
|
|
108
118
|
if rec.get("prev_hash") != prev:
|
|
109
119
|
errors.append("E_CHAIN_AT_%d" % i)
|
|
110
|
-
res = verify_receipt(rec, key=key)
|
|
120
|
+
res = verify_receipt(rec, key=key, require_signature=require_signature)
|
|
111
121
|
if not res["valid"]:
|
|
112
122
|
errors.extend("%s@%d" % (e, i) for e in res["errors"])
|
|
113
123
|
prev = rec.get("receipt_hash", "")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: proofgate-runtime
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Evidence-first claim verification, signed receipts, lite injection guard and MCP server (stdlib only).
|
|
5
5
|
Author-email: gamAI <info@gamai.io>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -19,10 +19,13 @@ Dynamic: license-file
|
|
|
19
19
|
# ProofGate Runtime
|
|
20
20
|
|
|
21
21
|
**Evidence-first claim verification, signed receipts, and a lite injection guard for AI agents.**
|
|
22
|
-
[](https://pypi.org/project/proofgate-runtime/) v0.
|
|
22
|
+
[](https://pypi.org/project/proofgate-runtime/) v0.2.0 · Python 3.10+ · stdlib only · Apache-2.0
|
|
23
23
|
|
|
24
24
|
Agent says "done". ProofGate asks: **where is the evidence?**
|
|
25
25
|
|
|
26
|
+
> **Start here if you are new:** [`gama-mandate`](https://pypi.org/project/gama-mandate/) — sign a business commitment, execute it once, prove it offline.
|
|
27
|
+
> This package is one layer of the same stack, not an alternative to it: `gama-mandate` (commitments) · `gamai-trust` (verify claims) · `gamai-guard` (injection) · `gamai-plugins` (policy, sandbox, team) · `sigil-profile` (receipt profile over MCP/A2A) · `proofgate-runtime` (claim/receipt core) · `gama-l` (provable computation).
|
|
28
|
+
|
|
26
29
|
This package is the small, installable core of the gamAI trust layer:
|
|
27
30
|
|
|
28
31
|
- **Claims** — `confirmed / refuted / unverified` per claim, fail-closed, SHA-256-bound report.
|
|
@@ -72,7 +75,7 @@ echo '{"posted":true,"total":"2808.00"}' > result.json
|
|
|
72
75
|
printf 'shared-secret' > key.bin
|
|
73
76
|
|
|
74
77
|
proofgate make-receipt intent.json result.json --key-file key.bin > receipt.json
|
|
75
|
-
proofgate verify-receipt receipt.json --key-file key.bin
|
|
78
|
+
proofgate verify-receipt receipt.json --key-file key.bin
|
|
76
79
|
```
|
|
77
80
|
|
|
78
81
|
Tamper with `result.json` or the receipt and verification fails closed.
|
|
@@ -107,8 +110,8 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
107
110
|
- **No anchor/lease service.** That is [`sigil`](https://github.com/gamai-io/sigil) (grants, receipts, anchor, MCP middleware). ProofGate v0.1 is the local verification core.
|
|
108
111
|
- **No embedding-based guard.** This is the lexical layer; the full multilingual cascade is [`gamai-guard`](https://github.com/gamai-io/gamai-guard).
|
|
109
112
|
- **No independent security audit.** Treat v0.1 as a reference implementation, not a certified product.
|
|
110
|
-
- **MCP receipts are
|
|
111
|
-
- **PyPI 0.
|
|
113
|
+
- **MCP receipts are signed only when `PROOFGATE_HMAC_KEY` is set** and are rejected as unsigned otherwise. Set it in the server environment; never put the key in a client or in git.
|
|
114
|
+
- **PyPI 0.2.0 is available.** Install with `pip install proofgate-runtime`.
|
|
112
115
|
|
|
113
116
|
## Design rules
|
|
114
117
|
|
|
@@ -122,10 +125,14 @@ Tools: `verify_claims`, `make_receipt`, `verify_receipt`, `check_injection`, `ru
|
|
|
122
125
|
|
|
123
126
|
- [`sigil`](https://github.com/gamai-io/sigil) — proof-carrying execution: grants, receipts, anchor, conformance.
|
|
124
127
|
- [`gamai-guard`](https://github.com/gamai-io/gamai-guard) — multilingual prompt-injection cascade.
|
|
125
|
-
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark
|
|
128
|
+
- [`crossnode-bench`](https://github.com/gamai-io/crossnode-bench) — claim-vs-truth benchmark. Shipped v1.4.0: honest fleet **25,600/25,600 pass, 0 false successes**; controlled liar variant 28,800 records with **400 false successes, all on the lying node** (detected). The separate 93.75% / 6.25% Slurm run is reported in `evidence-gate-runtime` and its dataset is not public yet.
|
|
126
129
|
- [`evidence-gate-runtime`](https://github.com/gamai-io/evidence-gate-runtime) — fuller runtime with replay.
|
|
127
130
|
- [`floor-copilot`](https://github.com/gamai-io/floor-copilot) — production case study: invoice intake with 17% VAT gate.
|
|
128
131
|
|
|
132
|
+
## v0.2 breaking change
|
|
133
|
+
|
|
134
|
+
`verify_receipt()` now requires a valid signature by default. For legacy unsigned receipts, call `verify_receipt(..., require_signature=False)` or the CLI with `--allow-unsigned`. Create signed receipts with `proofgate make-receipt ... --key-file`; the MCP server signs when `PROOFGATE_HMAC_KEY` is set.
|
|
135
|
+
|
|
129
136
|
## Honest status
|
|
130
137
|
|
|
131
138
|
- Claim verification: tested (BHS/EU/US money formats, predicates, tamper detection).
|
{proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/SOURCES.txt
RENAMED
|
@@ -13,6 +13,8 @@ src/proofgate_runtime.egg-info/dependency_links.txt
|
|
|
13
13
|
src/proofgate_runtime.egg-info/entry_points.txt
|
|
14
14
|
src/proofgate_runtime.egg-info/top_level.txt
|
|
15
15
|
tests/test_claims.py
|
|
16
|
+
tests/test_cli.py
|
|
16
17
|
tests/test_guard.py
|
|
17
18
|
tests/test_mcp.py
|
|
18
|
-
tests/test_receipts.py
|
|
19
|
+
tests/test_receipts.py
|
|
20
|
+
tests/test_verify_exit.py
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
from proofgate_runtime import cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CliTests(unittest.TestCase):
|
|
12
|
+
def _write(self, obj):
|
|
13
|
+
fd, path = tempfile.mkstemp(suffix=".json")
|
|
14
|
+
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
|
15
|
+
json.dump(obj, fh)
|
|
16
|
+
self.addCleanup(os.unlink, path)
|
|
17
|
+
return path
|
|
18
|
+
|
|
19
|
+
def test_verify_claims_passes_keyword_reported_hash(self):
|
|
20
|
+
path = self._write({"claims": [
|
|
21
|
+
{"text": "2+2", "predicate": "eq_num", "observed": 4, "expected": 4}
|
|
22
|
+
]})
|
|
23
|
+
buf = io.StringIO()
|
|
24
|
+
with contextlib.redirect_stdout(buf):
|
|
25
|
+
rc = cli.main(["verify-claims", path])
|
|
26
|
+
self.assertEqual(rc, 0)
|
|
27
|
+
report = json.loads(buf.getvalue())
|
|
28
|
+
self.assertEqual(report["status"], "confirmed")
|
|
29
|
+
self.assertEqual(report["counts"]["confirmed"], 1)
|
|
30
|
+
|
|
31
|
+
def test_verify_claims_tampered_hash_is_nonzero(self):
|
|
32
|
+
path = self._write({"claims": [
|
|
33
|
+
{"text": "2+2", "predicate": "eq_num", "observed": 4, "expected": 4}
|
|
34
|
+
]})
|
|
35
|
+
buf = io.StringIO()
|
|
36
|
+
with contextlib.redirect_stdout(buf):
|
|
37
|
+
rc = cli.main(["verify-claims", path, "--reported-hash", "0" * 64])
|
|
38
|
+
self.assertEqual(rc, 1)
|
|
39
|
+
report = json.loads(buf.getvalue())
|
|
40
|
+
self.assertTrue(report["tampered"])
|
|
41
|
+
self.assertFalse(report["ok"])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
unittest.main()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import unittest
|
|
4
|
+
from unittest import mock
|
|
5
|
+
|
|
6
|
+
from proofgate_runtime.mcp_server import TOOLS, handle
|
|
7
|
+
from proofgate_runtime.receipts import verify_receipt
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class McpTests(unittest.TestCase):
|
|
11
|
+
def test_initialize(self):
|
|
12
|
+
out = handle({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}})
|
|
13
|
+
self.assertEqual(out["result"]["serverInfo"]["name"], "proofgate-runtime")
|
|
14
|
+
|
|
15
|
+
def test_tools_list(self):
|
|
16
|
+
out = handle({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
|
|
17
|
+
self.assertEqual(len(out["result"]["tools"]), len(TOOLS))
|
|
18
|
+
|
|
19
|
+
def test_verify_claims(self):
|
|
20
|
+
out = handle({"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {
|
|
21
|
+
"name": "verify_claims", "arguments": {"claims": [
|
|
22
|
+
{"text": "m", "predicate": "eq_num", "observed": "2.400,00", "expected": "2400,00"}
|
|
23
|
+
]}}})
|
|
24
|
+
payload = json.loads(out["result"]["content"][0]["text"])
|
|
25
|
+
self.assertEqual(payload["counts"]["confirmed"], 1)
|
|
26
|
+
|
|
27
|
+
def test_notification_no_response(self):
|
|
28
|
+
out = handle({"jsonrpc": "2.0", "method": "notifications/initialized", "params": {}})
|
|
29
|
+
self.assertIsNone(out)
|
|
30
|
+
|
|
31
|
+
def test_unknown_method(self):
|
|
32
|
+
out = handle({"jsonrpc": "2.0", "id": 4, "method": "nope"})
|
|
33
|
+
self.assertEqual(out["error"]["code"], -32601)
|
|
34
|
+
|
|
35
|
+
def test_unsigned_receipt_is_refused_by_default(self):
|
|
36
|
+
with mock.patch.dict(os.environ, {"PROOFGATE_HMAC_KEY": "",
|
|
37
|
+
"PROOFGATE_ALLOW_UNSIGNED": ""}):
|
|
38
|
+
out = handle({"jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": {
|
|
39
|
+
"name": "make_receipt", "arguments": {"intent": {"op": "x"},
|
|
40
|
+
"result": {"ok": True}}}})
|
|
41
|
+
self.assertTrue(out["result"].get("isError"), out)
|
|
42
|
+
self.assertIn("unsigned", out["result"]["content"][0]["text"])
|
|
43
|
+
|
|
44
|
+
def test_unsigned_must_be_opted_into_explicitly(self):
|
|
45
|
+
with mock.patch.dict(os.environ, {"PROOFGATE_HMAC_KEY": "",
|
|
46
|
+
"PROOFGATE_ALLOW_UNSIGNED": "1"}):
|
|
47
|
+
out = handle({"jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": {
|
|
48
|
+
"name": "make_receipt", "arguments": {"intent": {"op": "x"},
|
|
49
|
+
"result": {"ok": True}}}})
|
|
50
|
+
rec = json.loads(out["result"]["content"][0]["text"])
|
|
51
|
+
self.assertFalse(rec["signed"])
|
|
52
|
+
self.assertIn("_warning", rec)
|
|
53
|
+
check = verify_receipt(rec, require_signature=False)
|
|
54
|
+
self.assertTrue(check["valid"], check)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
unittest.main()
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
|
|
3
|
-
from proofgate_runtime.receipts import make_receipt, verify_receipt,
|
|
3
|
+
from proofgate_runtime.receipts import (make_receipt, verify_receipt,
|
|
4
|
+
verify_chain, canonical_json)
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class ReceiptTests(unittest.TestCase):
|
|
7
8
|
def test_unsigned_receipt(self):
|
|
8
9
|
r = make_receipt({"op": "x"}, {"ok": True})
|
|
9
|
-
out = verify_receipt(r)
|
|
10
|
+
out = verify_receipt(r, require_signature=False)
|
|
10
11
|
self.assertTrue(out["valid"], out)
|
|
11
12
|
self.assertFalse(out["signed"])
|
|
13
|
+
self.assertFalse(verify_receipt(r)["valid"])
|
|
12
14
|
|
|
13
15
|
def test_signed_receipt(self):
|
|
14
16
|
r = make_receipt({"op": "x"}, {"ok": True}, key="secret")
|
|
@@ -29,15 +31,34 @@ class ReceiptTests(unittest.TestCase):
|
|
|
29
31
|
self.assertFalse(out["valid"])
|
|
30
32
|
self.assertIn("E_RESULT_DIGEST", out["errors"])
|
|
31
33
|
|
|
32
|
-
def
|
|
34
|
+
def test_require_signature_default(self):
|
|
33
35
|
r = make_receipt({"op": "x"}, {"ok": True})
|
|
34
|
-
out = verify_receipt(r
|
|
36
|
+
out = verify_receipt(r)
|
|
35
37
|
self.assertFalse(out["valid"])
|
|
36
38
|
self.assertIn("E_UNSIGNED", out["errors"])
|
|
37
39
|
|
|
38
40
|
def test_canonical_json_stable(self):
|
|
39
41
|
self.assertEqual(canonical_json({"b": 1, "a": 2}), '{"a":2,"b":1}')
|
|
40
42
|
|
|
43
|
+
def test_make_receipt_writes_prev_hash(self):
|
|
44
|
+
r = make_receipt({"op": "x"}, {"ok": True})
|
|
45
|
+
self.assertEqual(r["prev_hash"], "GENESIS")
|
|
46
|
+
|
|
47
|
+
def test_chain_verifies(self):
|
|
48
|
+
r1 = make_receipt({"op": 1}, {"ok": True}, key="secret")
|
|
49
|
+
r2 = make_receipt({"op": 2}, {"ok": True}, key="secret",
|
|
50
|
+
prev_hash=r1["receipt_hash"])
|
|
51
|
+
out = verify_chain([r1, r2], key="secret")
|
|
52
|
+
self.assertTrue(out["valid"], out)
|
|
53
|
+
self.assertEqual(out["count"], 2)
|
|
54
|
+
|
|
55
|
+
def test_chain_detects_break(self):
|
|
56
|
+
r1 = make_receipt({"op": 1}, {"ok": True}, key="secret")
|
|
57
|
+
r2 = make_receipt({"op": 2}, {"ok": True}, key="secret")
|
|
58
|
+
out = verify_chain([r1, r2], key="secret")
|
|
59
|
+
self.assertFalse(out["valid"])
|
|
60
|
+
self.assertIn("E_CHAIN_AT_1", out["errors"])
|
|
61
|
+
|
|
41
62
|
|
|
42
63
|
if __name__ == "__main__":
|
|
43
64
|
unittest.main()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
from proofgate_runtime import claims
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class VerifyExitTests(unittest.TestCase):
|
|
12
|
+
def _write(self, obj):
|
|
13
|
+
fd, path = tempfile.mkstemp(suffix=".json")
|
|
14
|
+
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
|
15
|
+
json.dump(obj, fh)
|
|
16
|
+
self.addCleanup(os.unlink, path)
|
|
17
|
+
return path
|
|
18
|
+
|
|
19
|
+
def _run(self, path):
|
|
20
|
+
with contextlib.redirect_stdout(io.StringIO()):
|
|
21
|
+
return claims.main(["proofgate.py", "verify", path])
|
|
22
|
+
|
|
23
|
+
def test_verify_accepts_intact_report(self):
|
|
24
|
+
report = claims.check([
|
|
25
|
+
{"text": "ok", "predicate": "eq_num", "observed": 1, "expected": 1}
|
|
26
|
+
])
|
|
27
|
+
self.assertEqual(self._run(self._write(report)), 0)
|
|
28
|
+
|
|
29
|
+
def test_verify_rejects_tampered_report(self):
|
|
30
|
+
report = claims.check([
|
|
31
|
+
{"text": "ok", "predicate": "eq_num", "observed": 1, "expected": 1}
|
|
32
|
+
])
|
|
33
|
+
report["claims"][0]["observed"] = 2
|
|
34
|
+
self.assertEqual(self._run(self._write(report)), 1)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
unittest.main()
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import unittest
|
|
3
|
-
|
|
4
|
-
from proofgate_runtime.mcp_server import TOOLS, handle
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class McpTests(unittest.TestCase):
|
|
8
|
-
def test_initialize(self):
|
|
9
|
-
out = handle({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}})
|
|
10
|
-
self.assertEqual(out["result"]["serverInfo"]["name"], "proofgate-runtime")
|
|
11
|
-
|
|
12
|
-
def test_tools_list(self):
|
|
13
|
-
out = handle({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
|
|
14
|
-
self.assertEqual(len(out["result"]["tools"]), len(TOOLS))
|
|
15
|
-
|
|
16
|
-
def test_verify_claims(self):
|
|
17
|
-
out = handle({"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {
|
|
18
|
-
"name": "verify_claims", "arguments": {"claims": [
|
|
19
|
-
{"text": "m", "predicate": "eq_num", "observed": "2.400,00", "expected": "2400,00"}
|
|
20
|
-
]}}})
|
|
21
|
-
payload = json.loads(out["result"]["content"][0]["text"])
|
|
22
|
-
self.assertEqual(payload["counts"]["confirmed"], 1)
|
|
23
|
-
|
|
24
|
-
def test_notification_no_response(self):
|
|
25
|
-
out = handle({"jsonrpc": "2.0", "method": "notifications/initialized", "params": {}})
|
|
26
|
-
self.assertIsNone(out)
|
|
27
|
-
|
|
28
|
-
def test_unknown_method(self):
|
|
29
|
-
out = handle({"jsonrpc": "2.0", "id": 4, "method": "nope"})
|
|
30
|
-
self.assertEqual(out["error"]["code"], -32601)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if __name__ == "__main__":
|
|
34
|
-
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{proofgate_runtime-0.1.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|