Repository navigation
Commit 9c33f86
authored
fix: fence turn interrupt retries to the original prompt (#723)
## Summary
Continues the original SDK 2.2 audit at specification baseline
`d5e9949c3e6a9cd072adebaa44e6f63289590c17`. No later specification
changes are included.
The missing cancellation-crossing-next-prompt test exposed a real bug:
an old `turn/interrupt` could return `no active turn to interrupt` after
a newer prompt started. Retry eligibility checked only whether *any*
prompt was active, then recomputed the turn ID from the newer prompt's
state. The old cancellation could therefore interrupt work received
after it.
- Bind interrupt retries to the original active-prompt identity and its
registered turn, rather than to the presence of any active prompt.
- Recheck ownership after retry waits and while awaiting child
interruption/pending turn starts.
- Do not remap an explicit late turn ID through a newer prompt's
registered state.
- Keep legitimate same-prompt registration retries, including the
existing shared v1 cancellation behavior.
- Add a v2 wire regression matrix for acknowledgement-before-completion,
completion-before-acknowledgement, and a delayed no-active-turn error.
Earlier queued prompts are cancelled; later prompts run normally and are
never targeted by the old interrupt.
## Validation
- `npm run typecheck`: passed
- `npm run build`: passed
- `npm test`: 2,368 passed, 39 skipped
- `npm run test:integration`: all 19 passed
- `git diff --check`: passed
The late-error regression failed before the implementation fix by
observing an extra interrupt against `turn-2`. Existing v1 cancellation
and retry tests pass unchanged. The real-Codex integration matrix covers
normal cancellation and child ownership; the exact delayed-error race is
injected through the native mock for deterministic wire coverage. Opt-in
E2E tests were not run.
This PR is independently based on main and does not include #720, #721,
or #722. No review Markdown file is included.1 parent 3720341 commit 9c33f86
2 files changed
Lines changed: 64 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4374 | 4374 | | |
4375 | 4375 | | |
4376 | 4376 | | |
| 4377 | + | |
4377 | 4378 | | |
4378 | 4379 | | |
4379 | 4380 | | |
4380 | 4381 | | |
4381 | 4382 | | |
4382 | 4383 | | |
| 4384 | + | |
4383 | 4385 | | |
4384 | 4386 | | |
4385 | 4387 | | |
| |||
4395 | 4397 | | |
4396 | 4398 | | |
4397 | 4399 | | |
| 4400 | + | |
4398 | 4401 | | |
4399 | 4402 | | |
4400 | 4403 | | |
| |||
4407 | 4410 | | |
4408 | 4411 | | |
4409 | 4412 | | |
4410 | | - | |
| 4413 | + | |
| 4414 | + | |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
4411 | 4419 | | |
4412 | 4420 | | |
4413 | 4421 | | |
| |||
4420 | 4428 | | |
4421 | 4429 | | |
4422 | 4430 | | |
4423 | | - | |
4424 | 4431 | | |
4425 | 4432 | | |
4426 | 4433 | | |
4427 | 4434 | | |
4428 | | - | |
| 4435 | + | |
4429 | 4436 | | |
4430 | 4437 | | |
4431 | 4438 | | |
| |||
4438 | 4445 | | |
4439 | 4446 | | |
4440 | 4447 | | |
| 4448 | + | |
4441 | 4449 | | |
4442 | 4450 | | |
4443 | 4451 | | |
| |||
4470 | 4478 | | |
4471 | 4479 | | |
4472 | 4480 | | |
| 4481 | + | |
4473 | 4482 | | |
| 4483 | + | |
4474 | 4484 | | |
4475 | | - | |
| 4485 | + | |
4476 | 4486 | | |
4477 | 4487 | | |
4478 | 4488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 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 | + | |
139 | 189 | | |
140 | 190 | | |
141 | 191 | | |
| |||
0 commit comments