Exemplo
github.com/prometheus/procfs v0.20.1
Amostra verificada para golang github.com/prometheus/procfs v0.20.1. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou.
sha256:6bda26126bcddd284d5c47d295bd3ae86ce7e52d737ec8223812794af97151f7
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-28 |
Caso
HOW- Objetivo
- verify pkg:golang/github.com/prometheus/procfs@v0.20.1
- Criado
- 2026-08-28T00:32:46Z
Contrato
- procfs.NewDefaultFS() returns (FS, error) where error is nil
- fs.Meminfo() returns (*Meminfo, error) where error is nil and MemTotal is non-nil
- fs.Self() returns (Proc, error) where error is nil and PID is positive
- proc.Stat() returns (ProcStat, error) where error is nil, PID matches, and Comm is non-empty
- fs.Stat() returns (Stat, error) where error is nil and BootTime is non-zero
- procfs.NewFS(procfs.DefaultMountPoint) returns (FS, error) where error is nil
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 pkg:golang/github.com/prometheus/procfs@v0.20.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/procfs@v0.20.1
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:66866adca82b2743330e8fb2e84ae9e3e700b0e2cd33f9be3519bba7b2be4f9e","contract":["procfs.NewDefaultFS() returns (FS, error) where error is nil","fs.Meminfo() returns (*Meminfo, error) where error is nil and MemTotal is non-nil","fs.Self() returns (Proc, error) where error is nil and PID is positive","proc.Stat() returns (ProcStat, error) where error is nil, PID matches, and Comm is non-empty","fs.Stat() returns (Stat, error) where error is nil and BootTime is non-zero","procfs.NewFS(procfs.DefaultMountPoint) returns (FS, error) where error is nil"],"goal":"verify pkg:golang/github.com/prometheus/procfs@v0.20.1","kind":"HOW","packages":["pkg:golang/github.com/prometheus/procfs@v0.20.1"],"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/github.com/prometheus/procfs@v0.20.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/procfs@v0.20.1","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/prometheus/procfs v0.20.1
require golang.org/x/sys v0.41.0 // indirect
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
package main
import (
"fmt"
"os"
"github.com/prometheus/procfs"
)
func ReadSystemMemory() (uint64, error) {
fs, err := procfs.NewDefaultFS()
if err != nil {
return 0, err
}
meminfo, err := fs.Meminfo()
if err != nil {
return 0, err
}
if meminfo.MemTotal == nil {
return 0, fmt.Errorf("memtotal not found")
}
return *meminfo.MemTotal, nil
}
func ReadCurrentProcessStat() (int, string, error) {
fs, err := procfs.NewDefaultFS()
if err != nil {
return 0, "", err
}
proc, err := fs.Self()
if err != nil {
return 0, "", err
}
stat, err := proc.Stat()
if err != nil {
return 0, "", err
}
return proc.PID, stat.Comm, nil
}
func main() {
memTotal, err := ReadSystemMemory()
if err != nil {
fmt.Fprintf(os.Stderr, "error reading meminfo: %v\n", err)
os.Exit(1)
}
pid, comm, err := ReadCurrentProcessStat()
if err != nil {
fmt.Fprintf(os.Stderr, "error reading proc stat: %v\n", err)
os.Exit(1)
}
fmt.Printf("PID: %d, Comm: %s, MemTotal: %d kB\n", pid, comm, memTotal)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/prometheus/procfs@v0.20.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/procfs@v0.20.1"
]
}
package main
import (
"fmt"
"os"
"github.com/prometheus/procfs"
)
func main() {
// 1. procfs.NewDefaultFS() returns (FS, error) where error is nil
fs, err := procfs.NewDefaultFS()
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewDefaultFS failed: %v\n", err)
os.Exit(1)
}
// 2. fs.Meminfo() returns (*Meminfo, error) where error is nil and MemTotal is non-nil
meminfo, err := fs.Meminfo()
if err != nil {
fmt.Fprintf(os.Stderr, "fs.Meminfo failed: %v\n", err)
os.Exit(1)
}
if meminfo.MemTotal == nil || *meminfo.MemTotal == 0 {
fmt.Fprintf(os.Stderr, "expected positive MemTotal, got %v\n", meminfo.MemTotal)
os.Exit(1)
}
// 3. fs.Self() returns (Proc, error) where error is nil and PID is positive
proc, err := fs.Self()
if err != nil {
fmt.Fprintf(os.Stderr, "fs.Self failed: %v\n", err)
os.Exit(1)
}
if proc.PID <= 0 {
fmt.Fprintf(os.Stderr, "expected positive PID, got %d\n", proc.PID)
os.Exit(1)
}
// 4. proc.Stat() returns (ProcStat, error) where error is nil, PID matches, and Comm is non-empty
stat, err := proc.Stat()
if err != nil {
fmt.Fprintf(os.Stderr, "proc.Stat failed: %v\n", err)
os.Exit(1)
}
if stat.PID != proc.PID {
fmt.Fprintf(os.Stderr, "expected stat.PID %d == proc.PID %d\n", stat.PID, proc.PID)
os.Exit(1)
}
if stat.Comm == "" {
fmt.Fprintf(os.Stderr, "expected non-empty stat.Comm\n")
os.Exit(1)
}
// 5. fs.Stat() returns (Stat, error) where error is nil and BootTime is non-zero
systemStat, err := fs.Stat()
if err != nil {
fmt.Fprintf(os.Stderr, "fs.Stat failed: %v\n", err)
os.Exit(1)
}
if systemStat.BootTime == 0 {
fmt.Fprintf(os.Stderr, "expected non-zero BootTime\n")
os.Exit(1)
}
// 6. procfs.NewFS(procfs.DefaultMountPoint) returns (FS, error) where error is nil
fsCustom, err := procfs.NewFS(procfs.DefaultMountPoint)
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewFS failed: %v\n", err)
os.Exit(1)
}
_ = fsCustom
fmt.Println("All contracts verified successfully.")
}
Seeder de origem
anônimo