Skip to content

fix(codex): preserve classic RPC turn lifecycle and replay - #601

Draft
xiaoxueSunn wants to merge 9 commits into
deepcoldy:masterfrom
xiaoxueSunn:split/classic-codex-rpc
Draft

fix(codex): preserve classic RPC turn lifecycle and replay#601
xiaoxueSunn wants to merge 9 commits into
deepcoldy:masterfrom
xiaoxueSunn:split/classic-codex-rpc

Conversation

@xiaoxueSunn

@xiaoxueSunn xiaoxueSunn commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Extract the classic Codex/RPC lifecycle fixes from the original mixed PR into a dedicated review branch.

This PR:

  • keeps pending RPC turns in the active lifecycle until an authoritative terminal boundary
  • preserves native turn routing and replay anchors across activation races, restarts, delayed ACKs, and worker replacement
  • reconciles response-last/history matches without attaching a completion to the wrong turn
  • keeps classic Codex, Codex RPC, and Coco history-append behavior covered together

It intentionally excludes RIFF shutdown, PM2 fleet shutdown, and managed-origin/read-isolation hardening.

Stack

#596 has merged. This PR still depends on #597 and remains Draft until #597 merges.

The branch has been refreshed onto the current master. A merge-state-only wiring assertion was updated for master's empty-completed diagnostic fallback; no production code changed in that follow-up.

Validation

Latest master merge-state validation:

  • PR-specific changed tests: 17 files, 461 tests passed
  • lifecycle / pending turn / ACK / replay / worker replacement / mutation-gate regression: 12 files, 380 tests passed
  • timeout/reaping pair: 37 tests passed, then 5 additional rounds (185/185)
  • real tmux worker replacement / reattach integration: 4/4 passed in two consecutive single-worker runs after generating current merge-state build artifacts
  • merge-compat wiring + fallback + gate: 3 files, 72 tests passed
  • TypeScript typecheck (tsc --noEmit)
  • git diff --check

No daemon, PM2, or RIFF runtime was restarted during validation.

经典 Codex 在 structured turn 已 started 未 final 时,屏幕启发式会把
prompt/PTY 静默投影为 idle。统一用 projectRuntimeScreenStatus:
structuredTurnBlocking 优先于 promptReady;三入口(markPromptReady /
周期 screen update / 截图)共用;仅 codex allowlist 强门控;
submit verification/confirm 使用 30s/20s 有界 lease,到期 fail-open
防止掉 Enter 永久假忙。
…+ coco/codex history-append tests

RPC mode has no local transcript ingest, so a turn never reaches
'started' and relied solely on the 20s confirmation lease. A turn running
longer than 20s (e.g. approval pending) was pruned by pruneExpiredPreStartHeads
→ false idle. Add rpcActive flag + markRpcActive/stopRpcActive so the
lifecycle gate stays asserted for the full server-side run; hasBlockingTurn,
pruneExpiredPreStartHeads, preStartLeaseRemainingMs, and refreshNextPreStartLease
all respect it. stopCodexRpcEngine clears rpcActive turns + rejected-ready
evidence.

Add 5 RPC tests (codex-bridge-queue) and 3 coco/codex history-append return-value
tests (write-input).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant