sdk(P1.2): payload commitment + safe-number preflight in all three SDKs

Adds payload_commitment / metadata_commitment / verify_payload_commitment
and assert_commitment_safe_numbers to the Python, TypeScript, and Go SDKs,
each building on the frozen canonical_json/domain_hash primitives (no change
to their byte output). The number preflight is a byte-for-byte port of the
backend assert_commitment_safe_numbers (floats rejected, |int| > 2^53-1
rejected, bool exempt) and is wired into the v2 log_event / log_events send
path, raising a typed AttestoUnsafeNumberError with the JSON path so the rule
fails at dev time rather than as a production 422; preflight=False /
SkipPreflight defers to the server.

New shared corpus golden-vectors/sdk-parity/canonical-numbers.json (15 accept
+ 8 reject), accept-hashes generated from the backend _commitment. Proven:
Python = TypeScript = Go = backend produce byte-identical commitment hashes
for every accept vector and identical reject paths (the Go float64-vs-Python-
int serialization parity holds). READMEs updated per SDK.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-06-11 14:05:49 +02:00
parent edec105858
commit 27a1bfcd00
5 changed files with 364 additions and 0 deletions

View File

@@ -6,6 +6,10 @@ type M map[string]any
type RequestOptions struct {
IdempotencyKey string
// SkipPreflight disables the client-side commitment number preflight, which
// rejects non-integer / out-of-range numbers locally before LogEvent /
// LogEvents sends them. Default false: the preflight runs.
SkipPreflight bool
}
type StreamCreateInput struct {