Exemplo
github.com/google/uuid v1.6.0: MarshalBinary, UnmarshalBinary
Amostra verificada para golang github.com/google/uuid v1.6.0: MarshalBinary, UnmarshalBinary. O contrato rodou em go 1.26 · linux alpine/x64 · docker e…
sha256:e1363fc973565db6033a4a327185b1f028680fd904648425c72e6f18efe71d96
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 2
- Chaves de assinatura que o compilaram
- 2
Ambiente declarado
go 1.26 windows 11 x64 go 1.26 go go 1
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-19 |
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-09-07 |
Caso
HOW- Objetivo
- verify pkg:golang/github.com/google/uuid@v1.6.0
- Pacotes
- Símbolos
-
- github.com/google/uuid.MarshalBinary
- github.com/google/uuid.UnmarshalBinary
- Ambiente
- go 1.26.5
- Criado
- 2026-08-18T22:44:28Z
Contrato
- uuid.MarshalBinary encodes UUID into 16-byte raw slice without error
- uuid.MarshalBinary encodes uuid.Nil into 16 zero bytes
- uuid.UnmarshalBinary decodes 16-byte binary data into UUID
- uuid.UnmarshalBinary decodes 16 zero bytes into uuid.Nil
- uuid.UnmarshalBinary rejects byte slices with length other than 16 with error
- uuid.MarshalBinary and uuid.UnmarshalBinary round-trip accurately preserves UUID value
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:golang/github.com/google/uuid@v1.6.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/uuid@v1.6.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:44ae1af78b91eecac1ce4b3e41df1aab87c014a6067aa09d2cb01c7b2227e3c8","contract":["uuid.MarshalBinary encodes UUID into 16-byte raw slice without error","uuid.MarshalBinary encodes uuid.Nil into 16 zero bytes","uuid.UnmarshalBinary decodes 16-byte binary data into UUID","uuid.UnmarshalBinary decodes 16 zero bytes into uuid.Nil","uuid.UnmarshalBinary rejects byte slices with length other than 16 with error","uuid.MarshalBinary and uuid.UnmarshalBinary round-trip accurately preserves UUID value"],"goal":"verify pkg:golang/github.com/google/uuid@v1.6.0","kind":"HOW","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["github.com/google/uuid.MarshalBinary","github.com/google/uuid.UnmarshalBinary"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","ecosystem":"golang","language":"go","os":"windows","osVersionBucket":"11","packageManager":"go","packageManagerVersion":"1.26.5","runtime":"go","runtimeVersion":"1.26.5","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"symbols":["github.com/google/uuid.MarshalBinary","github.com/google/uuid.UnmarshalBinary"],"verifierAdapter":"golang@1"}
module sample
go 1.22.0
require github.com/google/uuid v1.6.0
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
package main
import (
"fmt"
"log"
"github.com/google/uuid"
)
// MarshalUUIDBinary converts a UUID to its binary representation (16 bytes).
func MarshalUUIDBinary(u uuid.UUID) ([]byte, error) {
return u.MarshalBinary()
}
// UnmarshalUUIDBinary decodes binary data into a UUID.
func UnmarshalUUIDBinary(data []byte) (uuid.UUID, error) {
var u uuid.UUID
err := u.UnmarshalBinary(data)
return u, err
}
func main() {
original := uuid.New()
bin, err := MarshalUUIDBinary(original)
if err != nil {
log.Fatalf("MarshalBinary failed: %v", err)
}
fmt.Printf("Marshaled binary (%d bytes): %x\n", len(bin), bin)
restored, err := UnmarshalUUIDBinary(bin)
if err != nil {
log.Fatalf("UnmarshalBinary failed: %v", err)
}
fmt.Printf("Restored UUID: %s (matches: %t)\n", restored.String(), restored == original)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/google/uuid@v1.6.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/uuid@v1.6.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/google/uuid"
)
func main() {
// Assertion 1: uuid.MarshalBinary encodes UUID into 16-byte raw slice without error
sampleUUID, err := uuid.Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: setup parse failed: %v\n", err)
os.Exit(1)
}
marshaled, err := sampleUUID.MarshalBinary()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalBinary failed: %v\n", err)
os.Exit(1)
}
if len(marshaled) != 16 {
fmt.Fprintf(os.Stderr, "FAIL: expected byte length 16, got %d\n", len(marshaled))
os.Exit(1)
}
if !bytes.Equal(marshaled, sampleUUID[:]) {
fmt.Fprintf(os.Stderr, "FAIL: MarshalBinary output did not match underlying slice: got %x, want %x\n", marshaled, sampleUUID[:])
os.Exit(1)
}
// Assertion 2: uuid.MarshalBinary encodes uuid.Nil into 16 zero bytes
nilMarshaled, err := uuid.Nil.MarshalBinary()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalBinary on Nil failed: %v\n", err)
os.Exit(1)
}
if len(nilMarshaled) != 16 {
fmt.Fprintf(os.Stderr, "FAIL: expected 16 zero bytes, got %d bytes\n", len(nilMarshaled))
os.Exit(1)
}
for i, b := range nilMarshaled {
if b != 0 {
fmt.Fprintf(os.Stderr, "FAIL: non-zero byte at index %d: %x\n", i, b)
os.Exit(1)
}
}
// Assertion 3: uuid.UnmarshalBinary decodes 16-byte binary data into UUID
var u1 uuid.UUID
rawBytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
if err := u1.UnmarshalBinary(rawBytes); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalBinary failed on valid 16-byte slice: %v\n", err)
os.Exit(1)
}
if u1 != sampleUUID {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalBinary mismatch: got %s, want %s\n", u1, sampleUUID)
os.Exit(1)
}
// Assertion 4: uuid.UnmarshalBinary decodes 16 zero bytes into uuid.Nil
var uNil uuid.UUID
zeroBytes := make([]byte, 16)
if err := uNil.UnmarshalBinary(zeroBytes); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalBinary failed on zero bytes: %v\n", err)
os.Exit(1)
}
if uNil != uuid.Nil {
fmt.Fprintf(os.Stderr, "FAIL: expected uuid.Nil, got %s\n", uNil)
os.Exit(1)
}
// Assertion 5: uuid.UnmarshalBinary rejects byte slices with length other than 16 with error
invalidLengths := [][]byte{
{},
{0x01, 0x02, 0x03},
make([]byte, 15),
make([]byte, 17),
make([]byte, 36),
}
for _, inv := range invalidLengths {
var uInv uuid.UUID
if err := uInv.UnmarshalBinary(inv); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error for slice of length %d, got nil\n", len(inv))
os.Exit(1)
}
}
// Assertion 6: uuid.MarshalBinary and uuid.UnmarshalBinary round-trip accurately preserves UUID value
randUUID := uuid.New()
encoded, err := randUUID.MarshalBinary()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalBinary on random UUID failed: %v\n", err)
os.Exit(1)
}
var decoded uuid.UUID
if err := decoded.UnmarshalBinary(encoded); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: UnmarshalBinary round-trip failed: %v\n", err)
os.Exit(1)
}
if decoded != randUUID {
fmt.Fprintf(os.Stderr, "FAIL: round-trip value mismatch: got %s, want %s\n", decoded, randUUID)
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed for uuid.MarshalBinary and uuid.UnmarshalBinary")
}
Seeder de origem
anônimo