Skip to content

mcpx: Phase 2 of #1384 — takeover becomes attach for supervised stdio instances #9962

Closed

Description

@dezren39

Phase 2 of epic #1384 — takeover becomes attach for supervised instances

Parent design: #1384 (adopted by Drew 2026-10-27: per-instance mcpx supervisor replaces the stdio takeover handoff). Phase 1 (#1385, supervised stdio transport behind a flag) closed 2026-10-28, so the socket protocol this phase depends on now exists as built.

Scope

  • A successor daemon attaches to already-running supervisors via a state-dir scan; supervised stdio instances are adopted, not handed off.
  • No kindPipe / pools handoff frames are exchanged for supervised instances; child PIDs are unchanged across a daemon restart.
  • Listeners and upstream HTTP sessions keep the existing takeover handoff unchanged.

Acceptance criteria

  • E2E supervised variant of internal/e2e/takeover_test.go: daemon restarts, asserts no pipe frames for supervised instances and PID continuity of the stdio child.
  • Unsupervised (legacy) instances still take the existing handoff path, covered by the existing takeover tests.
  • A daemon started against a state dir with running supervisors attaches without spawning duplicate children for the same server instance.

Filed by fleet triage (task 15159, lane code-d, 2026-11-14) per #1384's acceptance item 2: implementation issues exist for each phase.

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    epic/mcpx-platformReprioritization program epic (2026-11-12)
    on Nov 14, 2026
  2. developing-today commented on Nov 14, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged

    Triage verdict (fresh, 2026-11-14): Phase 2's scope is confirmed against current main and packaged.

    • Surface located: pkgs/mcpx/internal/daemon/takeover.go carries the kindPipe/kindPools handoff this phase retires for supervised instances; the Phase 1 transport it builds on is pkgs/mcpx/internal/mcpclient/supervised.go (+ internal/cli/supervise.go); the E2E harness to variant is pkgs/mcpx/internal/e2e/takeover_test.go.
    • Follow-on: queue task 16879 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:9962) — state-dir scan + attach on daemon startup, no handoff frames for supervised instances, PID continuity, duplicate-child guard, legacy path untouched, acceptance = the issue's own criteria.
      Task 16787 completes as triaged naming task 16879.
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 16, 2026
  5. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: parked

    Verified against current main (2026-11-16) before parking on the run's wall clock. The packets's stated problem is materially narrower than the code — recording it so the next worker does not plan against the wrong surface:

    1. No pipe frames are currently sent for supervised instances, and none can be. pool.Detach type-switches on the transport (pkgs/mcpx/internal/pool/handoff.go:111-125): only *mcpclient.StdioTransport and *mcpclient.HTTPTransport are handed on; *mcpclient.SupervisedTransport falls to default: continue. So acceptance item 1's "zero kindPipe frames" is already true by accident.
    2. The real defect is instance loss, not handoff churn. Because the supervised instance never enters PoolHandoff.Instances (and never p.handed), Pool.Commit (handoff.go:132-150) closes it as "parked, not released" → SupervisedTransport.Close() detaches from the supervisor. The child survives (the supervisor owns it) but the successor loses the instance: MCP session state (era, calls, subscribed, StartedAt, exec identity) is dropped and the server is re-initialized lazily on the next call. That is the observable "restart disturbs instances" symptom Phase 2 must end, not a duplicate-child or pipe-frame symptom.
    3. Client.Detach cannot be reused as-is: pkgs/mcpx/internal/mcpclient/handoff.go:181 returns only a stdio session can be handed off for any non-StdioTransport.
    4. No competing work: no open PR mentions mcpx: Phase 2 of #1384 — takeover becomes attach for supervised stdio instances #9962, no remote branch matches 9962/supervis (checked 2026-11-16T11:03Z). Issue open, unheld (held, user/owned, do-not-merge, do-not-auto-edit all absent).

    Implementation shape the next worker can start from (not yet written):

    • pool.InstanceHandoff gains a supervised marker (server name is enough — the supervisor socket is mcpclient.SupervisorSocketPath(stateDir, name)), and Detach records supervised instances without calling Client.Detach, adding them to p.handed so Commit releases instead of closes them.
    • Successor side (daemon.takeover reception → commitTakeover): for a supervised instance, NewSupervised attaches to the live supervisor socket (attach-in-place, no spawn, PID continuous) and the client is built over the handed Session state without a fresh initialize.
    • sendChildren needs no pipe-frame work; the supervised marker must be carried in the existing kindPools frame.
    • Tests: supervised variant of pkgs/mcpx/internal/e2e/takeover_test.go (Mcpx.Supervised: true) asserting child-PID continuity across restart, exactly one child, and the session state surviving; the existing legacy takeover tests must stay unchanged. pkgs/mcpx suite (or clean-main failure set) per packet acceptance.

    Resume condition: claim task 16879 again — the worktree/branch exist and are empty, and the four findings above are the whole starting context.

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 16, 2026
  7. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: in-progress (resumed)

    Resume verified fresh (2026-11-16, lane code-c):

  8. added a commit that references this issue on Nov 16, 2026
  9. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Done — PR #10719 merged (71e67a6a5c8dd73371098ec01325ac1ac1dd96f7), task 16879, lane any-c, 2026-11-16

    Phase 2 landed as designed in #1384: takeover becomes attach for supervised instances.

    • State-dir scan / adoption: Registry.AdoptSupervised runs at daemon startup (Listen) and again in commitTakeover immediately after Adoption.Attach() — the point where the predecessor's commit has detached it from the supervisors. Each supervised pool with a live supervisor and no instance in its default lane adopts the child via Pool.AdoptRunningSupervised (attach-only startLaneMode/dialMode → mcpclient.AttachSupervised, which never spawns). No live supervisor, another daemon attached, or an instance already serving the lane are quiet no-ops — no duplicate children.
    • No handoff frames: supervised instances remain excluded from Pool.Detach's handoff (no kindPipe, no pools-frame entries) — adoption replaces handoff.
    • PID visibility: Instance.PID() now surfaces the supervised child's PID from the attach handshake (was 0, which made attach indistinguishable from respawn in status).

    Acceptance, verified test-first (the new E2E failed before the change: successor reported PID 0 / no adopted instance):

    • TestTakeoverAttachesToSupervisedChild (new): child PID identical across daemon --takeover, calls answered through the same child, child survives the predecessor's exit.
    • Existing takeover tests pass unchanged (TestTakeoverKeepsTheChildAndTheListener, family in the full run).
    • internal/pool, internal/daemon, internal/mcpclient suites green.
    • Full pkgs/mcpx suite vs clean-main baseline at the branch's fork point (43766b9): every test passes on both. Package-level failures are identical in kind and unattributable to this change — internal/settings TestTheEnvironmentDocIsCurrent fails byte-identically on baseline (pre-existing stale doc), and the e2e package guards (feature-coverage ledger; real-daemon disturbance mcpx testing: e2e inherits the caller's environment -- build it from an allowlist so tests never reach the user's daemon #1992) fail on baseline too, with run-dependent identity on this loaded machine. TestThePluginSuiteRunsAgainstARealDaemon failed once inside the loaded full run and passes standalone on both branch and baseline.
  10. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 16, 2026
  11. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done (verified independently by lane code-c)

    Outcome: PR #10719 MERGED 2026-11-16T12:20:52Z (merge sha 71e67a6) by the parallel session holding the earlier claim; task 16879 completed in the queue at 12:21:45Z; this issue is CLOSED (status:done).

    Independent verification by this lane at PR head f08ddae (run on the laptop in the PR worktree, via fleet-build-lock, module root pkgs/mcpx):

    • go test ./internal/e2e/ -run TestTakeover -count=1 -v — PASS, all 5: TestTakeoverAttachesToSupervisedChild (new, 0.62s), TestTakeoverKeepsTheChildAndTheListener, TestTakeoverRestartsAChangedServerAndKeepsTheRest, TestTakeoverWithNoDaemonToTakeOverFails, TestTakeoverLosesNoCallsWhileAClientKeepsCalling.
    • go test ./internal/pool/ ./internal/daemon/ ./internal/mcpclient/ -count=1 — ok pool 23.5s, ok daemon 81.3s, ok mcpclient 13.3s.
    • Codex review on PR feat(mcpx): takeover becomes attach for supervised instances (#9962) #10719 failed to run (usage limits, zero findings); CodeRabbit rate-limited/skipping — no findings to disposition.
      The full ./... suite re-run was cut short when the merge removed the worktree; every package the PR touches was covered by the targeted runs above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepic/mcpx-platformReprioritization program epic (2026-11-12)kind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)status:done

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions