サンプル
golang.org/x/net v0.37.0
検証済みサンプル — golang golang.org/x/net v0.37.0. go 1.26 · linux alpine/x64 · docker で contract を実行し、成功しました: websocket.NewConfig creates a valid WebSocket…
sha256:3d685a2fa5b75657300287b20653432feed1b1afa7370f950ec6a655a52650f1
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。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-27 |
ケース
HOW- ゴール
- verify pkg:golang/golang.org/x/net@v0.37.0
- パッケージ
- 作成日
- 2026-08-27T13:19:57Z
コントラクト
- websocket.NewConfig creates a valid WebSocket configuration with URL, Origin, and protocol version
- websocket.Handler converts a function into an http.Handler that serves WebSocket connections
- websocket.Dial establishes a WebSocket client connection to a server with specified origin
- websocket.Message.Send and websocket.Message.Receive transmit and receive text string payloads
- websocket.Message.Send and websocket.Message.Receive transmit and receive binary byte payloads
- websocket.JSON.Send and websocket.JSON.Receive serialize, transmit, and deserialize structured data
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- 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 pkg:golang/golang.org/x/net@v0.37.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.37.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:4259ae75d9ea90826b9b43fe82ca4056deb329fc3ae8e93d55fbccf4845bd600","contract":["websocket.NewConfig creates a valid WebSocket configuration with URL, Origin, and protocol version","websocket.Handler converts a function into an http.Handler that serves WebSocket connections","websocket.Dial establishes a WebSocket client connection to a server with specified origin","websocket.Message.Send and websocket.Message.Receive transmit and receive text string payloads","websocket.Message.Send and websocket.Message.Receive transmit and receive binary byte payloads","websocket.JSON.Send and websocket.JSON.Receive serialize, transmit, and deserialize structured data"],"goal":"verify pkg:golang/golang.org/x/net@v0.37.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.37.0"],"schemaVersion":1},"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/golang.org/x/net@v0.37.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.37.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/net v0.37.0 // indirect
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
package main
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"strings"
"golang.org/x/net/websocket"
)
// EchoServer handles WebSocket messages and echoes them back.
func EchoServer(ws *websocket.Conn) {
for {
var msg string
err := websocket.Message.Receive(ws, &msg)
if err != nil {
break
}
if err := websocket.Message.Send(ws, "echo: "+msg); err != nil {
break
}
}
}
type Payload struct {
Greeting string `json:"greeting"`
Count int `json:"count"`
}
// JSONServer handles JSON-encoded WebSocket messages.
func JSONServer(ws *websocket.Conn) {
for {
var p Payload
err := websocket.JSON.Receive(ws, &p)
if err != nil {
break
}
p.Greeting = strings.ToUpper(p.Greeting)
p.Count *= 2
if err := websocket.JSON.Send(ws, p); err != nil {
break
}
}
}
func main() {
mux := http.NewServeMux()
mux.Handle("/echo", websocket.Handler(EchoServer))
mux.Handle("/json", websocket.Handler(JSONServer))
server := httptest.NewServer(mux)
defer server.Close()
wsURL := "ws" + strings.TrimPrefix(server.URL, "http") + "/echo"
origin := "http://localhost"
ws, err := websocket.Dial(wsURL, "", origin)
if err != nil {
log.Fatalf("Dial failed: %v", err)
}
defer ws.Close()
if err := websocket.Message.Send(ws, "hello world"); err != nil {
log.Fatalf("Send failed: %v", err)
}
var reply string
if err := websocket.Message.Receive(ws, &reply); err != nil {
log.Fatalf("Receive failed: %v", err)
}
fmt.Printf("Received: %s\n", reply)
// Test JSON
jsonWSURL := "ws" + strings.TrimPrefix(server.URL, "http") + "/json"
wsJSON, err := websocket.Dial(jsonWSURL, "", origin)
if err != nil {
log.Fatalf("Dial json failed: %v", err)
}
defer wsJSON.Close()
sendPayload := Payload{Greeting: "ping", Count: 5}
if err := websocket.JSON.Send(wsJSON, sendPayload); err != nil {
log.Fatalf("JSON Send failed: %v", err)
}
var recvPayload Payload
if err := websocket.JSON.Receive(wsJSON, &recvPayload); err != nil {
log.Fatalf("JSON Receive failed: %v", err)
}
fmt.Printf("Received JSON: %+v\n", recvPayload)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/net@v0.37.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.37.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"bytes"
"fmt"
"net/http"
"net/http/httptest"
"os"
"strings"
"golang.org/x/net/websocket"
)
type TestMessage struct {
Command string `json:"command"`
Value int `json:"value"`
}
func main() {
// Assertion 1: websocket.NewConfig creates a valid WebSocket configuration with URL, Origin, and protocol version
cfg, err := websocket.NewConfig("ws://example.com/ws", "http://example.com")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.NewConfig failed: %v\n", err)
os.Exit(1)
}
if cfg.Location == nil || cfg.Location.Path != "/ws" {
fmt.Fprintf(os.Stderr, "FAIL: websocket.NewConfig invalid location: %v\n", cfg.Location)
os.Exit(1)
}
if cfg.Origin == nil || cfg.Origin.Host != "example.com" {
fmt.Fprintf(os.Stderr, "FAIL: websocket.NewConfig invalid origin: %v\n", cfg.Origin)
os.Exit(1)
}
if cfg.Version != websocket.ProtocolVersionHybi13 {
fmt.Fprintf(os.Stderr, "FAIL: websocket.NewConfig expected Hybi13 protocol version, got %d\n", cfg.Version)
os.Exit(1)
}
// Assertion 2: websocket.Handler converts a function into an http.Handler that serves WebSocket connections
mux := http.NewServeMux()
mux.Handle("/echo", websocket.Handler(func(ws *websocket.Conn) {
for {
var msg string
if err := websocket.Message.Receive(ws, &msg); err != nil {
break
}
if err := websocket.Message.Send(ws, "echo:"+msg); err != nil {
break
}
}
}))
mux.Handle("/binary", websocket.Handler(func(ws *websocket.Conn) {
for {
var data []byte
if err := websocket.Message.Receive(ws, &data); err != nil {
break
}
resp := append([]byte("bin:"), data...)
if err := websocket.Message.Send(ws, resp); err != nil {
break
}
}
}))
mux.Handle("/json", websocket.Handler(func(ws *websocket.Conn) {
for {
var m TestMessage
if err := websocket.JSON.Receive(ws, &m); err != nil {
break
}
m.Command = "ack:" + m.Command
m.Value *= 10
if err := websocket.JSON.Send(ws, m); err != nil {
break
}
}
}))
server := httptest.NewServer(mux)
defer server.Close()
wsBase := "ws" + strings.TrimPrefix(server.URL, "http")
// Assertion 3: websocket.Dial establishes a WebSocket client connection to a server with specified origin
wsEcho, err := websocket.Dial(wsBase+"/echo", "", "http://localhost")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Dial failed: %v\n", err)
os.Exit(1)
}
defer wsEcho.Close()
// Assertion 4: websocket.Message.Send and websocket.Message.Receive transmit and receive text string payloads
textPayload := "csx-test-payload-12345"
if err := websocket.Message.Send(wsEcho, textPayload); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Message.Send text failed: %v\n", err)
os.Exit(1)
}
var textReply string
if err := websocket.Message.Receive(wsEcho, &textReply); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Message.Receive text failed: %v\n", err)
os.Exit(1)
}
if textReply != "echo:"+textPayload {
fmt.Fprintf(os.Stderr, "FAIL: text reply mismatch: got %q, want %q\n", textReply, "echo:"+textPayload)
os.Exit(1)
}
// Assertion 5: websocket.Message.Send and websocket.Message.Receive transmit and receive binary byte payloads
wsBin, err := websocket.Dial(wsBase+"/binary", "", "http://localhost")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Dial binary failed: %v\n", err)
os.Exit(1)
}
defer wsBin.Close()
binPayload := []byte{0x01, 0x02, 0x03, 0xFF, 0xFE}
if err := websocket.Message.Send(wsBin, binPayload); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Message.Send binary failed: %v\n", err)
os.Exit(1)
}
var binReply []byte
if err := websocket.Message.Receive(wsBin, &binReply); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Message.Receive binary failed: %v\n", err)
os.Exit(1)
}
expectedBin := append([]byte("bin:"), binPayload...)
if !bytes.Equal(binReply, expectedBin) {
fmt.Fprintf(os.Stderr, "FAIL: binary reply mismatch: got %x, want %x\n", binReply, expectedBin)
os.Exit(1)
}
// Assertion 6: websocket.JSON.Send and websocket.JSON.Receive serialize, transmit, and deserialize structured data
wsJSON, err := websocket.Dial(wsBase+"/json", "", "http://localhost")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.Dial json failed: %v\n", err)
os.Exit(1)
}
defer wsJSON.Close()
sendObj := TestMessage{Command: "compute", Value: 42}
if err := websocket.JSON.Send(wsJSON, sendObj); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.JSON.Send failed: %v\n", err)
os.Exit(1)
}
var recvObj TestMessage
if err := websocket.JSON.Receive(wsJSON, &recvObj); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: websocket.JSON.Receive failed: %v\n", err)
os.Exit(1)
}
if recvObj.Command != "ack:compute" || recvObj.Value != 420 {
fmt.Fprintf(os.Stderr, "FAIL: JSON struct mismatch: got %+v, want Command='ack:compute', Value=420\n", recvObj)
os.Exit(1)
}
fmt.Println("PASS: pkg:golang/golang.org/x/net@v0.37.0 contract passed")
}
オリジンシーダー
匿名