Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions pkgs/mcpx/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1588,20 +1588,13 @@ func parse(b []byte) (*Config, error) {
if s.URL != "" && s.Transport == "" {
s.Transport = "http"
}
// Phase 3 of #1384 (#9963): supervised stdio is the default.
// Materialize it here, at file load, so every consumer of a
// parsed config (daemon, CLI, settings views) sees the same
// resolved value and an explicit "supervised": false remains
// the one opt-out into the legacy direct-spawn path.
if s.Command != "" {
if s.Mcpx == nil {
s.Mcpx = &Extras{}
}
if s.Mcpx.Supervised == nil {
tr := true
s.Mcpx.Supervised = &tr
}
}
// Supervised stdio is opt-in again ("supervised": true). #9963
// made it the default, but the supervisor socket is keyed by
// server name alone, so a server's second scoped instance
// (another session, repo or worktree) attached to the first
// one's supervisor and was refused, and supervisors outlived
// `mcpx stop`. The default returns once sockets are keyed per
// instance and stop reaps them.
}
return c, nil
}
Expand Down
19 changes: 10 additions & 9 deletions pkgs/mcpx/internal/config/supervised_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"github.com/developing-today/code/pkgs/mcpx/internal/config"
)

// Phase 3 of #1384 (#9963): a config loaded from a file defaults its
// stdio servers to supervised; "supervised": false is the opt-out
// into the legacy direct-spawn path, and HTTP servers are untouched.
func TestSupervisedDefaultsOnForStdioFromFile(t *testing.T) {
// Supervised stdio is opt-in: a stdio server with no supervised key
// runs direct-spawn; "supervised": true opts in, false stays out, and
// HTTP servers are untouched. (#9963 made it the default; that is
// paused until the supervisor socket is keyed per instance.)
func TestSupervisedIsOptInForStdioFromFile(t *testing.T) {
dir := t.TempDir()
p := write(t, dir, "c.json", `{
"mcpServers": {
Expand All @@ -23,23 +24,23 @@ func TestSupervisedDefaultsOnForStdioFromFile(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !c.MCPServers["plain"].Mcpx.SupervisedEnabled() {
t.Fatal("a stdio server with no supervised key should default to supervised after a file load")
if c.MCPServers["plain"].Mcpx.SupervisedEnabled() {
t.Fatal("a stdio server with no supervised key should not be supervised")
}
if c.MCPServers["optout"].Mcpx.SupervisedEnabled() {
t.Fatal("supervised:false should opt out of the default")
t.Fatal("supervised:false should not be supervised")
}
if !c.MCPServers["optin"].Mcpx.SupervisedEnabled() {
t.Fatal("supervised:true should stay supervised")
}
if c.MCPServers["web"].Mcpx != nil && c.MCPServers["web"].Mcpx.SupervisedEnabled() {
t.Fatal("an HTTP server should not be defaulted to supervised")
}
r, err := c.Resolve("plain")
r, err := c.Resolve("optin")
if err != nil {
t.Fatal(err)
}
if !r.Mcpx.SupervisedEnabled() {
t.Fatal("the resolved config should carry the supervised default to the pool")
t.Fatal("the resolved config should carry the supervised opt-in to the pool")
}
}
8 changes: 4 additions & 4 deletions pkgs/mcpx/internal/pool/supervised_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
)

// Phase 3 of #1384 (#9963), the headline acceptance: a fresh daemon
// start with a default config — loaded from a file, no supervised
// key anywhere — runs its stdio servers supervised. The pool is what
// start with a config loaded from a file that opts its stdio server
// in runs it supervised (opt-in while sockets are keyed by name). The pool is what
// a daemon start builds from the resolved config, so the proof is:
// load, resolve, acquire, and a supervisor socket exists with the
// instance's child behind it.
Expand All @@ -28,7 +28,7 @@ func TestDefaultConfigStdioRunsSupervised(t *testing.T) {
bin := testsupport.EraMCPBinary(t)
log := filepath.Join(t.TempDir(), "frames")
cfgPath := filepath.Join(t.TempDir(), "mcpx.json")
body := `{"mcpServers": {"era": {"command": "` + bin + `", "env": {"ERAMCP_MODE": "modern", "ERAMCP_LOG": "` + log + `"}}}}`
body := `{"mcpServers": {"era": {"command": "` + bin + `", "env": {"ERAMCP_MODE": "modern", "ERAMCP_LOG": "` + log + `"}, "mcpx": {"supervised": true}}}}`
if err := os.WriteFile(cfgPath, []byte(body), 0o644); err != nil {
t.Fatal(err)
}
Expand All @@ -41,7 +41,7 @@ func TestDefaultConfigStdioRunsSupervised(t *testing.T) {
t.Fatal(err)
}
if !r.Mcpx.SupervisedEnabled() {
t.Fatal("default config should resolve to supervised")
t.Fatal("an opted-in config should resolve to supervised")
}
p := pool.New(r)
defer p.Close()
Expand Down