From 5eaa859c07e481cc6da7638496de1f1b3b56ab9d Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:28:52 -0600 Subject: [PATCH 1/3] fix(mcpx): #6247 refresh task retention on the MCP access path --- pkgs/mcpx/internal/cli/serve.go | 7 ++++ pkgs/mcpx/internal/mcpserver/server.go | 10 +++++ pkgs/mcpx/internal/mcpserver/tasks.go | 9 +++++ .../mcpserver/tasks_shared_store_test.go | 39 +++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/pkgs/mcpx/internal/cli/serve.go b/pkgs/mcpx/internal/cli/serve.go index 05a5bde8ad..c4cd49d7e2 100644 --- a/pkgs/mcpx/internal/cli/serve.go +++ b/pkgs/mcpx/internal/cli/serve.go @@ -522,6 +522,13 @@ func (a *App) MCPServer(ctx context.Context) (*mcpserver.Server, error) { // below reads -- so neither surface's cadence changes. if a.daemonStore != nil { srv.TaskStore = a.daemonStore + // Retention follows the same settings the daemon's taskStore() + // reads on /v1 access (#6247): without this, a tasks.ttl / + // tasks.maxAge change made through /v1/settings never reached + // the MCP surface's cached store pointer. + srv.TaskRetention = func() (time.Duration, time.Duration) { + return a.Settings().Duration("tasks.ttl"), a.Settings().Duration("tasks.maxAge") + } } else { // A standalone server (mcpx serve) keeps a private store; // wire its audit seam to the durable log or its task diff --git a/pkgs/mcpx/internal/mcpserver/server.go b/pkgs/mcpx/internal/mcpserver/server.go index 22aae109b9..7d4d424ca0 100644 --- a/pkgs/mcpx/internal/mcpserver/server.go +++ b/pkgs/mcpx/internal/mcpserver/server.go @@ -303,6 +303,16 @@ type Server struct { // means the standalone behaviour: a private in-memory store. TaskStore *taskStore + // TaskRetention, when set, supplies the current tasks.ttl / + // tasks.maxAge retention settings and is consulted on every + // task-store access, so a /v1/settings change reaches MCP task + // traffic without an intervening /v1 task request (#6247). A + // function, because the settings are hot: a value copied here + // would never follow a change (the MaxCompletions pattern). The + // daemon wires it when it injects its store; nil keeps the + // store's construction-time configuration. + TaskRetention func() (ttl, maxAge time.Duration) + // TaskAudit, when set, is the audit seam a private task store // (the TaskStore == nil path in tasks()) is wired with, so a // standalone server's task lifecycle records reach a log instead diff --git a/pkgs/mcpx/internal/mcpserver/tasks.go b/pkgs/mcpx/internal/mcpserver/tasks.go index d2737732cf..94274f7091 100644 --- a/pkgs/mcpx/internal/mcpserver/tasks.go +++ b/pkgs/mcpx/internal/mcpserver/tasks.go @@ -53,6 +53,15 @@ func (s *Server) tasks() *taskStore { } } } + // Retention settings are hot (#6247): refresh them on every access, + // exactly as the daemon's taskStore() accessor does for /v1, so MCP + // traffic alone keeps the shared store's retention current after a + // /v1/settings change. Configure ignores nonpositive values, so a + // provider returning zeros leaves the current configuration alone. + if s.TaskRetention != nil { + ttl, maxAge := s.TaskRetention() + s.taskStore.Configure(ttl, maxAge) + } return s.taskStore } diff --git a/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go b/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go index 1a22811458..99dae38f66 100644 --- a/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go +++ b/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go @@ -77,6 +77,45 @@ func TestInjectedStoreIsTheStoreTheMCPSurfaceUses(t *testing.T) { } } +// Issue #6247: a tasks.maxAge change must reach MCP task traffic on its +// own — no intervening /v1 task request. The MCP surface refreshes the +// shared store's retention from TaskRetention on every access, so a task +// that turns terminal after the change carries the new (tiny) retention +// deadline instead of the hour the provider returned before it. +func TestMCPOnlyTrafficPicksUpRetentionChange(t *testing.T) { + store := tasks.New() + s := sharedStoreServer(store) + + maxAge := time.Hour + s.TaskRetention = func() (time.Duration, time.Duration) { return 0, maxAge } + + // Baseline MCP task under the old retention: nothing explodes, and + // the store is the injected one. + first := startSharedTask(t, s) + if done := waitTask(t, s, first, terminal); done["status"] != "completed" { + t.Fatalf("baseline task: %v", done) + } + + // The settings change (the /v1/settings write in production). From + // here the test exercises only the MCP path. + maxAge = 2 * time.Second + + id := startSharedTask(t, s) + if done := waitTask(t, s, id, terminal); done["status"] != "completed" { + t.Fatalf("post-change task: %v", done) + } + got, ok := store.Get(id) + if !ok { + t.Fatalf("post-change task %s missing from the store", id) + } + if got.ExpiresAt == nil { + t.Fatalf("post-change task %s has no retention deadline", id) + } + if remaining := time.Until(*got.ExpiresAt); remaining > 10*time.Second { + t.Errorf("post-change task keeps the old retention: expires in %v, want the new 2s maxAge to bound it", remaining) + } +} + func TestInjectedStoreKeepsMCPTasksAcrossReopen(t *testing.T) { path := filepath.Join(t.TempDir(), "tasks.db") store, err := tasks.Open(path) From 3ebac486113536aea05458f03e6e45bc9c6b916a Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:34:19 -0600 Subject: [PATCH 2/3] fix(mcpx): #6247 preserve task-store wiring through WithExtras (Codex P2, PR #6332) --- pkgs/mcpx/internal/mcpserver/server.go | 8 +++++ .../mcpserver/tasks_shared_store_test.go | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/pkgs/mcpx/internal/mcpserver/server.go b/pkgs/mcpx/internal/mcpserver/server.go index 7d4d424ca0..baae8fd9ea 100644 --- a/pkgs/mcpx/internal/mcpserver/server.go +++ b/pkgs/mcpx/internal/mcpserver/server.go @@ -391,6 +391,14 @@ func (s *Server) WithExtras(extras []Extra) *Server { // cannot detect a server that declared nothing. Notify: s.Notify, Ask: s.Ask, + // The task-store wiring comes along (#6247): dropping it here + // silently gave the extras server a private store and a nil + // retention provider, so the production MCPServer() path — + // which builds extras after injecting the daemon's store — + // lost both the shared store (#1555) and retention refresh. + TaskStore: s.TaskStore, + TaskRetention: s.TaskRetention, + TaskAudit: s.TaskAudit, ExtrasOnly: s.ExtrasOnly, OwnInstructions: s.OwnInstructions, Instance: s.Instance, diff --git a/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go b/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go index 99dae38f66..9fbb58ea7b 100644 --- a/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go +++ b/pkgs/mcpx/internal/mcpserver/tasks_shared_store_test.go @@ -2,6 +2,7 @@ package mcpserver_test import ( "context" + "encoding/json" "path/filepath" "strings" "testing" @@ -116,6 +117,38 @@ func TestMCPOnlyTrafficPicksUpRetentionChange(t *testing.T) { } } +// Issue #6247, extras construction path: App.MCPServer injects the +// store and the retention provider and *then* calls WithExtras, whose +// reconstruction must preserve both — a provider dropped there leaves +// the production server exactly as broken as before the fix. +func TestRetentionSurvivesWithExtras(t *testing.T) { + store := tasks.New() + s := sharedStoreServer(store) + + maxAge := time.Hour + s.TaskRetention = func() (time.Duration, time.Duration) { return 0, maxAge } + s = s.WithExtras([]mcpserver.Extra{{ + Tool: mcpserver.Tool{Name: "extra_tool", Description: "an extra"}, + Call: func(context.Context, json.RawMessage) (string, error) { return "ok", nil }, + }}) + + maxAge = 2 * time.Second + id := startSharedTask(t, s) + if done := waitTask(t, s, id, terminal); done["status"] != "completed" { + t.Fatalf("task through the extras server: %v", done) + } + got, ok := store.Get(id) + if !ok { + t.Fatalf("task %s is not in the injected store after WithExtras", id) + } + if got.ExpiresAt == nil { + t.Fatalf("task %s has no retention deadline", id) + } + if remaining := time.Until(*got.ExpiresAt); remaining > 10*time.Second { + t.Errorf("extras server kept the old retention: expires in %v, want the new 2s maxAge", remaining) + } +} + func TestInjectedStoreKeepsMCPTasksAcrossReopen(t *testing.T) { path := filepath.Join(t.TempDir(), "tasks.db") store, err := tasks.Open(path) From 9e7f4e101f87753d4bebfdb26d24aecc6b6bd8e9 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:34:36 -0600 Subject: [PATCH 3/3] style(mcpx): gofmt WithExtras literal --- pkgs/mcpx/internal/mcpserver/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/mcpx/internal/mcpserver/server.go b/pkgs/mcpx/internal/mcpserver/server.go index baae8fd9ea..b01b9a5f89 100644 --- a/pkgs/mcpx/internal/mcpserver/server.go +++ b/pkgs/mcpx/internal/mcpserver/server.go @@ -389,16 +389,16 @@ func (s *Server) WithExtras(extras []Extra) *Server { // Notify comes along. Dropping it silently turned off every push // capability the moment a single extra tool existed, and a client // cannot detect a server that declared nothing. - Notify: s.Notify, - Ask: s.Ask, + Notify: s.Notify, + Ask: s.Ask, // The task-store wiring comes along (#6247): dropping it here // silently gave the extras server a private store and a nil // retention provider, so the production MCPServer() path — // which builds extras after injecting the daemon's store — // lost both the shared store (#1555) and retention refresh. - TaskStore: s.TaskStore, - TaskRetention: s.TaskRetention, - TaskAudit: s.TaskAudit, + TaskStore: s.TaskStore, + TaskRetention: s.TaskRetention, + TaskAudit: s.TaskAudit, ExtrasOnly: s.ExtrasOnly, OwnInstructions: s.OwnInstructions, Instance: s.Instance,