Sample
modernc.org/strutil v1.2.1
Verified sample for golang modernc.org/strutil v1.2.1. The contract ran on go 1.26 · linux debian/x64 · docker and passed: strutil.NewDict assigns 0 to empty…
sha256:0d1932006a15c755e42618b8c4b4b4de629ec39fa8c4f33afcdde17b1257b059
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
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
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-16 |
Case
HOW- Goal
- verify pkg:golang/modernc.org/strutil@v1.2.1
- Packages
- Environment
- go 1.26.6
- Created
- 2026-09-16T02:17:53Z
Contract
- strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings
- strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs
- strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice
- strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss
- strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count
- strutil.StrPack returns an identical string value packed in memory
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/modernc.org/strutil@v1.2.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/modernc.org/strutil@v1.2.1
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:212fe6d10b91dcecef00a9d02409884565179604ec3e6e2758f23384261ba810","contract":["strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings","strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs","strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice","strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss","strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count","strutil.StrPack returns an identical string value packed in memory"],"goal":"verify pkg:golang/modernc.org/strutil@v1.2.1","kind":"HOW","packages":["pkg:golang/modernc.org/strutil@v1.2.1"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/modernc.org/strutil@v1.2.1"],"schemaVersion":1,"subject":"pkg:golang/modernc.org/strutil@v1.2.1","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require modernc.org/strutil v1.2.1
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
package main
import (
"fmt"
"modernc.org/strutil"
)
func main() {
// Dict demonstration: string <-> id bijection
dict := strutil.NewDict()
id1 := dict.Id("alpha")
id2 := dict.Id("beta")
s1, _ := dict.S(id1)
s2, _ := dict.S(id2)
fmt.Printf("Dict entries: %d -> %s, %d -> %s (count: %d)\n", id1, s1, id2, s2, dict.Count())
// JoinFields and SplitFields demonstration
parts := []string{"foo", "bar:baz", "qux"}
joined := strutil.JoinFields(parts, ":")
split := strutil.SplitFields(joined, ":")
fmt.Printf("Joined: %s, Split count: %d\n", joined, len(split))
// Base64Encode and Base64Decode demonstration
raw := []byte("CodeSampleX verification")
encoded := strutil.Base64Encode(raw)
decoded, err := strutil.Base64Decode(encoded)
if err != nil {
panic(err)
}
fmt.Printf("Base64: %s -> %s\n", string(encoded), string(decoded))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/modernc.org/strutil@v1.2.1",
"kind": "HOW",
"packages": [
"pkg:golang/modernc.org/strutil@v1.2.1"
]
}
package main
import (
"bytes"
"fmt"
"os"
"reflect"
"modernc.org/strutil"
)
func main() {
// Assertion 1: strutil.NewDict assigns 0 to empty string and positive unique IDs to distinct non-empty strings
dict := strutil.NewDict()
if dict == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: NewDict returned nil\n")
os.Exit(1)
}
idEmpty := dict.Id("")
if idEmpty != 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"\") = %d, expected 0\n", idEmpty)
os.Exit(1)
}
idAlpha := dict.Id("alpha")
if idAlpha <= 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"alpha\") = %d, expected positive integer\n", idAlpha)
os.Exit(1)
}
idBeta := dict.Id("beta")
if idBeta <= 0 || idBeta == idAlpha {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"beta\") = %d, expected positive integer distinct from %d\n", idBeta, idAlpha)
os.Exit(1)
}
if idAlpha2 := dict.Id("alpha"); idAlpha2 != idAlpha {
fmt.Fprintf(os.Stderr, "FAIL assertion 1: dict.Id(\"alpha\") second call = %d, expected %d\n", idAlpha2, idAlpha)
os.Exit(1)
}
// Assertion 2: strutil.Dict.S retrieves the original string by its ID and returns true for valid IDs or false for invalid IDs
sEmpty, okEmpty := dict.S(idEmpty)
if !okEmpty || sEmpty != "" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"\", true)\n", idEmpty, sEmpty, okEmpty)
os.Exit(1)
}
sAlpha, okAlpha := dict.S(idAlpha)
if !okAlpha || sAlpha != "alpha" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"alpha\", true)\n", idAlpha, sAlpha, okAlpha)
os.Exit(1)
}
sBeta, okBeta := dict.S(idBeta)
if !okBeta || sBeta != "beta" {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(%d) = (%q, %v), expected (\"beta\", true)\n", idBeta, sBeta, okBeta)
os.Exit(1)
}
_, okInvalid := dict.S(999999)
if okInvalid {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.S(999999) returned ok=true for nonexistent id\n")
os.Exit(1)
}
if cnt := dict.Count(); cnt != 3 {
fmt.Fprintf(os.Stderr, "FAIL assertion 2: dict.Count() = %d, expected 3\n", cnt)
os.Exit(1)
}
// Assertion 3: strutil.JoinFields joins string slices with delimiter escaping and SplitFields accurately reconstructs the original slice
origFields := []string{"apple", "banana:split", "cherry\\pie", "date", ""}
joined := strutil.JoinFields(origFields, ":")
if len(joined) == 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 3: JoinFields returned empty string\n")
os.Exit(1)
}
reconstructed := strutil.SplitFields(joined, ":")
if !reflect.DeepEqual(origFields, reconstructed) {
fmt.Fprintf(os.Stderr, "FAIL assertion 3: SplitFields mismatch: got %v, expected %v\n", reconstructed, origFields)
os.Exit(1)
}
// Assertion 4: strutil.Base64Encode and strutil.Base64Decode roundtrip arbitrary byte sequences without data loss
rawPayload := []byte("Testing modernc.org/strutil base64 roundtrip 0123456789!@#$%^&*()_+")
encoded := strutil.Base64Encode(rawPayload)
if len(encoded) == 0 {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64Encode returned empty slice\n")
os.Exit(1)
}
decoded, err := strutil.Base64Decode(encoded)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64Decode failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(rawPayload, decoded) {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: Base64 roundtrip mismatch: got %q, expected %q\n", decoded, rawPayload)
os.Exit(1)
}
_, errInvalidB64 := strutil.Base64Decode([]byte("@@invalid_base64@@"))
if errInvalidB64 == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 4: expected Base64Decode to return error for invalid data\n")
os.Exit(1)
}
// Assertion 5: strutil.NewPool deduplicates identical strings to return the existing instance and tracks pool count
pool := strutil.NewPool()
if pool == nil {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: NewPool returned nil\n")
os.Exit(1)
}
str1 := pool.Align("pool_sample_string")
str2 := pool.Align("pool_sample_string")
if str1 != "pool_sample_string" || str2 != "pool_sample_string" {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Align returned unexpected value\n")
os.Exit(1)
}
if pool.Count() != 1 {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Count() = %d, expected 1\n", pool.Count())
os.Exit(1)
}
pool.Align("different_sample_string")
if pool.Count() != 2 {
fmt.Fprintf(os.Stderr, "FAIL assertion 5: pool.Count() = %d, expected 2\n", pool.Count())
os.Exit(1)
}
// Assertion 6: strutil.StrPack returns an identical string value packed in memory
originalStr := "packed_string_test"
packedStr := strutil.StrPack(originalStr)
if packedStr != originalStr {
fmt.Fprintf(os.Stderr, "FAIL assertion 6: StrPack mismatch: got %q, expected %q\n", packedStr, originalStr)
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed")
}
Origin Seeder
anonymous