From aaa300c1666ed0f222a2ce5e1a8b463c564f1bcd Mon Sep 17 00:00:00 2001 From: lux-liang <249971141+lux-liang@users.noreply.github.com> Date: Mon, 21 Sep 2026 00:49:55 +0800 Subject: [PATCH 1/2] Fix flaky activation scope assertion --- internal/httpapi/scope_round11_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/httpapi/scope_round11_test.go b/internal/httpapi/scope_round11_test.go index 2b5915826..69acef1e8 100644 --- a/internal/httpapi/scope_round11_test.go +++ b/internal/httpapi/scope_round11_test.go @@ -2,6 +2,7 @@ package httpapi import ( "bytes" + "fmt" "net/http" "net/http/httptest" "path/filepath" @@ -33,9 +34,8 @@ import ( const ( activationClientAlpha = "cursor-on-operators-laptop" activationClientBeta = "claude-desktop-on-operators-laptop" - // A count no other field of a /status response can produce: the sibling - // numbers are unix timestamps and single-digit server counts, so a raw-body - // "4711" assertion cannot pass for an unrelated reason. + // A distinctive count whose complete JSON number token is checked below. + // The bare digits may also occur inside an unrelated unix timestamp. activationCalls24h = 4711 activationSavedBucket = "10k_100k" ) @@ -119,7 +119,8 @@ func TestGetStatus_ActivationBlockIsOperatorOnly(t *testing.T) { body := agent.Body.String() assert.NotContains(t, body, activationClientAlpha, "MCP-client inventory leaked to a scoped caller") assert.NotContains(t, body, activationClientBeta, "MCP-client inventory leaked to a scoped caller") - assert.NotContains(t, body, "4711", "exact deployment-wide retrieve_tools count leaked to a scoped caller") + assert.NotRegexp(t, fmt.Sprintf(`":%d[,}]`, activationCalls24h), body, + "exact deployment-wide retrieve_tools count leaked to a scoped caller") assert.NotContains(t, body, activationSavedBucket, "deployment-wide tokens-saved bucket leaked to a scoped caller") // Key names too, so a projection that kept the numbers under a renamed or // re-nested key would still fail. From 5e8f0329793799cd03c1c693eb1fb87079032e65 Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Mon, 21 Sep 2026 13:56:19 +0300 Subject: [PATCH 2/2] test(httpapi): simplify leak-check assertion to match file idiom Replace the regex-based NotRegexp check with two plain NotContains calls for the same boundary condition, matching every other assertion in this file. Co-Authored-By: Claude Sonnet 5 --- internal/httpapi/scope_round11_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/httpapi/scope_round11_test.go b/internal/httpapi/scope_round11_test.go index 69acef1e8..4b4183a03 100644 --- a/internal/httpapi/scope_round11_test.go +++ b/internal/httpapi/scope_round11_test.go @@ -119,7 +119,9 @@ func TestGetStatus_ActivationBlockIsOperatorOnly(t *testing.T) { body := agent.Body.String() assert.NotContains(t, body, activationClientAlpha, "MCP-client inventory leaked to a scoped caller") assert.NotContains(t, body, activationClientBeta, "MCP-client inventory leaked to a scoped caller") - assert.NotRegexp(t, fmt.Sprintf(`":%d[,}]`, activationCalls24h), body, + assert.NotContains(t, body, fmt.Sprintf(`":%d,`, activationCalls24h), + "exact deployment-wide retrieve_tools count leaked to a scoped caller") + assert.NotContains(t, body, fmt.Sprintf(`":%d}`, activationCalls24h), "exact deployment-wide retrieve_tools count leaked to a scoped caller") assert.NotContains(t, body, activationSavedBucket, "deployment-wide tokens-saved bucket leaked to a scoped caller") // Key names too, so a projection that kept the numbers under a renamed or