CodeSampleX

샘플

golang.org/x/sys v0.12.0

검증된 샘플 — golang golang.org/x/sys v0.12.0. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: unix.Getpid and unix.Getppid return positive process…

sha256:a1af15ea2d4698a3b7b890e02dfcbe5b790eaabdbca5e5aeb73df15d4ece6036

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 go

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:golang/golang.org/x/sys@v0.12.0
패키지
생성일
2026-08-27T13:23:09Z

컨트랙트

  1. unix.Getpid and unix.Getppid return positive process identifiers
  2. unix.ClockGettime retrieves monotonic clock time with valid nanoseconds
  3. unix.Statfs queries filesystem statistics returning positive block size and total blocks
  4. unix.Eventfd creates non-blocking event file descriptor transferring integer counter value

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/sys@v0.12.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:0841ee1fc4b9c6f445189d5fa011008b877329f13112dc922c82141822b7d774","contract":["unix.Getpid and unix.Getppid return positive process identifiers","unix.ClockGettime retrieves monotonic clock time with valid nanoseconds","unix.Statfs queries filesystem statistics returning positive block size and total blocks","unix.Eventfd creates non-blocking event file descriptor transferring integer counter value"],"goal":"verify pkg:golang/golang.org/x/sys@v0.12.0","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.12.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.12.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.12.0","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/sys v0.12.0
go.sum
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
main.go
package main

import (
	"encoding/binary"
	"fmt"
	"os"

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

// GetProcessIDs returns the current process ID and parent process ID.
func GetProcessIDs() (int, int) {
	pid := unix.Getpid()
	ppid := unix.Getppid()
	return pid, ppid
}

// GetMonotonicTime returns current monotonic clock reading as unix.Timespec.
func GetMonotonicTime() (unix.Timespec, error) {
	var ts unix.Timespec
	if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
		return ts, fmt.Errorf("clock_gettime failed: %w", err)
	}
	return ts, nil
}

// GetFilesystemStats returns filesystem statistics for the specified path.
func GetFilesystemStats(path string) (unix.Statfs_t, error) {
	var stat unix.Statfs_t
	if err := unix.Statfs(path, &stat); err != nil {
		return stat, fmt.Errorf("statfs failed: %w", err)
	}
	return stat, nil
}

// TransferEventCounter creates an eventfd, writes a counter value, and reads it back.
func TransferEventCounter(val uint64) (uint64, error) {
	fd, err := unix.Eventfd(0, unix.EFD_CLOEXEC|unix.EFD_NONBLOCK)
	if err != nil {
		return 0, fmt.Errorf("eventfd failed: %w", err)
	}
	defer unix.Close(fd)

	var buf [8]byte
	binary.NativeEndian.PutUint64(buf[:], val)
	n, err := unix.Write(fd, buf[:])
	if err != nil {
		return 0, fmt.Errorf("write to eventfd failed: %w", err)
	}
	if n != 8 {
		return 0, fmt.Errorf("short write to eventfd: %d bytes", n)
	}

	var readBuf [8]byte
	rn, err := unix.Read(fd, readBuf[:])
	if err != nil {
		return 0, fmt.Errorf("read from eventfd failed: %w", err)
	}
	if rn != 8 {
		return 0, fmt.Errorf("short read from eventfd: %d bytes", rn)
	}

	result := binary.NativeEndian.Uint64(readBuf[:])
	return result, nil
}

func main() {
	pid, ppid := GetProcessIDs()
	fmt.Printf("Process IDs: PID=%d, PPID=%d\n", pid, ppid)

	ts, err := GetMonotonicTime()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error getting monotonic time: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Monotonic time: %d.%09d s\n", ts.Sec, ts.Nsec)

	stat, err := GetFilesystemStats(".")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error getting filesystem stats: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Filesystem stats: Bsize=%d, Blocks=%d\n", stat.Bsize, stat.Blocks)

	counter, err := TransferEventCounter(42)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error with eventfd counter: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Eventfd transferred value: %d\n", counter)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/sys@v0.12.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/sys@v0.12.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 (
	"encoding/binary"
	"fmt"
	"os"

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

func main() {
	// Assertion 1: unix.Getpid and unix.Getppid return positive process identifiers
	pid := unix.Getpid()
	ppid := unix.Getppid()
	if pid <= 0 || ppid < 0 {
		fmt.Fprintf(os.Stderr, "FAIL: invalid PID=%d or PPID=%d\n", pid, ppid)
		os.Exit(1)
	}

	// Assertion 2: unix.ClockGettime retrieves monotonic clock time with valid nanoseconds
	var ts unix.Timespec
	if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.ClockGettime CLOCK_MONOTONIC failed: %v\n", err)
		os.Exit(1)
	}
	if ts.Sec < 0 || ts.Nsec < 0 || ts.Nsec >= 1000000000 {
		fmt.Fprintf(os.Stderr, "FAIL: invalid timespec values: sec=%d, nsec=%d\n", ts.Sec, ts.Nsec)
		os.Exit(1)
	}

	// Assertion 3: unix.Statfs queries filesystem statistics returning positive block size and total blocks
	var stat unix.Statfs_t
	if err := unix.Statfs(".", &stat); err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Statfs failed: %v\n", err)
		os.Exit(1)
	}
	if stat.Bsize <= 0 || stat.Blocks == 0 {
		fmt.Fprintf(os.Stderr, "FAIL: invalid statfs values: bsize=%d, blocks=%d\n", stat.Bsize, stat.Blocks)
		os.Exit(1)
	}

	// Assertion 4: unix.Eventfd creates non-blocking event file descriptor transferring integer counter value
	fd, err := unix.Eventfd(0, unix.EFD_CLOEXEC|unix.EFD_NONBLOCK)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Eventfd failed: %v\n", err)
		os.Exit(1)
	}
	defer unix.Close(fd)

	var writeBuf [8]byte
	binary.NativeEndian.PutUint64(writeBuf[:], 12345)
	n, err := unix.Write(fd, writeBuf[:])
	if err != nil || n != 8 {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Write on eventfd failed: n=%d, err=%v\n", n, err)
		os.Exit(1)
	}

	var readBuf [8]byte
	rn, err := unix.Read(fd, readBuf[:])
	if err != nil || rn != 8 {
		fmt.Fprintf(os.Stderr, "FAIL: unix.Read on eventfd failed: rn=%d, err=%v\n", rn, err)
		os.Exit(1)
	}

	val := binary.NativeEndian.Uint64(readBuf[:])
	if val != 12345 {
		fmt.Fprintf(os.Stderr, "FAIL: unexpected eventfd value: got %d, expected 12345\n", val)
		os.Exit(1)
	}

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

오리진 시더

익명