Sample
golang.org/x/text v0.42.0
Verified sample for golang golang.org/x/text v0.42.0. The contract ran on go 1.26 · linux debian/x64 · docker and passed: bidi.Paragraph.SetString and…
sha256:471569fc0b7983e8cecdb6b9f46c0ca590a7995dbec8ce83bfa8985792e47a2d
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-15 |
Case
HOW- Goal
- verify pkg:golang/golang.org/x/text@v0.42.0
- Packages
- Created
- 2026-09-15T06:51:11Z
Contract
- bidi.Paragraph.SetString and Paragraph.Order determine directional ordering and runs for bidirectional text
- bidirule.ValidString and bidirule.Direction enforce RFC 5893 Bidi Rule constraints on string labels
- runenames.Name resolves official Unicode character names for individual runes
- ianaindex.IANA and ianaindex.MIME resolve character encodings and standardized MIME names
- japanese.ShiftJIS and korean.EUCKR encode and decode legacy CJK text with transform
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/golang.org/x/text@v0.42.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/text@v0.42.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:126ccb9254149227b8d89a670cd3f324f0e5362250daaba0b529de1519e4a4f5","contract":["bidi.Paragraph.SetString and Paragraph.Order determine directional ordering and runs for bidirectional text","bidirule.ValidString and bidirule.Direction enforce RFC 5893 Bidi Rule constraints on string labels","runenames.Name resolves official Unicode character names for individual runes","ianaindex.IANA and ianaindex.MIME resolve character encodings and standardized MIME names","japanese.ShiftJIS and korean.EUCKR encode and decode legacy CJK text with transform"],"goal":"verify pkg:golang/golang.org/x/text@v0.42.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.42.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/golang.org/x/text@v0.42.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.42.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/text v0.42.0
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
package main
import (
"fmt"
"os"
"golang.org/x/text/encoding"
"golang.org/x/text/encoding/ianaindex"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/encoding/korean"
"golang.org/x/text/secure/bidirule"
"golang.org/x/text/unicode/bidi"
"golang.org/x/text/unicode/runenames"
)
// AnalyzeBidiText parses text and reports its primary direction and visual runs count.
func AnalyzeBidiText(text string) (bidi.Direction, int, error) {
var p bidi.Paragraph
_, err := p.SetString(text)
if err != nil {
return bidi.LeftToRight, 0, err
}
order, err := p.Order()
if err != nil {
return bidi.LeftToRight, 0, err
}
return order.Direction(), order.NumRuns(), nil
}
// ValidateBidiIdentifier checks whether a string conforms to RFC 5893 Bidi rules.
func ValidateBidiIdentifier(label string) (bool, bidi.Direction) {
isValid := bidirule.ValidString(label)
dir := bidirule.Direction([]byte(label))
return isValid, dir
}
// LookupCharacterName returns the official Unicode name of a rune.
func LookupCharacterName(r rune) string {
return runenames.Name(r)
}
// LookupEncodingByName finds an encoding by standard IANA or MIME identifier.
func LookupEncodingByName(name string) (encoding.Encoding, string, error) {
enc, err := ianaindex.IANA.Encoding(name)
if err != nil {
return nil, "", err
}
ianaName, err := ianaindex.IANA.Name(enc)
if err != nil {
return enc, "", err
}
return enc, ianaName, nil
}
// EncodeAndDecodeShiftJIS encodes UTF-8 text to Shift_JIS and decodes it back.
func EncodeAndDecodeShiftJIS(input string) (string, error) {
enc := japanese.ShiftJIS.NewEncoder()
encoded, err := enc.Bytes([]byte(input))
if err != nil {
return "", err
}
dec := japanese.ShiftJIS.NewDecoder()
decoded, err := dec.Bytes(encoded)
if err != nil {
return "", err
}
return string(decoded), nil
}
// EncodeAndDecodeEUCKR encodes UTF-8 text to EUC-KR and decodes it back.
func EncodeAndDecodeEUCKR(input string) (string, error) {
enc := korean.EUCKR.NewEncoder()
encoded, err := enc.Bytes([]byte(input))
if err != nil {
return "", err
}
dec := korean.EUCKR.NewDecoder()
decoded, err := dec.Bytes(encoded)
if err != nil {
return "", err
}
return string(decoded), nil
}
func main() {
// 1. Bidirectional text analysis
dir, runs, err := AnalyzeBidiText("Hello World!")
if err != nil {
fmt.Fprintf(os.Stderr, "Bidi analysis error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Bidi direction: %v (LTR), runs: %d\n", dir == bidi.LeftToRight, runs)
// 2. Bidi rule validation
valid, bidiDir := ValidateBidiIdentifier("hello")
fmt.Printf("Label 'hello' valid: %t, direction: %v\n", valid, bidiDir)
// 3. Unicode character name lookup
fmt.Printf("Rune '©' name: %s\n", LookupCharacterName('©'))
fmt.Printf("Rune '€' name: %s\n", LookupCharacterName('€'))
// 4. IANA encoding lookup
enc, ianaName, err := LookupEncodingByName("Shift_JIS")
if err != nil {
fmt.Fprintf(os.Stderr, "IANA lookup error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Resolved encoding %v to IANA name %s\n", enc != nil, ianaName)
// 5. CJK Encoding / Decoding
sjisText, err := EncodeAndDecodeShiftJIS("こんにちは")
if err != nil {
fmt.Fprintf(os.Stderr, "Shift_JIS error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Shift_JIS roundtrip: %s\n", sjisText)
euckrText, err := EncodeAndDecodeEUCKR("안녕하세요")
if err != nil {
fmt.Fprintf(os.Stderr, "EUC-KR error: %v\n", err)
os.Exit(1)
}
fmt.Printf("EUC-KR roundtrip: %s\n", euckrText)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/text@v0.42.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.42.0"
]
}
package main
import (
"fmt"
"os"
"golang.org/x/text/encoding/ianaindex"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/encoding/korean"
"golang.org/x/text/secure/bidirule"
"golang.org/x/text/unicode/bidi"
"golang.org/x/text/unicode/runenames"
)
func main() {
// Assertion 1: bidi.Paragraph.SetString and Paragraph.Order determine directional ordering and runs for bidirectional text
var pLTR bidi.Paragraph
_, err := pLTR.SetString("English Text Example")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: pLTR.SetString error: %v\n", err)
os.Exit(1)
}
orderLTR, err := pLTR.Order()
if err != nil || orderLTR.Direction() != bidi.LeftToRight || orderLTR.NumRuns() < 1 {
fmt.Fprintf(os.Stderr, "FAIL: orderLTR mismatch: err=%v, dir=%v, runs=%d\n", err, orderLTR.Direction(), orderLTR.NumRuns())
os.Exit(1)
}
var pRTL bidi.Paragraph
_, err = pRTL.SetString("مرحبا بالعالم")
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: pRTL.SetString error: %v\n", err)
os.Exit(1)
}
orderRTL, err := pRTL.Order()
if err != nil || orderRTL.Direction() != bidi.RightToLeft || orderRTL.NumRuns() < 1 {
fmt.Fprintf(os.Stderr, "FAIL: orderRTL mismatch: err=%v, dir=%v, runs=%d\n", err, orderRTL.Direction(), orderRTL.NumRuns())
os.Exit(1)
}
// Assertion 2: bidirule.ValidString and bidirule.Direction enforce RFC 5893 Bidi Rule constraints on string labels
if !bidirule.ValidString("example") {
fmt.Fprintf(os.Stderr, "FAIL: bidirule.ValidString('example') returned false\n")
os.Exit(1)
}
if !bidirule.ValidString("العربية") {
fmt.Fprintf(os.Stderr, "FAIL: bidirule.ValidString('العربية') returned false\n")
os.Exit(1)
}
if bidirule.ValidString("example العربية") {
fmt.Fprintf(os.Stderr, "FAIL: bidirule.ValidString('example العربية') returned true for mixed invalid label\n")
os.Exit(1)
}
if bidirule.Direction([]byte("example")) != bidi.LeftToRight {
fmt.Fprintf(os.Stderr, "FAIL: bidirule.Direction for LTR mismatch\n")
os.Exit(1)
}
if bidirule.Direction([]byte("العربية")) != bidi.RightToLeft {
fmt.Fprintf(os.Stderr, "FAIL: bidirule.Direction for RTL mismatch\n")
os.Exit(1)
}
// Assertion 3: runenames.Name resolves official Unicode character names for individual runes
if name := runenames.Name('A'); name != "LATIN CAPITAL LETTER A" {
fmt.Fprintf(os.Stderr, "FAIL: runenames.Name('A') mismatch: got %q\n", name)
os.Exit(1)
}
if name := runenames.Name('©'); name != "COPYRIGHT SIGN" {
fmt.Fprintf(os.Stderr, "FAIL: runenames.Name('©') mismatch: got %q\n", name)
os.Exit(1)
}
if name := runenames.Name('€'); name != "EURO SIGN" {
fmt.Fprintf(os.Stderr, "FAIL: runenames.Name('€') mismatch: got %q\n", name)
os.Exit(1)
}
// Assertion 4: ianaindex.IANA and ianaindex.MIME resolve character encodings and standardized MIME names
sjisEnc, err := ianaindex.IANA.Encoding("Shift_JIS")
if err != nil || sjisEnc == nil {
fmt.Fprintf(os.Stderr, "FAIL: ianaindex.IANA.Encoding('Shift_JIS') failed: %v\n", err)
os.Exit(1)
}
sjisName, err := ianaindex.IANA.Name(sjisEnc)
if err != nil || sjisName != "Shift_JIS" {
fmt.Fprintf(os.Stderr, "FAIL: ianaindex.IANA.Name mismatch: %v, got %q\n", err, sjisName)
os.Exit(1)
}
euckrEnc, err := ianaindex.MIME.Encoding("euc-kr")
if err != nil || euckrEnc == nil {
fmt.Fprintf(os.Stderr, "FAIL: ianaindex.MIME.Encoding('euc-kr') failed: %v\n", err)
os.Exit(1)
}
euckrMimeName, err := ianaindex.MIME.Name(euckrEnc)
if err != nil || euckrMimeName != "EUC-KR" {
fmt.Fprintf(os.Stderr, "FAIL: ianaindex.MIME.Name mismatch: %v, got %q\n", err, euckrMimeName)
os.Exit(1)
}
// Assertion 5: japanese.ShiftJIS and korean.EUCKR encode and decode legacy CJK text with transform
sjisBytes, err := japanese.ShiftJIS.NewEncoder().Bytes([]byte("日本語テキスト"))
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: ShiftJIS encoding failed: %v\n", err)
os.Exit(1)
}
sjisDecoded, err := japanese.ShiftJIS.NewDecoder().Bytes(sjisBytes)
if err != nil || string(sjisDecoded) != "日本語テキスト" {
fmt.Fprintf(os.Stderr, "FAIL: ShiftJIS decoding failed: %v, got %q\n", err, string(sjisDecoded))
os.Exit(1)
}
euckrBytes, err := korean.EUCKR.NewEncoder().Bytes([]byte("한국어텍스트"))
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: EUCKR encoding failed: %v\n", err)
os.Exit(1)
}
euckrDecoded, err := korean.EUCKR.NewDecoder().Bytes(euckrBytes)
if err != nil || string(euckrDecoded) != "한국어텍스트" {
fmt.Fprintf(os.Stderr, "FAIL: EUCKR decoding failed: %v, got %q\n", err, string(euckrDecoded))
os.Exit(1)
}
fmt.Println("PASS: pkg:golang/golang.org/x/text@v0.42.0 contract verified")
}
Origin Seeder
anonymous