mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Track executor registrations across connection refresh and recovery (#46555)
## Why An executor can renew its registration while retaining its Noise identity. Connection refresh must distinguish registrations even when their keys match, and a stale registry lookup must not retire a session that recovery has already renewed. ## What changed - Track the installed session's registration and expose it through `Environment::cached_executor_registration_id()` without connecting. Publish registration changes only when the new connection is installed. - Require both registration and executor key to match before refresh reuses a session. Retry stale lookups and prevent recovery from installing a connection after retirement. - Pin session recovery to the original Noise key while allowing registration renewal to preserve the session and running processes. - Expose `CodexThread::active_turn_environment_selections()` so hosts can authorize steering against the active turn's selections, including starting and failed environments, independently of later settings updates. ## Testing Add regression coverage for registration replacement, renewal with a running process, stale refresh lookups, missing sessions, and rejection of changed Noise keys. Extend active-turn tests to check selection snapshots across settings updates, deferred startup, and turn completion. GitOrigin-RevId: 4395bc6c57f137691887e6585f52dcc5b958101c
This commit is contained in:
@@ -908,6 +908,19 @@ impl Environment {
|
||||
}
|
||||
}
|
||||
|
||||
/// Registration on the installed Noise session, without connecting or refreshing it.
|
||||
///
|
||||
/// Returns `None` before a session is installed and for non-Noise environments.
|
||||
/// A registry lookup does not change this value until the new connection is
|
||||
/// installed. Recovery may renew the registration while preserving the session.
|
||||
/// Callers that authorize asynchronously must check the snapshot again before
|
||||
/// admitting work.
|
||||
pub fn cached_executor_registration_id(&self) -> Option<String> {
|
||||
self.remote_client
|
||||
.as_ref()
|
||||
.and_then(LazyRemoteExecServerClient::cached_executor_registration_id)
|
||||
}
|
||||
|
||||
/// Refresh the connection to the executor currently registered for this environment.
|
||||
///
|
||||
/// # Caller contract
|
||||
@@ -920,11 +933,11 @@ impl Environment {
|
||||
/// # Session behavior
|
||||
///
|
||||
/// A fresh registry lookup determines whether the current session can be reused.
|
||||
/// A changed executor key, or a failed or missing session, causes a fresh connection
|
||||
/// A changed registration or executor key, or a failed or missing session, causes a fresh connection
|
||||
/// without resuming the old session. Retirement cancels old recovery, fails its
|
||||
/// outstanding work and process handles, and never replays commands. The environment
|
||||
/// object and filesystem handle remain usable through the new connection.
|
||||
/// A matching executor key preserves a session that has not failed, including one
|
||||
/// A matching registration and executor key preserve a session that has not failed, including one
|
||||
/// that is recovering; the live readiness check rejects a recovering connection.
|
||||
///
|
||||
/// # Completion and errors
|
||||
|
||||
Reference in New Issue
Block a user