サンプル
github.com/jackc/chunkreader/v2 v2.0.1
検証済みサンプル — golang github.com/jackc/chunkreader/v2 v2.0.1. go 1.26 · linux alpine/x64 · docker で contract を実行し、成功しました: chunkreader.New initializes a…
sha256:84a32428bdea7edc4f8e47757a2535121c3d9e323e0fca9f3a6dc0f189fcc873
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 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-23 |
| 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 |
ケース
HOW- ゴール
- verify pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1
- 作成日
- 2026-08-23T17:19:13Z
コントラクト
- chunkreader.New initializes a ChunkReader with default 8192-byte minimum buffer length wrapping an io.Reader
- chunkreader.NewConfig initializes a ChunkReader with a custom Config specifying MinBufLen
- chunkreader.ChunkReader.Next returns consecutive slices of requested byte lengths from the underlying stream
- chunkreader.ChunkReader.Next expands internal buffer when requested chunk size exceeds MinBufLen
- chunkreader.ChunkReader.Next returns io.ErrUnexpectedEOF or io.EOF when underlying reader has fewer bytes than requested
- chunkreader.ChunkReader.Next guarantees caller ownership of returned byte slices across subsequent reads
ファイル
- 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/github.com/jackc/chunkreader/v2@v2.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1
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:a1ac5cce644ba9cd35ac020f879d19b1c3b370c2b0ac6f0c59ad4d29172262d6","contract":["chunkreader.New initializes a ChunkReader with default 8192-byte minimum buffer length wrapping an io.Reader","chunkreader.NewConfig initializes a ChunkReader with a custom Config specifying MinBufLen","chunkreader.ChunkReader.Next returns consecutive slices of requested byte lengths from the underlying stream","chunkreader.ChunkReader.Next expands internal buffer when requested chunk size exceeds MinBufLen","chunkreader.ChunkReader.Next returns io.ErrUnexpectedEOF or io.EOF when underlying reader has fewer bytes than requested","chunkreader.ChunkReader.Next guarantees caller ownership of returned byte slices across subsequent reads"],"goal":"verify pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1","kind":"HOW","packages":["pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1"],"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/github.com/jackc/chunkreader/v2@v2.0.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1","verifierAdapter":"golang@1"}
module sample-chunkreader
go 1.22
require github.com/jackc/chunkreader/v2 v2.0.1
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
package main
import (
"bytes"
"fmt"
"github.com/jackc/chunkreader/v2"
)
func main() {
data := []byte("example payload stream for chunkreader")
r := bytes.NewReader(data)
cr := chunkreader.New(r)
chunk, err := cr.Next(7)
if err != nil {
fmt.Printf("read error: %v\n", err)
return
}
fmt.Printf("Read chunk: %s\n", string(chunk))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"github.com/jackc/chunkreader/v2"
)
func main() {
// Assertion 1: chunkreader.New initializes a ChunkReader with default 8192-byte minimum buffer length wrapping an io.Reader
{
data := []byte("hello world")
r := bytes.NewReader(data)
cr := chunkreader.New(r)
if cr == nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: cr is nil\n")
os.Exit(1)
}
chunk, err := cr.Next(5)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed on Next: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(chunk, []byte("hello")) {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected 'hello', got '%s'\n", string(chunk))
os.Exit(1)
}
}
// Assertion 2: chunkreader.NewConfig initializes a ChunkReader with a custom Config specifying MinBufLen
{
data := []byte("custom buffer size test")
r := bytes.NewReader(data)
cfg := chunkreader.Config{MinBufLen: 16}
cr, err := chunkreader.NewConfig(r, cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: %v\n", err)
os.Exit(1)
}
if cr == nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: cr is nil\n")
os.Exit(1)
}
chunk, err := cr.Next(6)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed on Next: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(chunk, []byte("custom")) {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: expected 'custom', got '%s'\n", string(chunk))
os.Exit(1)
}
}
// Assertion 3: chunkreader.ChunkReader.Next returns consecutive slices of requested byte lengths from the underlying stream
{
payload := []byte("0123456789ABCDEF")
r := bytes.NewReader(payload)
cr := chunkreader.New(r)
part1, err := cr.Next(4)
if err != nil || !bytes.Equal(part1, []byte("0123")) {
fmt.Fprintf(os.Stderr, "Assertion 3 failed part1: %v, got %s\n", err, string(part1))
os.Exit(1)
}
part2, err := cr.Next(6)
if err != nil || !bytes.Equal(part2, []byte("456789")) {
fmt.Fprintf(os.Stderr, "Assertion 3 failed part2: %v, got %s\n", err, string(part2))
os.Exit(1)
}
part3, err := cr.Next(6)
if err != nil || !bytes.Equal(part3, []byte("ABCDEF")) {
fmt.Fprintf(os.Stderr, "Assertion 3 failed part3: %v, got %s\n", err, string(part3))
os.Exit(1)
}
}
// Assertion 4: chunkreader.ChunkReader.Next expands internal buffer when requested chunk size exceeds MinBufLen
{
largeData := make([]byte, 32)
for i := range largeData {
largeData[i] = byte('A' + (i % 26))
}
r := bytes.NewReader(largeData)
cr, err := chunkreader.NewConfig(r, chunkreader.Config{MinBufLen: 8})
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 4 failed NewConfig: %v\n", err)
os.Exit(1)
}
// Request 20 bytes (larger than MinBufLen of 8)
chunk, err := cr.Next(20)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 4 failed Next: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(chunk, largeData[:20]) {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: content mismatch\n")
os.Exit(1)
}
}
// Assertion 5: chunkreader.ChunkReader.Next returns io.ErrUnexpectedEOF or io.EOF when underlying reader has fewer bytes than requested
{
shortData := []byte("short")
r := bytes.NewReader(shortData)
cr := chunkreader.New(r)
chunk, err := cr.Next(10)
if err == nil {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected error, got nil error and chunk %v\n", chunk)
os.Exit(1)
}
if chunk != nil {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected nil buffer on error, got %v\n", chunk)
os.Exit(1)
}
if !errors.Is(err, io.ErrUnexpectedEOF) && !errors.Is(err, io.EOF) {
fmt.Fprintf(os.Stderr, "Assertion 5 failed: expected EOF error, got %v\n", err)
os.Exit(1)
}
}
// Assertion 6: chunkreader.ChunkReader.Next guarantees caller ownership of returned byte slices across subsequent reads
{
data := []byte("first_chunk_data!second_chunk_data#third_chunk_data$")
r := bytes.NewReader(data)
cr, err := chunkreader.NewConfig(r, chunkreader.Config{MinBufLen: 16})
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 6 failed: %v\n", err)
os.Exit(1)
}
c1, err := cr.Next(17)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 6 failed c1: %v\n", err)
os.Exit(1)
}
c1Copy := string(c1)
c2, err := cr.Next(18)
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 6 failed c2: %v\n", err)
os.Exit(1)
}
if string(c1) != c1Copy || string(c1) != "first_chunk_data!" {
fmt.Fprintf(os.Stderr, "Assertion 6 failed: c1 mutated. expected 'first_chunk_data!', got '%s'\n", string(c1))
os.Exit(1)
}
if string(c2) != "second_chunk_data#" {
fmt.Fprintf(os.Stderr, "Assertion 6 failed: c2 mismatch. expected 'second_chunk_data#', got '%s'\n", string(c2))
os.Exit(1)
}
}
fmt.Println("PASS: pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1 contract passed")
}
オリジンシーダー
匿名