샘플
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 ChunkReader…
sha256:84a32428bdea7edc4f8e47757a2535121c3d9e323e0fca9f3a6dc0f189fcc873
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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")
}
오리진 시더
익명