Commit e75fa8c
committed
fix(agent): eliminate TOCTOU in process_approval auto-approve + state transition
Merge the two separate lock scopes in process_approval() into a single
lock acquisition. Previously, auto_approve_tool() and the
ThreadState::Processing transition used separate locks, allowing the
thread to be pruned between them — leaving a dangling auto-approve
policy for a tool that never executed.
Now both operations happen under one lock. If the thread disappears,
the auto-approve is rolled back.
Adds regression test: test_auto_approve_with_thread_disappearance_rolls_back
https://claude.ai/code/session_01AjVMwYPFLcPPFAhN1YyPow1 parent 702af21 commit e75fa8c
1 file changed
+46
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1044 | 1035 | | |
1045 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
1050 | 1050 | | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1051 | 1055 | | |
1052 | 1056 | | |
1053 | 1057 | | |
| |||
2415 | 2419 | | |
2416 | 2420 | | |
2417 | 2421 | | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2418 | 2452 | | |
2419 | 2453 | | |
2420 | 2454 | | |
| |||
0 commit comments