Exemple
github.com/quic-go/qpack v0.5.1: NewDecoder
Échantillon vérifié pour golang github.com/quic-go/qpack v0.5.1: NewDecoder. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a réussi.
sha256:ffb971ae678e5da5fd39c7f18e40162ad3f02a845db15ff9201ecded8349e23c
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-08-26 |
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-07 |
Cas
HOW- Objectif
- verify github.com/quic-go/qpack.NewDecoder in pkg:golang/github.com/quic-go/qpack@v0.5.1
- Paquets
- Symboles
-
- github.com/quic-go/qpack.NewDecoder
- Créé
- 2026-08-26T11:53:38Z
Contrat
- qpack.NewDecoder decodes full QPACK header blocks containing pseudo-headers and regular headers via DecodeFull
- qpack.NewDecoder with emit callback processes header fields incrementally via Write
- qpack.HeaderField.IsPseudo returns true for pseudo-headers starting with a colon and false for standard headers
- qpack.NewDecoder.DecodeFull returns an error when decoding malformed or invalid header block data
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code source
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 github.com/quic-go/qpack.NewDecoder in pkg:golang/github.com/quic-go/qpack@v0.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/quic-go/qpack@v0.5.1
Demonstrate these symbols/APIs:
- github.com/quic-go/qpack.NewDecoder
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:9b5736473076931b1ad889031d38bb918b7651f64c706c3efcf9e0515368e416","contract":["qpack.NewDecoder decodes full QPACK header blocks containing pseudo-headers and regular headers via DecodeFull","qpack.NewDecoder with emit callback processes header fields incrementally via Write","qpack.HeaderField.IsPseudo returns true for pseudo-headers starting with a colon and false for standard headers","qpack.NewDecoder.DecodeFull returns an error when decoding malformed or invalid header block data"],"goal":"verify github.com/quic-go/qpack.NewDecoder in pkg:golang/github.com/quic-go/qpack@v0.5.1","kind":"HOW","packages":["pkg:golang/github.com/quic-go/qpack@v0.5.1"],"schemaVersion":1,"symbols":["github.com/quic-go/qpack.NewDecoder"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/quic-go/qpack@v0.5.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/quic-go/qpack@v0.5.1","symbols":["github.com/quic-go/qpack.NewDecoder"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.24.0
require github.com/quic-go/qpack v0.5.1
require golang.org/x/net v0.28.0 // indirect
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"bytes"
"fmt"
"os"
"github.com/quic-go/qpack"
)
// DecodeHeaders decodes QPACK encoded header block bytes into a list of HeaderFields.
func DecodeHeaders(data []byte) ([]qpack.HeaderField, error) {
dec := qpack.NewDecoder(nil)
return dec.DecodeFull(data)
}
// EncodeHeaders encodes a list of HeaderFields into QPACK byte slice.
func EncodeHeaders(fields []qpack.HeaderField) ([]byte, error) {
var buf bytes.Buffer
enc := qpack.NewEncoder(&buf)
for _, f := range fields {
if err := enc.WriteField(f); err != nil {
return nil, fmt.Errorf("failed to encode field %s: %w", f.Name, err)
}
}
if err := enc.Close(); err != nil {
return nil, fmt.Errorf("failed to close encoder: %w", err)
}
return buf.Bytes(), nil
}
func main() {
headers := []qpack.HeaderField{
{Name: ":status", Value: "200"},
{Name: ":path", Value: "/api/v1/resource"},
{Name: "content-type", Value: "application/json"},
}
encoded, err := EncodeHeaders(headers)
if err != nil {
fmt.Fprintf(os.Stderr, "Error encoding headers: %v\n", err)
os.Exit(1)
}
fmt.Printf("Encoded %d headers into %d bytes\n", len(headers), len(encoded))
decoded, err := DecodeHeaders(encoded)
if err != nil {
fmt.Fprintf(os.Stderr, "Error decoding headers: %v\n", err)
os.Exit(1)
}
for _, h := range decoded {
pseudo := ""
if h.IsPseudo() {
pseudo = " (pseudo-header)"
}
fmt.Printf("Header: %s = %s%s\n", h.Name, h.Value, pseudo)
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/quic-go/qpack.NewDecoder in pkg:golang/github.com/quic-go/qpack@v0.5.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/quic-go/qpack@v0.5.1"
],
"symbols": [
"github.com/quic-go/qpack.NewDecoder"
]
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/quic-go/qpack"
)
func main() {
// Assertion 1: qpack.NewDecoder decodes full QPACK header blocks containing pseudo-headers and regular headers via DecodeFull
var buf bytes.Buffer
enc := qpack.NewEncoder(&buf)
if err := enc.WriteField(qpack.HeaderField{Name: ":status", Value: "200"}); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: enc.WriteField :status: %v\n", err)
os.Exit(1)
}
if err := enc.WriteField(qpack.HeaderField{Name: ":path", Value: "/index.html"}); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: enc.WriteField :path: %v\n", err)
os.Exit(1)
}
if err := enc.WriteField(qpack.HeaderField{Name: "content-type", Value: "application/json"}); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: enc.WriteField content-type: %v\n", err)
os.Exit(1)
}
if err := enc.Close(); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: enc.Close: %v\n", err)
os.Exit(1)
}
dec := qpack.NewDecoder(nil)
fields, err := dec.DecodeFull(buf.Bytes())
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: dec.DecodeFull: %v\n", err)
os.Exit(1)
}
if len(fields) != 3 {
fmt.Fprintf(os.Stderr, "FAIL: expected 3 decoded fields, got %d\n", len(fields))
os.Exit(1)
}
if fields[0].Name != ":status" || fields[0].Value != "200" {
fmt.Fprintf(os.Stderr, "FAIL: field 0 mismatch: %+v\n", fields[0])
os.Exit(1)
}
if fields[1].Name != ":path" || fields[1].Value != "/index.html" {
fmt.Fprintf(os.Stderr, "FAIL: field 1 mismatch: %+v\n", fields[1])
os.Exit(1)
}
if fields[2].Name != "content-type" || fields[2].Value != "application/json" {
fmt.Fprintf(os.Stderr, "FAIL: field 2 mismatch: %+v\n", fields[2])
os.Exit(1)
}
// Assertion 2: qpack.NewDecoder with emit callback processes header fields incrementally via Write
var emitted []qpack.HeaderField
streamDec := qpack.NewDecoder(func(hf qpack.HeaderField) {
emitted = append(emitted, hf)
})
n, err := streamDec.Write(buf.Bytes())
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: streamDec.Write: %v\n", err)
os.Exit(1)
}
if n != buf.Len() {
fmt.Fprintf(os.Stderr, "FAIL: streamDec.Write returned %d, expected %d\n", n, buf.Len())
os.Exit(1)
}
if err := streamDec.Close(); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: streamDec.Close: %v\n", err)
os.Exit(1)
}
if len(emitted) != 3 {
fmt.Fprintf(os.Stderr, "FAIL: expected 3 emitted fields, got %d\n", len(emitted))
os.Exit(1)
}
if emitted[0].Name != ":status" || emitted[1].Name != ":path" || emitted[2].Name != "content-type" {
fmt.Fprintf(os.Stderr, "FAIL: emitted fields mismatch: %+v\n", emitted)
os.Exit(1)
}
// Assertion 3: qpack.HeaderField.IsPseudo returns true for pseudo-headers starting with a colon and false for standard headers
pseudoField := qpack.HeaderField{Name: ":method", Value: "GET"}
if !pseudoField.IsPseudo() {
fmt.Fprintf(os.Stderr, "FAIL: expected IsPseudo() to be true for :method\n")
os.Exit(1)
}
regularField := qpack.HeaderField{Name: "user-agent", Value: "test-client"}
if regularField.IsPseudo() {
fmt.Fprintf(os.Stderr, "FAIL: expected IsPseudo() to be false for user-agent\n")
os.Exit(1)
}
// Assertion 4: qpack.NewDecoder.DecodeFull returns an error when decoding malformed or invalid header block data
errDec := qpack.NewDecoder(nil)
_, err = errDec.DecodeFull([]byte{0xff, 0xff, 0xff})
if err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error decoding malformed bytes, got nil\n")
os.Exit(1)
}
fmt.Println("PASS: github.com/quic-go/qpack.NewDecoder contract verified")
}
Seeder d'origine
anonyme