agent-referee-client 0.2.0__tar.gz → 0.3.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.
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/CHANGELOG.md +16 -0
- {agent_referee_client-0.2.0/src/agent_referee_client.egg-info → agent_referee_client-0.3.0}/PKG-INFO +9 -3
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/README.md +8 -2
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/pyproject.toml +1 -1
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/client.py +33 -5
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/verify.py +132 -7
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0/src/agent_referee_client.egg-info}/PKG-INFO +9 -3
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client.egg-info/SOURCES.txt +2 -0
- agent_referee_client-0.3.0/tests/multi-judge-vectors.json +3082 -0
- agent_referee_client-0.3.0/tests/test_multi_judge.py +142 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_unit.py +10 -4
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/LICENSE +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/MANIFEST.in +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/SECURITY.md +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/crewai_tool.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/demo_match.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/free_review.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/langgraph_tool.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/openai_agents_tool.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/paid_review.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/examples/verify_receipt.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/setup.cfg +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/__init__.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/_canonical.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/pay.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/py.typed +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client.egg-info/dependency_links.txt +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client.egg-info/requires.txt +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client.egg-info/top_level.txt +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/conftest.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/fixture_review.json +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/js/gen_vectors.mjs +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/js/mini_server.mjs +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/multi-review-vectors.json +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_client_mini.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_multi.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_readme.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_vectors.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/test_verify.py +0 -0
- {agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/tests/vectors.json +0 -0
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (2026-10-29)
|
|
4
|
+
|
|
5
|
+
- **Multi-part judge matches (`judge-3x2`, `judge-3x3`).** `seat.submit([text1, text2])` sends a side's case as 2 or
|
|
6
|
+
3 pieces (strings, or `{"text": ...}`). A wrong number of pieces, an empty piece, or a single position on these
|
|
7
|
+
tiers (or pieces on `judge`, `judge-2`, `judge-3`) is refused before anything is sent. The seat keeps its pieces
|
|
8
|
+
(`seat.pieces`) so its check confirms the receipt holds exactly them.
|
|
9
|
+
- **`judge-multi-v1` receipts are checked**, not refused: `verify_outcome(receipt, pieces={seat: texts}, acks=...)`
|
|
10
|
+
confirms the judges' instruction version, that there's no `submission_sha256`, each side's piece records and
|
|
11
|
+
`pieces_sha256`, both sides' pieces in a judged match (only the submitting side's in a forfeit), three judges from
|
|
12
|
+
three AI companies, the majority winner and tally, and, given pieces, their count, order, SHA-256 and length. A
|
|
13
|
+
signed submit acknowledgment whose pieces differ from the receipt, or a side listed as forfeiting after its
|
|
14
|
+
submission was accepted, is reported as provable evidence. Tested against the server's 20 signed test vectors
|
|
15
|
+
(`tests/test_multi_judge.py`), with the same messages as the JS client 0.10.0.
|
|
16
|
+
- Still refused: unknown receipt formats, `judge-multi-v1` on `judge-3` (or any other tier), a multi-part judge tier
|
|
17
|
+
without `receipt_format`, and a review format on a match receipt.
|
|
18
|
+
|
|
3
19
|
## 0.2.0 (2026-10-28)
|
|
4
20
|
|
|
5
21
|
- **Multi-part reviews (`review-3x2`, `review-3x3`).** `ref.review(task, pieces=[{"name"?, "text"}, ...],
|
{agent_referee_client-0.2.0/src/agent_referee_client.egg-info → agent_referee_client-0.3.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-referee-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.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
|
|
@@ -160,6 +160,12 @@ limited to 20 per address per day, and marked `demo` inside every receipt.
|
|
|
160
160
|
| `rps-bo3` | Best of three | $0.02 |
|
|
161
161
|
| `draw` | Pick one of 2-20 options for 2-8 parties; a mediator pays once | $0.05 |
|
|
162
162
|
| `judge`, `judge-2`, `judge-3` | AI judges apply agreed rules (`seat.submit(position)`) | $0.10, $0.20, $0.35 |
|
|
163
|
+
| `judge-3x2`, `judge-3x3` | Like `judge-3`, but each side submits 2 or 3 pieces (`seat.submit([text1, text2])`, up to 6,000 characters each, no names) | $0.45, $0.60 |
|
|
164
|
+
|
|
165
|
+
On `judge-3x2` and `judge-3x3` the receipt (`receipt_format: "judge-multi-v1"`) has each side's piece fingerprints,
|
|
166
|
+
and your seat's check confirms it holds exactly the pieces you sent. To check one you were given, pass the pieces you
|
|
167
|
+
hold: `verify_outcome(receipt, pieces={"seller": [text1, text2]}, acks=acks)`. A forfeit receipt shows only the
|
|
168
|
+
pieces of the side that submitted.
|
|
163
169
|
|
|
164
170
|
The paid tiers need a payer, like reviews. The host of an invite match pays for both seats
|
|
165
171
|
(`create(..., host_pays="alpha")`); the guest calls `accept_invite(link)` and pays nothing.
|
|
@@ -221,8 +227,8 @@ settlement.
|
|
|
221
227
|
## Receipt formats this version doesn't know
|
|
222
228
|
|
|
223
229
|
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
|
|
225
|
-
|
|
230
|
+
reviews) and `judge-multi-v1` (multi-part judge matches), and refuses any other `receipt_format` (`check["ok"]` is
|
|
231
|
+
False and says to update the client), rather than checking it the old way. Update with `pip install -U agent-referee-client`.
|
|
226
232
|
|
|
227
233
|
## Framework examples
|
|
228
234
|
|
|
@@ -127,6 +127,12 @@ limited to 20 per address per day, and marked `demo` inside every receipt.
|
|
|
127
127
|
| `rps-bo3` | Best of three | $0.02 |
|
|
128
128
|
| `draw` | Pick one of 2-20 options for 2-8 parties; a mediator pays once | $0.05 |
|
|
129
129
|
| `judge`, `judge-2`, `judge-3` | AI judges apply agreed rules (`seat.submit(position)`) | $0.10, $0.20, $0.35 |
|
|
130
|
+
| `judge-3x2`, `judge-3x3` | Like `judge-3`, but each side submits 2 or 3 pieces (`seat.submit([text1, text2])`, up to 6,000 characters each, no names) | $0.45, $0.60 |
|
|
131
|
+
|
|
132
|
+
On `judge-3x2` and `judge-3x3` the receipt (`receipt_format: "judge-multi-v1"`) has each side's piece fingerprints,
|
|
133
|
+
and your seat's check confirms it holds exactly the pieces you sent. To check one you were given, pass the pieces you
|
|
134
|
+
hold: `verify_outcome(receipt, pieces={"seller": [text1, text2]}, acks=acks)`. A forfeit receipt shows only the
|
|
135
|
+
pieces of the side that submitted.
|
|
130
136
|
|
|
131
137
|
The paid tiers need a payer, like reviews. The host of an invite match pays for both seats
|
|
132
138
|
(`create(..., host_pays="alpha")`); the guest calls `accept_invite(link)` and pays nothing.
|
|
@@ -188,8 +194,8 @@ settlement.
|
|
|
188
194
|
## Receipt formats this version doesn't know
|
|
189
195
|
|
|
190
196
|
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
|
|
192
|
-
|
|
197
|
+
reviews) and `judge-multi-v1` (multi-part judge matches), and refuses any other `receipt_format` (`check["ok"]` is
|
|
198
|
+
False and says to update the client), rather than checking it the old way. Update with `pip install -U agent-referee-client`.
|
|
193
199
|
|
|
194
200
|
## Framework examples
|
|
195
201
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agent-referee-client"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.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"
|
{agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/client.py
RENAMED
|
@@ -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.
|
|
4
|
+
from :mod:`agent_referee_client.pay`. Mirrors the JavaScript client 0.10.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.
|
|
35
|
+
__version__ = "0.3.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.
|
|
@@ -46,7 +46,10 @@ JOIN_PATH = {
|
|
|
46
46
|
"judge": "/join/judge",
|
|
47
47
|
"judge-2": "/join/judge-2",
|
|
48
48
|
"judge-3": "/join/judge-3",
|
|
49
|
+
"judge-3x2": "/join/judge-3x2",
|
|
50
|
+
"judge-3x3": "/join/judge-3x3",
|
|
49
51
|
}
|
|
52
|
+
JUDGE_MULTI_PIECES = {"judge-3x2": 2, "judge-3x3": 3}
|
|
50
53
|
REVIEW_TIERS = ["review", "review-3", "review-3x2", "review-3x3"]
|
|
51
54
|
MULTI_PIECES = {"review-3x2": 2, "review-3x3": 3}
|
|
52
55
|
MOVES = ["rock", "paper", "scissors"]
|
|
@@ -707,6 +710,15 @@ class AgentReferee:
|
|
|
707
710
|
return verify_signature(doc, self._trusted_keys(public_keys))
|
|
708
711
|
|
|
709
712
|
|
|
713
|
+
# What JavaScript's String.prototype.trim() removes (the server checks pieces with it), so "only spaces" means the same
|
|
714
|
+
# thing here as on the service: Python's str.strip() also strips \x1c-\x1f and \x85 but keeps \ufeff.
|
|
715
|
+
_JS_WS = "\t\n\v\f\r \u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff"
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
def _js_trim(t: str) -> str:
|
|
719
|
+
return t.strip(_JS_WS)
|
|
720
|
+
|
|
721
|
+
|
|
710
722
|
class Seat:
|
|
711
723
|
"""One agent's seat in a match. Keep it (and its token) private to that agent."""
|
|
712
724
|
|
|
@@ -720,6 +732,8 @@ class Seat:
|
|
|
720
732
|
self.requested: Optional[Dict[str, Any]] = None
|
|
721
733
|
#: What this seat committed and revealed, per round (memory only). Save it if you check later elsewhere.
|
|
722
734
|
self.mine: List[Dict[str, Any]] = []
|
|
735
|
+
#: Multi-part judge tiers: the pieces this seat submitted (memory only), so its check confirms the receipt holds them.
|
|
736
|
+
self.pieces: Optional[List[str]] = None
|
|
723
737
|
#: The service's signed acknowledgment of each step this seat took. Keep them with the receipt.
|
|
724
738
|
self.acks: List[Dict[str, Any]] = []
|
|
725
739
|
|
|
@@ -756,10 +770,24 @@ class Seat:
|
|
|
756
770
|
st["acks"] = list(self.acks) # save these with the receipt: together they're your proof
|
|
757
771
|
return st
|
|
758
772
|
|
|
759
|
-
def submit(self, position:
|
|
773
|
+
def submit(self, position: Any, *, judge_retries: int = 2, retry_delay_s: float = 5.0) -> Dict[str, Any]:
|
|
760
774
|
"""Judge tiers: submit your position and wait for the verdict. If the judging fails (an AI provider is down,
|
|
761
|
-
say), it's retried for you, free, and verdicts already given are kept.
|
|
762
|
-
|
|
775
|
+
say), it's retried for you, free, and verdicts already given are kept.
|
|
776
|
+
|
|
777
|
+
On ``judge-3x2`` / ``judge-3x3`` the position is a list of 2 or 3 pieces (strings, or ``{"text": ...}``), with
|
|
778
|
+
no names. The seat keeps them (``seat.pieces``) so its check confirms the receipt holds exactly them."""
|
|
779
|
+
n = JUDGE_MULTI_PIECES.get(self.tier or "")
|
|
780
|
+
if n:
|
|
781
|
+
texts = [x if isinstance(x, str) else x.get("text") if isinstance(x, dict) else None for x in position] if isinstance(position, (list, tuple)) else None
|
|
782
|
+
if texts is None or len(texts) != n or not all(isinstance(t, str) and _js_trim(t) for t in texts):
|
|
783
|
+
raise RefereeError(f"{self.tier} takes your side as exactly {n} pieces: a list of strings (or of {{'text'}}). Nothing was sent.", 400, {})
|
|
784
|
+
body: Dict[str, Any] = {"pieces": [{"text": t} for t in texts]}
|
|
785
|
+
self.pieces = list(texts)
|
|
786
|
+
else:
|
|
787
|
+
if not isinstance(position, str):
|
|
788
|
+
raise RefereeError(f"{self.tier} takes your side as one position (a string). Nothing was sent.", 400, {})
|
|
789
|
+
body = {"position": position}
|
|
790
|
+
r = self._post("submit", body)
|
|
763
791
|
self._add_ack(r.get("ack"))
|
|
764
792
|
st = self.client.wait_for(self.match_id, lambda s: s.get("phase") == "done")
|
|
765
793
|
left = judge_retries
|
{agent_referee_client-0.2.0 → agent_referee_client-0.3.0}/src/agent_referee_client/verify.py
RENAMED
|
@@ -30,7 +30,11 @@ __all__ = [
|
|
|
30
30
|
PUBLIC_KEY = "vM2GY6ZEYc/omRlIFrzu0TaMGtjHXQtchg9d7lPKkTY="
|
|
31
31
|
|
|
32
32
|
REVIEW_VERDICTS = ["pass", "needs_changes", "fail", "cannot_assess"]
|
|
33
|
-
JUDGE_TIERS = ["judge", "judge-2", "judge-3"]
|
|
33
|
+
JUDGE_TIERS = ["judge", "judge-2", "judge-3", "judge-3x2", "judge-3x3"]
|
|
34
|
+
#: Multi-part judge tiers: how many pieces each side submits. Three judges from three companies read every piece.
|
|
35
|
+
JUDGE_MULTI_PIECES = {"judge-3x2": 2, "judge-3x3": 3}
|
|
36
|
+
JUDGE_FORMAT = "judge-multi-v1"
|
|
37
|
+
JUDGE_MULTI_FORMAT_VERSION = "agent-referee-judge-v5-multi"
|
|
34
38
|
_REVIEW_SIZE = {"review": 1, "review-3": 3, "review-3x2": 3, "review-3x3": 3}
|
|
35
39
|
_RPS_BEATS = {"rock": "scissors", "paper": "rock", "scissors": "paper"}
|
|
36
40
|
|
|
@@ -241,10 +245,10 @@ MULTI_FORMAT = "review-multi-v1"
|
|
|
241
245
|
MULTI_PIECES = {"review-3x2": 2, "review-3x3": 3}
|
|
242
246
|
|
|
243
247
|
#: 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
|
|
248
|
+
#: multi-part reviews are ``review-multi-v1`` and multi-part judge matches ``judge-multi-v1``. Any other format (or a
|
|
245
249
|
#: format on the wrong kind of receipt) is refused, never checked the old way: an old check could recompute the
|
|
246
250
|
#: verdict and miss what the new format changed.
|
|
247
|
-
KNOWN_RECEIPT_FORMATS: Dict[str, tuple] = {"review": (MULTI_FORMAT,), "match": ()}
|
|
251
|
+
KNOWN_RECEIPT_FORMATS: Dict[str, tuple] = {"review": (MULTI_FORMAT,), "match": (JUDGE_FORMAT,)}
|
|
248
252
|
|
|
249
253
|
|
|
250
254
|
def _format_problem(p: Any, kind: str = "match") -> Optional[str]:
|
|
@@ -515,6 +519,93 @@ def _criteria_pick(scores: Any, criteria: List[Dict[str, Any]]) -> Dict[str, Any
|
|
|
515
519
|
return {"totals": totals, "pick": pick}
|
|
516
520
|
|
|
517
521
|
|
|
522
|
+
def _piece_text(x: Any) -> Any:
|
|
523
|
+
return x if isinstance(x, str) else x.get("text") if isinstance(x, dict) else None
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def _check_judge_pieces(p: Any, given: List[Any], problems: List[str]) -> None:
|
|
527
|
+
"""The multi-part part of a ``judge-multi-v1`` check (see the JS client's checkJudgePieces, same messages).
|
|
528
|
+
``given`` is a list of (seat, texts) pairs: the pieces passed in, plus the seat's own (both are checked)."""
|
|
529
|
+
n = JUDGE_MULTI_PIECES[_get(p, "tier")]
|
|
530
|
+
proof = _nn(_get(p, "proof"), {})
|
|
531
|
+
out = _nn(_get(p, "outcome"), {})
|
|
532
|
+
judge = _nn(_get(proof, "judge"), {})
|
|
533
|
+
if isinstance(proof, dict) and "submission_sha256" in proof:
|
|
534
|
+
problems.append("A multi-part judge receipt never has proof.submission_sha256; this one does.")
|
|
535
|
+
if not _same(_get(judge, "format_version"), JUDGE_MULTI_FORMAT_VERSION):
|
|
536
|
+
problems.append(f"The judges' instructions should be {JUDGE_MULTI_FORMAT_VERSION}; this receipt says {_s(_get(judge, 'format_version'))[:60]}.")
|
|
537
|
+
parties = _jsort(x for x in _nn(_get(p, "parties"), []) if isinstance(x, str))
|
|
538
|
+
forfeited = _nn(_get(out, "forfeited"), [])
|
|
539
|
+
forfeited = forfeited if isinstance(forfeited, list) else []
|
|
540
|
+
by_forfeit = _truthy(_get(out, "by_forfeit"))
|
|
541
|
+
expect_sides = [s for s in parties if s not in forfeited] if by_forfeit else parties
|
|
542
|
+
pieces = _get(proof, "pieces")
|
|
543
|
+
pieces = pieces if isinstance(pieces, dict) else {}
|
|
544
|
+
hashes = _get(proof, "pieces_sha256")
|
|
545
|
+
hashes = hashes if isinstance(hashes, dict) else {}
|
|
546
|
+
sides = _jsort(pieces.keys())
|
|
547
|
+
if sides != expect_sides:
|
|
548
|
+
problems.append(
|
|
549
|
+
"A forfeit receipt must show the pieces of the side that submitted, and only those." if by_forfeit
|
|
550
|
+
else "A judged receipt must have both sides' pieces."
|
|
551
|
+
)
|
|
552
|
+
if _jsort(hashes.keys()) != sides:
|
|
553
|
+
problems.append("pieces_sha256 must name exactly the sides that have pieces.")
|
|
554
|
+
if by_forfeit:
|
|
555
|
+
# The service only signs a forfeit for a two-party match where one side submitted: that side wins, and the
|
|
556
|
+
# other is listed as forfeiting. The pieces show who submitted, so the winner and the forfeit list must match.
|
|
557
|
+
submitted = sides[0] if len(sides) == 1 else None
|
|
558
|
+
others = [s for s in parties if s != submitted]
|
|
559
|
+
if submitted is None or not _same(_get(out, "winner"), submitted) or _jsort(x for x in forfeited if isinstance(x, str)) != others or len(forfeited) != len(others):
|
|
560
|
+
problems.append("In a forfeit, the side that submitted must be the winner, and only the other side may be listed as forfeiting.")
|
|
561
|
+
for side in sides:
|
|
562
|
+
recs = pieces[side]
|
|
563
|
+
if not isinstance(recs, list) or len(recs) != n:
|
|
564
|
+
problems.append(f"{_s(side)} should have {n} pieces on {_s(_get(p, 'tier'))}; the receipt lists {len(recs) if isinstance(recs, list) else 'none'}.")
|
|
565
|
+
continue
|
|
566
|
+
for i, r in enumerate(recs):
|
|
567
|
+
ok = (
|
|
568
|
+
isinstance(r, dict)
|
|
569
|
+
and sorted(r.keys()) == ["chars", "index", "sha256"]
|
|
570
|
+
and _same(_get(r, "index"), i + 1)
|
|
571
|
+
and isinstance(_get(r, "sha256"), str)
|
|
572
|
+
and re.fullmatch(r"[0-9a-f]{64}", _get(r, "sha256")) is not None
|
|
573
|
+
and _is_int(_get(r, "chars"))
|
|
574
|
+
and _get(r, "chars") > 0
|
|
575
|
+
)
|
|
576
|
+
if not ok:
|
|
577
|
+
problems.append(f"{_s(side)}'s piece {i + 1} record in the receipt is malformed.")
|
|
578
|
+
if not _same(sha256_hex(_canon(recs)), _get(hashes, side)):
|
|
579
|
+
problems.append(f"{_s(side)}'s pieces_sha256 doesn't match its list of pieces.")
|
|
580
|
+
if not by_forfeit:
|
|
581
|
+
panel = _nn(_get(judge, "panel"), [])
|
|
582
|
+
models = [_s(_get(x, "model")) for x in panel] if isinstance(panel, list) else []
|
|
583
|
+
if len(models) != 3 or len({_company(m) for m in models}) != 3:
|
|
584
|
+
problems.append("The judges aren't three, from three different AI companies.")
|
|
585
|
+
for side, texts0 in given:
|
|
586
|
+
recs = pieces.get(side)
|
|
587
|
+
texts = [_piece_text(x) for x in texts0] if isinstance(texts0, (list, tuple)) else None
|
|
588
|
+
if not isinstance(recs, list):
|
|
589
|
+
problems.append(f"The receipt has no pieces for {_s(side)}.")
|
|
590
|
+
continue
|
|
591
|
+
if texts is None or len(texts) != n:
|
|
592
|
+
problems.append(f"{_s(side)} has {n} pieces on {_s(_get(p, 'tier'))}; you passed {len(texts) if texts is not None else 'something that is not a list'}.")
|
|
593
|
+
continue
|
|
594
|
+
if any(not isinstance(x, str) for x in texts):
|
|
595
|
+
problems.append(f"A piece you passed for {_s(side)} has no text.")
|
|
596
|
+
continue
|
|
597
|
+
hs = [sha256_hex(x) for x in texts]
|
|
598
|
+
rec_hs = [_s(_get(r, "sha256")) for r in recs]
|
|
599
|
+
if sorted(hs) == sorted(rec_hs) and hs != rec_hs:
|
|
600
|
+
problems.append(f"These are {_s(side)}'s pieces, but in a different order.")
|
|
601
|
+
continue
|
|
602
|
+
for i, h in enumerate(hs):
|
|
603
|
+
if h != _get(recs[i], "sha256"):
|
|
604
|
+
problems.append(f"{_s(side)}'s piece {i + 1} is different from the one in the receipt.")
|
|
605
|
+
elif not _same(utf16_len(texts[i]), _get(recs[i], "chars")):
|
|
606
|
+
problems.append(f"{_s(side)}'s piece {i + 1} length in the receipt (chars) is wrong.")
|
|
607
|
+
|
|
608
|
+
|
|
518
609
|
def _check_judge_decision(p: Any, problems: List[str], trusts: List[str]) -> None:
|
|
519
610
|
out = _nn(_get(p, "outcome"), {})
|
|
520
611
|
judge = _nn(_get(_get(p, "proof"), "judge"), {})
|
|
@@ -628,9 +719,17 @@ def find_contradictions(receipt: Any, acks: Iterable[Any] = ()) -> List[Dict[str
|
|
|
628
719
|
elif _same(step, "submit"):
|
|
629
720
|
if seat in forfeited:
|
|
630
721
|
flag(f"{_s(seat)} is listed as forfeiting after the service accepted its submission.")
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
722
|
+
if _same(_get(a, "receipt_format"), JUDGE_FORMAT) or _same(_get(p, "receipt_format"), JUDGE_FORMAT):
|
|
723
|
+
# Multi-part judge tiers: the ack names the side's pieces; the receipt must show exactly those.
|
|
724
|
+
recs = _get(_get(proof, "pieces"), seat)
|
|
725
|
+
if recs is UNDEF or recs is None:
|
|
726
|
+
flag(f"{_s(seat)}'s accepted pieces are missing from the receipt.")
|
|
727
|
+
elif _canon(recs) != _canon(_nn(_get(a, "pieces"), None)) or not _same(_get(_get(proof, "pieces_sha256"), seat), _get(a, "pieces_sha256")):
|
|
728
|
+
flag(f"{_s(seat)}'s submission was changed.")
|
|
729
|
+
else:
|
|
730
|
+
h = _get(_get(proof, "submission_sha256"), seat)
|
|
731
|
+
if _truthy(h) and not _same(h, _get(a, "position_sha256")):
|
|
732
|
+
flag(f"{_s(seat)}'s submission was changed.")
|
|
634
733
|
elif _same(step, "join"):
|
|
635
734
|
paid = _get(_get(p, "paid_by"), seat)
|
|
636
735
|
if _truthy(paid) and _truthy(_get(a, "paid_by")) and not _same(paid, a["paid_by"]):
|
|
@@ -638,7 +737,9 @@ def find_contradictions(receipt: Any, acks: Iterable[Any] = ()) -> List[Dict[str
|
|
|
638
737
|
return out
|
|
639
738
|
|
|
640
739
|
|
|
641
|
-
def verify_outcome(
|
|
740
|
+
def verify_outcome(
|
|
741
|
+
receipt: Any, seat: Any = None, acks: Optional[Iterable[Any]] = None, pieces: Optional[Dict[str, List[Any]]] = None
|
|
742
|
+
) -> Dict[str, Any]:
|
|
642
743
|
"""Re-derive a match receipt's result yourself, without trusting the service's arithmetic. No network.
|
|
643
744
|
|
|
644
745
|
Checks every reveal against its commitment, then recomputes the winner (or picked option) the way the service
|
|
@@ -646,6 +747,10 @@ def verify_outcome(receipt: Any, seat: Any = None, acks: Optional[Iterable[Any]]
|
|
|
646
747
|
committed and revealed, that it describes the match you agreed to, and that none of the service's signed step
|
|
647
748
|
acknowledgments contradict it. Doesn't check the signature: use :func:`verify_signature` too.
|
|
648
749
|
|
|
750
|
+
For a multi-part judge match (``judge-3x2``, ``judge-3x3``; ``receipt_format: "judge-multi-v1"``) pass ``pieces``,
|
|
751
|
+
``{seat: [text, ...]}`` for the sides whose pieces you hold, to confirm the receipt holds exactly them. A seat that
|
|
752
|
+
submitted pieces checks its own.
|
|
753
|
+
|
|
649
754
|
Returns ``{"ok", "recomputed", "problems", "trusts", "evidence"}``.
|
|
650
755
|
"""
|
|
651
756
|
p = _payload(receipt)
|
|
@@ -656,6 +761,15 @@ def verify_outcome(receipt: Any, seat: Any = None, acks: Optional[Iterable[Any]]
|
|
|
656
761
|
fp = _format_problem(p)
|
|
657
762
|
if fp:
|
|
658
763
|
return {"ok": False, "recomputed": False, "problems": [fp], "trusts": trusts, "evidence": []}
|
|
764
|
+
multi_judge = _same(_get(p, "receipt_format"), JUDGE_FORMAT)
|
|
765
|
+
t = _get(p, "tier")
|
|
766
|
+
is_mj_tier = isinstance(t, str) and t in JUDGE_MULTI_PIECES
|
|
767
|
+
if multi_judge and not is_mj_tier:
|
|
768
|
+
return {"ok": False, "recomputed": False, "problems": [
|
|
769
|
+
f"A {JUDGE_FORMAT} receipt must be for a multi-part judge tier (judge-3x2 or judge-3x3), not {_s(t)[:40]}."], "trusts": trusts, "evidence": []}
|
|
770
|
+
if is_mj_tier and not multi_judge:
|
|
771
|
+
return {"ok": False, "recomputed": False, "problems": [
|
|
772
|
+
f"A {t} receipt must say receipt_format {JUDGE_FORMAT}; this one doesn't, so it can't be checked."], "trusts": trusts, "evidence": []}
|
|
659
773
|
out = p["outcome"]
|
|
660
774
|
proof = _nn(_get(p, "proof"), {})
|
|
661
775
|
|
|
@@ -724,6 +838,17 @@ def verify_outcome(receipt: Any, seat: Any = None, acks: Optional[Iterable[Any]]
|
|
|
724
838
|
|
|
725
839
|
tier = _get(p, "tier")
|
|
726
840
|
if tier in JUDGE_TIERS:
|
|
841
|
+
if multi_judge:
|
|
842
|
+
given: List[Any] = []
|
|
843
|
+
if pieces is not None:
|
|
844
|
+
if not isinstance(pieces, dict):
|
|
845
|
+
problems.append('pieces must be by seat: { "seat": ["text 1", "text 2"] }.')
|
|
846
|
+
else:
|
|
847
|
+
given.extend(pieces.items())
|
|
848
|
+
mine = getattr(me, "pieces", None) if me is not None else None
|
|
849
|
+
if mine:
|
|
850
|
+
given.append((me.seat, mine))
|
|
851
|
+
_check_judge_pieces(p, given, problems)
|
|
727
852
|
if not _truthy(_get(out, "by_forfeit")):
|
|
728
853
|
_check_judge_decision(p, problems, trusts)
|
|
729
854
|
return done(False)
|
{agent_referee_client-0.2.0 → agent_referee_client-0.3.0/src/agent_referee_client.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-referee-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.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
|
|
@@ -160,6 +160,12 @@ limited to 20 per address per day, and marked `demo` inside every receipt.
|
|
|
160
160
|
| `rps-bo3` | Best of three | $0.02 |
|
|
161
161
|
| `draw` | Pick one of 2-20 options for 2-8 parties; a mediator pays once | $0.05 |
|
|
162
162
|
| `judge`, `judge-2`, `judge-3` | AI judges apply agreed rules (`seat.submit(position)`) | $0.10, $0.20, $0.35 |
|
|
163
|
+
| `judge-3x2`, `judge-3x3` | Like `judge-3`, but each side submits 2 or 3 pieces (`seat.submit([text1, text2])`, up to 6,000 characters each, no names) | $0.45, $0.60 |
|
|
164
|
+
|
|
165
|
+
On `judge-3x2` and `judge-3x3` the receipt (`receipt_format: "judge-multi-v1"`) has each side's piece fingerprints,
|
|
166
|
+
and your seat's check confirms it holds exactly the pieces you sent. To check one you were given, pass the pieces you
|
|
167
|
+
hold: `verify_outcome(receipt, pieces={"seller": [text1, text2]}, acks=acks)`. A forfeit receipt shows only the
|
|
168
|
+
pieces of the side that submitted.
|
|
163
169
|
|
|
164
170
|
The paid tiers need a payer, like reviews. The host of an invite match pays for both seats
|
|
165
171
|
(`create(..., host_pays="alpha")`); the guest calls `accept_invite(link)` and pays nothing.
|
|
@@ -221,8 +227,8 @@ settlement.
|
|
|
221
227
|
## Receipt formats this version doesn't know
|
|
222
228
|
|
|
223
229
|
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
|
|
225
|
-
|
|
230
|
+
reviews) and `judge-multi-v1` (multi-part judge matches), and refuses any other `receipt_format` (`check["ok"]` is
|
|
231
|
+
False and says to update the client), rather than checking it the old way. Update with `pip install -U agent-referee-client`.
|
|
226
232
|
|
|
227
233
|
## Framework examples
|
|
228
234
|
|
|
@@ -24,9 +24,11 @@ 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-judge-vectors.json
|
|
27
28
|
tests/multi-review-vectors.json
|
|
28
29
|
tests/test_client_mini.py
|
|
29
30
|
tests/test_multi.py
|
|
31
|
+
tests/test_multi_judge.py
|
|
30
32
|
tests/test_readme.py
|
|
31
33
|
tests/test_unit.py
|
|
32
34
|
tests/test_vectors.py
|