Fix premature Codex completion notifications

Merged
AU
2mo ago
+2091-244

Summary

  • Add behavior regressions for nested Codex reviewer Stops, native child lifecycle, exact final completion, and normal top-level Stops.
  • Supersedes the approach in #9512 without modifying that open PR.

Fixes #7520

Regression provenance

The first commit (be5ee2a567) intentionally adds executable behavior tests before the implementation. CI should fail until the ownership/settlement implementation lands.

Testing

  • Pending CI red baseline for CodexTurnCompletionOwnershipTests.
  • Implementation and final CI proof will follow in a separate commit.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features

    • Improved Codex turn tracking for nested agents and child processes.
    • Completion notifications and runtime status now reflect child lifecycle events more accurately.
    • Prevented duplicate or premature completion notifications while child work remains active.
    • Added reliable handling for Codex subagent start and stop events.
    • Improved persistence and recovery of Codex turn state.
  • Tests

    • Added coverage for nested processes, child-agent activity, exactly-once completion, and standard top-level stops.