test: cover a live Codex turn owner keeping its turn on SessionStart

Merged
TE
2mo ago
+38-17

Refs #13395.

The dead-turn fix this PR originally carried landed on main through #13891 as CodexSessionTurnOwnerAdmission.recordedTurnOwnerMayStillBeAlive (83a1980379). Main's CodexSessionStartDeadTurnTests covers both reclaim branches, a dead owner and a reused PID, so this PR's original restart test is dropped as a duplicate.

What main still doesn't cover is the other side: a recorded owner that's still alive must keep its active turn when a second SessionStart arrives. The only no-overwrite test used a record with no PID, which takes the missing-evidence branch. A regression that reclaimed turns from live Codex processes would pass everything on main.

codexSessionStartDoesNotOverwriteExistingTurnState now runs twice: once with no recorded PID, as before, and once with the record owned by the test process itself, PID and start generation included. Both expect the turn, lifecycle, and resume binding to be left alone.

Validation

Focused run at b517cac3b3, 35965554685: CLICodexHookTimeoutRegressionTests (17 tests, both new cases passing) and CodexSessionStartDeadTurnTests (2 tests) passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded regression coverage for session-start handling across multiple process-identity scenarios.
    • Verified that rejected session starts preserve existing active-turn state and do not emit events. This strengthens validation of expected behavior when a session start encounters an already active turn.