proofgate-runtime 0.2.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.2.0 → proofgate_runtime-0.2.1}/PKG-INFO +5 -2
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/README.md +4 -1
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/pyproject.toml +5 -1
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/__init__.py +1 -1
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/claims.py +3 -2
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/cli.py +3 -2
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/mcp_server.py +12 -3
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/receipts.py +11 -2
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/PKG-INFO +5 -2
- {proofgate_runtime-0.2.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.2.0 → proofgate_runtime-0.2.1}/tests/test_receipts.py +21 -1
- proofgate_runtime-0.2.1/tests/test_verify_exit.py +38 -0
- proofgate_runtime-0.2.0/tests/test_mcp.py +0 -34
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/LICENSE +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/setup.cfg +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime/guard.py +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/dependency_links.txt +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/entry_points.txt +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/top_level.txt +0 -0
- {proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/tests/test_claims.py +0 -0
- {proofgate_runtime-0.2.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.2.
|
|
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
|
|
@@ -23,6 +23,9 @@ Dynamic: license-file
|
|
|
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.
|
|
@@ -122,7 +125,7 @@ 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
|
|
|
@@ -5,6 +5,9 @@
|
|
|
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.
|
|
@@ -104,7 +107,7 @@ 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
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "proofgate-runtime"
|
|
7
|
-
version = "0.2.
|
|
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.2.
|
|
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
|
|
|
@@ -61,8 +61,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
61
61
|
if args.cmd == "verify-claims":
|
|
62
62
|
data = _load(args.file)
|
|
63
63
|
claims = data.get("claims") if isinstance(data, dict) else data
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
report = check(claims or [], reported_hash=args.reported_hash)
|
|
65
|
+
_print(report)
|
|
66
|
+
return 0 if report["ok"] else 1
|
|
66
67
|
if args.cmd == "make-receipt":
|
|
67
68
|
key = _key(args.key_file)
|
|
68
69
|
if key is None and not args.allow_unsigned:
|
|
@@ -27,7 +27,7 @@ TOOLS = [
|
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "make_receipt",
|
|
30
|
-
"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.",
|
|
31
31
|
"inputSchema": {
|
|
32
32
|
"type": "object",
|
|
33
33
|
"properties": {"intent": {}, "result": {}, "meta": {"type": "object"}},
|
|
@@ -76,9 +76,18 @@ def call_tool(name: str, args: dict) -> dict:
|
|
|
76
76
|
if "intent" not in args or "result" not in args:
|
|
77
77
|
return _text({"error": "intent and result are required"}, True)
|
|
78
78
|
key = os.environ.get("PROOFGATE_HMAC_KEY") or None
|
|
79
|
-
|
|
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)}
|
|
80
87
|
if not key:
|
|
81
|
-
|
|
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)
|
|
82
91
|
return _text(rec)
|
|
83
92
|
if name == "verify_receipt":
|
|
84
93
|
if not isinstance(args.get("receipt"), dict):
|
|
@@ -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:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: proofgate-runtime
|
|
3
|
-
Version: 0.2.
|
|
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
|
|
@@ -23,6 +23,9 @@ Dynamic: license-file
|
|
|
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.
|
|
@@ -122,7 +125,7 @@ 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
|
|
{proofgate_runtime-0.2.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,6 +1,7 @@
|
|
|
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):
|
|
@@ -39,6 +40,25 @@ class ReceiptTests(unittest.TestCase):
|
|
|
39
40
|
def test_canonical_json_stable(self):
|
|
40
41
|
self.assertEqual(canonical_json({"b": 1, "a": 2}), '{"a":2,"b":1}')
|
|
41
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
|
+
|
|
42
62
|
|
|
43
63
|
if __name__ == "__main__":
|
|
44
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.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{proofgate_runtime-0.2.0 → proofgate_runtime-0.2.1}/src/proofgate_runtime.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|