GeezerVison is showing github.com — design(mcpx): resume upstream HTTP sessions after a cold restart — persist the resumable session state · Issue #1414 · developing-today/code
design(mcpx): resume upstream HTTP sessions after a cold restart — persist the resumable session state #1414Done 2 / 22 of 2 issues completedDone 2 / 22 of 2 issues completed Labels app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)epic/mcpx-platformReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionDecision for Drew (one line): Approve persisting mcpx upstream HTTP session state (session IDs + protocol state, never resolved header secrets) to the owner-only state dir so a cold restart resumes sessions instead of re-initialising every HTTP upstream — yes/no; the graceful-shutdown DELETE question in Phase 3 rides on the same decision.
Design doc: files/designs/code-mcpx-cold-restart-session-resume.md in the keep-the-four-repos-healthy goal workspace. Register: central potential-projects list, same workspace (files/potential-projects.md).
Summary
A takeover preserves upstream HTTP sessions; a cold restart does not. pkgs/mcpx/TODO.md item 3: "The lease table is restored from sessions.json, but the upstream Mcp-Session-Id is kept only in memory and in the takeover handoff, so after a restart each HTTP upstream is initialised again." Roadmap: planning/roadmaps/mcpx.md → Next → "Resume upstream sessions after a cold restart" (status idea).
Costs per cold restart, per HTTP upstream: a fresh initialize handshake, silent loss of upstream per-session state, and one leaked upstream session (the dead daemon never sent DELETE; the new daemon doesn't know the ID — #260 fixed this leak for takeover only).
Proposal: persist the resumable half of each legacy streamable-HTTP upstream session in a new versioned state-dir file (same discipline as internal/daemon/sessions.go: atomic tmp+rename, defaults.PrivateMode, version envelope, ignore-on-mismatch), and let a cold-started daemon take the existing takeover restore path with the record standing in for the socket:
- Record per pool instance: instance key, URL, config fingerprint (hash over session-defining config fields + header/auth names, never values),
HTTPHandoff minus Headers (SessionID, Negotiated), the full mcpclient.Session protocol state, savedAt.
- No resolved header values on disk — the codebase's rule is that handoff headers travel "over the takeover's unix socket only" (
internal/mcpclient/http.go, HTTPHandoff comment). On restore, headers are re-derived from live config (httpOptions() + resolveAuth()), then the transport/client are seeded with the exact calls takeover makes: ht.Resume(...) and mcpclient.Resume(...) (internal/pool/handoff.go:238,326). No parallel resume implementation.
- Save on legacy session establishment and on session-ID change (
internal/mcpclient/http.go:156 is where IDs are adopted); save failure is logged, non-fatal — resume is an optimisation.
- Scope: legacy-era streamable HTTP only. Modern era (2026-07-28) has no sessions; legacy SSE holds its session in the GET stream (TODO item 2 already accepts re-init there).
Grounding: internal/mcpclient/http.go (sessionID/negotiated in memory only), internal/mcpclient/handoff.go (SessionState(), Resume — the no-handshake client already exists), internal/pool/pool.go:704 (dial() seeds nothing today), internal/daemon/sessions.go (persistence precedent). Sibling of #1384 (stdio supervisor), which names cold-restart HTTP resume as an explicit non-goal — this design is that non-goal, designed separately. Alternatives (do nothing; fold into sessions.json; persist full handoff incl. headers; era-cache-only) and risks (stale-session resume, session IDs as bearer tokens on disk, write amplification, restore-path drift) are argued in the design doc.
Phased breakdown
- Phase 1 — persist and resume. New state file + record type; fingerprint gate; restore via the takeover path. Defining test: session established → daemon SIGKILLed → restarted → first call succeeds, upstream saw no second
initialize, request carried the original Mcp-Session-Id. Filed as a sub-issue of this issue.
- Phase 2 — expiry fallback and record hygiene. First request on a resumed session answered 404 (or 401/403 after credential rotation) → drop record, fresh
initialize, retry once, transparently. Server removed from config → record deleted + best-effort upstream DELETE, or logged left-to-expire (the mcpx: takeover orphans a removed server's upstream HTTP session — never DELETEd, left to expire upstream #260 degradation, made explicit). Coordinate with the roadmap's "Legacy client robustness" row (nix#200–Update module golang.org/x/net to v0.55.0 [SECURITY] #203) — this is only the resumed-session slice. Filed as a sub-issue of this issue.
- Phase 3 — open questions, NOT filed. Graceful-shutdown semantics (should a restart-intent stop skip the DELETE that
Close → closeSession sends today?); record TTL; dashboard resumed-vs-fresh visibility; whether takeover should also write the record. The shutdown question is part of Drew's decision above.
agent-note:v1 — filed by the repo design architect (dedicated code job, pass 2, 2026-10-27). Design doc + register entry as linked above. user/review carries the one-line direction decision at the top; Phases 1–2 are filed as sub-issues with queue/queued + task/triage packets enqueued to repo-health-code-pilot; Phase 3 stays as questions in the design doc.
Acceptance criteria
Sub-issuesCollapse Sub-issuesSub-issues2 of 22 of 2 Issues completedLoading 2 sub-issues Activityadded user/reviewNeeds a user-look: Muse reviews first and handles what it can app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo) epicMeta-issue grouping multiple items (org Project Type=Epic) effort/lLarge: multi-day or open-ended; expect staged check-ins kind/designA design proposal (design-architect): multi-step, phased, decision-bearing on Oct 27, 2026developing-today commented on Oct 27, 2026 dezren39 commented on Oct 27, 2026 Intake review
Fleet monitor intake pass, 2026-10-27 (repo-fleet-monitor).
Related: implementation phases already filed — #1415 (Phase 1: persist + resume legacy HTTP sessions) and #1416 (Phase 2: expiry fallback + record hygiene), both enriched earlier today and queued. Design doc: files/designs/code-mcpx-cold-restart-session-resume.md in the goal workspace.
Notes: This is the decision parent, not a work item: it already carries priority/normal, effort/l, kind/design and user/review. The one-line decision in the body (persist session state — yes/no) is genuinely Drew's, so the phases stay queued behind it.
Risks: Persisting anything beyond session IDs + protocol state would be a secrets bug — the acceptance criteria restate the never-secrets boundary.
Suggested approach: Drew decides on this issue; on a yes, #1415 is the first claimable step. dezren39 commented on Oct 28, 2026
agent-note:v1 — escalated to user (worker-first review attached)
- task: 1483 implementation of mcpx: Phase 1 of #1414 — persist legacy HTTP upstream sessions and resume them after a cold restart #1415 (lane A shift, 2026-10-28)
- review: I reviewed design design(mcpx): resume upstream HTTP sessions after a cold restart — persist the resumable session state #1414 as the worker-first reviewer before implementing mcpx: Phase 1 of #1414 — persist legacy HTTP upstream sessions and resume them after a cold restart #1415. The design is technically landable as scoped (triage task 1409 verified every reused building block on main: SessionState/Resume in mcpclient, the takeover restore calls in pool/handoff.go, the sessions.go persistence discipline), and the security invariant is structural: the record type has NO field for headers or resolved secret values, the file is owner-only (defaults.PrivateMode), and headers are re-derived from live config on restore.
- why this is still yours: the one-line decision in this issue — persist upstream session IDs (which act as bearer credentials) to disk at all — is a security posture call the fleet monitor's intake review (2026-10-27) already identified as genuinely Drew's, and Phase 1 must not be implemented against an undecided design. My read: the mitigations above make "yes" defensible; the residual risk is that a stolen state-dir file yields resumable session IDs until the upstreams expire them (Phase 2's 404/401 fallback bounds, but does not erase, that).
- action needed: yes/no on this issue. On yes, task 1483 unblocks and mcpx: Phase 1 of #1414 — persist legacy HTTP upstream sessions and resume them after a cold restart #1415 is the first claimable step (it also gates mcpx: Phase 2 of #1414 — resumed-session expiry fallback (404/401) and record hygiene #1416 / task 1484). On no, mcpx: Phase 1 of #1414 — persist legacy HTTP upstream sessions and resume them after a cold restart #1415/mcpx: Phase 2 of #1414 — resumed-session expiry fallback (404/401) and record hygiene #1416 should be closed as declined.
- state: task 1483 blocked (escalated-to-user); this issue swapped user/review -> user/escalated.
dezren39 commented on Nov 16, 2026
Agent note — task 17432 picked up, resuming at PR stage (lane code-a)
dezren39 commented on Nov 16, 2026
Agent note — task 17432 done, fixed_merged (lane code-a)
- PR fix(mcpx): restart-intent shutdown keeps upstream HTTP sessions (#1414) #10755 MERGED — merge commit db37118 (verified fresh after merge).
- Outcome: restart-intent graceful shutdown now skips the upstream DELETE and keeps the persisted mcpx session resumable; explicit session end still sends DELETE (ruling shutdown-delete-1414). Tests recorded on the PR: transport-level both paths + pool-level end-to-end,
go test ./internal/mcpclient ./internal/pool ./internal/daemon passing.
- Codex gate: review failed on usage limits, zero inline findings — no actionable finding; merged under standing criteria (noted on the pickup note).
- Issue design(mcpx): resume upstream HTTP sessions after a cold restart — persist the resumable session state #1414 is an epic and stays OPEN per the program-tending convention on this issue (epic closure is left to a person); this task's Phase 3 implementation — the last unimplemented phase — is landed.
- Queue: task 17432 completed fixed_merged by lane code-a; claim/park labels cleared in the same pass.
dezren39 commented on Nov 22, 2026 Merged work, still open. Every pull request that references this issue has merged (#1426, #5455, #5036, #5517, #5559, #5658) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.
status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").
By: Claude, 2026-11-22 flow review.
Generated by Claude Code dezren39 commented on Nov 25, 2026 Closing as completed. All three acceptance items are met:
pkgs/mcpx/TODO.md was updated with the landed phases in the 2026-11-08 small fix. Reopen this issue if anything is still owed.
Generated by Claude Code
MetadataMetadataapp/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)epic/mcpx-platformReprioritization program epic (2026-11-12)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|