From 4b8b549143a769d8fe9a7c31333c660b993e2a99 Mon Sep 17 00:00:00 2001 From: Snider Date: Sat, 8 Aug 2026 14:50:34 +0100 Subject: [PATCH] fix(ide): assert the contract NewBridge actually has MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestBridge_NewBridge_Bad has failed on main since 1523144, which made NewBridge apply cfg.WithDefaults() so a zero Config cannot leave ReconnectInterval at 0 — connectLoop's min(delay*2, max) backoff would stay pinned at zero and reconnect in a tight loop. The fix was right. The test was left asserting the behaviour the fix removed: AssertEqual(t, "", bridge.cfg.LaravelWSURL) want="" got="ws://localhost:9876/ws" So the assertion has been describing the bug rather than the contract, and every push to main since has been red on it. It now asserts what NewBridge guarantees: a zero Config comes back defaulted, with a URL, a workspace root, and both reconnect intervals non-zero — the property the change existed to establish, rather than the one string it happened to set. Not caused by dAppCore/mcp#20, which is red for this and touches no Go at all: its fourteen files are php/ plus composer.json and composer.lock. go test ./... now passes for the whole module. Co-Authored-By: Virgil --- go/pkg/mcp/ide/bridge_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/go/pkg/mcp/ide/bridge_test.go b/go/pkg/mcp/ide/bridge_test.go index 6187e8d..1559dd0 100644 --- a/go/pkg/mcp/ide/bridge_test.go +++ b/go/pkg/mcp/ide/bridge_test.go @@ -516,7 +516,18 @@ func TestBridge_NewBridge_Good(t *T) { func TestBridge_NewBridge_Bad(t *T) { bridge := NewBridge(nil, Config{}) AssertNil(t, bridge.hub) - AssertEqual(t, "", bridge.cfg.LaravelWSURL) + + // A zero Config must come back defaulted, not raw. This asserted "" until + // now, which was the behaviour before NewBridge started calling + // WithDefaults — the test kept the old contract while the fix that + // introduced defaults went in without it. A raw Config leaves + // ReconnectInterval at 0, and connectLoop's min(delay*2, max) backoff stays + // pinned at zero, which is a tight reconnect flood: the exact thing that + // change existed to stop. + AssertEqual(t, "ws://localhost:9876/ws", bridge.cfg.LaravelWSURL) + AssertEqual(t, ".", bridge.cfg.WorkspaceRoot) + AssertTrue(t, bridge.cfg.ReconnectInterval > 0) + AssertTrue(t, bridge.cfg.MaxReconnectInterval > 0) } // moved AX-7 triplet TestBridge_NewBridge_Ugly