Sample
golang.org/x/sys v0.22.0: unix.Stat_t
Verified sample for golang golang.org/x/sys v0.22.0: unix.Stat_t. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:4b9b974038afd592183e1b2e46aaa3ce808fc604174825df717c25a531457edb
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-15 |
Case
HOW- Goal
- verify golang.org/x/sys/unix.Stat_t in pkg:golang/golang.org/x/sys@v0.22.0
- Packages
- Symbols
-
- golang.org/x/sys/unix.Stat_t
- Created
- 2026-09-15T11:20:32Z
Contract
- unix.Stat populates unix.Stat_t with file metadata including size, mode, and timestamps
- unix.Fstat populates unix.Stat_t from an open file descriptor matching unix.Stat
- unix.Lstat populates unix.Stat_t for a symbolic link without following it
- unix.Stat_t Mode identifies regular files, directories, and symlinks
- unix.Fstatat populates unix.Stat_t relative to a directory file descriptor
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- stat.go
- test/contract.go
Source
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 golang.org/x/sys/unix.Stat_t in pkg:golang/golang.org/x/sys@v0.22.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/sys@v0.22.0
Demonstrate these symbols/APIs:
- golang.org/x/sys/unix.Stat_t
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:b5389bfdd32d97e0ff47bf1da5dcae40aadadf6b824ba94edb8e69d732a33064","contract":["unix.Stat populates unix.Stat_t with file metadata including size, mode, and timestamps","unix.Fstat populates unix.Stat_t from an open file descriptor matching unix.Stat","unix.Lstat populates unix.Stat_t for a symbolic link without following it","unix.Stat_t Mode identifies regular files, directories, and symlinks","unix.Fstatat populates unix.Stat_t relative to a directory file descriptor"],"goal":"verify golang.org/x/sys/unix.Stat_t in pkg:golang/golang.org/x/sys@v0.22.0","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.22.0"],"schemaVersion":1,"symbols":["golang.org/x/sys/unix.Stat_t"]},"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.22.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.22.0","symbols":["golang.org/x/sys/unix.Stat_t"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require golang.org/x/sys v0.22.0
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
{
"schemaVersion": 1,
"goal": "verify golang.org/x/sys/unix.Stat_t in pkg:golang/golang.org/x/sys@v0.22.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/sys@v0.22.0"
],
"symbols": [
"golang.org/x/sys/unix.Stat_t"
]
}
package sample
import (
"golang.org/x/sys/unix"
)
// GetFileStat retrieves file metadata using unix.Stat into unix.Stat_t.
func GetFileStat(path string) (*unix.Stat_t, error) {
var st unix.Stat_t
if err := unix.Stat(path, &st); err != nil {
return nil, err
}
return &st, nil
}
// GetFdStat retrieves file metadata using unix.Fstat into unix.Stat_t.
func GetFdStat(fd int) (*unix.Stat_t, error) {
var st unix.Stat_t
if err := unix.Fstat(fd, &st); err != nil {
return nil, err
}
return &st, nil
}
// GetLinkStat retrieves symlink metadata without following the link using unix.Lstat.
func GetLinkStat(path string) (*unix.Stat_t, error) {
var st unix.Stat_t
if err := unix.Lstat(path, &st); err != nil {
return nil, err
}
return &st, nil
}
// GetAtStat retrieves file metadata relative to a directory descriptor using unix.Fstatat.
func GetAtStat(dirfd int, path string, flags int) (*unix.Stat_t, error) {
var st unix.Stat_t
if err := unix.Fstatat(dirfd, path, &st, flags); err != nil {
return nil, err
}
return &st, nil
}
// IsRegularFile returns true if unix.Stat_t Mode represents a regular file.
func IsRegularFile(st *unix.Stat_t) bool {
return (st.Mode & unix.S_IFMT) == unix.S_IFREG
}
// IsDirectory returns true if unix.Stat_t Mode represents a directory.
func IsDirectory(st *unix.Stat_t) bool {
return (st.Mode & unix.S_IFMT) == unix.S_IFDIR
}
// IsSymlink returns true if unix.Stat_t Mode represents a symbolic link.
func IsSymlink(st *unix.Stat_t) bool {
return (st.Mode & unix.S_IFMT) == unix.S_IFLNK
}
package main
import (
"fmt"
"os"
"path/filepath"
"example.com/sample"
"golang.org/x/sys/unix"
)
func main() {
if err := runTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All unix.Stat_t contract assertions passed.")
}
func runTests() error {
tmpDir, err := os.MkdirTemp(".", "csx_stat_test_*")
if err != nil {
return fmt.Errorf("failed to create temp dir: %w", err)
}
defer os.RemoveAll(tmpDir)
filePath := filepath.Join(tmpDir, "testfile.txt")
testData := []byte("hello stat_t!!") // 14 bytes
if err := os.WriteFile(filePath, testData, 0644); err != nil {
return fmt.Errorf("failed to write test file: %w", err)
}
// 1. unix.Stat populates unix.Stat_t with file metadata including size, mode, and timestamps
stat, err := sample.GetFileStat(filePath)
if err != nil {
return fmt.Errorf("sample.GetFileStat failed: %w", err)
}
if stat.Size != int64(len(testData)) {
return fmt.Errorf("expected size %d, got %d", len(testData), stat.Size)
}
if stat.Ino == 0 {
return fmt.Errorf("expected non-zero inode, got %d", stat.Ino)
}
if stat.Nlink < 1 {
return fmt.Errorf("expected Nlink >= 1, got %d", stat.Nlink)
}
if stat.Mtim.Sec == 0 {
return fmt.Errorf("expected non-zero Mtim.Sec, got %d", stat.Mtim.Sec)
}
// 2. unix.Fstat populates unix.Stat_t from an open file descriptor matching unix.Stat
fd, err := unix.Open(filePath, unix.O_RDONLY, 0)
if err != nil {
return fmt.Errorf("unix.Open failed: %w", err)
}
defer unix.Close(fd)
fstat, err := sample.GetFdStat(fd)
if err != nil {
return fmt.Errorf("sample.GetFdStat failed: %w", err)
}
if fstat.Ino != stat.Ino || fstat.Dev != stat.Dev || fstat.Size != stat.Size {
return fmt.Errorf("fstat mismatch: got ino=%d dev=%d size=%d, expected ino=%d dev=%d size=%d",
fstat.Ino, fstat.Dev, fstat.Size, stat.Ino, stat.Dev, stat.Size)
}
// 3. unix.Lstat populates unix.Stat_t for a symbolic link without following it
symlinkPath := filepath.Join(tmpDir, "testlink")
if err := os.Symlink(filePath, symlinkPath); err != nil {
return fmt.Errorf("failed to create symlink: %w", err)
}
lstat, err := sample.GetLinkStat(symlinkPath)
if err != nil {
return fmt.Errorf("sample.GetLinkStat failed: %w", err)
}
if !sample.IsSymlink(lstat) {
return fmt.Errorf("expected IsSymlink to be true for symlink")
}
if lstat.Ino == stat.Ino {
return fmt.Errorf("expected lstat.Ino (%d) to differ from target stat.Ino (%d)", lstat.Ino, stat.Ino)
}
// 4. unix.Stat_t Mode identifies regular files, directories, and symlinks
if !sample.IsRegularFile(stat) {
return fmt.Errorf("expected IsRegularFile to be true for testfile")
}
if sample.IsDirectory(stat) {
return fmt.Errorf("expected IsDirectory to be false for testfile")
}
dirStat, err := sample.GetFileStat(tmpDir)
if err != nil {
return fmt.Errorf("sample.GetFileStat on dir failed: %w", err)
}
if !sample.IsDirectory(dirStat) {
return fmt.Errorf("expected IsDirectory to be true for tmpDir")
}
if sample.IsRegularFile(dirStat) {
return fmt.Errorf("expected IsRegularFile to be false for tmpDir")
}
// 5. unix.Fstatat populates unix.Stat_t relative to a directory file descriptor
dirFd, err := unix.Open(tmpDir, unix.O_RDONLY|unix.O_DIRECTORY, 0)
if err != nil {
return fmt.Errorf("unix.Open on tmpDir failed: %w", err)
}
defer unix.Close(dirFd)
atStat, err := sample.GetAtStat(dirFd, "testfile.txt", 0)
if err != nil {
return fmt.Errorf("sample.GetAtStat failed: %w", err)
}
if atStat.Ino != stat.Ino || atStat.Size != stat.Size {
return fmt.Errorf("atStat mismatch: got ino=%d size=%d, expected ino=%d size=%d",
atStat.Ino, atStat.Size, stat.Ino, stat.Size)
}
return nil
}
Origin Seeder
anonymous