Repository navigation
Pass current-session identity through the Rust port-restart lifecycle test fixture #269
Description
Problem
proxy::tests::restart_after_settings_port_change_stops_recorded_port_before_starting_new_port is flaky in the debug Rust flavor. The exact failure is:
Gateway user-requested shutdown refused force-close because #139 has no current-session identity
The test starts the old Gateway through test-only start_with_paths(), then constructs a fresh lifecycle coordinator/backend with session_owned_identity: None. Restart has one hard two-second stop budget. When debug instrumentation makes graceful exit cross that deadline, the test enters the force-close path, where the #139/#143 safety contract correctly refuses to kill a process without an exact current-session identity.
The production restart_after() path obtains session_owned_identity() from the global coordinator, so the test fixture currently bypasses the ownership handoff it intends to exercise. The same SHA passed in the normal flavor and passed on rerun in debug, confirming a pre-existing fixture/timing flake rather than a runtime regression from #265.
Related: #139 and #143 define the safety boundary and must remain intact. #263 covers a different Rust helper/cache cleanup problem.
Required behavior
- Start the old Gateway through one
GatewayLifecycleCoordinator. - Assert that the coordinator acquired an exact current-session identity for the old Gateway.
- Construct the restart backend with that exact
session_owned_identity()and exercise the real port-change path. - Preserve the hard two-second lifecycle budget.
- Preserve fail-closed behavior when no current-session identity exists.
- Do not permit force-close based only on a durable PID, and do not weaken Serialize Gateway lifecycle operations and prevent duplicate startup processes #139/Cancel active Gateway work within two seconds on explicit lifecycle stops #143 to make the test pass.
Acceptance
- The port-restart test proves the old port is released before the new port is published in both normal and debug flavors.
- The test asserts that the exact old Gateway identity was captured before restart.
- Deterministic controls cover:
- a process still alive at the deadline plus the exact identity → exactly one force-kill of that identity and restart succeeds;
- a process still alive at the deadline plus no identity → exact refusal, no kill, and preserved PID evidence.
- The targeted normal and debug test each pass 10 consecutive runs.
- The complete Rust suite passes in both normal and debug flavors.
Verification
Verification class: strict (Gateway lifecycle, process ownership, and nondeterministic timing evidence).
Run the targeted repetitions, then cargo test --locked for both feature flavors and cargo clippy --locked --all-targets -- -D warnings. Exact-candidate CI must be green.
Activity
NOirBRight commentedon Aug 1, 2026
Agent Brief
Category: bug
Summary: Finish the exact-session-identity contract for the port-change restart fixture.
Current behavior:
Merged PR #297 now starts through a lifecycle coordinator, copies its session-owned identity into the controlled restart backend, and passed targeted normal/debug tests plus both full Rust suites. The issue is therefore partially implemented, not a fresh rewrite. It still lacks the issue's explicit acquired-identity assertion, deterministic exact-identity versus no-identity controls, and recorded ten-run repetitions.
Desired behavior:
The fixture proves it holds the exact old Gateway identity before restart, succeeds through the exact-identity force-close path when needed, and continues to fail closed without that identity.
Key interfaces:
Acceptance criteria:
Out of scope:
test: pass exact Gateway session identity through port restart
NOirBRight commentedon Aug 2, 2026
Implemented and merged via #323 (squash commit 0225e7f). Exact-head review passed; normal/debug targeted repetitions 10/10, full Rust suites, Clippy, and Hosted CI / gate all passed.