Sample
github.com/klauspost/compress v1.20.0
Verified sample for golang github.com/klauspost/compress v1.20.0. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:f2bcef2b223dbf739d908a20508fbbe7dd34f973e289832b89ff6fabff4704aa
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-02 |
Case
HOW- Goal
- verify pkg:golang/github.com/klauspost/compress@v1.20.0
- Created
- 2026-09-02T23:28:55Z
Contract
- s2.NewWriter compresses data stream and s2.NewReader decompresses to restore exact original payload
- s2.NewWriter with WriterBetterCompression compresses data stream
- s2.NewWriter and s2.NewReader correctly roundtrip empty input payload
- s2.NewReader returns error when reading invalid or corrupted s2 stream
- s2.NewWriter and s2.NewReader support stream reuse via Reset
- s2.Encode compresses byte slice and s2.Decode decompresses to restore exact original payload
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
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/klauspost/compress@v1.20.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/klauspost/compress@v1.20.0
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:85dc910c42fc5778dceda8f0a7cf91f0d1e024d17c26441e58e2ce1da6bce52e","contract":["s2.NewWriter compresses data stream and s2.NewReader decompresses to restore exact original payload","s2.NewWriter with WriterBetterCompression compresses data stream","s2.NewWriter and s2.NewReader correctly roundtrip empty input payload","s2.NewReader returns error when reading invalid or corrupted s2 stream","s2.NewWriter and s2.NewReader support stream reuse via Reset","s2.Encode compresses byte slice and s2.Decode decompresses to restore exact original payload"],"goal":"verify pkg:golang/github.com/klauspost/compress@v1.20.0","kind":"HOW","packages":["pkg:golang/github.com/klauspost/compress@v1.20.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/github.com/klauspost/compress@v1.20.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/klauspost/compress@v1.20.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/klauspost/compress v1.20.0
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
package main
import (
"bytes"
"fmt"
"io"
"log"
"github.com/klauspost/compress/s2"
)
func main() {
original := []byte("Hello, CodeSampleX with klauspost/compress s2!")
var buf bytes.Buffer
writer := s2.NewWriter(&buf)
if _, err := writer.Write(original); err != nil {
log.Fatalf("failed to write compressed data: %v", err)
}
if err := writer.Close(); err != nil {
log.Fatalf("failed to close s2 writer: %v", err)
}
reader := s2.NewReader(&buf)
decompressed, err := io.ReadAll(reader)
if err != nil {
log.Fatalf("failed to read decompressed data: %v", err)
}
fmt.Printf("Original: %s\n", string(original))
fmt.Printf("Decompressed: %s\n", string(decompressed))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/klauspost/compress@v1.20.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/klauspost/compress@v1.20.0"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"github.com/klauspost/compress/s2"
)
func main() {
// 1. s2.NewWriter compresses data stream and s2.NewReader decompresses to restore exact original payload
{
original := []byte("CodeSampleX verification payload for github.com/klauspost/compress/s2 streaming compression.")
var buf bytes.Buffer
sw := s2.NewWriter(&buf)
if _, err := sw.Write(original); err != nil {
fmt.Fprintf(os.Stderr, "s2.NewWriter Write failed: %v\n", err)
os.Exit(1)
}
if err := sw.Close(); err != nil {
fmt.Fprintf(os.Stderr, "s2.NewWriter Close failed: %v\n", err)
os.Exit(1)
}
sr := s2.NewReader(&buf)
decompressed, err := io.ReadAll(sr)
if err != nil {
fmt.Fprintf(os.Stderr, "s2.NewReader ReadAll failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(original, decompressed) {
fmt.Fprintf(os.Stderr, "decompressed mismatch: got %q, want %q\n", string(decompressed), string(original))
os.Exit(1)
}
}
// 2. s2.NewWriter with WriterBetterCompression compresses data stream
{
sampleData := bytes.Repeat([]byte("High repetition pattern for testing klauspost s2 compression options. "), 40)
var b bytes.Buffer
sw := s2.NewWriter(&b, s2.WriterBetterCompression(), s2.WriterBlockSize(64*1024))
if _, err := sw.Write(sampleData); err != nil {
fmt.Fprintf(os.Stderr, "s2 write with options failed: %v\n", err)
os.Exit(1)
}
if err := sw.Close(); err != nil {
fmt.Fprintf(os.Stderr, "s2 close failed: %v\n", err)
os.Exit(1)
}
sr := s2.NewReader(&b)
decomp, err := io.ReadAll(sr)
if err != nil {
fmt.Fprintf(os.Stderr, "s2 read failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(sampleData, decomp) {
fmt.Fprintf(os.Stderr, "options roundtrip mismatch\n")
os.Exit(1)
}
}
// 3. s2.NewWriter and s2.NewReader correctly roundtrip empty input payload
{
var emptyBuf bytes.Buffer
swEmpty := s2.NewWriter(&emptyBuf)
if err := swEmpty.Close(); err != nil {
fmt.Fprintf(os.Stderr, "s2 empty write close failed: %v\n", err)
os.Exit(1)
}
srEmpty := s2.NewReader(&emptyBuf)
emptyDecomp, err := io.ReadAll(srEmpty)
if err != nil {
fmt.Fprintf(os.Stderr, "s2 empty read failed: %v\n", err)
os.Exit(1)
}
if len(emptyDecomp) != 0 {
fmt.Fprintf(os.Stderr, "expected empty decompressed payload, got %d bytes\n", len(emptyDecomp))
os.Exit(1)
}
}
// 4. s2.NewReader returns error when reading invalid or corrupted s2 stream
{
corrupted := []byte{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc}
srBad := s2.NewReader(bytes.NewReader(corrupted))
_, readErr := io.ReadAll(srBad)
if readErr == nil {
fmt.Fprintf(os.Stderr, "expected error reading corrupted s2 stream, got nil\n")
os.Exit(1)
}
}
// 5. s2.NewWriter and s2.NewReader support stream reuse via Reset
{
var buf1 bytes.Buffer
swReuse := s2.NewWriter(&buf1)
p1 := []byte("first stream payload for reusable s2 writer")
if _, err := swReuse.Write(p1); err != nil {
fmt.Fprintf(os.Stderr, "p1 write failed: %v\n", err)
os.Exit(1)
}
if err := swReuse.Close(); err != nil {
fmt.Fprintf(os.Stderr, "p1 close failed: %v\n", err)
os.Exit(1)
}
var buf2 bytes.Buffer
swReuse.Reset(&buf2)
p2 := []byte("second stream payload after s2 writer reset")
if _, err := swReuse.Write(p2); err != nil {
fmt.Fprintf(os.Stderr, "p2 write failed: %v\n", err)
os.Exit(1)
}
if err := swReuse.Close(); err != nil {
fmt.Fprintf(os.Stderr, "p2 close failed: %v\n", err)
os.Exit(1)
}
srReuse := s2.NewReader(&buf1)
res1, err := io.ReadAll(srReuse)
if err != nil || !bytes.Equal(res1, p1) {
fmt.Fprintf(os.Stderr, "p1 mismatch: %v\n", err)
os.Exit(1)
}
srReuse.Reset(&buf2)
res2, err := io.ReadAll(srReuse)
if err != nil || !bytes.Equal(res2, p2) {
fmt.Fprintf(os.Stderr, "p2 mismatch: %v\n", err)
os.Exit(1)
}
}
// 6. s2.Encode compresses byte slice and s2.Decode decompresses to restore exact original payload
{
payload := []byte("Block-level s2 encoding and decoding contract test payload.")
encoded := s2.Encode(nil, payload)
if len(encoded) == 0 {
fmt.Fprintf(os.Stderr, "s2.Encode returned empty slice\n")
os.Exit(1)
}
decoded, err := s2.Decode(nil, encoded)
if err != nil {
fmt.Fprintf(os.Stderr, "s2.Decode failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(payload, decoded) {
fmt.Fprintf(os.Stderr, "s2 block decode mismatch: got %q, want %q\n", string(decoded), string(payload))
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous