fix(antigravity): allow 32MB bypass signatures

Raise the local bypass-signature ceiling so long Claude thinking signatures are not rejected before request translation, and keep the oversized-signature test cheap to execute.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
sususu98
2026-04-12 00:48:01 +08:00
parent 0ab1f5412f
commit 727221df2e
2 changed files with 29 additions and 6 deletions

View File

@@ -468,11 +468,7 @@ func TestValidateBypassMode_HandlesWhitespace(t *testing.T) {
func TestValidateBypassMode_RejectsOversizedSignature(t *testing.T) {
t.Parallel()
payload := append([]byte{0x12}, bytes.Repeat([]byte{0x34}, maxBypassSignatureLen)...)
sig := base64.StdEncoding.EncodeToString(payload)
if len(sig) <= maxBypassSignatureLen {
t.Fatalf("test setup: signature should exceed max length, got %d", len(sig))
}
sig := strings.Repeat("A", maxBypassSignatureLen+1)
inputJSON := []byte(`{
"messages": [{"role": "assistant", "content": [
@@ -489,6 +485,33 @@ func TestValidateBypassMode_RejectsOversizedSignature(t *testing.T) {
}
}
func TestValidateBypassMode_StrictAcceptsSignatureBetween16KiBAnd32MiB(t *testing.T) {
previous := cache.SignatureBypassStrictMode()
cache.SetSignatureBypassStrictMode(true)
t.Cleanup(func() {
cache.SetSignatureBypassStrictMode(previous)
})
payload := buildClaudeSignaturePayload(t, 12, uint64Ptr(2), strings.Repeat("m", 20000), true)
sig := base64.StdEncoding.EncodeToString(payload)
if len(sig) <= 1<<14 {
t.Fatalf("test setup: signature should exceed previous 16KiB guardrail, got %d", len(sig))
}
if len(sig) > maxBypassSignatureLen {
t.Fatalf("test setup: signature should remain within new max length, got %d", len(sig))
}
inputJSON := []byte(`{
"messages": [{"role": "assistant", "content": [
{"type": "thinking", "thinking": "t", "signature": "` + sig + `"}
]}]
}`)
if err := ValidateClaudeBypassSignatures(inputJSON); err != nil {
t.Fatalf("expected strict mode to accept signature below 32MiB max, got: %v", err)
}
}
func TestResolveBypassModeSignature_TrimsWhitespace(t *testing.T) {
previous := cache.SignatureCacheEnabled()
cache.SetSignatureCacheEnabled(false)

View File

@@ -58,7 +58,7 @@ import (
"google.golang.org/protobuf/encoding/protowire"
)
const maxBypassSignatureLen = 8192
const maxBypassSignatureLen = 32 * 1024 * 1024
type claudeSignatureTree struct {
EncodingLayers int