Exemplo
golang.org/x/sys v0.18.0
Amostra verificada para golang golang.org/x/sys v0.18.0. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou: unix.Getpagesize returns a…
sha256:f1a2f783da16120ec642c2140cd47bf0e4a7e66910dd62f9231a556a96047d99
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
Caso
HOW- Objetivo
- verify pkg:golang/golang.org/x/sys@v0.18.0
- Pacotes
- Criado
- 2026-08-27T12:13:02Z
Contrato
- unix.Getpagesize returns a positive system memory page size in bytes
- unix.Pipe creates a unidirectional pipe returning valid non-negative file descriptors for read and write
- unix.Write writes bytes to a pipe descriptor and unix.Read reads the matching bytes back
- unix.Getpid returns the caller process ID matching os.Getpid
- unix.NsecToTimeval converts nanoseconds to Timeval and unix.TimevalToNsec accurately converts back
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
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.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/sys@v0.18.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:f6275f362c3de54fcd98626ca29d43f26f6881ad8dd700b373e1dd9b2477e902","contract":["unix.Getpagesize returns a positive system memory page size in bytes","unix.Pipe creates a unidirectional pipe returning valid non-negative file descriptors for read and write","unix.Write writes bytes to a pipe descriptor and unix.Read reads the matching bytes back","unix.Getpid returns the caller process ID matching os.Getpid","unix.NsecToTimeval converts nanoseconds to Timeval and unix.TimevalToNsec accurately converts back"],"goal":"verify pkg:golang/golang.org/x/sys@v0.18.0","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.18.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/sys@v0.18.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.18.0","verifierAdapter":"golang@1"}
module example.com/sample
go 1.22.0
require golang.org/x/sys v0.18.0
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
package main
import (
"fmt"
"os"
"golang.org/x/sys/unix"
)
// GetPageSize returns the memory page size in bytes.
func GetPageSize() int {
return unix.Getpagesize()
}
// CreatePipe creates a pipe and returns the read and write file descriptors.
func CreatePipe() ([2]int, error) {
var fds [2]int
if err := unix.Pipe(fds[:]); err != nil {
return fds, fmt.Errorf("pipe failed: %w", err)
}
return fds, nil
}
// PipeEcho writes a message to the pipe and reads it back.
func PipeEcho(msg []byte) ([]byte, error) {
fds, err := CreatePipe()
if err != nil {
return nil, err
}
defer unix.Close(fds[0])
defer unix.Close(fds[1])
if _, err := unix.Write(fds[1], msg); err != nil {
return nil, fmt.Errorf("write failed: %w", err)
}
buf := make([]byte, len(msg))
n, err := unix.Read(fds[0], buf)
if err != nil {
return nil, fmt.Errorf("read failed: %w", err)
}
return buf[:n], nil
}
// ConvertTimevalRoundTrip converts nanoseconds to Timeval and back.
func ConvertTimevalRoundTrip(nsec int64) (unix.Timeval, int64) {
tv := unix.NsecToTimeval(nsec)
recovered := unix.TimevalToNsec(tv)
return tv, recovered
}
func main() {
pageSize := GetPageSize()
fmt.Printf("Memory page size: %d bytes\n", pageSize)
pid := unix.Getpid()
fmt.Printf("Current PID: %d\n", pid)
data := []byte("hello from unix pipe")
echoed, err := PipeEcho(data)
if err != nil {
fmt.Fprintf(os.Stderr, "Error in PipeEcho: %v\n", err)
os.Exit(1)
}
fmt.Printf("Echoed data: %s\n", string(echoed))
tv, rec := ConvertTimevalRoundTrip(1_234_567_000)
fmt.Printf("Timeval: %d sec, %d usec -> Recovered: %d nsec\n", tv.Sec, tv.Usec, rec)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/sys@v0.18.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/sys@v0.18.0"
]
}
package main
import (
"bytes"
"fmt"
"os"
"golang.org/x/sys/unix"
)
func main() {
// Assertion 1: unix.Getpagesize returns a positive system memory page size in bytes
pageSize := unix.Getpagesize()
if pageSize <= 0 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Getpagesize returned non-positive size: %d\n", pageSize)
os.Exit(1)
}
if pageSize%512 != 0 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Getpagesize unexpected non-multiple of 512: %d\n", pageSize)
os.Exit(1)
}
// Assertion 2: unix.Pipe creates a unidirectional pipe returning valid non-negative file descriptors for read and write
var fds [2]int
if err := unix.Pipe(fds[:]); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Pipe failed: %v\n", err)
os.Exit(1)
}
defer unix.Close(fds[0])
defer unix.Close(fds[1])
if fds[0] < 0 || fds[1] < 0 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Pipe returned negative file descriptors: [%d, %d]\n", fds[0], fds[1])
os.Exit(1)
}
// Assertion 3: unix.Write writes bytes to a pipe descriptor and unix.Read reads the matching bytes back
payload := []byte("csx-sys-contract-verification-payload")
nWritten, err := unix.Write(fds[1], payload)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Write failed: %v\n", err)
os.Exit(1)
}
if nWritten != len(payload) {
fmt.Fprintf(os.Stderr, "FAIL: unix.Write short write: wrote %d, want %d\n", nWritten, len(payload))
os.Exit(1)
}
readBuf := make([]byte, len(payload))
nRead, err := unix.Read(fds[0], readBuf)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Read failed: %v\n", err)
os.Exit(1)
}
if nRead != len(payload) {
fmt.Fprintf(os.Stderr, "FAIL: unix.Read short read: read %d, want %d\n", nRead, len(payload))
os.Exit(1)
}
if !bytes.Equal(readBuf, payload) {
fmt.Fprintf(os.Stderr, "FAIL: read data does not match payload: got %q, want %q\n", readBuf, payload)
os.Exit(1)
}
// Assertion 4: unix.Getpid returns the caller process ID matching os.Getpid
pid := unix.Getpid()
if pid <= 0 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Getpid returned non-positive PID: %d\n", pid)
os.Exit(1)
}
if pid != os.Getpid() {
fmt.Fprintf(os.Stderr, "FAIL: unix.Getpid mismatch: got %d, want %d\n", pid, os.Getpid())
os.Exit(1)
}
// Assertion 5: unix.NsecToTimeval converts nanoseconds to Timeval and unix.TimevalToNsec accurately converts back
const testNsec = int64(3_500_000_000)
tv := unix.NsecToTimeval(testNsec)
if tv.Sec != 3 || tv.Usec != 500_000 {
fmt.Fprintf(os.Stderr, "FAIL: unix.NsecToTimeval mismatch: sec=%d, usec=%d (expected sec=3, usec=500000)\n", tv.Sec, tv.Usec)
os.Exit(1)
}
recoveredNsec := unix.TimevalToNsec(tv)
if recoveredNsec != testNsec {
fmt.Fprintf(os.Stderr, "FAIL: unix.TimevalToNsec mismatch: got %d, want %d\n", recoveredNsec, testNsec)
os.Exit(1)
}
fmt.Println("PASS: pkg:golang/golang.org/x/sys@v0.18.0 contract passed")
}
Seeder de origem
anônimo