Beispiel
github.com/jackc/pgproto3/v2 v2.1.1: AuthenticationOk
Verifiziertes Beispiel für golang github.com/jackc/pgproto3/v2 v2.1.1: AuthenticationOk. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:fa8c5e6ed3987f1a340af98e91a27f61b16d7f167537255139e915afa4cae2a4
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-14 |
Fall
HOW- Ziel
- verify github.com/jackc/pgproto3/v2.AuthenticationOk in pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1
- Symbole
-
- github.com/jackc/pgproto3/v2.AuthenticationOk
- Erstellt
- 2026-09-14T22:22:19Z
Contract
- AuthenticationOk.Encode encodes backend authentication success message into wire format with message type identifier 'R', length 8, and AuthTypeOk
- AuthenticationOk.Decode decodes wire message body into AuthenticationOk struct
- AuthenticationOk.Decode rejects invalid body length or incorrect auth type
- AuthenticationOk.MarshalJSON serializes to JSON object with Type AuthenticationOK
- AuthenticationOk implements BackendMessage and AuthenticationResponseMessage interfaces
- pgproto3.Frontend and pgproto3.Backend exchange AuthenticationOk over client and server streams
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
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/jackc/pgproto3/v2.AuthenticationOk in pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1
Demonstrate these symbols/APIs:
- github.com/jackc/pgproto3/v2.AuthenticationOk
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:eb863c5605f72d28e7ce7a59eb5439381c6cb215920365b97edc76f239d3ee50","contract":["AuthenticationOk.Encode encodes backend authentication success message into wire format with message type identifier 'R', length 8, and AuthTypeOk","AuthenticationOk.Decode decodes wire message body into AuthenticationOk struct","AuthenticationOk.Decode rejects invalid body length or incorrect auth type","AuthenticationOk.MarshalJSON serializes to JSON object with Type AuthenticationOK","AuthenticationOk implements BackendMessage and AuthenticationResponseMessage interfaces","pgproto3.Frontend and pgproto3.Backend exchange AuthenticationOk over client and server streams"],"goal":"verify github.com/jackc/pgproto3/v2.AuthenticationOk in pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1","kind":"HOW","packages":["pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1"],"schemaVersion":1,"symbols":["github.com/jackc/pgproto3/v2.AuthenticationOk"]},"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/jackc/pgproto3/v2@v2.1.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1","symbols":["github.com/jackc/pgproto3/v2.AuthenticationOk"],"verifierAdapter":"golang@1"}
module example.com/authenticationok
go 1.22
require github.com/jackc/pgproto3/v2 v2.1.1
require (
github.com/jackc/chunkreader/v2 v2.0.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
)
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"fmt"
"github.com/jackc/pgproto3/v2"
)
func main() {
authOk := &pgproto3.AuthenticationOk{}
buf := authOk.Encode(nil)
var decoded pgproto3.AuthenticationOk
if err := decoded.Decode(buf[5:]); err != nil {
fmt.Printf("Decode error: %v\n", err)
return
}
jsonBytes, err := decoded.MarshalJSON()
if err != nil {
fmt.Printf("MarshalJSON error: %v\n", err)
return
}
fmt.Printf("AuthenticationOk encoded %d bytes: %s\n", len(buf), string(jsonBytes))
}
{
"schemaVersion": 1,
"goal": "verify github.com/jackc/pgproto3/v2.AuthenticationOk in pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/jackc/pgproto3/v2@v2.1.1"
],
"symbols": [
"github.com/jackc/pgproto3/v2.AuthenticationOk"
]
}
package main
import (
"bytes"
"encoding/binary"
"fmt"
"os"
"github.com/jackc/pgproto3/v2"
)
func main() {
// 1. AuthenticationOk.Encode encodes backend authentication success message into wire format with message type identifier 'R', length 8, and AuthTypeOk
{
auth := &pgproto3.AuthenticationOk{}
buf := auth.Encode(nil)
if len(buf) != 9 {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected 9 bytes, got %d\n", len(buf))
os.Exit(1)
}
if buf[0] != 'R' {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected type identifier 'R', got %c\n", buf[0])
os.Exit(1)
}
msgLen := binary.BigEndian.Uint32(buf[1:5])
if msgLen != 8 {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected message length 8, got %d\n", msgLen)
os.Exit(1)
}
authType := binary.BigEndian.Uint32(buf[5:9])
if authType != 0 {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected AuthTypeOk (0), got %d\n", authType)
os.Exit(1)
}
}
// 2. AuthenticationOk.Decode decodes wire message body into AuthenticationOk struct
{
auth := &pgproto3.AuthenticationOk{}
buf := auth.Encode(nil)
var decoded pgproto3.AuthenticationOk
if err := decoded.Decode(buf[5:]); err != nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed Decode: %v\n", err)
os.Exit(1)
}
}
// 3. AuthenticationOk.Decode rejects invalid body length or incorrect auth type
{
var decoded pgproto3.AuthenticationOk
if err := decoded.Decode([]byte{0, 0, 0}); err == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: expected error on 3 bytes body\n")
os.Exit(1)
}
if err := decoded.Decode([]byte{0, 0, 0, 0, 0}); err == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: expected error on 5 bytes body\n")
os.Exit(1)
}
badAuthPayload := make([]byte, 4)
binary.BigEndian.PutUint32(badAuthPayload, 1)
if err := decoded.Decode(badAuthPayload); err == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: expected error on non-zero auth type\n")
os.Exit(1)
}
}
// 4. AuthenticationOk.MarshalJSON serializes to JSON object with Type AuthenticationOK
{
auth := pgproto3.AuthenticationOk{}
data, err := auth.MarshalJSON()
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed MarshalJSON: %v\n", err)
os.Exit(1)
}
expectedJSON := `{"Type":"AuthenticationOK"}`
if string(data) != expectedJSON {
fmt.Fprintf(os.Stderr, "Contract 4 failed: expected %s, got %s\n", expectedJSON, string(data))
os.Exit(1)
}
}
// 5. AuthenticationOk implements BackendMessage and AuthenticationResponseMessage interfaces
{
var (
_ pgproto3.BackendMessage = (*pgproto3.AuthenticationOk)(nil)
_ pgproto3.AuthenticationResponseMessage = (*pgproto3.AuthenticationOk)(nil)
)
auth := &pgproto3.AuthenticationOk{}
auth.Backend()
auth.AuthenticationResponse()
}
// 6. pgproto3.Frontend and pgproto3.Backend exchange AuthenticationOk over client and server streams
{
clientToServer := &bytes.Buffer{}
serverToClient := &bytes.Buffer{}
frontend := pgproto3.NewFrontend(pgproto3.NewChunkReader(serverToClient), clientToServer)
backend := pgproto3.NewBackend(pgproto3.NewChunkReader(clientToServer), serverToClient)
if err := backend.Send(&pgproto3.AuthenticationOk{}); err != nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed backend.Send: %v\n", err)
os.Exit(1)
}
msg, err := frontend.Receive()
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed frontend.Receive: %v\n", err)
os.Exit(1)
}
if _, ok := msg.(*pgproto3.AuthenticationOk); !ok {
fmt.Fprintf(os.Stderr, "Contract 6 failed: expected *pgproto3.AuthenticationOk, got %T\n", msg)
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym