Files
codex/codex-rs/core/tests
pakrym-oai ddbd1889ca Run write_stdin in parallel across unified-exec sessions (#1992)
## Why

`write_stdin` inherited serial tool dispatch, so long polls for
independent unified-exec sessions blocked each other even when the
caller used parallel tool calls or code-mode `Promise.all`.

The useful boundary is the terminal process: independent sessions should
overlap, while operations sharing one process must not overlap because
they mutate stdin, drain one output buffer, and observe the same
lifecycle.

## What changed

- opt `write_stdin` into parallel tool dispatch
- guard each unified-exec process with a process-local interaction mutex
while allowing different process IDs to overlap
- treat a held interaction mutex as a pruning reservation so parallel
`exec_command` calls cannot evict an actively polled process
- revalidate process identity after waiting for that mutex so a stale
waiter cannot redirect input to a replacement process
- add direct non-code and code-mode integration coverage using a
symmetric rendezvous: both sessions can finish only if their
`write_stdin` calls overlap

This does not add a source-order contract for calls targeting the same
session. Their interactions are mutually exclusive, but callers must not
depend on which concurrent call acquires the process mutex first.

## Testing

- `just test -p codex-core write_stdin` (13 passed)
- `just fix -p codex-core`
2026-07-20 18:04:56 -07:00
..