CodeSampleX

Ejemplo

golang.org/x/text v0.24.0

Muestra verificada para golang golang.org/x/text v0.24.0. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.

sha256:1e8a7f8f93e2ef6a98c2ed45dfb3e06a85a76671a6684183c9cc1b8b49a0de4c

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
1
Claves de firma que lo compilaron
1
Entorno declarado go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:golang/golang.org/x/text@v0.24.0
Paquetes
Entorno
go 1.26.6
Creado
2026-09-18T13:53:05Z

Contrato

  1. language.Parse and language.NewMatcher match requested BCP 47 language tags against supported preferences
  2. cases.Title, cases.Upper and cases.Lower apply language-aware case transformations
  3. norm.NFC, norm.NFD and norm.NFKD perform canonical and compatibility Unicode normalization
  4. width.Fold normalizes fullwidth characters to standard halfwidth ASCII forms
  5. bidirule.ValidString validates directional strings according to RFC 5893

Archivos

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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.24.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/text@v0.24.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.
csx.json
{"case":{"caseId":"case:sha256:1151d301c3e9cf06fc7ef152b74de5c21a0ad6b314a1881ed69c1a36ce6ae982","contract":["language.Parse and language.NewMatcher match requested BCP 47 language tags against supported preferences","cases.Title, cases.Upper and cases.Lower apply language-aware case transformations","norm.NFC, norm.NFD and norm.NFKD perform canonical and compatibility Unicode normalization","width.Fold normalizes fullwidth characters to standard halfwidth ASCII forms","bidirule.ValidString validates directional strings according to RFC 5893"],"goal":"verify pkg:golang/golang.org/x/text@v0.24.0","kind":"HOW","packages":["pkg:golang/golang.org/x/text@v0.24.0"],"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/golang.org/x/text@v0.24.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/text@v0.24.0","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/text v0.24.0
go.sum
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
main.go
package main

import (
	"fmt"

	"golang.org/x/text/cases"
	"golang.org/x/text/language"
	"golang.org/x/text/secure/bidirule"
	"golang.org/x/text/unicode/norm"
	"golang.org/x/text/width"
)

func main() {
	// 1. Language matching
	serverLangs := []language.Tag{language.English, language.German, language.French}
	matcher := language.NewMatcher(serverLangs)
	tag, index, conf := matcher.Match(language.BritishEnglish)
	fmt.Printf("Matched: %s at %d (%v)\n", tag, index, conf)

	// 2. Locale-sensitive casing
	fmt.Printf("Turkish upper: %s\n", cases.Upper(language.Turkish).String("istanbul"))

	// 3. Unicode normalization
	fmt.Printf("NFC: %s\n", norm.NFC.String("e\u0301"))

	// 4. Width folding
	fmt.Printf("Fold: %s\n", width.Fold.String("Hello 123!"))

	// 5. Bidi rule validation
	fmt.Printf("Bidi valid: %t\n", bidirule.ValidString("example"))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/text@v0.24.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/text@v0.24.0"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"golang.org/x/text/cases"
	"golang.org/x/text/language"
	"golang.org/x/text/secure/bidirule"
	"golang.org/x/text/unicode/norm"
	"golang.org/x/text/width"
)

func main() {
	// Assertion 1: language.Parse and language.NewMatcher match requested BCP 47 language tags against supported preferences
	supported := []language.Tag{language.English, language.German, language.French}
	matcher := language.NewMatcher(supported)

	parsedTag, err := language.Parse("de-AT")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Assertion 1 failed: language.Parse error: %v\n", err)
		os.Exit(1)
	}

	_, index, conf := matcher.Match(parsedTag)
	if supported[index] != language.German || index != 1 || conf < language.High {
		fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected German at index 1 with High+ conf, got %v at %d (%v)\n", supported[index], index, conf)
		os.Exit(1)
	}

	// Assertion 2: cases.Title, cases.Upper and cases.Lower apply language-aware case transformations
	trUpper := cases.Upper(language.Turkish).String("istanbul")
	enUpper := cases.Upper(language.English).String("istanbul")
	if trUpper != "İSTANBUL" || enUpper != "ISTANBUL" {
		fmt.Fprintf(os.Stderr, "Assertion 2 failed: Upper expected tr='İSTANBUL', en='ISTANBUL', got tr='%s', en='%s'\n", trUpper, enUpper)
		os.Exit(1)
	}

	trLower := cases.Lower(language.Turkish).String("ISTANBUL")
	enLower := cases.Lower(language.English).String("ISTANBUL")
	if trLower != "ıstanbul" || enLower != "istanbul" {
		fmt.Fprintf(os.Stderr, "Assertion 2 failed: Lower expected tr='ıstanbul', en='istanbul', got tr='%s', en='%s'\n", trLower, enLower)
		os.Exit(1)
	}

	trTitle := cases.Title(language.Turkish).String("istanbul")
	enTitle := cases.Title(language.English).String("istanbul")
	if trTitle != "İstanbul" || enTitle != "Istanbul" {
		fmt.Fprintf(os.Stderr, "Assertion 2 failed: Title expected tr='İstanbul', en='Istanbul', got tr='%s', en='%s'\n", trTitle, enTitle)
		os.Exit(1)
	}

	// Assertion 3: norm.NFC, norm.NFD and norm.NFKD perform canonical and compatibility Unicode normalization
	decomposed := "e\u0301" // e + combining acute accent
	composed := norm.NFC.String(decomposed)
	if composed != "é" || len(composed) != 2 {
		fmt.Fprintf(os.Stderr, "Assertion 3 failed: NFC expected 'é' (2 bytes), got '%s' (%d bytes)\n", composed, len(composed))
		os.Exit(1)
	}

	if norm.NFD.String("é") != decomposed {
		fmt.Fprintf(os.Stderr, "Assertion 3 failed: NFD did not match decomposed form\n")
		os.Exit(1)
	}

	if norm.NFKD.String("fi") != "fi" {
		fmt.Fprintf(os.Stderr, "Assertion 3 failed: NFKD ligature decomposition failed\n")
		os.Exit(1)
	}

	// Assertion 4: width.Fold normalizes fullwidth characters to standard halfwidth ASCII forms
	fullwidth := "Hello 123!"
	folded := width.Fold.String(fullwidth)
	if folded != "Hello 123!" {
		fmt.Fprintf(os.Stderr, "Assertion 4 failed: width.Fold expected 'Hello 123!', got '%s'\n", folded)
		os.Exit(1)
	}

	// Assertion 5: bidirule.ValidString validates directional strings according to RFC 5893
	if !bidirule.ValidString("example") {
		fmt.Fprintf(os.Stderr, "Assertion 5 failed: bidirule.ValidString('example') returned false\n")
		os.Exit(1)
	}
	if !bidirule.ValidString("العربية") {
		fmt.Fprintf(os.Stderr, "Assertion 5 failed: bidirule.ValidString('العربية') returned false\n")
		os.Exit(1)
	}
	if bidirule.ValidString("example العربية") {
		fmt.Fprintf(os.Stderr, "Assertion 5 failed: bidirule.ValidString('example العربية') returned true for mixed invalid label\n")
		os.Exit(1)
	}

	fmt.Println("Contract passed: all assertions verified successfully.")
}

Seeder de origen

anónimo