Commit 3a94637
authored
fix: improve DIFC error messages and replace issue:#0 sentinel (#2202)
## Summary
Improves DIFC error messaging for non-expert users and fixes the
synthetic `issue:#0` resource descriptions reported in [gh-aw#21866
(recommendation 5)](github/gh-aw#21866).
Addresses [gh-aw#21824](github/gh-aw#21824) —
confusing "Agent would need to drop integrity tags" messages.
## Changes
### Guard (Rust) — Replace `#0` sentinel with `#unknown`
- New `extract_resource_number()` helper in `helpers.rs` returns
`"unknown"` (with `log_warn`) when the `number` field is missing or
invalid
- Replaces `unwrap_or(0)` in both `response_items.rs` and
`response_paths.rs` for issues and PRs
- **Before**: `issue:github/gh-aw#0` → **After**:
`issue:github/gh-aw#unknown`
### DIFC Evaluator (Go) — Human-readable error messages
| Context | Before | After |
|---------|--------|-------|
| Read denied (integrity) | "Agent would need to drop integrity tags
[unapproved:all approved:all] to trust this resource" | "The agent
cannot read data with integrity below \"approved\"" |
| Read denied (secrecy) | "Agent would need to add secrecy tags
[private:org/repo] to read this resource" | "The agent is not authorized
to access private (org/repo)-scoped data" |
| Write denied (integrity) | "Resource requires integrity tags
[production] that agent doesn't have" | "The agent's integrity level is
insufficient; it needs \"production\" integrity" |
| Write denied (secrecy) | "Resource would need these secrecy
requirements to accept the write" | "The agent carries sensitive data
that the target resource is not authorized to receive" |
### New helper functions
- `formatIntegrityLevel()` — converts tag lists to named levels (e.g.,
`[unapproved:all approved:all]` → `"approved"`)
- `formatSecrecyLevel()` — converts tags to scope descriptions (e.g.,
`[private:org/repo]` → `"private (org/repo)"`)
## Test Results
- All 70 Rust guard tests pass ✅
- All Go unit tests pass (including updated assertion expectations) ✅
- 0 lint issues ✅6 files changed
Lines changed: 102 additions & 30 deletions
File tree
- guards/github-guard/rust-guard/src/labels
- internal/difc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
10 | 25 | | |
11 | 26 | | |
12 | 27 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 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 | + | |
| 221 | + | |
158 | 222 | | |
159 | 223 | | |
160 | 224 | | |
| |||
249 | 313 | | |
250 | 314 | | |
251 | 315 | | |
252 | | - | |
253 | | - | |
| 316 | + | |
| 317 | + | |
254 | 318 | | |
255 | 319 | | |
256 | 320 | | |
| |||
259 | 323 | | |
260 | 324 | | |
261 | 325 | | |
262 | | - | |
263 | | - | |
| 326 | + | |
| 327 | + | |
264 | 328 | | |
265 | 329 | | |
266 | 330 | | |
| |||
287 | 351 | | |
288 | 352 | | |
289 | 353 | | |
290 | | - | |
291 | | - | |
| 354 | + | |
| 355 | + | |
292 | 356 | | |
293 | 357 | | |
294 | 358 | | |
| |||
300 | 364 | | |
301 | 365 | | |
302 | 366 | | |
303 | | - | |
304 | | - | |
305 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
306 | 370 | | |
307 | 371 | | |
308 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
377 | | - | |
| 376 | + | |
378 | 377 | | |
379 | 378 | | |
380 | 379 | | |
381 | 380 | | |
382 | 381 | | |
383 | | - | |
384 | | - | |
| 382 | + | |
385 | 383 | | |
386 | 384 | | |
387 | 385 | | |
388 | 386 | | |
389 | | - | |
390 | | - | |
| 387 | + | |
391 | 388 | | |
392 | 389 | | |
393 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | | - | |
511 | | - | |
512 | | - | |
| 510 | + | |
513 | 511 | | |
514 | 512 | | |
515 | 513 | | |
| |||
523 | 521 | | |
524 | 522 | | |
525 | 523 | | |
526 | | - | |
527 | | - | |
| 524 | + | |
| 525 | + | |
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
| |||
537 | 535 | | |
538 | 536 | | |
539 | 537 | | |
540 | | - | |
541 | | - | |
| 538 | + | |
542 | 539 | | |
543 | 540 | | |
544 | 541 | | |
| |||
555 | 552 | | |
556 | 553 | | |
557 | 554 | | |
558 | | - | |
| 555 | + | |
559 | 556 | | |
560 | 557 | | |
561 | 558 | | |
| |||
568 | 565 | | |
569 | 566 | | |
570 | 567 | | |
571 | | - | |
572 | | - | |
| 568 | + | |
573 | 569 | | |
574 | 570 | | |
575 | 571 | | |
| |||
585 | 581 | | |
586 | 582 | | |
587 | 583 | | |
588 | | - | |
| 584 | + | |
589 | 585 | | |
590 | 586 | | |
591 | 587 | | |
| |||
0 commit comments