aimarket-reputation 2.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI-Factory Project Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,248 @@
1
+ Metadata-Version: 2.4
2
+ Name: aimarket-reputation
3
+ Version: 2.0.0
4
+ Summary: Stake-bond + signed reputation events with on-chain settlement
5
+ License: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: aimarket-hub>=3.0.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=8; extra == "dev"
12
+ Dynamic: license-file
13
+
14
+ # aimarket-reputation
15
+
16
+ ## Documentation
17
+
18
+ | Document | Description |
19
+ |----------|-------------|
20
+ | [User guide](docs/user-guide.md) | Install, configure, verify plugin is loaded |
21
+ | [User cases](docs/user-cases.md) | Personas and cross-plugin workflows |
22
+ | [SDK integration](docs/sdk-integration.md) | Code examples and hook behavior |
23
+
24
+ ---
25
+
26
+ **Stake-bond + signed outcomes + dispute resolution. On-chain reputation aggregation.**
27
+ Providers lock USDT bond against quality. Every invoke generates a signed outcome. Disputes slash bonds. Reputation is a cryptographically verifiable aggregate — not website reviews.
28
+
29
+ ---
30
+
31
+ ## When to Use
32
+
33
+ | Scenario | Why this plugin |
34
+ |----------|----------------|
35
+ | Marketplace where providers compete on quality | Consumers see trust scores before choosing a capability — providers with higher bonds and success rates rank higher |
36
+ | High-stakes invocations ($10+/call) | Provider has economic stake. If they deliver garbage, bond gets slashed and paid to consumer |
37
+ | Sybil-resistant provider onboarding | Bond requirement ($100 testnet, $1000 mainnet) makes fake provider farms economically unviable |
38
+ | Consumer dispute resolution | Signed dispute → auditor reviews → bond slashed → consumer compensated. All on-chain verifiable |
39
+ | Compliance audit of provider performance | `compute_reputation_score()` returns auditable breakdown: age, bond, success_rate, dispute_count, slash_ratio |
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install aimarket-reputation
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Configuration
52
+
53
+ | Env Variable | Default | Description |
54
+ |-------------|---------|-------------|
55
+ | `AIMARKET_REPUTATION_MIN_BOND_USD` | `100` | Minimum bond for testnet listing |
56
+ | `AIMARKET_REPUTATION_MAINNET_MIN_BOND_USD` | `1000` | Minimum bond for mainnet listing |
57
+ | `AIMARKET_REPUTATION_WINDOW_DAYS` | `30` | Rolling window for success rate calculation |
58
+ | `AIMARKET_REPUTATION_DEFAULT_WEIGHTS` | `0.2,0.3,0.35,0.15` | age, bond, success_rate, volume |
59
+
60
+ ---
61
+
62
+ ## API Endpoints Added
63
+
64
+ | Method | Path | Description |
65
+ |--------|------|-------------|
66
+ | `GET` | `/ai-market/v2/reputation/{hub_url}` | Full trust score breakdown for a provider |
67
+ | `POST` | `/ai-market/v2/reputation/events` | Submit signed reputation attestations |
68
+
69
+ ### Get Reputation
70
+
71
+ ```bash
72
+ curl https://modelmarket.dev/ai-market/v2/reputation/https://provider.example.com | jq .
73
+ ```
74
+
75
+ ```json
76
+ {
77
+ "hub_url": "https://provider.example.com",
78
+ "trust_score": 0.872,
79
+ "details": {
80
+ "provider_hub": "https://provider.example.com",
81
+ "score": 0.872,
82
+ "bond_usd": 2500.0,
83
+ "success_rate_30d": 0.967,
84
+ "avg_quality_score_30d": 0.94,
85
+ "dispute_count": 1,
86
+ "slash_ratio": 0.05,
87
+ "total_outcomes": 3412
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Submit Reputation Events
93
+
94
+ ```bash
95
+ curl -X POST https://modelmarket.dev/ai-market/v2/reputation/events \
96
+ -H "Content-Type: application/json" \
97
+ -d '{
98
+ "events": [{
99
+ "type": "invocation_success",
100
+ "provider_hub": "https://provider.example.com",
101
+ "capability_id": "translate.multi@v2",
102
+ "price_usd": 0.40,
103
+ "latency_ms": 8100,
104
+ "consumer_hub": "https://consumer.example.com"
105
+ }]
106
+ }'
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Trust Score Formula
112
+
113
+ ```
114
+ trust_score = w1 × age_factor + w2 × bond_factor + w3 × success_rate + w4 × volume_factor
115
+ - 0.3 × slash_ratio - 0.05 × min(disputes/10, 1.0)
116
+
117
+ age_factor = min(days_since_first_seen / 365, 1.0)
118
+ bond_factor = min(log10(bond_usd) / 4, 1.0) # 0 at $1, 1 at $10k
119
+ success_rate = successful / total (30-day rolling window)
120
+ volume_factor = min(log10(volume_usd_30d) / 5, 1.0)
121
+
122
+ Default weights: 0.20, 0.30, 0.35, 0.15
123
+ ```
124
+
125
+ ---
126
+
127
+ ## End-to-End Example
128
+
129
+ ```python
130
+ from aimarket_hub.signing import Signer
131
+ from aimarket_reputation.reputation_oracle import (
132
+ ReputationOracle, OutcomeStatus
133
+ )
134
+
135
+ signer = Signer()
136
+ oracle = ReputationOracle(signer)
137
+
138
+ # 1. Provider stakes bond
139
+ bond = oracle.stake_bond(
140
+ provider_hub="https://translate-pro.example.com",
141
+ amount_usd=2000.0,
142
+ token="USDT", chain="base",
143
+ tx_hash="0x_on_chain_bond_deposit"
144
+ )
145
+ print(f"Bond: ${bond.amount_usd}")
146
+
147
+ # 2. Consumers invoke and sign outcomes
148
+ for i in range(100):
149
+ oracle.record_outcome(
150
+ invocation_id=f"inv_{i}",
151
+ capability_id="translate.multi@v2",
152
+ product_id="prod-001",
153
+ provider_hub="https://translate-pro.example.com",
154
+ consumer_hub=f"consumer_{i % 5}",
155
+ status=OutcomeStatus.SUCCESS,
156
+ price_usd=0.40,
157
+ latency_ms=8000 + (i % 20) * 100,
158
+ quality_score=0.90 + (i % 10) * 0.01
159
+ )
160
+
161
+ # 3. Some consumer files dispute for one bad invocation
162
+ dispute = oracle.file_dispute(
163
+ invocation_id="inv_42",
164
+ provider_hub="https://translate-pro.example.com",
165
+ consumer_hub="consumer_2",
166
+ reason="Returned wrong language — asked for French, got German",
167
+ requested_slash_pct=0.10,
168
+ evidence={"expected_lang": "fr", "received_lang": "de",
169
+ "screenshot_url": "https://..."}
170
+ )
171
+ print(f"Dispute filed: {dispute.dispute_id}")
172
+
173
+ # 4. Auditor resolves dispute — 5% bond slash
174
+ resolution = oracle.resolve_dispute(dispute.dispute_id, slash_pct=0.05)
175
+ print(f"Slashed: ${resolution['slashed_usd']:.2f}")
176
+ print(f"Bond remaining: ${resolution['bond_remaining_usd']:.2f}")
177
+
178
+ # 5. Compute reputation score
179
+ score = oracle.compute_reputation_score("https://translate-pro.example.com")
180
+ print(f"Trust Score: {score['score']:.3f}")
181
+ print(f" Success Rate: {score['success_rate_30d']:.1%}")
182
+ print(f" Quality Avg: {score['avg_quality_score_30d']:.2f}")
183
+ print(f" Disputes: {score['dispute_count']}")
184
+ print(f" Slash Ratio: {score['slash_ratio']:.1%}")
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Manifest Extension
190
+
191
+ ```json
192
+ {
193
+ "plugin_extensions": {
194
+ "aimarket-reputation": {
195
+ "reputation": {
196
+ "bond_required": true,
197
+ "slashing_enabled": true,
198
+ "min_bond_testnet_usd": 100,
199
+ "min_bond_mainnet_usd": 1000,
200
+ "weights": {"age": 0.20, "bond": 0.30, "success_rate": 0.35, "volume": 0.15}
201
+ }
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Recommended Deployment
210
+
211
+ | Environment | Recommendation |
212
+ |-------------|---------------|
213
+ | Development | Use in-memory ledger, no real bonds |
214
+ | Staging | Testnet bonds on Base Sepolia ($100 minimum) |
215
+ | Production | Mainnet bonds on Base ($1000 minimum). Multi-sig dispute resolution |
216
+ | Enterprise | DAO-governed dispute resolution with multi-sig auditor committee |
217
+
218
+ **Combine with:**
219
+ - `aimarket-safety` — safety blocks don't count as failures (consumer isn't penalized)
220
+ - `aimarket-zk` — ZK proofs of invocation quality without revealing consumer identity
221
+ - `aimarket-nft` — stake bond as NFT for transferable provider reputation
222
+
223
+ ---
224
+
225
+ ## Performance
226
+
227
+ | Metric | Value |
228
+ |--------|-------|
229
+ | Outcome recording | < 1ms |
230
+ | Dispute filing + signing | < 2ms |
231
+ | Trust score computation (1000 outcomes) | < 5ms |
232
+ | Storage per outcome | ~200 bytes |
233
+ | Scalability | 1M outcomes = ~200 MB (fits in memory) |
234
+
235
+ ---
236
+
237
+ ## Security Considerations
238
+
239
+ - **Outcomes are Ed25519-signed** by consumer — providers can't forge good reviews
240
+ - **Disputes are Ed25519-signed** — consumers can't file disputes for invocations that didn't happen
241
+ - **Bond slashing requires auditor resolution** — not automatic. Prevents griefing attacks
242
+ - **Reputation is a protocol-level aggregate** — not a website review. Sybil-resistant via bond requirement
243
+
244
+ ---
245
+
246
+ ## License
247
+
248
+ MIT · Maintained by AI-Factory · [GitHub](https://github.com/ai-factory/aimarket-reputation)
@@ -0,0 +1,235 @@
1
+ # aimarket-reputation
2
+
3
+ ## Documentation
4
+
5
+ | Document | Description |
6
+ |----------|-------------|
7
+ | [User guide](docs/user-guide.md) | Install, configure, verify plugin is loaded |
8
+ | [User cases](docs/user-cases.md) | Personas and cross-plugin workflows |
9
+ | [SDK integration](docs/sdk-integration.md) | Code examples and hook behavior |
10
+
11
+ ---
12
+
13
+ **Stake-bond + signed outcomes + dispute resolution. On-chain reputation aggregation.**
14
+ Providers lock USDT bond against quality. Every invoke generates a signed outcome. Disputes slash bonds. Reputation is a cryptographically verifiable aggregate — not website reviews.
15
+
16
+ ---
17
+
18
+ ## When to Use
19
+
20
+ | Scenario | Why this plugin |
21
+ |----------|----------------|
22
+ | Marketplace where providers compete on quality | Consumers see trust scores before choosing a capability — providers with higher bonds and success rates rank higher |
23
+ | High-stakes invocations ($10+/call) | Provider has economic stake. If they deliver garbage, bond gets slashed and paid to consumer |
24
+ | Sybil-resistant provider onboarding | Bond requirement ($100 testnet, $1000 mainnet) makes fake provider farms economically unviable |
25
+ | Consumer dispute resolution | Signed dispute → auditor reviews → bond slashed → consumer compensated. All on-chain verifiable |
26
+ | Compliance audit of provider performance | `compute_reputation_score()` returns auditable breakdown: age, bond, success_rate, dispute_count, slash_ratio |
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install aimarket-reputation
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Configuration
39
+
40
+ | Env Variable | Default | Description |
41
+ |-------------|---------|-------------|
42
+ | `AIMARKET_REPUTATION_MIN_BOND_USD` | `100` | Minimum bond for testnet listing |
43
+ | `AIMARKET_REPUTATION_MAINNET_MIN_BOND_USD` | `1000` | Minimum bond for mainnet listing |
44
+ | `AIMARKET_REPUTATION_WINDOW_DAYS` | `30` | Rolling window for success rate calculation |
45
+ | `AIMARKET_REPUTATION_DEFAULT_WEIGHTS` | `0.2,0.3,0.35,0.15` | age, bond, success_rate, volume |
46
+
47
+ ---
48
+
49
+ ## API Endpoints Added
50
+
51
+ | Method | Path | Description |
52
+ |--------|------|-------------|
53
+ | `GET` | `/ai-market/v2/reputation/{hub_url}` | Full trust score breakdown for a provider |
54
+ | `POST` | `/ai-market/v2/reputation/events` | Submit signed reputation attestations |
55
+
56
+ ### Get Reputation
57
+
58
+ ```bash
59
+ curl https://modelmarket.dev/ai-market/v2/reputation/https://provider.example.com | jq .
60
+ ```
61
+
62
+ ```json
63
+ {
64
+ "hub_url": "https://provider.example.com",
65
+ "trust_score": 0.872,
66
+ "details": {
67
+ "provider_hub": "https://provider.example.com",
68
+ "score": 0.872,
69
+ "bond_usd": 2500.0,
70
+ "success_rate_30d": 0.967,
71
+ "avg_quality_score_30d": 0.94,
72
+ "dispute_count": 1,
73
+ "slash_ratio": 0.05,
74
+ "total_outcomes": 3412
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### Submit Reputation Events
80
+
81
+ ```bash
82
+ curl -X POST https://modelmarket.dev/ai-market/v2/reputation/events \
83
+ -H "Content-Type: application/json" \
84
+ -d '{
85
+ "events": [{
86
+ "type": "invocation_success",
87
+ "provider_hub": "https://provider.example.com",
88
+ "capability_id": "translate.multi@v2",
89
+ "price_usd": 0.40,
90
+ "latency_ms": 8100,
91
+ "consumer_hub": "https://consumer.example.com"
92
+ }]
93
+ }'
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Trust Score Formula
99
+
100
+ ```
101
+ trust_score = w1 × age_factor + w2 × bond_factor + w3 × success_rate + w4 × volume_factor
102
+ - 0.3 × slash_ratio - 0.05 × min(disputes/10, 1.0)
103
+
104
+ age_factor = min(days_since_first_seen / 365, 1.0)
105
+ bond_factor = min(log10(bond_usd) / 4, 1.0) # 0 at $1, 1 at $10k
106
+ success_rate = successful / total (30-day rolling window)
107
+ volume_factor = min(log10(volume_usd_30d) / 5, 1.0)
108
+
109
+ Default weights: 0.20, 0.30, 0.35, 0.15
110
+ ```
111
+
112
+ ---
113
+
114
+ ## End-to-End Example
115
+
116
+ ```python
117
+ from aimarket_hub.signing import Signer
118
+ from aimarket_reputation.reputation_oracle import (
119
+ ReputationOracle, OutcomeStatus
120
+ )
121
+
122
+ signer = Signer()
123
+ oracle = ReputationOracle(signer)
124
+
125
+ # 1. Provider stakes bond
126
+ bond = oracle.stake_bond(
127
+ provider_hub="https://translate-pro.example.com",
128
+ amount_usd=2000.0,
129
+ token="USDT", chain="base",
130
+ tx_hash="0x_on_chain_bond_deposit"
131
+ )
132
+ print(f"Bond: ${bond.amount_usd}")
133
+
134
+ # 2. Consumers invoke and sign outcomes
135
+ for i in range(100):
136
+ oracle.record_outcome(
137
+ invocation_id=f"inv_{i}",
138
+ capability_id="translate.multi@v2",
139
+ product_id="prod-001",
140
+ provider_hub="https://translate-pro.example.com",
141
+ consumer_hub=f"consumer_{i % 5}",
142
+ status=OutcomeStatus.SUCCESS,
143
+ price_usd=0.40,
144
+ latency_ms=8000 + (i % 20) * 100,
145
+ quality_score=0.90 + (i % 10) * 0.01
146
+ )
147
+
148
+ # 3. Some consumer files dispute for one bad invocation
149
+ dispute = oracle.file_dispute(
150
+ invocation_id="inv_42",
151
+ provider_hub="https://translate-pro.example.com",
152
+ consumer_hub="consumer_2",
153
+ reason="Returned wrong language — asked for French, got German",
154
+ requested_slash_pct=0.10,
155
+ evidence={"expected_lang": "fr", "received_lang": "de",
156
+ "screenshot_url": "https://..."}
157
+ )
158
+ print(f"Dispute filed: {dispute.dispute_id}")
159
+
160
+ # 4. Auditor resolves dispute — 5% bond slash
161
+ resolution = oracle.resolve_dispute(dispute.dispute_id, slash_pct=0.05)
162
+ print(f"Slashed: ${resolution['slashed_usd']:.2f}")
163
+ print(f"Bond remaining: ${resolution['bond_remaining_usd']:.2f}")
164
+
165
+ # 5. Compute reputation score
166
+ score = oracle.compute_reputation_score("https://translate-pro.example.com")
167
+ print(f"Trust Score: {score['score']:.3f}")
168
+ print(f" Success Rate: {score['success_rate_30d']:.1%}")
169
+ print(f" Quality Avg: {score['avg_quality_score_30d']:.2f}")
170
+ print(f" Disputes: {score['dispute_count']}")
171
+ print(f" Slash Ratio: {score['slash_ratio']:.1%}")
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Manifest Extension
177
+
178
+ ```json
179
+ {
180
+ "plugin_extensions": {
181
+ "aimarket-reputation": {
182
+ "reputation": {
183
+ "bond_required": true,
184
+ "slashing_enabled": true,
185
+ "min_bond_testnet_usd": 100,
186
+ "min_bond_mainnet_usd": 1000,
187
+ "weights": {"age": 0.20, "bond": 0.30, "success_rate": 0.35, "volume": 0.15}
188
+ }
189
+ }
190
+ }
191
+ }
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Recommended Deployment
197
+
198
+ | Environment | Recommendation |
199
+ |-------------|---------------|
200
+ | Development | Use in-memory ledger, no real bonds |
201
+ | Staging | Testnet bonds on Base Sepolia ($100 minimum) |
202
+ | Production | Mainnet bonds on Base ($1000 minimum). Multi-sig dispute resolution |
203
+ | Enterprise | DAO-governed dispute resolution with multi-sig auditor committee |
204
+
205
+ **Combine with:**
206
+ - `aimarket-safety` — safety blocks don't count as failures (consumer isn't penalized)
207
+ - `aimarket-zk` — ZK proofs of invocation quality without revealing consumer identity
208
+ - `aimarket-nft` — stake bond as NFT for transferable provider reputation
209
+
210
+ ---
211
+
212
+ ## Performance
213
+
214
+ | Metric | Value |
215
+ |--------|-------|
216
+ | Outcome recording | < 1ms |
217
+ | Dispute filing + signing | < 2ms |
218
+ | Trust score computation (1000 outcomes) | < 5ms |
219
+ | Storage per outcome | ~200 bytes |
220
+ | Scalability | 1M outcomes = ~200 MB (fits in memory) |
221
+
222
+ ---
223
+
224
+ ## Security Considerations
225
+
226
+ - **Outcomes are Ed25519-signed** by consumer — providers can't forge good reviews
227
+ - **Disputes are Ed25519-signed** — consumers can't file disputes for invocations that didn't happen
228
+ - **Bond slashing requires auditor resolution** — not automatic. Prevents griefing attacks
229
+ - **Reputation is a protocol-level aggregate** — not a website review. Sybil-resistant via bond requirement
230
+
231
+ ---
232
+
233
+ ## License
234
+
235
+ MIT · Maintained by AI-Factory · [GitHub](https://github.com/ai-factory/aimarket-reputation)
@@ -0,0 +1 @@
1
+ # aimarket-reputation plugin
@@ -0,0 +1,25 @@
1
+ """reputation plugin for AIMarket Hub."""
2
+
3
+ from aimarket_hub.plugin import HubPlugin
4
+ from aimarket_reputation.reputation_oracle import *
5
+
6
+
7
+ class ReputationPlugin(HubPlugin):
8
+ name = "aimarket-reputation"
9
+ version = "2.0.0"
10
+ description = "reputation oracle"
11
+ homepage = "https://github.com/ai-factory/aimarket-reputation"
12
+ category = "reputation"
13
+
14
+ def register_routes(self, router):
15
+ # The reputation HTTP API (/reputation/events, /reputation/slashes,
16
+ # /reputation/{hub_url}) is served by the hub core (aimarket_hub.api) and the
17
+ # oracle is canonical in aimarket_hub.reputation_oracle. This plugin is a thin
18
+ # re-export shim and intentionally registers no routes of its own.
19
+ return
20
+
21
+ def on_startup(self, db):
22
+ self._oracle = None
23
+
24
+ def get_manifest_extension(self) -> dict:
25
+ return {"reputation": {"bond_required": True, "slashing_enabled": True}}
@@ -0,0 +1,3 @@
1
+ """Reputation Oracle — re-export shim from aimarket_hub.reputation_oracle (canonical)."""
2
+
3
+ from aimarket_hub.reputation_oracle import * # noqa: F401, F403
@@ -0,0 +1,248 @@
1
+ Metadata-Version: 2.4
2
+ Name: aimarket-reputation
3
+ Version: 2.0.0
4
+ Summary: Stake-bond + signed reputation events with on-chain settlement
5
+ License: MIT
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: aimarket-hub>=3.0.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=8; extra == "dev"
12
+ Dynamic: license-file
13
+
14
+ # aimarket-reputation
15
+
16
+ ## Documentation
17
+
18
+ | Document | Description |
19
+ |----------|-------------|
20
+ | [User guide](docs/user-guide.md) | Install, configure, verify plugin is loaded |
21
+ | [User cases](docs/user-cases.md) | Personas and cross-plugin workflows |
22
+ | [SDK integration](docs/sdk-integration.md) | Code examples and hook behavior |
23
+
24
+ ---
25
+
26
+ **Stake-bond + signed outcomes + dispute resolution. On-chain reputation aggregation.**
27
+ Providers lock USDT bond against quality. Every invoke generates a signed outcome. Disputes slash bonds. Reputation is a cryptographically verifiable aggregate — not website reviews.
28
+
29
+ ---
30
+
31
+ ## When to Use
32
+
33
+ | Scenario | Why this plugin |
34
+ |----------|----------------|
35
+ | Marketplace where providers compete on quality | Consumers see trust scores before choosing a capability — providers with higher bonds and success rates rank higher |
36
+ | High-stakes invocations ($10+/call) | Provider has economic stake. If they deliver garbage, bond gets slashed and paid to consumer |
37
+ | Sybil-resistant provider onboarding | Bond requirement ($100 testnet, $1000 mainnet) makes fake provider farms economically unviable |
38
+ | Consumer dispute resolution | Signed dispute → auditor reviews → bond slashed → consumer compensated. All on-chain verifiable |
39
+ | Compliance audit of provider performance | `compute_reputation_score()` returns auditable breakdown: age, bond, success_rate, dispute_count, slash_ratio |
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install aimarket-reputation
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Configuration
52
+
53
+ | Env Variable | Default | Description |
54
+ |-------------|---------|-------------|
55
+ | `AIMARKET_REPUTATION_MIN_BOND_USD` | `100` | Minimum bond for testnet listing |
56
+ | `AIMARKET_REPUTATION_MAINNET_MIN_BOND_USD` | `1000` | Minimum bond for mainnet listing |
57
+ | `AIMARKET_REPUTATION_WINDOW_DAYS` | `30` | Rolling window for success rate calculation |
58
+ | `AIMARKET_REPUTATION_DEFAULT_WEIGHTS` | `0.2,0.3,0.35,0.15` | age, bond, success_rate, volume |
59
+
60
+ ---
61
+
62
+ ## API Endpoints Added
63
+
64
+ | Method | Path | Description |
65
+ |--------|------|-------------|
66
+ | `GET` | `/ai-market/v2/reputation/{hub_url}` | Full trust score breakdown for a provider |
67
+ | `POST` | `/ai-market/v2/reputation/events` | Submit signed reputation attestations |
68
+
69
+ ### Get Reputation
70
+
71
+ ```bash
72
+ curl https://modelmarket.dev/ai-market/v2/reputation/https://provider.example.com | jq .
73
+ ```
74
+
75
+ ```json
76
+ {
77
+ "hub_url": "https://provider.example.com",
78
+ "trust_score": 0.872,
79
+ "details": {
80
+ "provider_hub": "https://provider.example.com",
81
+ "score": 0.872,
82
+ "bond_usd": 2500.0,
83
+ "success_rate_30d": 0.967,
84
+ "avg_quality_score_30d": 0.94,
85
+ "dispute_count": 1,
86
+ "slash_ratio": 0.05,
87
+ "total_outcomes": 3412
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Submit Reputation Events
93
+
94
+ ```bash
95
+ curl -X POST https://modelmarket.dev/ai-market/v2/reputation/events \
96
+ -H "Content-Type: application/json" \
97
+ -d '{
98
+ "events": [{
99
+ "type": "invocation_success",
100
+ "provider_hub": "https://provider.example.com",
101
+ "capability_id": "translate.multi@v2",
102
+ "price_usd": 0.40,
103
+ "latency_ms": 8100,
104
+ "consumer_hub": "https://consumer.example.com"
105
+ }]
106
+ }'
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Trust Score Formula
112
+
113
+ ```
114
+ trust_score = w1 × age_factor + w2 × bond_factor + w3 × success_rate + w4 × volume_factor
115
+ - 0.3 × slash_ratio - 0.05 × min(disputes/10, 1.0)
116
+
117
+ age_factor = min(days_since_first_seen / 365, 1.0)
118
+ bond_factor = min(log10(bond_usd) / 4, 1.0) # 0 at $1, 1 at $10k
119
+ success_rate = successful / total (30-day rolling window)
120
+ volume_factor = min(log10(volume_usd_30d) / 5, 1.0)
121
+
122
+ Default weights: 0.20, 0.30, 0.35, 0.15
123
+ ```
124
+
125
+ ---
126
+
127
+ ## End-to-End Example
128
+
129
+ ```python
130
+ from aimarket_hub.signing import Signer
131
+ from aimarket_reputation.reputation_oracle import (
132
+ ReputationOracle, OutcomeStatus
133
+ )
134
+
135
+ signer = Signer()
136
+ oracle = ReputationOracle(signer)
137
+
138
+ # 1. Provider stakes bond
139
+ bond = oracle.stake_bond(
140
+ provider_hub="https://translate-pro.example.com",
141
+ amount_usd=2000.0,
142
+ token="USDT", chain="base",
143
+ tx_hash="0x_on_chain_bond_deposit"
144
+ )
145
+ print(f"Bond: ${bond.amount_usd}")
146
+
147
+ # 2. Consumers invoke and sign outcomes
148
+ for i in range(100):
149
+ oracle.record_outcome(
150
+ invocation_id=f"inv_{i}",
151
+ capability_id="translate.multi@v2",
152
+ product_id="prod-001",
153
+ provider_hub="https://translate-pro.example.com",
154
+ consumer_hub=f"consumer_{i % 5}",
155
+ status=OutcomeStatus.SUCCESS,
156
+ price_usd=0.40,
157
+ latency_ms=8000 + (i % 20) * 100,
158
+ quality_score=0.90 + (i % 10) * 0.01
159
+ )
160
+
161
+ # 3. Some consumer files dispute for one bad invocation
162
+ dispute = oracle.file_dispute(
163
+ invocation_id="inv_42",
164
+ provider_hub="https://translate-pro.example.com",
165
+ consumer_hub="consumer_2",
166
+ reason="Returned wrong language — asked for French, got German",
167
+ requested_slash_pct=0.10,
168
+ evidence={"expected_lang": "fr", "received_lang": "de",
169
+ "screenshot_url": "https://..."}
170
+ )
171
+ print(f"Dispute filed: {dispute.dispute_id}")
172
+
173
+ # 4. Auditor resolves dispute — 5% bond slash
174
+ resolution = oracle.resolve_dispute(dispute.dispute_id, slash_pct=0.05)
175
+ print(f"Slashed: ${resolution['slashed_usd']:.2f}")
176
+ print(f"Bond remaining: ${resolution['bond_remaining_usd']:.2f}")
177
+
178
+ # 5. Compute reputation score
179
+ score = oracle.compute_reputation_score("https://translate-pro.example.com")
180
+ print(f"Trust Score: {score['score']:.3f}")
181
+ print(f" Success Rate: {score['success_rate_30d']:.1%}")
182
+ print(f" Quality Avg: {score['avg_quality_score_30d']:.2f}")
183
+ print(f" Disputes: {score['dispute_count']}")
184
+ print(f" Slash Ratio: {score['slash_ratio']:.1%}")
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Manifest Extension
190
+
191
+ ```json
192
+ {
193
+ "plugin_extensions": {
194
+ "aimarket-reputation": {
195
+ "reputation": {
196
+ "bond_required": true,
197
+ "slashing_enabled": true,
198
+ "min_bond_testnet_usd": 100,
199
+ "min_bond_mainnet_usd": 1000,
200
+ "weights": {"age": 0.20, "bond": 0.30, "success_rate": 0.35, "volume": 0.15}
201
+ }
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Recommended Deployment
210
+
211
+ | Environment | Recommendation |
212
+ |-------------|---------------|
213
+ | Development | Use in-memory ledger, no real bonds |
214
+ | Staging | Testnet bonds on Base Sepolia ($100 minimum) |
215
+ | Production | Mainnet bonds on Base ($1000 minimum). Multi-sig dispute resolution |
216
+ | Enterprise | DAO-governed dispute resolution with multi-sig auditor committee |
217
+
218
+ **Combine with:**
219
+ - `aimarket-safety` — safety blocks don't count as failures (consumer isn't penalized)
220
+ - `aimarket-zk` — ZK proofs of invocation quality without revealing consumer identity
221
+ - `aimarket-nft` — stake bond as NFT for transferable provider reputation
222
+
223
+ ---
224
+
225
+ ## Performance
226
+
227
+ | Metric | Value |
228
+ |--------|-------|
229
+ | Outcome recording | < 1ms |
230
+ | Dispute filing + signing | < 2ms |
231
+ | Trust score computation (1000 outcomes) | < 5ms |
232
+ | Storage per outcome | ~200 bytes |
233
+ | Scalability | 1M outcomes = ~200 MB (fits in memory) |
234
+
235
+ ---
236
+
237
+ ## Security Considerations
238
+
239
+ - **Outcomes are Ed25519-signed** by consumer — providers can't forge good reviews
240
+ - **Disputes are Ed25519-signed** — consumers can't file disputes for invocations that didn't happen
241
+ - **Bond slashing requires auditor resolution** — not automatic. Prevents griefing attacks
242
+ - **Reputation is a protocol-level aggregate** — not a website review. Sybil-resistant via bond requirement
243
+
244
+ ---
245
+
246
+ ## License
247
+
248
+ MIT · Maintained by AI-Factory · [GitHub](https://github.com/ai-factory/aimarket-reputation)
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ aimarket_reputation/__init__.py
5
+ aimarket_reputation/plugin.py
6
+ aimarket_reputation/reputation_oracle.py
7
+ aimarket_reputation.egg-info/PKG-INFO
8
+ aimarket_reputation.egg-info/SOURCES.txt
9
+ aimarket_reputation.egg-info/dependency_links.txt
10
+ aimarket_reputation.egg-info/entry_points.txt
11
+ aimarket_reputation.egg-info/requires.txt
12
+ aimarket_reputation.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [aimarket.plugins]
2
+ reputation = aimarket_reputation.plugin:ReputationPlugin
@@ -0,0 +1,4 @@
1
+ aimarket-hub>=3.0.0
2
+
3
+ [dev]
4
+ pytest>=8
@@ -0,0 +1 @@
1
+ aimarket_reputation
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=75", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aimarket-reputation"
7
+ version = "2.0.0"
8
+ description = "Stake-bond + signed reputation events with on-chain settlement"
9
+ license = {text = "MIT"}
10
+ readme = "README.md"
11
+ requires-python = ">=3.11"
12
+ dependencies = ["aimarket-hub>=3.0.0"]
13
+
14
+ [project.optional-dependencies]
15
+ dev = ["pytest>=8"]
16
+
17
+ [project.entry-points."aimarket.plugins"]
18
+ reputation = "aimarket_reputation.plugin:ReputationPlugin"
19
+
20
+ [tool.setuptools.packages.find]
21
+ include = ["aimarket_reputation*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+