CodeSampleX

Exemplo

golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8

Amostra verificada para golang golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:dd3840d7a1d9f3fea8ad7c71aa8533dd73ba35bcc24210b8ea9e0684bb50c2d9

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-10-10

Caso

HOW
Objetivo
verify pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8
Pacotes
Criado
2026-10-10T05:54:25Z

Contrato

  1. unix.Getpid returns a positive process identifier
  2. unix.Getpagesize returns a valid page size of at least 4096 bytes
  3. unix.Uname populates Utsname with non-empty system metadata
  4. unix.ByteSliceToString properly decodes null-terminated byte slices
  5. unix.EINVAL matches errno 22 and is recognized by errors.Is

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/sys@v0.0.0-20220715151400-c0bba94af5f8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8

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:5214fdad7c7b3c70c8c0f3e9d7d8bb1bf0914ce21cd25acad84e6d2551a0a87e","contract":["unix.Getpid returns a positive process identifier","unix.Getpagesize returns a valid page size of at least 4096 bytes","unix.Uname populates Utsname with non-empty system metadata","unix.ByteSliceToString properly decodes null-terminated byte slices","unix.EINVAL matches errno 22 and is recognized by errors.Is"],"goal":"verify pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8"],"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/sys@v0.0.0-20220715151400-c0bba94af5f8"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
go.sum
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
main.go
package main

import (
	"fmt"

	"golang.org/x/sys/unix"
)

func main() {
	pid := unix.Getpid()
	pageSize := unix.Getpagesize()
	fmt.Printf("Process ID: %d, Page size: %d\n", pid, pageSize)

	var uname unix.Utsname
	if err := unix.Uname(&uname); err == nil {
		sysname := unix.ByteSliceToString(uname.Sysname[:])
		fmt.Printf("System: %s\n", sysname)
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/sys@v0.0.0-20220715151400-c0bba94af5f8"
  ]
}
test/contract.go
package main

import (
	"errors"
	"fmt"
	"os"

	"golang.org/x/sys/unix"
)

func main() {
	// Assertion 1: unix.Getpid returns a positive process identifier
	pid := unix.Getpid()
	if pid <= 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected unix.Getpid() > 0, got %d\n", pid)
		os.Exit(1)
	}

	// Assertion 2: unix.Getpagesize returns a valid page size of at least 4096 bytes
	pageSize := unix.Getpagesize()
	if pageSize < 4096 {
		fmt.Fprintf(os.Stderr, "FAIL: expected unix.Getpagesize() >= 4096, got %d\n", pageSize)
		os.Exit(1)
	}

	// Assertion 3: unix.Uname populates Utsname with non-empty system metadata
	var uname unix.Utsname
	if err := unix.Uname(&uname); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Uname failed: %v\n", err)
		os.Exit(1)
	}
	sysname := unix.ByteSliceToString(uname.Sysname[:])
	if len(sysname) == 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected non-empty Sysname from unix.Uname\n")
		os.Exit(1)
	}

	// Assertion 4: unix.ByteSliceToString properly decodes null-terminated byte slices
	testSlice := []byte{'h', 'e', 'l', 'l', 'o', 0, 'w', 'o', 'r', 'l', 'd'}
	if got := unix.ByteSliceToString(testSlice); got != "hello" {
		fmt.Fprintf(os.Stderr, "FAIL: expected ByteSliceToString to return 'hello', got %q\n", got)
		os.Exit(1)
	}

	// Assertion 5: unix.EINVAL matches errno 22 and is recognized by errors.Is
	if int(unix.EINVAL) != 22 {
		fmt.Fprintf(os.Stderr, "FAIL: expected unix.EINVAL == 22, got %d\n", int(unix.EINVAL))
		os.Exit(1)
	}
	err := unix.Nanosleep(&unix.Timespec{Sec: 0, Nsec: -1}, nil)
	if !errors.Is(err, unix.EINVAL) {
		fmt.Fprintf(os.Stderr, "FAIL: expected errors.Is(err, unix.EINVAL) to be true, got %v\n", err)
		os.Exit(1)
	}

	fmt.Println("PASS: golang.org/x/sys contract verified successfully")
}

Seeder de origem

anônimo