You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: stale connect/disconnect workers and supervisor actions re-install old server configs after a newer commit #1563
Connection work spawned from a config snapshot is not re-validated at execution time, so an old action can install a stale client config after a newer commit:
LoadConfiguredServers spawns go func(...){ upstreamManager.AddServer(cfg.Name, cfg) } (internal/runtime/lifecycle.go:1573-1574) and a disabled-server goroutine calling RemoveServer; the lock/ordering, if any, covers scheduling, not execution.
The supervisor dispatches asynchronous actions carrying captured snapshots (internal/runtime/supervisor/supervisor.go:589, :629) that call ActorPoolSimple.AddServer -> Manager.AddServerConfig (internal/runtime/supervisor/actor_pool.go:84-87, internal/upstream/manager.go:443) with no check against the live config or pending removals.
Supervisor reconciliation also treats a server awaiting async removal as current when a save republished it.
Failure scenario
Enabled server's connect action is delayed; a newer commit removes, re-adds with a different endpoint, or quarantines the server; the old action runs and recreates the removed client, replaces the quarantined client with the unquarantined config, or an old disable goroutine disconnects a newly enabled client.
Suggested direction
Validate against the current live config (and pending-removal set) at the moment of AddServerConfig/RemoveServer, e.g. via a config generation checked inside the manager's registration lock. Tests: pause an enabled worker before AddServer and a disabled worker before RemoveServer, apply newer commits, release.
Found by OpenCode Sol 6.1 cross-model review of the (now split) oversized PRs #1553 (UX-01) and #1555 (UX-02); verified still present on origin/main (704795c) by reading the cited sites. Pre-existing, deliberately out of scope of the minimal core PRs. Review transcripts: docs/qa/0.70.0-ux-2026-10-10/remediation/reviews/.
Related pre-existing race found during the Spec 116 design review (round 6), not addressed by the Spec 116 design and recorded here so it is not lost:
Runtime.TriggerOAuthLogout (internal/runtime/runtime.go:3240-3275) runs three separate name-resolved steps: SetUserLoggedOut(name), ClearOAuthToken(name) and DisconnectServer(name). If the server is replaced in between (OAuth-config change, remove and re-add, or RestartServer), the logged-out flag can land on the old instance while the clear and the disconnect hit the replacement, or the reverse. This is the same name-resolution hazard as the stale disconnect in this issue. A fix would capture (gen, InstanceID) once at the start and run all three steps against that instance (DisconnectServerAt), treating ErrStaleGeneration as "replaced, nothing to log out". It is intentionally out of Spec 116 PR2 scope; the PR3 work for this issue is the natural home.
Spec 116 PR1 (#1590) review round 6 observed one more concrete shape of this, for PR3 to cover:
Two MCP upstream_servers update calls change one server's url back to back (A -> B -> C), and the B commit's connect worker is delayed (the test holds Manager.captureMu for reading, as a capture section does).
When the B worker runs after the C commit, it either replaces the C instance with a B instance (AddServerConfigAt compares only ConnectionEquivalent, not the generation), or, having installed B, calls Connect on whatever GetClient(name) returns, which may by then be the C instance. The C worker's own Connect then hits the in-flight guard, and the C instance can stay Disconnected indefinitely (seen in about 1 of 6 -race runs).
PR1 makes the MCP update result read only an instance stamped with the committed generation (monitorConnectionStatusAt, tasks.md T029), so the reported status is never the previous instance's. The worker itself is still unbound, as the plan says, and that remains PR3's job: AddServerAt should refuse a generation older than the registered instance's, and the worker should connect the instance it installed rather than looking the name up again. Regression shape: internal/server/spec116_round6_test.go (the second phase waits for the B worker to finish before the C update, so the test avoids this race).
Activity
docs(specs): Spec 116: config commit consistency, atomic removal and …
Dumbris commentedon Oct 11, 2026
Related pre-existing race found during the Spec 116 design review (round 6), not addressed by the Spec 116 design and recorded here so it is not lost:
Runtime.TriggerOAuthLogout(internal/runtime/runtime.go:3240-3275) runs three separate name-resolved steps:SetUserLoggedOut(name),ClearOAuthToken(name)andDisconnectServer(name). If the server is replaced in between (OAuth-config change, remove and re-add, orRestartServer), the logged-out flag can land on the old instance while the clear and the disconnect hit the replacement, or the reverse. This is the same name-resolution hazard as the stale disconnect in this issue. A fix would capture(gen, InstanceID)once at the start and run all three steps against that instance (DisconnectServerAt), treatingErrStaleGenerationas "replaced, nothing to log out". It is intentionally out of Spec 116 PR2 scope; the PR3 work for this issue is the natural home.Dumbris commentedon Oct 11, 2026
Spec 116 PR1 (#1590) review round 6 observed one more concrete shape of this, for PR3 to cover:
upstream_servers updatecalls change one server'surlback to back (A -> B -> C), and the B commit's connect worker is delayed (the test holdsManager.captureMufor reading, as a capture section does).AddServerConfigAtcompares onlyConnectionEquivalent, not the generation), or, having installed B, callsConnecton whateverGetClient(name)returns, which may by then be the C instance. The C worker's ownConnectthen hits the in-flight guard, and the C instance can stayDisconnectedindefinitely (seen in about 1 of 6-raceruns).PR1 makes the MCP update result read only an instance stamped with the committed generation (
monitorConnectionStatusAt, tasks.md T029), so the reported status is never the previous instance's. The worker itself is still unbound, as the plan says, and that remains PR3's job:AddServerAtshould refuse a generation older than the registered instance's, and the worker should connect the instance it installed rather than looking the name up again. Regression shape:internal/server/spec116_round6_test.go(the second phase waits for the B worker to finish before the C update, so the test avoids this race).fix: bind upstream workers and supervisor actions to the server gener…