Ejemplo
golang.org/x/sys v0.22.0: unix.O_ACCMODE
Muestra verificada para golang golang.org/x/sys v0.22.0: unix.O_ACCMODE. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.
sha256:0c334ddeb1a69a0c0db3cccf28f8db6b314455e6c198dd18f846a829d76adf18
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify golang.org/x/sys/unix.O_ACCMODE in pkg:golang/golang.org/x/sys@v0.22.0
- Paquetes
- Símbolos
-
- golang.org/x/sys/unix.O_ACCMODE
- Creado
- 2026-09-15T22:49:05Z
Contrato
- unix.O_ACCMODE constant equals 3 (0x3) and masks O_RDONLY, O_WRONLY, and O_RDWR access modes
- bitwise AND with unix.O_ACCMODE extracts access mode from flags combined with creation and status flags
- fcntl F_GETFL on open file descriptors masked with unix.O_ACCMODE returns the expected access mode
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
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.O_ACCMODE 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.O_ACCMODE
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:0dece87b2a5ab166668e275f75e22dd682a4782fc4868f27da39109b9a010e95","contract":["unix.O_ACCMODE constant equals 3 (0x3) and masks O_RDONLY, O_WRONLY, and O_RDWR access modes","bitwise AND with unix.O_ACCMODE extracts access mode from flags combined with creation and status flags","fcntl F_GETFL on open file descriptors masked with unix.O_ACCMODE returns the expected access mode"],"goal":"verify golang.org/x/sys/unix.O_ACCMODE 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.O_ACCMODE"]},"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.O_ACCMODE"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
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=
package main
import (
"fmt"
"os"
"golang.org/x/sys/unix"
)
func main() {
tmpFile, err := os.CreateTemp("", "accmode_demo_*")
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create temp file: %v\n", err)
os.Exit(1)
}
defer os.Remove(tmpFile.Name())
defer tmpFile.Close()
fd, err := unix.Open(tmpFile.Name(), unix.O_RDWR, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to open file: %v\n", err)
os.Exit(1)
}
defer unix.Close(fd)
flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFL, 0)
if err != nil {
fmt.Fprintf(os.Stderr, "fcntl F_GETFL failed: %v\n", err)
os.Exit(1)
}
accessMode := flags & unix.O_ACCMODE
fmt.Printf("O_ACCMODE mask: 0x%x\n", unix.O_ACCMODE)
fmt.Printf("File descriptor access mode: %d (O_RDWR = %d)\n", accessMode, unix.O_RDWR)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/sys/unix.O_ACCMODE 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.O_ACCMODE"
]
}
package main
import (
"fmt"
"os"
"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 contract assertions passed.")
}
func runTests() error {
// 1. unix.O_ACCMODE constant equals 3 (0x3) and masks O_RDONLY, O_WRONLY, and O_RDWR access modes
if unix.O_ACCMODE != 3 {
return fmt.Errorf("expected unix.O_ACCMODE to be 3, got %d", unix.O_ACCMODE)
}
if (unix.O_RDONLY & unix.O_ACCMODE) != unix.O_RDONLY {
return fmt.Errorf("expected O_RDONLY & O_ACCMODE to equal O_RDONLY")
}
if (unix.O_WRONLY & unix.O_ACCMODE) != unix.O_WRONLY {
return fmt.Errorf("expected O_WRONLY & O_ACCMODE to equal O_WRONLY")
}
if (unix.O_RDWR & unix.O_ACCMODE) != unix.O_RDWR {
return fmt.Errorf("expected O_RDWR & O_ACCMODE to equal O_RDWR")
}
// 2. bitwise AND with unix.O_ACCMODE extracts access mode from flags combined with creation and status flags
combinedRdwr := unix.O_RDWR | unix.O_APPEND | unix.O_CLOEXEC | unix.O_NONBLOCK
if (combinedRdwr & unix.O_ACCMODE) != unix.O_RDWR {
return fmt.Errorf("expected combinedRdwr & O_ACCMODE to be O_RDWR (%d), got %d", unix.O_RDWR, combinedRdwr&unix.O_ACCMODE)
}
combinedWronly := unix.O_WRONLY | unix.O_CREAT | unix.O_TRUNC | unix.O_SYNC
if (combinedWronly & unix.O_ACCMODE) != unix.O_WRONLY {
return fmt.Errorf("expected combinedWronly & O_ACCMODE to be O_WRONLY (%d), got %d", unix.O_WRONLY, combinedWronly&unix.O_ACCMODE)
}
combinedRdonly := unix.O_RDONLY | unix.O_CLOEXEC
if (combinedRdonly & unix.O_ACCMODE) != unix.O_RDONLY {
return fmt.Errorf("expected combinedRdonly & O_ACCMODE to be O_RDONLY (%d), got %d", unix.O_RDONLY, combinedRdonly&unix.O_ACCMODE)
}
// 3. fcntl F_GETFL on open file descriptors masked with unix.O_ACCMODE returns the expected access mode
tmpFile, err := os.CreateTemp("", "accmode_contract_*")
if err != nil {
return fmt.Errorf("failed to create temp file: %w", err)
}
defer os.Remove(tmpFile.Name())
defer tmpFile.Close()
// O_RDONLY fd
roFd, err := unix.Open(tmpFile.Name(), unix.O_RDONLY, 0)
if err != nil {
return fmt.Errorf("open O_RDONLY failed: %w", err)
}
defer unix.Close(roFd)
roFlags, err := unix.FcntlInt(uintptr(roFd), unix.F_GETFL, 0)
if err != nil {
return fmt.Errorf("fcntl F_GETFL on roFd failed: %w", err)
}
if (roFlags & unix.O_ACCMODE) != unix.O_RDONLY {
return fmt.Errorf("expected (roFlags & unix.O_ACCMODE) to be O_RDONLY (%d), got %d", unix.O_RDONLY, roFlags&unix.O_ACCMODE)
}
// O_WRONLY fd
woFd, err := unix.Open(tmpFile.Name(), unix.O_WRONLY, 0)
if err != nil {
return fmt.Errorf("open O_WRONLY failed: %w", err)
}
defer unix.Close(woFd)
woFlags, err := unix.FcntlInt(uintptr(woFd), unix.F_GETFL, 0)
if err != nil {
return fmt.Errorf("fcntl F_GETFL on woFd failed: %w", err)
}
if (woFlags & unix.O_ACCMODE) != unix.O_WRONLY {
return fmt.Errorf("expected (woFlags & unix.O_ACCMODE) to be O_WRONLY (%d), got %d", unix.O_WRONLY, woFlags&unix.O_ACCMODE)
}
// O_RDWR fd
rwFd, err := unix.Open(tmpFile.Name(), unix.O_RDWR, 0)
if err != nil {
return fmt.Errorf("open O_RDWR failed: %w", err)
}
defer unix.Close(rwFd)
rwFlags, err := unix.FcntlInt(uintptr(rwFd), unix.F_GETFL, 0)
if err != nil {
return fmt.Errorf("fcntl F_GETFL on rwFd failed: %w", err)
}
if (rwFlags & unix.O_ACCMODE) != unix.O_RDWR {
return fmt.Errorf("expected (rwFlags & unix.O_ACCMODE) to be O_RDWR (%d), got %d", unix.O_RDWR, rwFlags&unix.O_ACCMODE)
}
return nil
}
Seeder de origen
anónimo