agent-referee-client 0.1.1__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 (38) hide show
  1. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/CHANGELOG.md +16 -0
  2. {agent_referee_client-0.1.1/src/agent_referee_client.egg-info → agent_referee_client-0.2.0}/PKG-INFO +33 -4
  3. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/README.md +32 -3
  4. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/pyproject.toml +1 -1
  5. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/client.py +33 -11
  6. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/verify.py +106 -11
  7. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0/src/agent_referee_client.egg-info}/PKG-INFO +33 -4
  8. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/SOURCES.txt +2 -0
  9. agent_referee_client-0.2.0/tests/multi-review-vectors.json +1947 -0
  10. agent_referee_client-0.2.0/tests/test_multi.py +149 -0
  11. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/test_unit.py +18 -4
  12. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/LICENSE +0 -0
  13. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/MANIFEST.in +0 -0
  14. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/SECURITY.md +0 -0
  15. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/crewai_tool.py +0 -0
  16. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/demo_match.py +0 -0
  17. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/free_review.py +0 -0
  18. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/langgraph_tool.py +0 -0
  19. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/openai_agents_tool.py +0 -0
  20. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/paid_review.py +0 -0
  21. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/examples/verify_receipt.py +0 -0
  22. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/setup.cfg +0 -0
  23. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/__init__.py +0 -0
  24. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/_canonical.py +0 -0
  25. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/pay.py +0 -0
  26. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client/py.typed +0 -0
  27. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/dependency_links.txt +0 -0
  28. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/requires.txt +0 -0
  29. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/src/agent_referee_client.egg-info/top_level.txt +0 -0
  30. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/conftest.py +0 -0
  31. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/fixture_review.json +0 -0
  32. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/js/gen_vectors.mjs +0 -0
  33. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/js/mini_server.mjs +0 -0
  34. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/test_client_mini.py +0 -0
  35. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/test_readme.py +0 -0
  36. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/test_vectors.py +0 -0
  37. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/test_verify.py +0 -0
  38. {agent_referee_client-0.1.1 → agent_referee_client-0.2.0}/tests/vectors.json +0 -0
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
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
+
3
19
  ## 0.1.1 (2026-10-28)
4
20
 
5
21
  - **Receipts in a format this version doesn't know are refused, never passed.** The coming multi-part review and
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-referee-client
3
- Version: 0.1.1
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
6
  License-Expression: MIT
@@ -96,6 +96,35 @@ print(r["result"]["verdict"], r["check"]["ok"], r["payment"]["transaction"])
96
96
  refused before payment, and `"rotate"` leaves it out by itself.
97
97
  - **Timeouts:** the client waits up to 330 s, because a slow provider can stretch a review to about 300 s.
98
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
+
99
128
  ## Settle a tie between two agents (free demo)
100
129
 
101
130
  <!-- test -->
@@ -191,9 +220,9 @@ settlement.
191
220
 
192
221
  ## Receipt formats this version doesn't know
193
222
 
194
- New kinds of review and judging can bring new receipt formats. This version refuses any receipt with a
195
- `receipt_format` it doesn't know (`check["ok"]` is False and says to update the client), rather than checking it
196
- the old way. Update with `pip install -U agent-referee-client`.
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`.
197
226
 
198
227
  ## Framework examples
199
228
 
@@ -63,6 +63,35 @@ print(r["result"]["verdict"], r["check"]["ok"], r["payment"]["transaction"])
63
63
  refused before payment, and `"rotate"` leaves it out by itself.
64
64
  - **Timeouts:** the client waits up to 330 s, because a slow provider can stretch a review to about 300 s.
65
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
+
66
95
  ## Settle a tie between two agents (free demo)
67
96
 
68
97
  <!-- test -->
@@ -158,9 +187,9 @@ settlement.
158
187
 
159
188
  ## Receipt formats this version doesn't know
160
189
 
161
- New kinds of review and judging can bring new receipt formats. This version refuses any receipt with a
162
- `receipt_format` it doesn't know (`check["ok"]` is False and says to update the client), rather than checking it
163
- the old way. Update with `pip install -U agent-referee-client`.
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`.
164
193
 
165
194
  ## Framework examples
166
195
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "agent-referee-client"
7
- version = "0.1.1"
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
10
  license = "MIT"
@@ -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.1"
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,14 +236,20 @@ def panel_problem(panel: Any, models: List[str], selection: Any) -> Optional[str
236
236
  # ---------------------------------------------------------------------------------------------------------------
237
237
 
238
238
 
239
- #: Receipt formats this client can check. Today's receipts have no ``receipt_format`` field at all; the multi-part
240
- #: tiers (``review-multi-v1``, ``judge-multi-v1``) will add one. A receipt with any other format is refused, never
241
- #: checked the old way: an old check could recompute the verdict and miss what the new format changed.
242
- KNOWN_RECEIPT_FORMATS: tuple = ()
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}
243
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": ()}
244
248
 
245
- def _format_problem(p: Any) -> Optional[str]:
246
- if isinstance(p, dict) and "receipt_format" in p and p["receipt_format"] not in KNOWN_RECEIPT_FORMATS:
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):
247
253
  return (
248
254
  f"This receipt uses the {_s(p['receipt_format'])[:60]} format, which this version of agent-referee-client "
249
255
  "can't check, so nothing was confirmed. Update the client (pip install -U agent-referee-client)."
@@ -251,6 +257,63 @@ def _format_problem(p: Any) -> Optional[str]:
251
257
  return None
252
258
 
253
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
+
254
317
  def verify_review_outcome(
255
318
  receipt: Any,
256
319
  task: Optional[str] = None,
@@ -258,9 +321,13 @@ def verify_review_outcome(
258
321
  tier: Optional[str] = None,
259
322
  panel: Any = None,
260
323
  funding: Optional[str] = None,
324
+ pieces: Optional[List[Dict[str, Any]]] = None,
261
325
  ) -> Dict[str, Any]:
262
326
  """Check a sealed-review receipt offline (not the signature: use :func:`verify_signature` for that).
263
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
+
264
331
  Confirms it's a review (never a match receipt), that it's about exactly the ``task`` and ``output`` you pass
265
332
  (by SHA-256 of the exact text), that the reviewers are the ones you asked for (``panel``), that every vote
266
333
  comes from the committed reviewer, and that the verdict and tally recompute from the votes. Pass
@@ -276,16 +343,29 @@ def verify_review_outcome(
276
343
  ]
277
344
  if not _same(_get(p, "type"), "review"):
278
345
  return {"ok": False, "problems": ["Not a sealed-review receipt."], "trusts": trusts}
279
- fp = _format_problem(p)
346
+ fp = _format_problem(p, "review")
280
347
  if fp:
281
348
  return {"ok": False, "problems": [fp], "trusts": trusts}
282
- if not isinstance(_get(p, "tier"), str) or _get(p, "tier") not in _REVIEW_SIZE:
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:
283
359
  return {"ok": False, "problems": [
284
360
  f"This client doesn't know the {_s(_get(p, 'tier'))[:40]} review tier, so nothing was confirmed. Update the "
285
361
  "client (pip install -U agent-referee-client)."], "trusts": trusts}
286
362
  if tier and not _same(_get(p, "tier"), tier):
287
363
  problems.append(f"This review is {_s(_get(p, 'tier'))}, not {tier}.")
288
- 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")):
289
369
  problems.append("This review is about a different output than the one you have.")
290
370
  if task is not None and not _same(sha256_hex(task), _get(p, "task_sha256")):
291
371
  problems.append("This review is for a different task than the one you have.")
@@ -311,6 +391,21 @@ def verify_review_outcome(
311
391
  total = _weighted_total(scores, criteria)
312
392
  if not _same(_get(v, "total"), total):
313
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.")
314
409
  tally = {k: 0 for k in REVIEW_VERDICTS}
315
410
  for v in votes:
316
411
  verdict = _get(v, "verdict")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-referee-client
3
- Version: 0.1.1
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
6
  License-Expression: MIT
@@ -96,6 +96,35 @@ print(r["result"]["verdict"], r["check"]["ok"], r["payment"]["transaction"])
96
96
  refused before payment, and `"rotate"` leaves it out by itself.
97
97
  - **Timeouts:** the client waits up to 330 s, because a slow provider can stretch a review to about 300 s.
98
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
+
99
128
  ## Settle a tie between two agents (free demo)
100
129
 
101
130
  <!-- test -->
@@ -191,9 +220,9 @@ settlement.
191
220
 
192
221
  ## Receipt formats this version doesn't know
193
222
 
194
- New kinds of review and judging can bring new receipt formats. This version refuses any receipt with a
195
- `receipt_format` it doesn't know (`check["ok"]` is False and says to update the client), rather than checking it
196
- the old way. Update with `pip install -U agent-referee-client`.
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`.
197
226
 
198
227
  ## Framework examples
199
228
 
@@ -24,7 +24,9 @@ src/agent_referee_client.egg-info/requires.txt
24
24
  src/agent_referee_client.egg-info/top_level.txt
25
25
  tests/conftest.py
26
26
  tests/fixture_review.json
27
+ tests/multi-review-vectors.json
27
28
  tests/test_client_mini.py
29
+ tests/test_multi.py
28
30
  tests/test_readme.py
29
31
  tests/test_unit.py
30
32
  tests/test_vectors.py