サンプル
github.com/jackc/pgx/v5 v5.10.0: pgproto3.AuthenticationOk
検証済みサンプル — golang github.com/jackc/pgx/v5 v5.10.0: pgproto3.AuthenticationOk. go 1.26 · linux alpine/x64 · docker で contract を実行し、成功しました.
sha256:896c244de96d68c7e0d1895b300191f23ac16604d335b21b18fd3b6bb7853d78
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-28 |
ケース
HOW- ゴール
- verify github.com/jackc/pgx/v5/pgproto3.AuthenticationOk in pkg:golang/github.com/jackc/pgx/v5@v5.10.0
- シンボル
-
- github.com/jackc/pgx/v5/pgproto3.AuthenticationOk
- 作成日
- 2026-08-28T01:44:54Z
コントラクト
- AuthenticationOk implements pgproto3.BackendMessage
- AuthenticationOk implements pgproto3.AuthenticationResponseMessage
- AuthenticationOk.Encode encodes wire message with identifier 'R', length 8, and AuthTypeOk
- AuthenticationOk.Decode successfully decodes a 4-byte auth type 0 payload
- AuthenticationOk.Decode returns error on mismatched auth type or truncated payload
- AuthenticationOk.MarshalJSON serializes to JSON object with Type AuthenticationOK
ファイル
- PROMPT.md
- auth_ok.go
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
ソース
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/pgx/v5/pgproto3.AuthenticationOk in pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Demonstrate these symbols/APIs:
- github.com/jackc/pgx/v5/pgproto3.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.
package sample
import (
"github.com/jackc/pgx/v5/pgproto3"
)
// NewAuthenticationOk creates a new pgproto3.AuthenticationOk message pointer.
func NewAuthenticationOk() *pgproto3.AuthenticationOk {
return &pgproto3.AuthenticationOk{}
}
// EncodeAuthenticationOk encodes the AuthenticationOk message into wire format bytes.
func EncodeAuthenticationOk(msg *pgproto3.AuthenticationOk) ([]byte, error) {
return msg.Encode(nil)
}
// DecodeAuthenticationOk decodes message body bytes into an AuthenticationOk struct.
// src must contain the 4-byte auth type code (pgproto3.AuthTypeOk).
func DecodeAuthenticationOk(src []byte) (*pgproto3.AuthenticationOk, error) {
dst := &pgproto3.AuthenticationOk{}
if err := dst.Decode(src); err != nil {
return nil, err
}
return dst, nil
}
// IsAuthenticationResponse verifies that the message implements AuthenticationResponseMessage.
func IsAuthenticationResponse(msg pgproto3.AuthenticationResponseMessage) bool {
return msg != nil
}
// IsBackendMessage verifies that the message implements BackendMessage.
func IsBackendMessage(msg pgproto3.BackendMessage) bool {
return msg != nil
}
{"case":{"caseId":"case:sha256:865a617c1e844581d209f6eada83d0d830ca5481dd7fba5335c1e7bd7fd7237a","contract":["AuthenticationOk implements pgproto3.BackendMessage","AuthenticationOk implements pgproto3.AuthenticationResponseMessage","AuthenticationOk.Encode encodes wire message with identifier 'R', length 8, and AuthTypeOk","AuthenticationOk.Decode successfully decodes a 4-byte auth type 0 payload","AuthenticationOk.Decode returns error on mismatched auth type or truncated payload","AuthenticationOk.MarshalJSON serializes to JSON object with Type AuthenticationOK"],"goal":"verify github.com/jackc/pgx/v5/pgproto3.AuthenticationOk in pkg:golang/github.com/jackc/pgx/v5@v5.10.0","kind":"HOW","packages":["pkg:golang/github.com/jackc/pgx/v5@v5.10.0"],"schemaVersion":1,"symbols":["github.com/jackc/pgx/v5/pgproto3.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/pgx/v5@v5.10.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/jackc/pgx/v5@v5.10.0","symbols":["github.com/jackc/pgx/v5/pgproto3.AuthenticationOk"],"verifierAdapter":"golang@1"}
module sample
go 1.25.0
require github.com/jackc/pgx/v5 v5.10.0
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/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
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/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
{
"schemaVersion": 1,
"goal": "verify github.com/jackc/pgx/v5/pgproto3.AuthenticationOk in pkg:golang/github.com/jackc/pgx/v5@v5.10.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/jackc/pgx/v5@v5.10.0"
],
"symbols": [
"github.com/jackc/pgx/v5/pgproto3.AuthenticationOk"
]
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"os"
"github.com/jackc/pgx/v5/pgproto3"
"sample"
)
func main() {
msg := sample.NewAuthenticationOk()
// Assertion 1: AuthenticationOk implements pgproto3.BackendMessage
var backendMsg pgproto3.BackendMessage = msg
if !sample.IsBackendMessage(backendMsg) {
fmt.Fprintf(os.Stderr, "expected AuthenticationOk to implement BackendMessage\n")
os.Exit(1)
}
// Assertion 2: AuthenticationOk implements pgproto3.AuthenticationResponseMessage
var authResp pgproto3.AuthenticationResponseMessage = msg
if !sample.IsAuthenticationResponse(authResp) {
fmt.Fprintf(os.Stderr, "expected AuthenticationOk to implement AuthenticationResponseMessage\n")
os.Exit(1)
}
// Assertion 3: Encode serializes to 'R' followed by length 8 and AuthTypeOk (0)
encoded, err := sample.EncodeAuthenticationOk(msg)
if err != nil {
fmt.Fprintf(os.Stderr, "EncodeAuthenticationOk failed: %v\n", err)
os.Exit(1)
}
expectedWire := []byte{'R', 0, 0, 0, 8, 0, 0, 0, byte(pgproto3.AuthTypeOk)}
if !bytes.Equal(encoded, expectedWire) {
fmt.Fprintf(os.Stderr, "encoded mismatch: got %v, expected %v\n", encoded, expectedWire)
os.Exit(1)
}
// Assertion 4: Decode succeeds for 4-byte auth type 0 payload
validPayload := []byte{0, 0, 0, 0}
decoded, err := sample.DecodeAuthenticationOk(validPayload)
if err != nil {
fmt.Fprintf(os.Stderr, "DecodeAuthenticationOk failed: %v\n", err)
os.Exit(1)
}
if decoded == nil {
fmt.Fprintf(os.Stderr, "expected decoded message not to be nil\n")
os.Exit(1)
}
// Assertion 5: Decode returns error on mismatched auth type
mismatchedAuthPayload := []byte{0, 0, 0, 3}
if _, err := sample.DecodeAuthenticationOk(mismatchedAuthPayload); err == nil {
fmt.Fprintf(os.Stderr, "expected error decoding mismatched auth type payload\n")
os.Exit(1)
}
// Assertion 6: Decode returns error on invalid payload length
shortPayload := []byte{0, 0}
if _, err := sample.DecodeAuthenticationOk(shortPayload); err == nil {
fmt.Fprintf(os.Stderr, "expected error decoding short payload\n")
os.Exit(1)
}
// Assertion 7: MarshalJSON serializes AuthenticationOk to JSON with Type "AuthenticationOK"
jsonBytes, err := json.Marshal(msg)
if err != nil {
fmt.Fprintf(os.Stderr, "json.Marshal failed: %v\n", err)
os.Exit(1)
}
expectedJSON := `{"Type":"AuthenticationOK"}`
if string(jsonBytes) != expectedJSON {
fmt.Fprintf(os.Stderr, "json mismatch: got %s, expected %s\n", string(jsonBytes), expectedJSON)
os.Exit(1)
}
fmt.Println("All pgproto3.AuthenticationOk contract assertions passed.")
}
オリジンシーダー
匿名