CodeSampleX

Sample

golang.org/x/sys v0.29.0

Verified sample for golang golang.org/x/sys v0.29.0. The contract ran on go 1.26 · linux alpine/x64 · docker and passed: unix.Pipe creates a unidirectional…

sha256:263a95cfe984f190159d6890a1db47b876dbe21f9b8c0c41ecd55cc5ab8f0648

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 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

Case

HOW
Goal
verify pkg:golang/golang.org/x/sys@v0.29.0
Packages
Created
2026-08-27T13:05:15Z

Contract

  1. unix.Pipe creates a unidirectional byte stream channel between two file descriptors
  2. unix.Pipe2 creates non-blocking file descriptor pairs with O_CLOEXEC and O_NONBLOCK flags
  3. unix.Sysinfo queries kernel system statistics with positive uptime and totalram
  4. unix.Dup duplicates an existing file descriptor to reference the same open file description

Files

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

Download the source artifact (tar.gz)

Source

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.29.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/sys@v0.29.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:98848ccae2935eeaf78d7922a11966f1653b15257920a8c9e1d9a50bc5140a7f","contract":["unix.Pipe creates a unidirectional byte stream channel between two file descriptors","unix.Pipe2 creates non-blocking file descriptor pairs with O_CLOEXEC and O_NONBLOCK flags","unix.Sysinfo queries kernel system statistics with positive uptime and totalram","unix.Dup duplicates an existing file descriptor to reference the same open file description"],"goal":"verify pkg:golang/golang.org/x/sys@v0.29.0","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.29.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.29.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.29.0","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/sys v0.29.0
go.sum
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
main.go
package main

import (
	"bytes"
	"fmt"
	"os"

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

// PipeData creates a unidirectional pipe and transfers data through it using unix.Pipe.
func PipeData(data []byte) ([]byte, error) {
	fds := make([]int, 2)
	if err := unix.Pipe(fds); err != nil {
		return nil, fmt.Errorf("unix.Pipe error: %w", err)
	}
	defer unix.Close(fds[0])
	defer unix.Close(fds[1])

	nw, err := unix.Write(fds[1], data)
	if err != nil {
		return nil, fmt.Errorf("unix.Write error: %w", err)
	}
	if nw != len(data) {
		return nil, fmt.Errorf("short write: wrote %d of %d bytes", nw, len(data))
	}

	buf := make([]byte, len(data))
	nr, err := unix.Read(fds[0], buf)
	if err != nil {
		return nil, fmt.Errorf("unix.Read error: %w", err)
	}
	if nr != len(data) {
		return nil, fmt.Errorf("short read: read %d of %d bytes", nr, len(data))
	}

	return buf, nil
}

// Pipe2NonBlocking creates a non-blocking pipe with O_CLOEXEC and O_NONBLOCK using unix.Pipe2.
func Pipe2NonBlocking() ([2]int, error) {
	var fds [2]int
	if err := unix.Pipe2(fds[:], unix.O_CLOEXEC|unix.O_NONBLOCK); err != nil {
		return fds, fmt.Errorf("unix.Pipe2 error: %w", err)
	}
	return fds, nil
}

// GetSystemInfo queries basic system metrics using unix.Sysinfo.
func GetSystemInfo() (*unix.Sysinfo_t, error) {
	var info unix.Sysinfo_t
	if err := unix.Sysinfo(&info); err != nil {
		return nil, fmt.Errorf("unix.Sysinfo error: %w", err)
	}
	return &info, nil
}

func main() {
	msg := []byte("hello from pipe")
	readMsg, err := PipeData(msg)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}
	if !bytes.Equal(readMsg, msg) {
		fmt.Fprintf(os.Stderr, "Mismatch: got %s\n", string(readMsg))
		os.Exit(1)
	}
	fmt.Printf("Pipe transfer successful: %s\n", string(readMsg))

	info, err := GetSystemInfo()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Sysinfo error: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("System uptime: %d seconds, Total RAM: %d bytes\n", info.Uptime, info.Totalram)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/sys@v0.29.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/sys@v0.29.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.go
package main

import (
	"bytes"
	"fmt"
	"os"

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

func main() {
	// Assertion 1: unix.Pipe creates a unidirectional byte stream channel between two file descriptors
	fds := make([]int, 2)
	if err := unix.Pipe(fds); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Pipe error: %v\n", err)
		os.Exit(1)
	}
	defer unix.Close(fds[0])
	defer unix.Close(fds[1])

	payload := []byte("csx-pipe-test-data")
	nw, err := unix.Write(fds[1], payload)
	if err != nil || nw != len(payload) {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Write to pipe error: %v, written: %d\n", err, nw)
		os.Exit(1)
	}

	buf := make([]byte, len(payload))
	nr, err := unix.Read(fds[0], buf)
	if err != nil || nr != len(payload) || !bytes.Equal(buf, payload) {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Read from pipe error: %v, read: %d, got: %q\n", err, nr, string(buf))
		os.Exit(1)
	}

	// Assertion 2: unix.Pipe2 creates non-blocking file descriptor pairs with O_CLOEXEC and O_NONBLOCK flags
	var p2Fds [2]int
	if err := unix.Pipe2(p2Fds[:], unix.O_CLOEXEC|unix.O_NONBLOCK); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Pipe2 error: %v\n", err)
		os.Exit(1)
	}
	defer unix.Close(p2Fds[0])
	defer unix.Close(p2Fds[1])

	emptyBuf := make([]byte, 8)
	_, err = unix.Read(p2Fds[0], emptyBuf)
	if err != unix.EAGAIN && err != unix.EWOULDBLOCK {
		fmt.Fprintf(os.Stderr, "FAIL: expected EAGAIN/EWOULDBLOCK on empty non-blocking pipe, got: %v\n", err)
		os.Exit(1)
	}

	// Assertion 3: unix.Sysinfo queries kernel system statistics with positive uptime and totalram
	var sysinfo unix.Sysinfo_t
	if err := unix.Sysinfo(&sysinfo); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Sysinfo error: %v\n", err)
		os.Exit(1)
	}
	if sysinfo.Uptime <= 0 || sysinfo.Totalram <= 0 {
		fmt.Fprintf(os.Stderr, "FAIL: invalid sysinfo values: uptime=%d, totalram=%d\n", sysinfo.Uptime, sysinfo.Totalram)
		os.Exit(1)
	}

	// Assertion 4: unix.Dup duplicates an existing file descriptor to reference the same open file description
	dupFd, err := unix.Dup(fds[1])
	if err != nil || dupFd < 0 {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Dup error: %v, dupFd: %d\n", err, dupFd)
		os.Exit(1)
	}
	defer unix.Close(dupFd)

	dupPayload := []byte("dup-test-data")
	nw2, err := unix.Write(dupFd, dupPayload)
	if err != nil || nw2 != len(dupPayload) {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Write via dupFd error: %v, written: %d\n", err, nw2)
		os.Exit(1)
	}

	dupBuf := make([]byte, len(dupPayload))
	nr2, err := unix.Read(fds[0], dupBuf)
	if err != nil || nr2 != len(dupPayload) || !bytes.Equal(dupBuf, dupPayload) {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Read after dup write error: %v, read: %d, got: %q\n", err, nr2, string(dupBuf))
		os.Exit(1)
	}

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

Origin Seeder

anonymous