Commit 1ff799a
fix: parse Joy Trust API response correctly (#18)
* fix: parse Joy Trust API response correctly
The /agents/discover endpoint returns {agents: [...]} not top-level fields.
This fix extracts the agent from the array before reading trust_score.
Fixes #17
* fix: remove fallback-to-first-result (security risk)
Greptile correctly identified that falling back to the first search
result when no exact name match is found could return a different
agent's trust score, allowing untrusted agents to pass verification.
Now only exact name matches are accepted.
* fix: import time at top level and normalize response schema
- Move 'import time' to top of file (fixes NameError on cache check)
- Normalize response schema across success/error paths
- All responses now include: agent_id, vouch_count, capabilities, tier, badges
* Address code review feedback
- Use idiomatic next() with generator expression for agent lookup
- Fix ImportError response to use consistent schema with new fields
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove redundant time import from try block
time is already imported at module level (line 37)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Handle null trust_score from API
Use 'or' operator to handle both missing key AND null value,
preventing TypeError on comparison and security bypass.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Handle null agents array from API
Use 'or' operator to handle both missing key AND null value,
preventing TypeError when iterating and security bypass.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Security: Fail closed on all error paths
Error handlers now always set meets_threshold=False instead of
using fallback_on_error config. In trust-gating context, errors
should deny handoffs, not silently allow them.
Changes:
- meets_threshold: False (was self.config.fallback_on_error)
- fallback_used: True (indicates error occurred)
- logger.exception() for unexpected errors (includes stack trace)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix misleading fallback_used flag in error handlers
Set fallback_used=False so _get_handoff_recommendation returns
"Handoff not recommended" instead of misleading "Proceed with caution"
message when errors occur.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Handle null name and string trust_score edge cases
- Use (a.get("name") or "").lower() to handle {"name": null}
- Safely convert trust_score to float with try/except
- Return fail-closed response for invalid trust_score format
- Use 'or' pattern consistently for null-safe field access
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: Change default min_score from 3.0 to 1.5
The Joy Trust Network has:
- Network average: 1.11
- Network median: 1.10
- Network max: 2.40
- Agents >= 3.0: 0
A default of 3.0 blocks 100% of agents. Changed to 1.5
which is Joy's recommended 'standard' threshold.
Joy now returns trust_context.recommended_thresholds:
- permissive: 1.0 (low-risk tasks)
- standard: 1.5 (general use) <- new default
- moderate: 2.0 (established agents)
- strict: 2.5 (high security)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 1275ca4 commit 1ff799a
1 file changed
+111
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | | - | |
117 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
133 | | - | |
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
140 | | - | |
141 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
| |||
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
150 | | - | |
| 158 | + | |
151 | 159 | | |
152 | | - | |
153 | | - | |
| 160 | + | |
| 161 | + | |
154 | 162 | | |
155 | 163 | | |
156 | | - | |
| 164 | + | |
| 165 | + | |
157 | 166 | | |
158 | 167 | | |
159 | | - | |
| 168 | + | |
160 | 169 | | |
161 | | - | |
162 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
163 | 221 | | |
164 | | - | |
| 222 | + | |
| 223 | + | |
165 | 224 | | |
166 | | - | |
| 225 | + | |
167 | 226 | | |
168 | 227 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
173 | 232 | | |
174 | 233 | | |
175 | 234 | | |
176 | | - | |
| 235 | + | |
177 | 236 | | |
178 | 237 | | |
179 | | - | |
| 238 | + | |
180 | 239 | | |
181 | 240 | | |
182 | 241 | | |
183 | 242 | | |
184 | | - | |
| 243 | + | |
| 244 | + | |
185 | 245 | | |
| 246 | + | |
186 | 247 | | |
187 | 248 | | |
188 | | - | |
| 249 | + | |
189 | 250 | | |
190 | | - | |
191 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
192 | 255 | | |
193 | | - | |
| 256 | + | |
194 | 257 | | |
195 | | - | |
196 | 258 | | |
197 | 259 | | |
198 | | - | |
| 260 | + | |
| 261 | + | |
199 | 262 | | |
| 263 | + | |
200 | 264 | | |
201 | 265 | | |
202 | | - | |
| 266 | + | |
203 | 267 | | |
204 | | - | |
205 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
206 | 272 | | |
207 | | - | |
| 273 | + | |
208 | 274 | | |
209 | | - | |
210 | 275 | | |
211 | | - | |
212 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
213 | 279 | | |
| 280 | + | |
214 | 281 | | |
215 | 282 | | |
216 | | - | |
| 283 | + | |
217 | 284 | | |
218 | | - | |
219 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
220 | 289 | | |
221 | | - | |
| 290 | + | |
222 | 291 | | |
223 | | - | |
224 | 292 | | |
225 | 293 | | |
226 | 294 | | |
| |||
337 | 405 | | |
338 | 406 | | |
339 | 407 | | |
340 | | - | |
| 408 | + | |
341 | 409 | | |
342 | 410 | | |
343 | 411 | | |
| |||
351 | 419 | | |
352 | 420 | | |
353 | 421 | | |
354 | | - | |
| 422 | + | |
355 | 423 | | |
356 | 424 | | |
357 | 425 | | |
| |||
0 commit comments