Ejemplo
github.com/jackc/chunkreader/v2 v2.0.1
Muestra verificada para golang github.com/jackc/chunkreader/v2 v2.0.1. El contrato se ejecutó en go 1.26 · linux alpine/x64 · docker y pasó.
sha256:84a32428bdea7edc4f8e47757a2535121c3d9e323e0fca9f3a6dc0f189fcc873
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:golang/github.com/jackc/chunkreader/v2@v2.0.1
- Creado
- 2026-08-23T17:19:13Z
Contrato
- 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
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
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")
}
Seeder de origen
anónimo