Repository navigation
Commit c28cf4f
authored
fix(codex): force bounded settlement when a terminal turn notification stalls (#132413)
* fix(codex): force bounded settlement when a terminal turn notification stalls
After a gateway hard-kill mid Codex-harness run and restart, the resumed
turn could stay active forever: receiving a terminal turn notification
permanently disarmed the completion and terminal idle watches and disabled
route-close aborts, while completeTurn() only runs when the serialized
notification tail reaches the terminal handler. Any earlier never-settling
handler left the run active with every watchdog off - the session kept
reporting the dead run active and new chat sends queued behind the phantom
indefinitely ("codex app-server notification ignored for inactive turn").
The terminal idle watch now stays armed after terminal receipt and forces
settlement through the existing abort path within a 2-minute window
(deferring to pending server requests and finalization hooks, bounded by
the 30-minute absolute silence budget). Route drains resolve on route
release, and finalization's drain join also settles on run abort so Stop
cannot hang behind a blocked handler either.
Adds failing-first regression coverage for the watch controller, router
drain, and run-attempt finalization, plus a real-gateway boundary e2e:
SIGKILL mid-run, restart, startup orphan recovery, then a new inbound send
must produce a reply.
* fix(codex): join queued projection work within a bounded abort grace
Racing the finalize drain against the run abort signal skipped projection
work already queued on the notification tail whenever a timeout or Stop
completed the run, losing e.g. generated image media that the timeout
outcome is supposed to preserve. Give the drain a bounded grace after
abort instead: queued projections still join, while a blocked handler
tail can no longer hold finalization forever. Also scope the pinned
old-contract turn-watch test to the new settlement window and add a
deterministic queued-projection timeout regression.
* test(codex): pin short-window settlement after a queued finalization hook completes
Review flagged that hook settlement might leave the terminal watch on the
30-minute budget. Production already re-arms via the next turn-scoped
handler's entry touchActivity (attempt-notification-state.ts), so the
ordered case settles within the settlement window; this regression pins
that contract with the exact ordering: terminal received during a pending
hook, hook completes through the production decrement, and the following
blocked handler still settles on the short window.1 parent 2b1eee0 commit c28cf4f
9 files changed
Lines changed: 556 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | | - | |
182 | | - | |
| 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 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
183 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
184 | 243 | | |
185 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
186 | 250 | | |
187 | 251 | | |
188 | 252 | | |
189 | 253 | | |
190 | 254 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 255 | + | |
| 256 | + | |
195 | 257 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
201 | 261 | | |
202 | 262 | | |
203 | 263 | | |
204 | 264 | | |
| 265 | + | |
205 | 266 | | |
206 | 267 | | |
207 | 268 | | |
208 | 269 | | |
209 | 270 | | |
210 | | - | |
| 271 | + | |
211 | 272 | | |
212 | 273 | | |
213 | 274 | | |
214 | 275 | | |
215 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
216 | 321 | | |
217 | 322 | | |
218 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
162 | 174 | | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | | - | |
168 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
169 | 183 | | |
170 | 184 | | |
171 | 185 | | |
| |||
342 | 356 | | |
343 | 357 | | |
344 | 358 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
| 359 | + | |
358 | 360 | | |
359 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
360 | 367 | | |
361 | | - | |
| 368 | + | |
362 | 369 | | |
363 | 370 | | |
364 | 371 | | |
365 | 372 | | |
366 | 373 | | |
367 | 374 | | |
368 | | - | |
| 375 | + | |
369 | 376 | | |
370 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
371 | 381 | | |
372 | 382 | | |
373 | 383 | | |
| |||
454 | 464 | | |
455 | 465 | | |
456 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
457 | 471 | | |
458 | 472 | | |
459 | 473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | | - | |
98 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
99 | 118 | | |
100 | 119 | | |
101 | 120 | | |
| |||
0 commit comments