CodeSampleX

샘플

golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71

검증된 샘플 — golang golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:859ce8c7da3ed81ab7ca9b66cc296028f80437be3a6a62f7f0e07e040800ccd4

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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.0.0-20220406155245-289d7a0edf71
패키지
생성일
2026-08-27T13:05:23Z

컨트랙트

  1. unix.Getrlimit retrieves resource limits where Cur does not exceed Max
  2. unix.Getuid and unix.Getgid return non-negative user and group identifiers
  3. unix.Pipe creates connected pipe descriptors that transfer byte payload
  4. unix.ClockGettime with CLOCK_MONOTONIC retrieves non-zero Timespec

파일

  • 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.0.0-20220406155245-289d7a0edf71
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71
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:45d7476876e59e7bc0e4fbceb11fea625f3ced58b0587f099e45fa8dcfa88066","contract":["unix.Getrlimit retrieves resource limits where Cur does not exceed Max","unix.Getuid and unix.Getgid return non-negative user and group identifiers","unix.Pipe creates connected pipe descriptors that transfer byte payload","unix.ClockGettime with CLOCK_MONOTONIC retrieves non-zero Timespec"],"goal":"verify pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71"],"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-20220406155245-289d7a0edf71"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71
go.sum
golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71 h1:PRD0hj6tTuUnCFD08vkvjkYFbQg/9lV8KIxe1y4/cvU=
golang.org/x/sys v0.0.0-20220406155245-289d7a0edf71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
main.go
package main

import (
	"bytes"
	"fmt"
	"os"

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

func main() {
	var rlim unix.Rlimit
	if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlim); err != nil {
		fmt.Fprintf(os.Stderr, "failed to get rlimit: %v\n", err)
		os.Exit(1)
	}

	uid := unix.Getuid()
	gid := unix.Getgid()

	var p [2]int
	if err := unix.Pipe(p[:]); err != nil {
		fmt.Fprintf(os.Stderr, "failed to create pipe: %v\n", err)
		os.Exit(1)
	}
	defer unix.Close(p[0])
	defer unix.Close(p[1])

	msg := []byte("hello unix")
	if _, err := unix.Write(p[1], msg); err != nil {
		fmt.Fprintf(os.Stderr, "failed to write to pipe: %v\n", err)
		os.Exit(1)
	}

	buf := make([]byte, len(msg))
	if _, err := unix.Read(p[0], buf); err != nil {
		fmt.Fprintf(os.Stderr, "failed to read from pipe: %v\n", err)
		os.Exit(1)
	}

	var ts unix.Timespec
	if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
		fmt.Fprintf(os.Stderr, "failed to get monotonic clock: %v\n", err)
		os.Exit(1)
	}

	fmt.Printf("RLIMIT_NOFILE: Cur=%d, Max=%d\n", rlim.Cur, rlim.Max)
	fmt.Printf("UID: %d, GID: %d\n", uid, gid)
	fmt.Printf("Pipe read: %s (equal=%t)\n", string(buf), bytes.Equal(buf, msg))
	fmt.Printf("Monotonic time: %d.%09d\n", ts.Sec, ts.Nsec)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/sys@v0.0.0-20220406155245-289d7a0edf71"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"fmt"
	"os"

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

func main() {
	if err := runContract(); err != nil {
		fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("All golang.org/x/sys/unix contract assertions passed.")
}

func runContract() error {
	// Assertion 1: unix.Getrlimit retrieves resource limits where Cur does not exceed Max
	var rlim unix.Rlimit
	if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlim); err != nil {
		return fmt.Errorf("unix.Getrlimit failed: %w", err)
	}
	if rlim.Cur > rlim.Max {
		return fmt.Errorf("expected rlim.Cur <= rlim.Max, got Cur=%d Max=%d", rlim.Cur, rlim.Max)
	}

	// Assertion 2: unix.Getuid and unix.Getgid return non-negative user and group identifiers
	uid := unix.Getuid()
	gid := unix.Getgid()
	if uid < 0 || gid < 0 {
		return fmt.Errorf("expected non-negative uid and gid, got uid=%d gid=%d", uid, gid)
	}

	// Assertion 3: unix.Pipe creates connected pipe descriptors that transfer byte payload
	var p [2]int
	if err := unix.Pipe(p[:]); err != nil {
		return fmt.Errorf("unix.Pipe failed: %w", err)
	}
	defer unix.Close(p[0])
	defer unix.Close(p[1])

	testMsg := []byte("csx-pipe-test")
	n, err := unix.Write(p[1], testMsg)
	if err != nil || n != len(testMsg) {
		return fmt.Errorf("unix.Write failed: n=%d, err=%w", n, err)
	}

	buf := make([]byte, len(testMsg))
	nr, err := unix.Read(p[0], buf)
	if err != nil || nr != len(testMsg) {
		return fmt.Errorf("unix.Read failed: nr=%d, err=%w", nr, err)
	}
	if !bytes.Equal(buf, testMsg) {
		return fmt.Errorf("payload mismatch: got %s, want %s", string(buf), string(testMsg))
	}

	// Assertion 4: unix.ClockGettime with CLOCK_MONOTONIC retrieves non-zero Timespec
	var ts unix.Timespec
	if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
		return fmt.Errorf("unix.ClockGettime failed: %w", err)
	}
	if ts.Sec <= 0 && ts.Nsec <= 0 {
		return fmt.Errorf("expected non-zero Timespec from ClockGettime, got sec=%d nsec=%d", ts.Sec, ts.Nsec)
	}

	return nil
}

오리진 시더

익명