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:
@@ -468,11 +468,7 @@ func TestValidateBypassMode_HandlesWhitespace(t *testing.T) {
|
|||||||
|
|
||||||
func TestValidateBypassMode_RejectsOversizedSignature(t *testing.T) {
|
func TestValidateBypassMode_RejectsOversizedSignature(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
payload := append([]byte{0x12}, bytes.Repeat([]byte{0x34}, maxBypassSignatureLen)...)
|
sig := strings.Repeat("A", maxBypassSignatureLen+1)
|
||||||
sig := base64.StdEncoding.EncodeToString(payload)
|
|
||||||
if len(sig) <= maxBypassSignatureLen {
|
|
||||||
t.Fatalf("test setup: signature should exceed max length, got %d", len(sig))
|
|
||||||
}
|
|
||||||
|
|
||||||
inputJSON := []byte(`{
|
inputJSON := []byte(`{
|
||||||
"messages": [{"role": "assistant", "content": [
|
"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) {
|
func TestResolveBypassModeSignature_TrimsWhitespace(t *testing.T) {
|
||||||
previous := cache.SignatureCacheEnabled()
|
previous := cache.SignatureCacheEnabled()
|
||||||
cache.SetSignatureCacheEnabled(false)
|
cache.SetSignatureCacheEnabled(false)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ import (
|
|||||||
"google.golang.org/protobuf/encoding/protowire"
|
"google.golang.org/protobuf/encoding/protowire"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxBypassSignatureLen = 8192
|
const maxBypassSignatureLen = 32 * 1024 * 1024
|
||||||
|
|
||||||
type claudeSignatureTree struct {
|
type claudeSignatureTree struct {
|
||||||
EncodingLayers int
|
EncodingLayers int
|
||||||
|
|||||||
Reference in New Issue
Block a user