Skip to content

Pass current-session identity through the Rust port-restart lifecycle test fixture #269

Closed

Description

@NOirBRight

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

  1. Start the old Gateway through one GatewayLifecycleCoordinator.
  2. Assert that the coordinator acquired an exact current-session identity for the old Gateway.
  3. Construct the restart backend with that exact session_owned_identity() and exercise the real port-change path.
  4. Preserve the hard two-second lifecycle budget.
  5. Preserve fail-closed behavior when no current-session identity exists.
  6. 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

  1. added
    ready-for-agentFully specified, ready for an AFK agent
    P1Priority 1: current iteration goal
    bugSomething isn't working
    on Jul 30, 2026
  2. NOirBRight commented on Aug 1, 2026

    @NOirBRight
    OwnerAuthor

    This was generated by AI during triage.

    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:

    • Lifecycle coordinator session-owned identity.
    • Controlled restart backend and exact-identity force-close gate.
    • Normal/debug deterministic controls.

    Acceptance criteria:

    • Assert a non-empty exact old identity before restart.
    • Exact identity permits one bounded force-close; missing identity permits none.
    • Old port release and new publication ordering pass ten consecutive normal and debug runs.
    • Full Rust and Clippy checks remain green.

    Out of scope:

  3. NOirBRight commented on Aug 2, 2026

    @NOirBRight
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1: current iteration goalbugSomething isn't workingcampaign:0.1.8-beta20.1.8 Beta2 generic tool compatibility campaignready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions