Commit dbbc8fa
committed
FIX: Release the leading TAP branch as soon as the lead changes
Two defects, both found by diffing this branch against main rather than by a
test failing.
TAP records every branch as PRUNED while the run is in flight, and the leading
one was taken back out only while building the result. A run that raises never
builds one, so its own conversation stayed in both places: it was the error
result's conversation_id and a pruned entry at the same time.
attack_service.list_attacks adds the main conversation's message count to the
pruned ones and sums a list rather than a set, so that run's messages were
counted twice in the backend, and the markdown and pretty printers rendered the
conversation twice. The release now happens wherever the lead is recomputed,
which is the last step of every iteration, so the invariant holds at every
instant instead of only once a result exists. A branch that led and then lost it
is an abandoned branch again, so it goes back. The fallback that picks a
conversation when no node completed was setting the lead without releasing it;
it goes through the same path now.
That makes the release at result-build time unreachable, since the lead is
always recomputed last, so it is gone rather than left as dead code.
Second, _resolve_live_conversation_id had grown a hasattr dispatch that changed
what the error-result builder does for a TAPAttackContext with no nodes and no
best branch: main falls through to session.conversation_id, this returned None
and the caller minted a fresh uuid. Neither id names anything real, but that is
#2322's code and this PR was not asked to change it. It is back to main's exact
lookup, verified by computing both over all six concrete context types: zero
divergences.
Towards #12471 parent 548157e commit dbbc8fa
4 files changed
Lines changed: 96 additions & 29 deletions
File tree
- doc/code/targets
- pyrit/executor/attack
- core
- multi_turn
- tests/unit/executor/attack/multi_turn
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
186 | | - | |
| 188 | + | |
| 189 | + | |
187 | 190 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| |||
762 | 764 | | |
763 | 765 | | |
764 | 766 | | |
765 | | - | |
766 | | - | |
767 | | - | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
768 | 774 | | |
769 | 775 | | |
770 | 776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1921 | 1921 | | |
1922 | 1922 | | |
1923 | 1923 | | |
1924 | | - | |
| 1924 | + | |
1925 | 1925 | | |
1926 | | - | |
| 1926 | + | |
1927 | 1927 | | |
1928 | 1928 | | |
1929 | | - | |
1930 | | - | |
1931 | | - | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
1932 | 1939 | | |
1933 | 1940 | | |
1934 | 1941 | | |
| 1942 | + | |
| 1943 | + | |
1935 | 1944 | | |
| 1945 | + | |
| 1946 | + | |
1936 | 1947 | | |
1937 | 1948 | | |
1938 | 1949 | | |
| |||
2193 | 2204 | | |
2194 | 2205 | | |
2195 | 2206 | | |
| 2207 | + | |
2196 | 2208 | | |
2197 | 2209 | | |
2198 | 2210 | | |
| |||
2210 | 2222 | | |
2211 | 2223 | | |
2212 | 2224 | | |
| 2225 | + | |
| 2226 | + | |
2213 | 2227 | | |
2214 | 2228 | | |
2215 | 2229 | | |
| |||
2436 | 2450 | | |
2437 | 2451 | | |
2438 | 2452 | | |
2439 | | - | |
2440 | | - | |
2441 | | - | |
2442 | | - | |
2443 | 2453 | | |
2444 | 2454 | | |
2445 | 2455 | | |
| |||
2451 | 2461 | | |
2452 | 2462 | | |
2453 | 2463 | | |
2454 | | - | |
2455 | | - | |
2456 | 2464 | | |
2457 | 2465 | | |
2458 | 2466 | | |
| |||
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
1623 | 1636 | | |
1624 | 1637 | | |
1625 | 1638 | | |
| |||
3321 | 3334 | | |
3322 | 3335 | | |
3323 | 3336 | | |
3324 | | - | |
| 3337 | + | |
3325 | 3338 | | |
3326 | 3339 | | |
3327 | 3340 | | |
3328 | 3341 | | |
3329 | 3342 | | |
3330 | 3343 | | |
3331 | | - | |
3332 | | - | |
3333 | | - | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
3334 | 3347 | | |
3335 | 3348 | | |
3336 | 3349 | | |
| |||
3500 | 3513 | | |
3501 | 3514 | | |
3502 | 3515 | | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
3503 | 3530 | | |
3504 | 3531 | | |
3505 | 3532 | | |
| |||
3514 | 3541 | | |
3515 | 3542 | | |
3516 | 3543 | | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
3517 | 3570 | | |
3518 | 3571 | | |
3519 | 3572 | | |
| |||
0 commit comments