Skip to content

tower reconcile: failed reconnect triggers delete + SIGTERM without verifying the shellper is dead (destroyed 53 live sessions in the #1629 incident) #1686

Closed

Description

@amrmelsayed

Defect

Split from #1629's investigation (credit: builder-bugfix-1629). Reconcile Phase 2 (tower-terminals.ts:920-937) deletes the session row and SIGTERMs the pid for any shellper whose reconnect attempt merely FAILED — without verifying the process is actually dead or the socket file gone. In the #1629 incident this is the half that did the damage: the hijacking Tower's reconnects failed (sessions were owned by the real Tower — one-client-per-shellper), and Phase 2 destroyed 53/56 live rows on that failure alone.

The exposure is broader than the second-Tower scenario: any transient reconnect failure at boot (socket hiccup, slow shellper, fd pressure — see #1685's environment) can delete a live agent's row and signal its process, on a perfectly legitimate single Tower.

Fix shape

Reconnect failure must be treated as "could not confirm", not "dead":

  • Before delete/SIGTERM, require positive evidence of death: pid liveness check (process.kill(pid, 0) fails) AND/OR socket file absent — the same stale test the startup log already prints for genuinely dead sessions.
  • A row that fails reconnect but whose pid is alive is left in place (logged WARN, retried next reconcile/adoption pass) — never signaled.
  • Regression test: live-pid + failing-socket-connect row survives reconcile untouched.

Relationship

#1629's owner-lock guard (in flight for 3.3.4) prevents the second-Tower amplifier; this issue removes the destructive mechanism. Both are needed: the guard can't stop a single-Tower transient from triggering this path. Small, candidate for 3.3.4 if a lane moves fast, otherwise 3.3.5.

Activity

  1. added
    area/tower
    on Sep 16, 2026
  2. amrmelsayed commented on Sep 16, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  3. added 3 commits that reference this issue on Sep 17, 2026
    8707ea0
    6cd7d69
    86ec041
  4. added a commit that references this issue on Sep 17, 2026
    c2d0e3e
  5. added a commit that references this issue on Nov 4, 2026
  6. added a commit that references this issue on Nov 9, 2026
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

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions