agent-rating-protocol 0.1.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_rating_protocol-0.1.0/LICENSE +121 -0
- agent_rating_protocol-0.1.0/PKG-INFO +225 -0
- agent_rating_protocol-0.1.0/README.md +194 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/__init__.py +31 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/blind.py +281 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/cli.py +263 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/query.py +168 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/rating.py +198 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/store.py +169 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol/weight.py +105 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/PKG-INFO +225 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/SOURCES.txt +22 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/dependency_links.txt +1 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/entry_points.txt +2 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/requires.txt +7 -0
- agent_rating_protocol-0.1.0/agent_rating_protocol.egg-info/top_level.txt +1 -0
- agent_rating_protocol-0.1.0/pyproject.toml +43 -0
- agent_rating_protocol-0.1.0/setup.cfg +4 -0
- agent_rating_protocol-0.1.0/setup.py +4 -0
- agent_rating_protocol-0.1.0/tests/test_blind.py +173 -0
- agent_rating_protocol-0.1.0/tests/test_query.py +141 -0
- agent_rating_protocol-0.1.0/tests/test_rating.py +171 -0
- agent_rating_protocol-0.1.0/tests/test_store.py +131 -0
- agent_rating_protocol-0.1.0/tests/test_weight.py +126 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including
|
|
45
|
+
the original version of the Work and any modifications or additions
|
|
46
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
47
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
48
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
49
|
+
the copyright owner.
|
|
50
|
+
|
|
51
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
52
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
53
|
+
subsequently incorporated within the Work.
|
|
54
|
+
|
|
55
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
56
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
57
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
58
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
59
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
60
|
+
Work and such Derivative Works in Source or Object form.
|
|
61
|
+
|
|
62
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
63
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
64
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
65
|
+
(except as stated in this section) patent license to make, have made,
|
|
66
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
67
|
+
where such license applies only to those patent claims licensable
|
|
68
|
+
by such Contributor that are necessarily infringed by their
|
|
69
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
70
|
+
with the Work to which such Contribution(s) was submitted.
|
|
71
|
+
|
|
72
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
73
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
74
|
+
modifications, and in Source or Object form, provided that You
|
|
75
|
+
meet the following conditions:
|
|
76
|
+
|
|
77
|
+
(a) You must give any other recipients of the Work or
|
|
78
|
+
Derivative Works a copy of this License; and
|
|
79
|
+
|
|
80
|
+
(b) You must cause any modified files to carry prominent notices
|
|
81
|
+
stating that You changed the files; and
|
|
82
|
+
|
|
83
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
84
|
+
that You distribute, all copyright, patent, trademark, and
|
|
85
|
+
attribution notices from the Source form of the Work; and
|
|
86
|
+
|
|
87
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
88
|
+
distribution, then any Derivative Works that You distribute must
|
|
89
|
+
include a readable copy of the attribution notices contained
|
|
90
|
+
within such NOTICE file.
|
|
91
|
+
|
|
92
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
93
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
94
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
95
|
+
this License, without any additional terms or conditions.
|
|
96
|
+
|
|
97
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
98
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
99
|
+
|
|
100
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
101
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
102
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
103
|
+
|
|
104
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
105
|
+
any Contributor be liable to You for damages.
|
|
106
|
+
|
|
107
|
+
9. Accepting Warranty or Additional Liability.
|
|
108
|
+
|
|
109
|
+
Copyright 2026 AB Support LLC
|
|
110
|
+
|
|
111
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
112
|
+
you may not use this file except in compliance with the License.
|
|
113
|
+
You may obtain a copy of the License at
|
|
114
|
+
|
|
115
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
116
|
+
|
|
117
|
+
Unless required by applicable law or agreed to in writing, software
|
|
118
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
119
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
120
|
+
See the License for the specific language governing permissions and
|
|
121
|
+
limitations under the License.
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-rating-protocol
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Decentralized agent reputation protocol — multidimensional ratings with bilateral blind commit-reveal and Sybil-resistant weighting
|
|
5
|
+
Author-email: AB Support <info@vibeagentmaking.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://vibeagentmaking.com
|
|
8
|
+
Project-URL: Repository, https://github.com/brycebostick/agent-rating-protocol
|
|
9
|
+
Project-URL: Whitepaper, https://vibeagentmaking.com/whitepaper.html
|
|
10
|
+
Keywords: agent,rating,reputation,decentralized,provenance,trust
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: coc
|
|
26
|
+
Requires-Dist: chain-of-consciousness>=0.1.0; extra == "coc"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# Agent Rating Protocol
|
|
33
|
+
|
|
34
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
35
|
+
[](https://www.python.org/downloads/)
|
|
36
|
+
|
|
37
|
+
Decentralized agent reputation protocol — multidimensional ratings with bilateral blind commit-reveal and Sybil-resistant weighting. Companion to the [Chain of Consciousness](https://vibeagentmaking.com/whitepaper.html) specification.
|
|
38
|
+
|
|
39
|
+
## Quickstart
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from agent_rating_protocol import RatingRecord, RatingStore, get_reputation
|
|
43
|
+
|
|
44
|
+
store = RatingStore("ratings.jsonl")
|
|
45
|
+
store.append_rating(RatingRecord(rater_id="agent-a", ratee_id="agent-b", reliability=85, accuracy=90, rater_chain_age_days=100, rater_total_ratings_given=50))
|
|
46
|
+
print(get_reputation(store, "agent-b"))
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install agent-rating-protocol
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
With optional Chain of Consciousness integration:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install agent-rating-protocol[coc]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
- **5-dimension rating** — reliability, accuracy, latency, protocol_compliance, cost_efficiency (1-100 scale)
|
|
64
|
+
- **Bilateral blind protocol** — commit-reveal ensures neither party sees the other's rating until both submit
|
|
65
|
+
- **Sybil-resistant weighting** — W = log2(1 + age) × log2(1 + ratings_given). Score received never affects weight.
|
|
66
|
+
- **Append-only store** — JSONL-backed, tamper-evident via SHA-256 record hashes
|
|
67
|
+
- **Rolling windows** — default 365-day window prevents stale reputation
|
|
68
|
+
- **Confidence scoring** — new agents show high uncertainty, not zero trust
|
|
69
|
+
- **Zero required dependencies** — stdlib only for core. Optional CoC integration.
|
|
70
|
+
- **Identity-agnostic** — works with DIDs, URIs, ERC-8004, or plain strings
|
|
71
|
+
|
|
72
|
+
## API Reference
|
|
73
|
+
|
|
74
|
+
### RatingRecord
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from agent_rating_protocol import RatingRecord
|
|
78
|
+
|
|
79
|
+
record = RatingRecord(
|
|
80
|
+
rater_id="did:example:alice",
|
|
81
|
+
ratee_id="did:example:bob",
|
|
82
|
+
interaction_id="task-uuid-here",
|
|
83
|
+
reliability=85,
|
|
84
|
+
accuracy=90,
|
|
85
|
+
latency=75,
|
|
86
|
+
protocol_compliance=95,
|
|
87
|
+
cost_efficiency=70,
|
|
88
|
+
rater_chain_age_days=365,
|
|
89
|
+
rater_total_ratings_given=100,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
record.to_dict() # JSON-serializable dict
|
|
93
|
+
record.to_json() # JSON string
|
|
94
|
+
record.verify_hash() # True if record_hash is valid
|
|
95
|
+
record.compute_hash() # Recompute SHA-256 hash
|
|
96
|
+
|
|
97
|
+
RatingRecord.from_dict(d) # Deserialize from dict
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### RatingStore
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from agent_rating_protocol import RatingStore
|
|
104
|
+
|
|
105
|
+
store = RatingStore("ratings.jsonl")
|
|
106
|
+
|
|
107
|
+
store.append_rating(record) # Append (validates hash first)
|
|
108
|
+
store.get_ratings_for("agent-b") # Ratings received by agent
|
|
109
|
+
store.get_ratings_by("agent-a") # Ratings submitted by agent
|
|
110
|
+
store.get_rating("uuid") # Look up by rating_id
|
|
111
|
+
store.count() # Total ratings
|
|
112
|
+
store.stats() # Summary statistics
|
|
113
|
+
store.agents() # Per-agent rating counts
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Reputation Queries
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from agent_rating_protocol import get_reputation
|
|
120
|
+
|
|
121
|
+
# All dimensions
|
|
122
|
+
result = get_reputation(store, "agent-b", window_days=365)
|
|
123
|
+
# {'agent_id': 'agent-b', 'num_ratings': 5, 'confidence': 0.3333, 'scores': {...}}
|
|
124
|
+
|
|
125
|
+
# Single dimension
|
|
126
|
+
result = get_reputation(store, "agent-b", dimension="reliability")
|
|
127
|
+
# {'agent_id': 'agent-b', 'score': 85.0, 'dimension': 'reliability', ...}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Bilateral Blind Protocol
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from agent_rating_protocol import BlindExchange, generate_nonce
|
|
134
|
+
|
|
135
|
+
exchange = BlindExchange(interaction_id="task-001")
|
|
136
|
+
|
|
137
|
+
# Agent A commits
|
|
138
|
+
nonce_a = generate_nonce()
|
|
139
|
+
exchange.submit_commitment("agent-a", rating_a.to_dict(), nonce_a)
|
|
140
|
+
|
|
141
|
+
# Agent B commits
|
|
142
|
+
nonce_b = generate_nonce()
|
|
143
|
+
exchange.submit_commitment("agent-b", rating_b.to_dict(), nonce_b)
|
|
144
|
+
|
|
145
|
+
# Both reveal (triggered when both committed)
|
|
146
|
+
exchange.reveal_rating("agent-a", rating_a.to_dict(), nonce_a)
|
|
147
|
+
exchange.reveal_rating("agent-b", rating_b.to_dict(), nonce_b)
|
|
148
|
+
|
|
149
|
+
# Get simultaneous results
|
|
150
|
+
rating_a_result, rating_b_result = exchange.get_results()
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Weight Calculation
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from agent_rating_protocol import rater_weight, confidence
|
|
157
|
+
|
|
158
|
+
w = rater_weight(chain_age_days=365, total_ratings_given=100) # ≈ 56.4
|
|
159
|
+
c = confidence(num_ratings=50) # ≈ 0.833
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## CLI Reference
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Submit a rating
|
|
166
|
+
agent-rating rate agent-b --rater agent-a --reliability 85 --accuracy 90
|
|
167
|
+
|
|
168
|
+
# Query reputation
|
|
169
|
+
agent-rating query agent-b
|
|
170
|
+
agent-rating query agent-b --dimension reliability --window 180
|
|
171
|
+
|
|
172
|
+
# Verify a rating hash
|
|
173
|
+
agent-rating verify <rating-uuid>
|
|
174
|
+
|
|
175
|
+
# Store statistics
|
|
176
|
+
agent-rating status
|
|
177
|
+
|
|
178
|
+
# All commands support --json for machine-readable output
|
|
179
|
+
agent-rating query agent-b --json
|
|
180
|
+
|
|
181
|
+
# Custom store path
|
|
182
|
+
agent-rating --store /path/to/ratings.jsonl status
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## CoC Integration
|
|
186
|
+
|
|
187
|
+
If [chain-of-consciousness](https://pypi.org/project/chain-of-consciousness/) is installed and the `COC_CHAIN_FILE` environment variable is set, ratings are automatically recorded as `RATING_SUBMITTED` chain entries:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
export COC_CHAIN_FILE=chain.jsonl
|
|
191
|
+
agent-rating rate agent-b --rater agent-a --reliability 85
|
|
192
|
+
# -> Rating stored in ratings.jsonl AND recorded in chain.jsonl
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Rating Dimensions
|
|
196
|
+
|
|
197
|
+
| Dimension | Measures | Scale |
|
|
198
|
+
|-----------|----------|-------|
|
|
199
|
+
| reliability | Task completion, uptime | 1-100 |
|
|
200
|
+
| accuracy | Output correctness | 1-100 |
|
|
201
|
+
| latency | Response speed vs. complexity | 1-100 |
|
|
202
|
+
| protocol_compliance | Message format, handshake correctness | 1-100 |
|
|
203
|
+
| cost_efficiency | Resource usage vs. value | 1-100 |
|
|
204
|
+
|
|
205
|
+
Score buckets: 1-20 poor, 21-40 below average, 41-60 average, 61-80 good, 81-100 excellent.
|
|
206
|
+
|
|
207
|
+
## Weight Formula
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
W(rater) = log2(1 + chain_age_days) × log2(1 + total_ratings_given)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Governance weight equals rating weight by design — both derived from tenure and participation, never from score received.
|
|
214
|
+
|
|
215
|
+
## Design Specification
|
|
216
|
+
|
|
217
|
+
Full protocol design, game theory analysis, and governance model: see the [Agent Rating System Design](https://vibeagentmaking.com/whitepaper.html) specification.
|
|
218
|
+
|
|
219
|
+
## Security Disclaimer (VAM-SEC v1.0)
|
|
220
|
+
|
|
221
|
+
This software is provided for research and development purposes. The rating protocol includes cryptographic commitments (SHA-256) and a bilateral blind protocol, but has NOT been formally audited by a third-party security firm. Before using in production environments where reputation scores influence high-stakes decisions, conduct an independent security review. The append-only store provides tamper evidence but not tamper prevention — an attacker with filesystem access can modify the JSONL file directly. For stronger guarantees, use CoC integration with external anchoring (OTS + TSA).
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Agent Rating Protocol
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
|
|
6
|
+
Decentralized agent reputation protocol — multidimensional ratings with bilateral blind commit-reveal and Sybil-resistant weighting. Companion to the [Chain of Consciousness](https://vibeagentmaking.com/whitepaper.html) specification.
|
|
7
|
+
|
|
8
|
+
## Quickstart
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from agent_rating_protocol import RatingRecord, RatingStore, get_reputation
|
|
12
|
+
|
|
13
|
+
store = RatingStore("ratings.jsonl")
|
|
14
|
+
store.append_rating(RatingRecord(rater_id="agent-a", ratee_id="agent-b", reliability=85, accuracy=90, rater_chain_age_days=100, rater_total_ratings_given=50))
|
|
15
|
+
print(get_reputation(store, "agent-b"))
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install agent-rating-protocol
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
With optional Chain of Consciousness integration:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install agent-rating-protocol[coc]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **5-dimension rating** — reliability, accuracy, latency, protocol_compliance, cost_efficiency (1-100 scale)
|
|
33
|
+
- **Bilateral blind protocol** — commit-reveal ensures neither party sees the other's rating until both submit
|
|
34
|
+
- **Sybil-resistant weighting** — W = log2(1 + age) × log2(1 + ratings_given). Score received never affects weight.
|
|
35
|
+
- **Append-only store** — JSONL-backed, tamper-evident via SHA-256 record hashes
|
|
36
|
+
- **Rolling windows** — default 365-day window prevents stale reputation
|
|
37
|
+
- **Confidence scoring** — new agents show high uncertainty, not zero trust
|
|
38
|
+
- **Zero required dependencies** — stdlib only for core. Optional CoC integration.
|
|
39
|
+
- **Identity-agnostic** — works with DIDs, URIs, ERC-8004, or plain strings
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
### RatingRecord
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from agent_rating_protocol import RatingRecord
|
|
47
|
+
|
|
48
|
+
record = RatingRecord(
|
|
49
|
+
rater_id="did:example:alice",
|
|
50
|
+
ratee_id="did:example:bob",
|
|
51
|
+
interaction_id="task-uuid-here",
|
|
52
|
+
reliability=85,
|
|
53
|
+
accuracy=90,
|
|
54
|
+
latency=75,
|
|
55
|
+
protocol_compliance=95,
|
|
56
|
+
cost_efficiency=70,
|
|
57
|
+
rater_chain_age_days=365,
|
|
58
|
+
rater_total_ratings_given=100,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
record.to_dict() # JSON-serializable dict
|
|
62
|
+
record.to_json() # JSON string
|
|
63
|
+
record.verify_hash() # True if record_hash is valid
|
|
64
|
+
record.compute_hash() # Recompute SHA-256 hash
|
|
65
|
+
|
|
66
|
+
RatingRecord.from_dict(d) # Deserialize from dict
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### RatingStore
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agent_rating_protocol import RatingStore
|
|
73
|
+
|
|
74
|
+
store = RatingStore("ratings.jsonl")
|
|
75
|
+
|
|
76
|
+
store.append_rating(record) # Append (validates hash first)
|
|
77
|
+
store.get_ratings_for("agent-b") # Ratings received by agent
|
|
78
|
+
store.get_ratings_by("agent-a") # Ratings submitted by agent
|
|
79
|
+
store.get_rating("uuid") # Look up by rating_id
|
|
80
|
+
store.count() # Total ratings
|
|
81
|
+
store.stats() # Summary statistics
|
|
82
|
+
store.agents() # Per-agent rating counts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Reputation Queries
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from agent_rating_protocol import get_reputation
|
|
89
|
+
|
|
90
|
+
# All dimensions
|
|
91
|
+
result = get_reputation(store, "agent-b", window_days=365)
|
|
92
|
+
# {'agent_id': 'agent-b', 'num_ratings': 5, 'confidence': 0.3333, 'scores': {...}}
|
|
93
|
+
|
|
94
|
+
# Single dimension
|
|
95
|
+
result = get_reputation(store, "agent-b", dimension="reliability")
|
|
96
|
+
# {'agent_id': 'agent-b', 'score': 85.0, 'dimension': 'reliability', ...}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Bilateral Blind Protocol
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from agent_rating_protocol import BlindExchange, generate_nonce
|
|
103
|
+
|
|
104
|
+
exchange = BlindExchange(interaction_id="task-001")
|
|
105
|
+
|
|
106
|
+
# Agent A commits
|
|
107
|
+
nonce_a = generate_nonce()
|
|
108
|
+
exchange.submit_commitment("agent-a", rating_a.to_dict(), nonce_a)
|
|
109
|
+
|
|
110
|
+
# Agent B commits
|
|
111
|
+
nonce_b = generate_nonce()
|
|
112
|
+
exchange.submit_commitment("agent-b", rating_b.to_dict(), nonce_b)
|
|
113
|
+
|
|
114
|
+
# Both reveal (triggered when both committed)
|
|
115
|
+
exchange.reveal_rating("agent-a", rating_a.to_dict(), nonce_a)
|
|
116
|
+
exchange.reveal_rating("agent-b", rating_b.to_dict(), nonce_b)
|
|
117
|
+
|
|
118
|
+
# Get simultaneous results
|
|
119
|
+
rating_a_result, rating_b_result = exchange.get_results()
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Weight Calculation
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from agent_rating_protocol import rater_weight, confidence
|
|
126
|
+
|
|
127
|
+
w = rater_weight(chain_age_days=365, total_ratings_given=100) # ≈ 56.4
|
|
128
|
+
c = confidence(num_ratings=50) # ≈ 0.833
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## CLI Reference
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Submit a rating
|
|
135
|
+
agent-rating rate agent-b --rater agent-a --reliability 85 --accuracy 90
|
|
136
|
+
|
|
137
|
+
# Query reputation
|
|
138
|
+
agent-rating query agent-b
|
|
139
|
+
agent-rating query agent-b --dimension reliability --window 180
|
|
140
|
+
|
|
141
|
+
# Verify a rating hash
|
|
142
|
+
agent-rating verify <rating-uuid>
|
|
143
|
+
|
|
144
|
+
# Store statistics
|
|
145
|
+
agent-rating status
|
|
146
|
+
|
|
147
|
+
# All commands support --json for machine-readable output
|
|
148
|
+
agent-rating query agent-b --json
|
|
149
|
+
|
|
150
|
+
# Custom store path
|
|
151
|
+
agent-rating --store /path/to/ratings.jsonl status
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## CoC Integration
|
|
155
|
+
|
|
156
|
+
If [chain-of-consciousness](https://pypi.org/project/chain-of-consciousness/) is installed and the `COC_CHAIN_FILE` environment variable is set, ratings are automatically recorded as `RATING_SUBMITTED` chain entries:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
export COC_CHAIN_FILE=chain.jsonl
|
|
160
|
+
agent-rating rate agent-b --rater agent-a --reliability 85
|
|
161
|
+
# -> Rating stored in ratings.jsonl AND recorded in chain.jsonl
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Rating Dimensions
|
|
165
|
+
|
|
166
|
+
| Dimension | Measures | Scale |
|
|
167
|
+
|-----------|----------|-------|
|
|
168
|
+
| reliability | Task completion, uptime | 1-100 |
|
|
169
|
+
| accuracy | Output correctness | 1-100 |
|
|
170
|
+
| latency | Response speed vs. complexity | 1-100 |
|
|
171
|
+
| protocol_compliance | Message format, handshake correctness | 1-100 |
|
|
172
|
+
| cost_efficiency | Resource usage vs. value | 1-100 |
|
|
173
|
+
|
|
174
|
+
Score buckets: 1-20 poor, 21-40 below average, 41-60 average, 61-80 good, 81-100 excellent.
|
|
175
|
+
|
|
176
|
+
## Weight Formula
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
W(rater) = log2(1 + chain_age_days) × log2(1 + total_ratings_given)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Governance weight equals rating weight by design — both derived from tenure and participation, never from score received.
|
|
183
|
+
|
|
184
|
+
## Design Specification
|
|
185
|
+
|
|
186
|
+
Full protocol design, game theory analysis, and governance model: see the [Agent Rating System Design](https://vibeagentmaking.com/whitepaper.html) specification.
|
|
187
|
+
|
|
188
|
+
## Security Disclaimer (VAM-SEC v1.0)
|
|
189
|
+
|
|
190
|
+
This software is provided for research and development purposes. The rating protocol includes cryptographic commitments (SHA-256) and a bilateral blind protocol, but has NOT been formally audited by a third-party security firm. Before using in production environments where reputation scores influence high-stakes decisions, conduct an independent security review. The append-only store provides tamper evidence but not tamper prevention — an attacker with filesystem access can modify the JSONL file directly. For stronger guarantees, use CoC integration with external anchoring (OTS + TSA).
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Agent Rating Protocol — decentralized agent reputation system.
|
|
2
|
+
|
|
3
|
+
A pip-installable implementation of the Decentralized Agent Rating Protocol,
|
|
4
|
+
companion to the Chain of Consciousness specification.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .blind import BlindExchange, BlindCommitment, commit, generate_nonce, reveal
|
|
8
|
+
from .query import get_reputation, verify_rating
|
|
9
|
+
from .rating import DIMENSIONS, InteractionEvidence, RatingRecord
|
|
10
|
+
from .store import RatingStore
|
|
11
|
+
from .weight import confidence, rater_weight, weighted_score, weighted_scores_all
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"BlindCommitment",
|
|
15
|
+
"BlindExchange",
|
|
16
|
+
"DIMENSIONS",
|
|
17
|
+
"InteractionEvidence",
|
|
18
|
+
"RatingRecord",
|
|
19
|
+
"RatingStore",
|
|
20
|
+
"commit",
|
|
21
|
+
"confidence",
|
|
22
|
+
"generate_nonce",
|
|
23
|
+
"get_reputation",
|
|
24
|
+
"rater_weight",
|
|
25
|
+
"reveal",
|
|
26
|
+
"verify_rating",
|
|
27
|
+
"weighted_score",
|
|
28
|
+
"weighted_scores_all",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
__version__ = "0.1.0"
|