## Summary
Synchronize ACP v2 foreground state independently of prompt acceptance.
This PR is based directly on main after #649 merged.
- Send a current `state_update` after any requested history replay and
before every successful `session/resume` response, including
omitted/null `replayFrom`.
- Restore active runtime state on resume and serialize snapshots with
live state transitions so backpressure cannot send a stale snapshot
after newer state. Idle snapshots repeat neither completion usage nor
failure metadata.
- Report `running` when Codex accepts or reports foreground work,
including pre-insertion hooks. Prompt success still waits for the
user-message echo. Work that starts but never inserts input still ends
with an idle boundary, including transport loss before the turn-start
acknowledgment.
- Replace per-request requires_action/running brackets with
session-owned pending interactions and runnable items. Parallel work can
remain running; answering one wait does not blindly resume a
still-blocked workflow.
- Use actual runtime starts, streamed progress, and active status with
no wait flags as positive progress evidence. Nonempty Codex wait flags
count requests and are not by themselves evidence that the whole
workflow is blocked.
- Do not resume withdrawn interactions, and invalidate old waits at
idle/close so late answers cannot revive an ended turn or alter a newer
turn.
- Update the developer contract, snapshots, and focused regression
coverage. Add a real-process v2 integration test for early running,
prompt insertion, and all three resume modes.
ACP v1 behavior and the existing AIR subagent wire contract are
preserved. Standard structured failure reporting, initial commands,
system prompts, and standard subagent sessions remain separate work
packages; failure stop reasons are intentionally unchanged here.
## Specification and runtime evidence
Checked ACP specification revision `4034a8c`:
- [Current-state
synchronization](https://github.com/agentclientprotocol/agent-client-protocol/blob/4034a8cbc99bc48fd4579f70a3407b07907e0eb6/docs/protocol/v2/session-setup.mdx#L313-L329)
- [Foreground state and user-action
semantics](https://github.com/agentclientprotocol/agent-client-protocol/blob/4034a8cbc99bc48fd4579f70a3407b07907e0eb6/docs/protocol/v2/prompt-lifecycle.mdx#L843-L938)
Codex runtime status semantics checked against bundled runtime `0.160.1`
(`codex-rs/app-server/src/thread_status.rs`): wait flags count pending
interactions; active status with no wait flags implies the runtime is
running.
## Validation
- `npm run typecheck` — passed, including examples.
- `npm test` — 1,802 passed; 36 skipped.
- `npm run build` — passed.
- `npm run test:integration` — 5 passed, including the new real-process
ACP v2 test with a local mock model.
- `npm run codex-test` — live-model smoke test from an empty scratch
directory completed with `end_turn`.
- `git diff --check` — passed.
The full live-model E2E suite was not run.