Exemplo
golang.org/x/sys v0.31.0: unix.EFD_CLOEXEC
Amostra verificada para golang golang.org/x/sys v0.31.0: unix.EFD_CLOEXEC. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou.
sha256:6fc4455dc8d9ee7c83f9ac26cd64a9262e1357962b61d7e64aeaa7b140a458c1
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-30 |
Caso
HOW- Objetivo
- verify golang.org/x/sys/unix.EFD_CLOEXEC in pkg:golang/golang.org/x/sys@v0.31.0
- Pacotes
- Símbolos
-
- golang.org/x/sys/unix.EFD_CLOEXEC
- Criado
- 2026-08-30T16:14:35Z
Contrato
- unix.Eventfd creates a file descriptor with unix.EFD_CLOEXEC flag setting FD_CLOEXEC
- Writing and reading 8-byte uint64 counters transfers data across the eventfd
- unix.Eventfd with EFD_CLOEXEC and EFD_NONBLOCK returns EAGAIN when counter is zero
- unix.Eventfd with EFD_CLOEXEC and EFD_SEMAPHORE decrements counter by 1 on read
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 golang.org/x/sys/unix.EFD_CLOEXEC in pkg:golang/golang.org/x/sys@v0.31.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/sys@v0.31.0
Demonstrate these symbols/APIs:
- golang.org/x/sys/unix.EFD_CLOEXEC
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.
{"case":{"caseId":"case:sha256:3f7f62af2f744ddaf7ee26ec8d99dc1b5b9a41e077039b2b0e986d34415791a4","contract":["unix.Eventfd creates a file descriptor with unix.EFD_CLOEXEC flag setting FD_CLOEXEC","Writing and reading 8-byte uint64 counters transfers data across the eventfd","unix.Eventfd with EFD_CLOEXEC and EFD_NONBLOCK returns EAGAIN when counter is zero","unix.Eventfd with EFD_CLOEXEC and EFD_SEMAPHORE decrements counter by 1 on read"],"goal":"verify golang.org/x/sys/unix.EFD_CLOEXEC in pkg:golang/golang.org/x/sys@v0.31.0","kind":"HOW","packages":["pkg:golang/golang.org/x/sys@v0.31.0"],"schemaVersion":1,"symbols":["golang.org/x/sys/unix.EFD_CLOEXEC"]},"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.31.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/sys@v0.31.0","symbols":["golang.org/x/sys/unix.EFD_CLOEXEC"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/sys v0.31.0
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
package main
import (
"encoding/binary"
"fmt"
"os"
"golang.org/x/sys/unix"
)
// CreateEventFD creates an eventfd file descriptor with EFD_CLOEXEC and optional flags.
func CreateEventFD(initval uint, flags int) (int, error) {
fd, err := unix.Eventfd(initval, flags)
if err != nil {
return -1, fmt.Errorf("eventfd failed: %w", err)
}
return fd, nil
}
// WriteEventFD writes a 64-bit unsigned integer counter to the eventfd.
func WriteEventFD(fd int, val uint64) error {
var buf [8]byte
binary.LittleEndian.PutUint64(buf[:], val)
n, err := unix.Write(fd, buf[:])
if err != nil {
return fmt.Errorf("write to eventfd failed: %w", err)
}
if n != 8 {
return fmt.Errorf("short write to eventfd: %d bytes", n)
}
return nil
}
// ReadEventFD reads a 64-bit unsigned integer counter from the eventfd.
func ReadEventFD(fd int) (uint64, error) {
var buf [8]byte
n, err := unix.Read(fd, buf[:])
if err != nil {
return 0, fmt.Errorf("read from eventfd failed: %w", err)
}
if n != 8 {
return 0, fmt.Errorf("short read from eventfd: %d bytes", n)
}
return binary.LittleEndian.Uint64(buf[:]), nil
}
func main() {
// Create eventfd with EFD_CLOEXEC
fd, err := CreateEventFD(0, unix.EFD_CLOEXEC)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating eventfd: %v\n", err)
os.Exit(1)
}
defer unix.Close(fd)
// Verify close-on-exec flag is set
flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting fd flags: %v\n", err)
os.Exit(1)
}
if flags&unix.FD_CLOEXEC == 0 {
fmt.Fprintf(os.Stderr, "FD_CLOEXEC not set on eventfd\n")
os.Exit(1)
}
fmt.Printf("Eventfd created successfully with EFD_CLOEXEC (fd: %d, flags: %d)\n", fd, flags)
// Write counter value
valToWrite := uint64(42)
if err := WriteEventFD(fd, valToWrite); err != nil {
fmt.Fprintf(os.Stderr, "Error writing to eventfd: %v\n", err)
os.Exit(1)
}
fmt.Printf("Wrote counter %d to eventfd\n", valToWrite)
// Read counter value back
valRead, err := ReadEventFD(fd)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading from eventfd: %v\n", err)
os.Exit(1)
}
fmt.Printf("Read counter %d from eventfd\n", valRead)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/sys/unix.EFD_CLOEXEC in pkg:golang/golang.org/x/sys@v0.31.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/sys@v0.31.0"
],
"symbols": [
"golang.org/x/sys/unix.EFD_CLOEXEC"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"encoding/binary"
"errors"
"fmt"
"os"
"golang.org/x/sys/unix"
)
func main() {
// Assertion 1: unix.Eventfd creates a file descriptor with unix.EFD_CLOEXEC flag setting FD_CLOEXEC
fd, err := unix.Eventfd(0, unix.EFD_CLOEXEC)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Eventfd with EFD_CLOEXEC failed: %v\n", err)
os.Exit(1)
}
defer unix.Close(fd)
flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.FcntlInt F_GETFD failed: %v\n", err)
os.Exit(1)
}
if flags&unix.FD_CLOEXEC == 0 {
fmt.Fprintf(os.Stderr, "FAIL: FD_CLOEXEC flag was not set on eventfd\n")
os.Exit(1)
}
// Assertion 2: Writing and reading 8-byte uint64 counters transfers data across the eventfd
var writeBuf [8]byte
binary.LittleEndian.PutUint64(writeBuf[:], 7)
n, err := unix.Write(fd, writeBuf[:])
if err != nil || n != 8 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Write to eventfd failed: n=%d, err=%v\n", n, err)
os.Exit(1)
}
var readBuf [8]byte
n, err = unix.Read(fd, readBuf[:])
if err != nil || n != 8 {
fmt.Fprintf(os.Stderr, "FAIL: unix.Read from eventfd failed: n=%d, err=%v\n", n, err)
os.Exit(1)
}
readVal := binary.LittleEndian.Uint64(readBuf[:])
if readVal != 7 {
fmt.Fprintf(os.Stderr, "FAIL: eventfd read value mismatch: got %d, want 7\n", readVal)
os.Exit(1)
}
// Assertion 3: unix.Eventfd with EFD_CLOEXEC and EFD_NONBLOCK returns EAGAIN when counter is zero
nbFd, err := unix.Eventfd(0, unix.EFD_CLOEXEC|unix.EFD_NONBLOCK)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Eventfd with EFD_CLOEXEC|EFD_NONBLOCK failed: %v\n", err)
os.Exit(1)
}
defer unix.Close(nbFd)
var nbBuf [8]byte
_, err = unix.Read(nbFd, nbBuf[:])
if err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected EAGAIN on non-blocking empty eventfd, got nil error\n")
os.Exit(1)
}
if !errors.Is(err, unix.EAGAIN) && !errors.Is(err, unix.EWOULDBLOCK) {
fmt.Fprintf(os.Stderr, "FAIL: expected EAGAIN/EWOULDBLOCK, got %v\n", err)
os.Exit(1)
}
// Assertion 4: unix.Eventfd with EFD_CLOEXEC and EFD_SEMAPHORE decrements counter by 1 on read
semFd, err := unix.Eventfd(2, unix.EFD_CLOEXEC|unix.EFD_SEMAPHORE)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unix.Eventfd with EFD_CLOEXEC|EFD_SEMAPHORE failed: %v\n", err)
os.Exit(1)
}
defer unix.Close(semFd)
var semBuf [8]byte
n, err = unix.Read(semFd, semBuf[:])
if err != nil || n != 8 {
fmt.Fprintf(os.Stderr, "FAIL: semFd read failed: n=%d, err=%v\n", n, err)
os.Exit(1)
}
semVal := binary.LittleEndian.Uint64(semBuf[:])
if semVal != 1 {
fmt.Fprintf(os.Stderr, "FAIL: semaphore read expected 1, got %d\n", semVal)
os.Exit(1)
}
fmt.Println("PASS: golang.org/x/sys unix.EFD_CLOEXEC contract passed")
}
Seeder de origem
anônimo