Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

test: the cookie wiring guard was hollowed out by the funnel rule, so pin the four body shapes only the per-tool confirmation refuses (PIN-229)

Luigi Agostib6dc46774caa
diff --git a/internal/mcp/cookies_set_report_test.go b/internal/mcp/cookies_set_report_test.go
index 034ee086..a499d252 100644
--- a/internal/mcp/cookies_set_report_test.go
+++ b/internal/mcp/cookies_set_report_test.go
@@ -7,20 +7,53 @@ import (
"testing"
)
-// The WIRING, not the helper: reverting only the call site leaves the table below green, so
-// the confirmation has to be asserted through the tool. A 200 carrying set:0 must reach the
-// agent as an error result.
+// The WIRING, not the helper. Every error row asserts the per-tool wrapper's own words
+// ("cookie ... was not set"), which the funnel's body-level rule never produces, so removing
+// the call site reds every one of them — including the first, which the funnel would also
+// catch and which would otherwise pass on the funnel's message alone.
+//
+// The last four rows are the division of labour with reportsNoSuccess, and they are the
+// reason the per-tool check is kept rather than deleted as a duplicate: the funnel treats a
+// body with no failed count, a partial success, an unreadable body and a body with no counts
+// at all as successes, all deliberately. Confirming one named write is stricter than a rule
+// serving every tool can be.
func TestCookiesSetToolReportsAnUnstoredCookieAsAnError(t *testing.T) {
for _, tc := range []struct {
name string
respBody string
wantErr bool
+ wantSays string
}{
{name: "stored", respBody: `{"set":1,"failed":0,"total":1}`},
{
- name: "not stored",
+ name: "not stored, the funnel catches this one too",
respBody: `{"set":0,"failed":1,"total":1,"failures":[{"index":0,"name":"sid","error":"invalid sameSite value"}]}`,
wantErr: true,
+ wantSays: "invalid sameSite value",
+ },
+ {
+ name: "not stored with no failed count, outside the funnel shape",
+ respBody: `{"set":0,"total":1}`,
+ wantErr: true,
+ wantSays: "0 of 1 stored",
+ },
+ {
+ name: "partially stored, which the funnel passes as success carrying detail",
+ respBody: `{"set":1,"failed":1,"total":2}`,
+ wantErr: true,
+ wantSays: "1 of 2 stored",
+ },
+ {
+ name: "unreadable, which the funnel leaves to the status rule",
+ respBody: `not json`,
+ wantErr: true,
+ wantSays: "unreadable response",
+ },
+ {
+ name: "no counts at all, so nothing is confirmed",
+ respBody: `{"cookies":[]}`,
+ wantErr: true,
+ wantSays: "did not report how many cookies were set",
},
} {
t.Run(tc.name, func(t *testing.T) {
@@ -32,17 +65,21 @@ func TestCookiesSetToolReportsAnUnstoredCookieAsAnError(t *testing.T) {
r := callTool(t, "pinchtab_cookies_set", map[string]any{"name": "sid", "value": "abc"}, srv)
- if tc.wantErr {
- if !r.IsError {
- t.Fatalf("tool reported success for %s — the agent cannot tell the cookie was never stored", tc.respBody)
- }
- if text := resultText(t, r); !strings.Contains(text, "invalid sameSite value") {
- t.Errorf("error text = %q, want the reason the browser gave", text)
+ if !tc.wantErr {
+ if r.IsError {
+ t.Fatalf("tool reported an error for a stored cookie: %s", resultText(t, r))
}
return
}
- if r.IsError {
- t.Fatalf("tool reported an error for a stored cookie: %s", resultText(t, r))
+ if !r.IsError {
+ t.Fatalf("tool reported success for %s — the agent cannot tell the cookie was never stored", tc.respBody)
+ }
+ text := resultText(t, r)
+ if !strings.Contains(text, `cookie "sid" was not set`) {
+ t.Errorf("error text = %q, want the per-tool confirmation's own words — the funnel's class-wide message does not confirm this named write", text)
+ }
+ if !strings.Contains(text, tc.wantSays) {
+ t.Errorf("error text = %q, want it to mention %q so the agent knows what to change", text, tc.wantSays)
}
})
}