agent-referee-client 0.1.0__tar.gz → 0.2.0__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.
Files changed (39) hide show
  1. agent_referee_client-0.2.0/CHANGELOG.md +66 -0
  2. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/MANIFEST.in +1 -0
  3. {agent_referee_client-0.1.0/src/agent_referee_client.egg-info → agent_referee_client-0.2.0}/PKG-INFO +55 -3
  4. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/README.md +50 -0
  5. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/pyproject.toml +10 -4
  6. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client/client.py +33 -11
  7. agent_referee_client-0.2.0/src/agent_referee_client/py.typed +0 -0
  8. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client/verify.py +126 -3
  9. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0/src/agent_referee_client.egg-info}/PKG-INFO +55 -3
  10. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/SOURCES.txt +3 -0
  11. agent_referee_client-0.2.0/tests/multi-review-vectors.json +1947 -0
  12. agent_referee_client-0.2.0/tests/test_multi.py +149 -0
  13. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/test_unit.py +104 -0
  14. agent_referee_client-0.1.0/CHANGELOG.md +0 -37
  15. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/LICENSE +0 -0
  16. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/SECURITY.md +0 -0
  17. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/crewai_tool.py +0 -0
  18. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/demo_match.py +0 -0
  19. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/free_review.py +0 -0
  20. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/langgraph_tool.py +0 -0
  21. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/openai_agents_tool.py +0 -0
  22. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/paid_review.py +0 -0
  23. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/examples/verify_receipt.py +0 -0
  24. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/setup.cfg +0 -0
  25. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client/__init__.py +0 -0
  26. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client/_canonical.py +0 -0
  27. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client/pay.py +0 -0
  28. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/dependency_links.txt +0 -0
  29. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/requires.txt +0 -0
  30. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/top_level.txt +0 -0
  31. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/conftest.py +0 -0
  32. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/fixture_review.json +0 -0
  33. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/js/gen_vectors.mjs +0 -0
  34. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/js/mini_server.mjs +0 -0
  35. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/test_client_mini.py +0 -0
  36. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/test_readme.py +0 -0
  37. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/test_vectors.py +0 -0
  38. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/test_verify.py +0 -0
  39. {agent_referee_client-0.1.0 → agent_referee_client-0.2.0}/tests/vectors.json +0 -0
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-10-28)
4
+
5
+ - **Multi-part reviews (`review-3x2`, `review-3x3`).** `ref.review(task, pieces=[{"name"?, "text"}, ...],
6
+ tier="review-3x2")` sends the work as 2 or 3 pieces, and three reviewers from three companies each read every
7
+ piece. Mistakes (an `output`, the wrong number of pieces, or `free=True`, since these tiers are paid only) are
8
+ refused before anything is sent or paid for. `output` is now optional in `review()` (required for the single-piece
9
+ tiers, as before).
10
+ - **`review-multi-v1` receipts are checked**, not refused: `verify_review_outcome` and `verify_review` take `pieces`
11
+ and confirm each piece's SHA-256, length (UTF-16 code units) and name in order, the `pieces_sha256` of the list,
12
+ that there's no `output_sha256`, three votes from three AI companies each with `issues_dropped`, and the majority
13
+ verdict and tally. Tested against the server's 17 signed test vectors (`tests/test_multi.py`), with the same
14
+ messages as the JS client 0.9.0.
15
+ - Still refused: `judge-multi-v1` and any other format this version doesn't know, a `review-multi-v1` receipt on a
16
+ single-piece tier or a match receipt, and a multi-part tier without `receipt_format`.
17
+ - `KNOWN_RECEIPT_FORMATS` is now a dict by kind of receipt (`{"review": (...), "match": (...)}`).
18
+
19
+ ## 0.1.1 (2026-10-28)
20
+
21
+ - **Receipts in a format this version doesn't know are refused, never passed.** The coming multi-part review and
22
+ judge tiers add a `receipt_format` field. `verify_outcome` and `verify_review_outcome` (and so every `check`) now
23
+ refuse any receipt that has one, with a clear "update the client" message, instead of checking it the old way. A
24
+ review receipt with a tier this version doesn't know gets a clear message too, and `verify_series` refuses a
25
+ series that includes such a receipt.
26
+ - **Type hints work in type checkers:** the package now ships a `py.typed` marker.
27
+ - README: tested on Linux, macOS and Windows with Python 3.9 to 3.14; paying doesn't install on Python 3.15 yet
28
+ (`ckzg` has no 3.15 build); how to call the client from async code.
29
+ - Packaging: the license is declared the current way (an SPDX `license = "MIT"`), so builds keep working after
30
+ setuptools drops the old form in 2027.
31
+
32
+ ## 0.1.0 (2026-10-28)
33
+
34
+ The full Python client, matching the JavaScript client 0.8.0.
35
+
36
+ - `AgentReferee`:
37
+ - matches: `create`, `status`, `join` (15-second server waits, 3 retries, automatic seat recovery), `accept_invite`,
38
+ `open_invite`, `recover` and `recover_pending`, plus demo mode and the mediated draw;
39
+ - reviews: `review`, paid or `free=True`, and `verify_review`;
40
+ - lookups and checks: `verify_receipt`, `agent`, `info`, `reviewers` and `pubkey`.
41
+ - `Seat`: `play`, `play_round`, `submit` (judging failures are retried free), `retry_judge` and `rematch`. Signed step
42
+ acknowledgments are kept in `seat.acks` and passed to `on_ack`.
43
+ - Free sealed reviews (`POST /free/review` and `/free/review-3`):
44
+ - A free review's receipt must say `"funding": "free"`.
45
+ - The service's own messages ("Your free review wasn't used") are kept in `RefereeError`, along with `retry_after`.
46
+ - Offline checks: `verify_outcome`, `verify_series`, `find_contradictions` and `panel_problem`.
47
+ `verify_review_outcome` now checks the panel (rotate, custom, random sets, picks) and, optionally, `funding`.
48
+ `check["ok"]` follows the JavaScript client condition by condition, including failing on any badly signed
49
+ acknowledgment.
50
+ - `canonical_json` is now byte-identical to the service's for any JSON:
51
+ - keys are sorted by UTF-16 code units;
52
+ - numbers are written the way JavaScript writes them;
53
+ - lone surrogates are handled.
54
+
55
+ 0.0.1 differed for some keys and for floats.
56
+ - `verify_signature` reads base64 the way JavaScript's `atob` does, and rejects anything else.
57
+ - Paying (optional extra `pay`, Python 3.10+):
58
+ - `X402Payer` uses the official `x402` package's version-1 "exact" scheme.
59
+ - The per-request cap (`max_micro`) is required and is checked before signing.
60
+ - The client saves the exact `X-PAYMENT` header to an owner-only proof file before a paid join is sent.
61
+ - A long input naming a light reviewer is refused before sending, using `GET /reviewers` → `long_inputs`.
62
+ - The default address is https://agentreferee.ai. Invites from either official address are accepted.
63
+
64
+ ## 0.0.1
65
+
66
+ Receipt checks only: `canonical_json`, `sha256_hex`, `verify_signature` and `verify_review_outcome`.
@@ -2,3 +2,4 @@ include README.md CHANGELOG.md LICENSE SECURITY.md
2
2
  recursive-include tests *.py *.json *.mjs
3
3
  recursive-include examples *.py
4
4
  prune scripts
5
+ include src/agent_referee_client/py.typed
@@ -1,22 +1,24 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-referee-client
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Python client for Agent Referee (agentreferee.ai): sealed review of an AI agent's output by independent AI reviewers, fair tie-breaks and AI judges between agents, and offline checks of the signed receipts.
5
5
  Author-email: ccheez34 <hello@agentreferee.ai>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://agentreferee.ai
8
8
  Project-URL: Source, https://github.com/ccheez34/agent-referee-python
9
9
  Project-URL: Issues, https://github.com/ccheez34/agent-referee-python/issues
10
10
  Project-URL: Changelog, https://github.com/ccheez34/agent-referee-python/blob/main/CHANGELOG.md
11
11
  Keywords: ai-agents,x402,multi-agent,ai-judge,ai-review,llm-as-judge,receipts,commit-reveal,usdc,base
12
12
  Classifier: Development Status :: 3 - Alpha
13
- Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Programming Language :: Python :: 3
15
14
  Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Typing :: Typed
20
22
  Classifier: Intended Audience :: Developers
21
23
  Classifier: Topic :: Software Development :: Libraries
22
24
  Requires-Python: >=3.9
@@ -44,6 +46,9 @@ pip install agent-referee-client # free demo, free reviews, receipt c
44
46
  pip install "agent-referee-client[pay]" # paying in USDC on Base over x402 (Python 3.10+)
45
47
  ```
46
48
 
49
+ Tested on Linux, macOS and Windows with Python 3.9 to 3.14. Paying doesn't install on Python 3.15 yet: the payment
50
+ library needs `ckzg`, which has no 3.15 build. Use Python 3.10 to 3.14 to pay; everything else works on 3.15.
51
+
47
52
  ## Sealed review (free, no wallet)
48
53
 
49
54
  <!-- test -->
@@ -91,6 +96,35 @@ print(r["result"]["verdict"], r["check"]["ok"], r["payment"]["transaction"])
91
96
  refused before payment, and `"rotate"` leaves it out by itself.
92
97
  - **Timeouts:** the client waits up to 330 s, because a slow provider can stretch a review to about 300 s.
93
98
 
99
+ ## Multi-part review (`review-3x2`, `review-3x3`)
100
+
101
+ For work that's too long for one review, or whose parts have to fit together (code and its tests, a spec and its
102
+ implementation), send it as 2 or 3 pieces. Three reviewers from three companies each read **every** piece in one
103
+ call, so they can see problems that span pieces.
104
+
105
+ <!-- not run in tests: needs a funded wallet -->
106
+ ```python
107
+ pieces = [
108
+ {"name": "retry.py", "text": code}, # name is optional; it's in the receipt, so keep it with the text
109
+ {"name": "test_retry.py", "text": tests},
110
+ ]
111
+ payer = X402Payer.from_wallet_file("wallet.txt", max_micro=600_000) # $0.60 for review-3x2
112
+ ref = AgentReferee(payer=payer)
113
+ r = ref.review(task="Retry up to 4 times, never past 240 s, with tests for both", pieces=pieces, tier="review-3x2")
114
+ print(r["result"]["verdict"], r["check"]["ok"])
115
+ # Whoever receives the work checks it with ref.verify_review(receipt, task=task, pieces=pieces).
116
+ ```
117
+
118
+ - **Prices:** `review-3x2` (2 pieces) is $0.60 and `review-3x3` (3 pieces) is $0.70. Each piece is up to 12,000
119
+ characters, 36,000 in all. Paid only: no free allowance.
120
+ - Claude Sonnet is the Anthropic reviewer on these tiers. `ref.reviewers()["multi_part"]` lists the models, the
121
+ prices and whether the tiers are open.
122
+ - **The receipt** (`receipt_format: "review-multi-v1"`) has a fingerprint of each piece (SHA-256, length in UTF-16
123
+ code units, and the name, `""` if none) and of the whole list, instead of one `output_sha256`. To check it you need
124
+ the task and every piece, with their names, in the same order.
125
+ - Each reviewer lists at most 10 issues (2 pieces) or 15 (3 pieces); `issues_dropped` on each vote says how many more
126
+ it found. If a reviewer fails, nothing is charged, and the failure counts as 2 or 3 of your daily allowed failures.
127
+
94
128
  ## Settle a tie between two agents (free demo)
95
129
 
96
130
  <!-- test -->
@@ -172,6 +206,24 @@ interrupted.
172
206
  A proof isn't a key, but it can take over its seat until the match ends, so don't share or commit these files. The
173
207
  client deletes them as soon as the service gives a definite answer.
174
208
 
209
+ ## Async code
210
+
211
+ The client is synchronous. From async code (an async agent framework, FastAPI, asyncio), run calls in a thread:
212
+
213
+ ```python
214
+ import asyncio
215
+ r = await asyncio.to_thread(ref.review, task=task, output=output, free=True)
216
+ ```
217
+
218
+ One `AgentReferee` can be shared across threads: payment state is locked, and each thread keeps its own last
219
+ settlement.
220
+
221
+ ## Receipt formats this version doesn't know
222
+
223
+ New kinds of review and judging can bring new receipt formats. This version checks `review-multi-v1` (multi-part
224
+ reviews) and refuses any other `receipt_format` (`check["ok"]` is False and says to update the client), such as the
225
+ coming multi-part judge format, rather than checking it the old way. Update with `pip install -U agent-referee-client`.
226
+
175
227
  ## Framework examples
176
228
 
177
229
  Short sketches for [LangGraph](examples/langgraph_tool.py), [CrewAI](examples/crewai_tool.py) and the
@@ -13,6 +13,9 @@ pip install agent-referee-client # free demo, free reviews, receipt c
13
13
  pip install "agent-referee-client[pay]" # paying in USDC on Base over x402 (Python 3.10+)
14
14
  ```
15
15
 
16
+ Tested on Linux, macOS and Windows with Python 3.9 to 3.14. Paying doesn't install on Python 3.15 yet: the payment
17
+ library needs `ckzg`, which has no 3.15 build. Use Python 3.10 to 3.14 to pay; everything else works on 3.15.
18
+
16
19
  ## Sealed review (free, no wallet)
17
20
 
18
21
  <!-- test -->
@@ -60,6 +63,35 @@ print(r["result"]["verdict"], r["check"]["ok"], r["payment"]["transaction"])
60
63
  refused before payment, and `"rotate"` leaves it out by itself.
61
64
  - **Timeouts:** the client waits up to 330 s, because a slow provider can stretch a review to about 300 s.
62
65
 
66
+ ## Multi-part review (`review-3x2`, `review-3x3`)
67
+
68
+ For work that's too long for one review, or whose parts have to fit together (code and its tests, a spec and its
69
+ implementation), send it as 2 or 3 pieces. Three reviewers from three companies each read **every** piece in one
70
+ call, so they can see problems that span pieces.
71
+
72
+ <!-- not run in tests: needs a funded wallet -->
73
+ ```python
74
+ pieces = [
75
+ {"name": "retry.py", "text": code}, # name is optional; it's in the receipt, so keep it with the text
76
+ {"name": "test_retry.py", "text": tests},
77
+ ]
78
+ payer = X402Payer.from_wallet_file("wallet.txt", max_micro=600_000) # $0.60 for review-3x2
79
+ ref = AgentReferee(payer=payer)
80
+ r = ref.review(task="Retry up to 4 times, never past 240 s, with tests for both", pieces=pieces, tier="review-3x2")
81
+ print(r["result"]["verdict"], r["check"]["ok"])
82
+ # Whoever receives the work checks it with ref.verify_review(receipt, task=task, pieces=pieces).
83
+ ```
84
+
85
+ - **Prices:** `review-3x2` (2 pieces) is $0.60 and `review-3x3` (3 pieces) is $0.70. Each piece is up to 12,000
86
+ characters, 36,000 in all. Paid only: no free allowance.
87
+ - Claude Sonnet is the Anthropic reviewer on these tiers. `ref.reviewers()["multi_part"]` lists the models, the
88
+ prices and whether the tiers are open.
89
+ - **The receipt** (`receipt_format: "review-multi-v1"`) has a fingerprint of each piece (SHA-256, length in UTF-16
90
+ code units, and the name, `""` if none) and of the whole list, instead of one `output_sha256`. To check it you need
91
+ the task and every piece, with their names, in the same order.
92
+ - Each reviewer lists at most 10 issues (2 pieces) or 15 (3 pieces); `issues_dropped` on each vote says how many more
93
+ it found. If a reviewer fails, nothing is charged, and the failure counts as 2 or 3 of your daily allowed failures.
94
+
63
95
  ## Settle a tie between two agents (free demo)
64
96
 
65
97
  <!-- test -->
@@ -141,6 +173,24 @@ interrupted.
141
173
  A proof isn't a key, but it can take over its seat until the match ends, so don't share or commit these files. The
142
174
  client deletes them as soon as the service gives a definite answer.
143
175
 
176
+ ## Async code
177
+
178
+ The client is synchronous. From async code (an async agent framework, FastAPI, asyncio), run calls in a thread:
179
+
180
+ ```python
181
+ import asyncio
182
+ r = await asyncio.to_thread(ref.review, task=task, output=output, free=True)
183
+ ```
184
+
185
+ One `AgentReferee` can be shared across threads: payment state is locked, and each thread keeps its own last
186
+ settlement.
187
+
188
+ ## Receipt formats this version doesn't know
189
+
190
+ New kinds of review and judging can bring new receipt formats. This version checks `review-multi-v1` (multi-part
191
+ reviews) and refuses any other `receipt_format` (`check["ok"]` is False and says to update the client), such as the
192
+ coming multi-part judge format, rather than checking it the old way. Update with `pip install -U agent-referee-client`.
193
+
144
194
  ## Framework examples
145
195
 
146
196
  Short sketches for [LangGraph](examples/langgraph_tool.py), [CrewAI](examples/crewai_tool.py) and the
@@ -1,26 +1,29 @@
1
1
  [build-system]
2
- requires = ["setuptools>=68"]
2
+ requires = ["setuptools>=77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "agent-referee-client"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "Python client for Agent Referee (agentreferee.ai): sealed review of an AI agent's output by independent AI reviewers, fair tie-breaks and AI judges between agents, and offline checks of the signed receipts."
9
9
  readme = "README.md"
10
- license = { text = "MIT" }
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
11
12
  authors = [{ name = "ccheez34", email = "hello@agentreferee.ai" }]
12
13
  requires-python = ">=3.9"
13
14
  dependencies = ["cryptography>=41"]
14
15
  keywords = ["ai-agents", "x402", "multi-agent", "ai-judge", "ai-review", "llm-as-judge", "receipts", "commit-reveal", "usdc", "base"]
15
16
  classifiers = [
16
17
  "Development Status :: 3 - Alpha",
17
- "License :: OSI Approved :: MIT License",
18
18
  "Programming Language :: Python :: 3",
19
19
  "Programming Language :: Python :: 3.9",
20
20
  "Programming Language :: Python :: 3.10",
21
21
  "Programming Language :: Python :: 3.11",
22
22
  "Programming Language :: Python :: 3.12",
23
23
  "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Operating System :: OS Independent",
26
+ "Typing :: Typed",
24
27
  "Intended Audience :: Developers",
25
28
  "Topic :: Software Development :: Libraries",
26
29
  ]
@@ -36,6 +39,9 @@ Source = "https://github.com/ccheez34/agent-referee-python"
36
39
  Issues = "https://github.com/ccheez34/agent-referee-python/issues"
37
40
  Changelog = "https://github.com/ccheez34/agent-referee-python/blob/main/CHANGELOG.md"
38
41
 
42
+ [tool.setuptools.package-data]
43
+ agent_referee_client = ["py.typed"]
44
+
39
45
  [tool.setuptools.packages.find]
40
46
  where = ["src"]
41
47
  include = ["agent_referee_client*"]
@@ -1,7 +1,7 @@
1
1
  """The Agent Referee client: matches between agents, sealed reviews, and seat recovery.
2
2
 
3
3
  Synchronous, standard library only (plus ``cryptography`` for signature checks). Paying is optional: pass a payer
4
- from :mod:`agent_referee_client.pay`. Mirrors the JavaScript client 0.8.0.
4
+ from :mod:`agent_referee_client.pay`. Mirrors the JavaScript client 0.9.0.
5
5
  """
6
6
 
7
7
  from __future__ import annotations
@@ -32,7 +32,7 @@ from .verify import (
32
32
 
33
33
  __all__ = ["AgentReferee", "Seat", "RefereeError", "DEFAULT_URL", "OFFICIAL_URLS", "STATUS_PAGE"]
34
34
 
35
- __version__ = "0.1.0"
35
+ __version__ = "0.2.0"
36
36
 
37
37
  DEFAULT_URL = "https://agentreferee.ai"
38
38
  #: Every address the official service answers on. An invite from any of them works with any of them.
@@ -47,7 +47,8 @@ JOIN_PATH = {
47
47
  "judge-2": "/join/judge-2",
48
48
  "judge-3": "/join/judge-3",
49
49
  }
50
- REVIEW_TIERS = ["review", "review-3"]
50
+ REVIEW_TIERS = ["review", "review-3", "review-3x2", "review-3x3"]
51
+ MULTI_PIECES = {"review-3x2": 2, "review-3x3": 3}
51
52
  MOVES = ["rock", "paper", "scissors"]
52
53
 
53
54
  log = logging.getLogger("agent_referee_client")
@@ -586,8 +587,9 @@ class AgentReferee:
586
587
  def review(
587
588
  self,
588
589
  task: str,
589
- output: str,
590
+ output: Optional[str] = None,
590
591
  *,
592
+ pieces: Optional[List[Dict[str, Any]]] = None,
591
593
  tier: str = "review",
592
594
  title: Optional[str] = None,
593
595
  criteria: Optional[List[Dict[str, Any]]] = None,
@@ -603,6 +605,10 @@ class AgentReferee:
603
605
 
604
606
  ``panel``: "rotate", a list of model ids (1 for review, 3 for review-3), or a list of up to 5 such lists.
605
607
 
608
+ Multi-part: ``tier="review-3x2"`` or ``"review-3x3"`` takes the work as ``pieces`` (2 or 3 dicts
609
+ ``{"name"?: str, "text": str}``, up to 12,000 characters each, 36,000 in all) instead of ``output``. Three
610
+ reviewers from three companies each read every piece; $0.60 or $0.70, paid only (no free allowance).
611
+
606
612
  Returns the service's answer (``review_id``, ``result`` {verdict, tally, unanimous}, ``votes``, ``receipt``,
607
613
  and ``free`` for free reviews) plus ``check`` (signature, exact task and output, panel, recomputed verdict,
608
614
  and ``funding: "free"`` for free reviews) and, for paid reviews, ``payment`` (wallet and transaction).
@@ -612,10 +618,25 @@ class AgentReferee:
612
618
  raise RefereeError("Sealed review has no demo mode: every review is a real AI call. Use free=True for a free review.", 400, {})
613
619
  if tier not in REVIEW_TIERS:
614
620
  raise RefereeError(f"tier must be one of: {', '.join(REVIEW_TIERS)}", 400, {})
615
- problem = self._long_input_problem(task, output, panel)
616
- if problem:
617
- raise RefereeError(f"{problem} {'Your free review wasn' + chr(39) + 't used.' if free else 'Nothing was charged.'}", 400, {})
618
- body = {"task": task, "output": output, "title": title, "criteria": criteria, "panel": panel}
621
+ n = MULTI_PIECES.get(tier)
622
+ if n:
623
+ # Multi-part: the work goes in as pieces, never output. Checked here so a mistake costs nothing.
624
+ if free:
625
+ raise RefereeError(f"{tier} has no free allowance; it's paid only. Nothing was sent.", 400, {})
626
+ if output is not None:
627
+ raise RefereeError(f"{tier} takes the work as pieces=[{{'name'?, 'text'}}], not output. Nothing was sent.", 400, {})
628
+ if not isinstance(pieces, (list, tuple)) or len(pieces) != n:
629
+ raise RefereeError(f"{tier} takes exactly {n} pieces: [{{'name'?, 'text'}}]. Nothing was sent.", 400, {})
630
+ body = {"task": task, "pieces": list(pieces), "title": title, "criteria": criteria, "panel": panel}
631
+ else:
632
+ if pieces is not None:
633
+ raise RefereeError(f"pieces are for the multi-part tiers (review-3x2, review-3x3); {tier} takes one output. Nothing was sent.", 400, {})
634
+ if not isinstance(output, str):
635
+ raise RefereeError(f"{tier} needs the output to review. Nothing was sent.", 400, {})
636
+ problem = self._long_input_problem(task, output, panel)
637
+ if problem:
638
+ raise RefereeError(f"{problem} {'Your free review wasn' + chr(39) + 't used.' if free else 'Nothing was charged.'}", 400, {})
639
+ body = {"task": task, "output": output, "title": title, "criteria": criteria, "panel": panel}
619
640
  self._tl.settlement = None
620
641
  try:
621
642
  r = self._call("POST", f"/free/{tier}" if free else f"/{tier}", body, pay=not free)
@@ -640,7 +661,7 @@ class AgentReferee:
640
661
  200,
641
662
  {"answer": r, "settlement": settlement},
642
663
  )
643
- check = self.verify_review(r["receipt"], task=task, output=output, tier=tier, panel=panel, funding="free" if free else None)
664
+ check = self.verify_review(r["receipt"], task=task, output=output, pieces=list(pieces) if n else None, tier=tier, panel=panel, funding="free" if free else None)
644
665
  if not free:
645
666
  p = (r["receipt"] or {}).get("payload") or {}
646
667
  wallet = getattr(self.payer, "wallet", None)
@@ -668,11 +689,12 @@ class AgentReferee:
668
689
  panel: Any = None,
669
690
  funding: Optional[str] = None,
670
691
  public_keys: Optional[Sequence[str]] = None,
692
+ pieces: Optional[List[Dict[str, Any]]] = None,
671
693
  ) -> Dict[str, Any]:
672
694
  """Check a sealed-review receipt: the service's signature plus everything :func:`verify_review_outcome`
673
- checks. Pass the task and output you hold. Returns ``{ok, problems, trusts}``."""
695
+ checks. Pass the task and output (or, for a multi-part review, the pieces) you hold. Returns ``{ok, problems, trusts}``."""
674
696
  trusted = self._trusted_keys(public_keys)
675
- res = verify_review_outcome(receipt, task=task, output=output, tier=tier, panel=panel, funding=funding)
697
+ res = verify_review_outcome(receipt, task=task, output=output, tier=tier, panel=panel, funding=funding, pieces=pieces)
676
698
  if not verify_signature(receipt, trusted):
677
699
  res["problems"].insert(0, "The receipt's signature doesn't check out against the service's key.")
678
700
  res["ok"] = False
@@ -13,7 +13,7 @@ import math
13
13
  import re
14
14
  from typing import Any, Dict, Iterable, List, Optional
15
15
 
16
- from ._canonical import _utf16_key, canonical_json, sha256_hex
16
+ from ._canonical import _utf16_key, canonical_json, sha256_hex, utf16_len
17
17
 
18
18
  __all__ = [
19
19
  "PUBLIC_KEY",
@@ -31,7 +31,7 @@ PUBLIC_KEY = "vM2GY6ZEYc/omRlIFrzu0TaMGtjHXQtchg9d7lPKkTY="
31
31
 
32
32
  REVIEW_VERDICTS = ["pass", "needs_changes", "fail", "cannot_assess"]
33
33
  JUDGE_TIERS = ["judge", "judge-2", "judge-3"]
34
- _REVIEW_SIZE = {"review": 1, "review-3": 3}
34
+ _REVIEW_SIZE = {"review": 1, "review-3": 3, "review-3x2": 3, "review-3x3": 3}
35
35
  _RPS_BEATS = {"rock": "scissors", "paper": "rock", "scissors": "paper"}
36
36
 
37
37
 
@@ -236,6 +236,84 @@ def panel_problem(panel: Any, models: List[str], selection: Any) -> Optional[str
236
236
  # ---------------------------------------------------------------------------------------------------------------
237
237
 
238
238
 
239
+ MULTI_FORMAT = "review-multi-v1"
240
+ #: Multi-part review tiers and how many pieces each takes. Three reviewers from three companies read every piece.
241
+ MULTI_PIECES = {"review-3x2": 2, "review-3x3": 3}
242
+
243
+ #: Receipt formats this client can check, by kind of receipt. Single-piece receipts have no ``receipt_format`` field;
244
+ #: multi-part reviews are ``review-multi-v1``. Any other format (``judge-multi-v1`` until this client learns it, or a
245
+ #: format on the wrong kind of receipt) is refused, never checked the old way: an old check could recompute the
246
+ #: verdict and miss what the new format changed.
247
+ KNOWN_RECEIPT_FORMATS: Dict[str, tuple] = {"review": (MULTI_FORMAT,), "match": ()}
248
+
249
+
250
+ def _format_problem(p: Any, kind: str = "match") -> Optional[str]:
251
+ known = KNOWN_RECEIPT_FORMATS.get(kind, ())
252
+ if isinstance(p, dict) and "receipt_format" in p and not (isinstance(p["receipt_format"], str) and p["receipt_format"] in known):
253
+ return (
254
+ f"This receipt uses the {_s(p['receipt_format'])[:60]} format, which this version of agent-referee-client "
255
+ "can't check, so nothing was confirmed. Update the client (pip install -U agent-referee-client)."
256
+ )
257
+ return None
258
+
259
+
260
+ def _is_int(v: Any) -> bool:
261
+ """A whole number as JavaScript's Number.isInteger sees it (31 or 31.0, never a bool)."""
262
+ return not isinstance(v, bool) and (isinstance(v, int) or (isinstance(v, float) and v.is_integer()))
263
+
264
+
265
+ def _check_pieces(p: Any, output: Optional[str], pieces: Any, problems: List[str]) -> None:
266
+ """The multi-part part of a ``review-multi-v1`` check: the receipt's piece list is well formed, ``pieces_sha256``
267
+ is the hash of it, there's no ``output_sha256``, and (when you pass the pieces you hold) each piece's name, sha256
268
+ and chars match, in order. Pieces are ``{"name"?: str, "text": str}``; a piece without a name is recorded as ""."""
269
+ n = MULTI_PIECES[_get(p, "tier")]
270
+ if isinstance(p, dict) and "output_sha256" in p:
271
+ problems.append("A multi-part receipt never has output_sha256; this one does.")
272
+ if output is not None:
273
+ problems.append("This is a multi-part review: check it with pieces, not output.")
274
+ recs = _get(p, "pieces")
275
+ if not isinstance(recs, list) or len(recs) != n:
276
+ problems.append(f"A {_get(p, 'tier')} receipt lists {n} pieces; this one lists {len(recs) if isinstance(recs, list) else 'none'}.")
277
+ return
278
+ for i, r in enumerate(recs):
279
+ ok = (
280
+ isinstance(r, dict)
281
+ and _same(_get(r, "index"), i + 1)
282
+ and isinstance(_get(r, "name"), str)
283
+ and isinstance(_get(r, "sha256"), str)
284
+ and re.fullmatch(r"[0-9a-f]{64}", _get(r, "sha256")) is not None
285
+ and _is_int(_get(r, "chars"))
286
+ and _get(r, "chars") > 0
287
+ )
288
+ if not ok:
289
+ problems.append(f"Piece {i + 1}'s record in the receipt is malformed.")
290
+ if not _same(sha256_hex(_canon(recs)), _get(p, "pieces_sha256")):
291
+ problems.append("pieces_sha256 doesn't match the receipt's list of pieces.")
292
+ if pieces is None:
293
+ return
294
+ if not isinstance(pieces, (list, tuple)) or len(pieces) != n:
295
+ problems.append(f"This review has {n} pieces; you passed {len(pieces) if isinstance(pieces, (list, tuple)) else 'something that is not a list'}.")
296
+ return
297
+ texts = [g.get("text") if isinstance(g, dict) else None for g in pieces]
298
+ hashes = [sha256_hex(t) if isinstance(t, str) else None for t in texts]
299
+ rec_hashes = [_s(_get(r, "sha256")) for r in recs]
300
+ if all(h is not None for h in hashes) and sorted(hashes) == sorted(rec_hashes) and hashes != rec_hashes:
301
+ problems.append("These are the review's pieces, but in a different order.")
302
+ return
303
+ for i, g in enumerate(pieces):
304
+ r = recs[i]
305
+ if hashes[i] is None:
306
+ problems.append(f"Piece {i + 1} you passed has no text.")
307
+ continue
308
+ if hashes[i] != _get(r, "sha256"):
309
+ problems.append(f"Piece {i + 1} is different from the one this review is about.")
310
+ elif not _same(utf16_len(texts[i]), _get(r, "chars")):
311
+ problems.append(f"Piece {i + 1}'s length in the receipt (chars) is wrong.")
312
+ name = g.get("name")
313
+ if not _same("" if name is None else name, _get(r, "name")):
314
+ problems.append(f"Piece {i + 1}'s name differs from the one in the receipt (names are part of pieces_sha256).")
315
+
316
+
239
317
  def verify_review_outcome(
240
318
  receipt: Any,
241
319
  task: Optional[str] = None,
@@ -243,9 +321,13 @@ def verify_review_outcome(
243
321
  tier: Optional[str] = None,
244
322
  panel: Any = None,
245
323
  funding: Optional[str] = None,
324
+ pieces: Optional[List[Dict[str, Any]]] = None,
246
325
  ) -> Dict[str, Any]:
247
326
  """Check a sealed-review receipt offline (not the signature: use :func:`verify_signature` for that).
248
327
 
328
+ For a multi-part review (``review-3x2``, ``review-3x3``; ``receipt_format: "review-multi-v1"``) pass ``pieces``
329
+ (the list of ``{"name"?, "text"}`` you hold, in order) instead of ``output``.
330
+
249
331
  Confirms it's a review (never a match receipt), that it's about exactly the ``task`` and ``output`` you pass
250
332
  (by SHA-256 of the exact text), that the reviewers are the ones you asked for (``panel``), that every vote
251
333
  comes from the committed reviewer, and that the verdict and tally recompute from the votes. Pass
@@ -261,9 +343,29 @@ def verify_review_outcome(
261
343
  ]
262
344
  if not _same(_get(p, "type"), "review"):
263
345
  return {"ok": False, "problems": ["Not a sealed-review receipt."], "trusts": trusts}
346
+ fp = _format_problem(p, "review")
347
+ if fp:
348
+ return {"ok": False, "problems": [fp], "trusts": trusts}
349
+ t = _get(p, "tier")
350
+ multi = _same(_get(p, "receipt_format"), MULTI_FORMAT)
351
+ is_multi_tier = isinstance(t, str) and t in MULTI_PIECES
352
+ if multi and not is_multi_tier:
353
+ return {"ok": False, "problems": [
354
+ f"A {MULTI_FORMAT} receipt must be for a multi-part tier (review-3x2 or review-3x3), not {_s(t)[:40]}."], "trusts": trusts}
355
+ if is_multi_tier and not multi:
356
+ return {"ok": False, "problems": [
357
+ f"A {t} receipt must say receipt_format {MULTI_FORMAT}; this one doesn't, so it can't be checked."], "trusts": trusts}
358
+ if not isinstance(t, str) or t not in _REVIEW_SIZE:
359
+ return {"ok": False, "problems": [
360
+ f"This client doesn't know the {_s(_get(p, 'tier'))[:40]} review tier, so nothing was confirmed. Update the "
361
+ "client (pip install -U agent-referee-client)."], "trusts": trusts}
264
362
  if tier and not _same(_get(p, "tier"), tier):
265
363
  problems.append(f"This review is {_s(_get(p, 'tier'))}, not {tier}.")
266
- if output is not None and not _same(sha256_hex(output), _get(p, "output_sha256")):
364
+ if multi:
365
+ _check_pieces(p, output, pieces, problems)
366
+ elif pieces is not None:
367
+ problems.append("This is a single-piece review: check it with output, not pieces.")
368
+ if not multi and output is not None and not _same(sha256_hex(output), _get(p, "output_sha256")):
267
369
  problems.append("This review is about a different output than the one you have.")
268
370
  if task is not None and not _same(sha256_hex(task), _get(p, "task_sha256")):
269
371
  problems.append("This review is for a different task than the one you have.")
@@ -289,6 +391,21 @@ def verify_review_outcome(
289
391
  total = _weighted_total(scores, criteria)
290
392
  if not _same(_get(v, "total"), total):
291
393
  problems.append(f"Vote {i + 1}'s weighted total doesn't match its scores.")
394
+ if multi:
395
+ if not _same(_get(reviewers, "decision_rule"), "majority"):
396
+ problems.append("A multi-part review is decided by majority; this receipt names another rule.")
397
+ if len({_company(m) for m in models}) != len(models):
398
+ problems.append("The reviewers aren't from three different AI companies.")
399
+ for i, v in enumerate(votes):
400
+ d = _get(v, "issues_dropped")
401
+ if not (_is_int(d) and d >= 0):
402
+ problems.append(f"Vote {i + 1} is missing issues_dropped (always present in a multi-part receipt).")
403
+ if _same(_get(p, "funding"), "free"):
404
+ problems.append("Multi-part reviews are paid only, but this receipt says it was free.")
405
+ if votes:
406
+ first = _get(votes[0], "verdict")
407
+ if not _same(_get(_get(p, "result"), "unanimous"), all(_same(_get(v, "verdict"), first) for v in votes)):
408
+ problems.append("The receipt's unanimous flag doesn't match the votes.")
292
409
  tally = {k: 0 for k in REVIEW_VERDICTS}
293
410
  for v in votes:
294
411
  verdict = _get(v, "verdict")
@@ -536,6 +653,9 @@ def verify_outcome(receipt: Any, seat: Any = None, acks: Optional[Iterable[Any]]
536
653
  trusts: List[str] = []
537
654
  if not _truthy(_get(p, "tier")) or not _truthy(_get(p, "outcome")):
538
655
  return {"ok": False, "recomputed": False, "problems": ["Not a receipt payload."], "trusts": trusts, "evidence": []}
656
+ fp = _format_problem(p)
657
+ if fp:
658
+ return {"ok": False, "recomputed": False, "problems": [fp], "trusts": trusts, "evidence": []}
539
659
  out = p["outcome"]
540
660
  proof = _nn(_get(p, "proof"), {})
541
661
 
@@ -677,6 +797,9 @@ def verify_series(receipts: Iterable[Any]) -> Dict[str, Any]:
677
797
  problems: List[str] = []
678
798
  if not ps:
679
799
  return {"ok": False, "problems": ["No receipts given."], "tally": None}
800
+ fps = [fp for fp in (_format_problem(x) for x in ps) if fp]
801
+ if fps:
802
+ return {"ok": False, "problems": fps[:1], "tally": None}
680
803
 
681
804
  def game_of(p: Any) -> Any:
682
805
  return _nn(_get(_get(p, "series"), "game"), 1)