## Summary
Fix the `/compact` completion race observed while implementing client
system prompts.
Compaction item completion is a progress/lifecycle signal, not proof
that Codex has released the turn. The command now waits for the matching
terminal `turn/completed` notification before completing foreground
work. It returns the real turn result through the existing success,
cancellation, and failure handling.
- V1 holds the prompt response until the compact turn ends.
- V2 still accepts the prompt early, but holds idle and the next queued
prompt until the turn ends.
- Compaction progress updates, including legacy `thread/compacted`
rendering, are unchanged.
- Existing close/dispose/process-exit handling still rejects pending
waits and releases observers.
- Remove the runtime-log wait from the real-process system-prompt
integration fixture: it now starts the next probe immediately after ACP
completion.
Standard subagent support remains a separate work package.
## Validation
- Added a regression assertion that failed on the original
implementation: item completion resolved the command before turn
completion.
- Added v1/v2 wire-order snapshots proving the next prompt cannot start
in that gap.
- Cover early success/failure/cancellation before acknowledgement,
unrelated turn completion, and failure/cancellation after item
completion; retain rejection, cancellation, and connection/process-exit
coverage.
- `npm run typecheck` — passed, including examples.
- `npm test` — **1,867 passed**, 36 skipped.
- `npm run build` — passed.
- `npm run test:integration` — **7 passed**, including immediate
compact-to-prompt transitions through ACP v1/v2 against real Codex
app-server with a local mock model, without runtime-log synchronization.
- `npm run codex-test -- -p '/compact' ... -o summary` — passed against
real Codex; ended with `end_turn` and observed both item and turn
completion.
- `git diff --check` — passed.
The full live-model E2E suite and local cross-platform binary bundles
were not run; CI runs binary bundling.