Exemple
golang.org/x/text v0.13.0
Échantillon vérifié pour golang golang.org/x/text v0.13.0. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a réussi.
sha256:4c6e7c170e412ce2b297ecf7591dd2589f899ad89a36d79df414153e9303ef84
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-19 |
Cas
HOW- Objectif
- verify pkg:golang/golang.org/x/text@v0.13.0
- Paquets
- Créé
- 2026-09-18T10:37:28Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code 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.13.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/text@v0.13.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:e5301cfaddf304fdec70063e0eadbe145755be089a23aa082a9208acb4b920e6","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.13.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.13.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.13.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.13.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/text v0.13.0
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
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.13.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/text@v0.13.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.13.0 contract verified")
}
Seeder d'origine
anonyme