Sample
github.com/prometheus/procfs v0.22.0: FS.VM
Verified sample for golang github.com/prometheus/procfs v0.22.0: FS.VM. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:0aa8b682d179fc23010a597fc9206fa20ba7ebb44466c167d0114ea3c77bd660
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-05 |
Case
HOW- Goal
- verify procfs.FS.VM in pkg:golang/github.com/prometheus/procfs@v0.22.0
- Packages
- Symbols
-
- procfs.FS.VM
- Created
- 2026-09-05T08:45:30Z
Contract
- procfs.FS.VM reads and parses numerical sysctl virtual memory parameters from sys/vm
- procfs.FS.VM parses lowmem_reserve_ratio as an array of numerical values
- procfs.FS.VM parses numa_zonelist_order as a string
- procfs.FS.VM returns an error when sys/vm does not exist or is not a directory
- procfs.FS.VM returns an error when sys/vm parameter value cannot be parsed as an integer
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- 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 procfs.FS.VM in pkg:golang/github.com/prometheus/procfs@v0.22.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/procfs@v0.22.0
Demonstrate these symbols/APIs:
- procfs.FS.VM
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:b01d8a2d626c3976d9f639dbd133092c390c77d04ce2d0207ce7ff92aa9dd0e2","contract":["procfs.FS.VM reads and parses numerical sysctl virtual memory parameters from sys/vm","procfs.FS.VM parses lowmem_reserve_ratio as an array of numerical values","procfs.FS.VM parses numa_zonelist_order as a string","procfs.FS.VM returns an error when sys/vm does not exist or is not a directory","procfs.FS.VM returns an error when sys/vm parameter value cannot be parsed as an integer"],"goal":"verify procfs.FS.VM in pkg:golang/github.com/prometheus/procfs@v0.22.0","kind":"HOW","packages":["pkg:golang/github.com/prometheus/procfs@v0.22.0"],"schemaVersion":1,"symbols":["procfs.FS.VM"]},"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.22.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/procfs@v0.22.0","symbols":["procfs.FS.VM"],"verifierAdapter":"golang@1"}
module example.com/procfs-sample
go 1.26.6
require github.com/prometheus/procfs v0.22.0
require golang.org/x/sys v0.47.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.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics=
github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
package main
import (
"fmt"
"os"
"github.com/prometheus/procfs"
)
// GetVMStats reads virtual memory sysctl tunables from the specified procfs mount point.
func GetVMStats(mountPoint string) (*procfs.VM, error) {
fs, err := procfs.NewFS(mountPoint)
if err != nil {
return nil, fmt.Errorf("failed to open procfs at %q: %w", mountPoint, err)
}
vm, err := fs.VM()
if err != nil {
return nil, fmt.Errorf("failed to read vm statistics: %w", err)
}
return vm, nil
}
func main() {
vm, err := GetVMStats(procfs.DefaultMountPoint)
if err != nil {
fmt.Fprintf(os.Stderr, "Notice: could not read system procfs vm stats: %v\n", err)
return
}
if vm.Swappiness != nil {
fmt.Printf("swappiness: %d\n", *vm.Swappiness)
}
if vm.OvercommitMemory != nil {
fmt.Printf("overcommit_memory: %d\n", *vm.OvercommitMemory)
}
if vm.MaxMapCount != nil {
fmt.Printf("max_map_count: %d\n", *vm.MaxMapCount)
}
}
{
"schemaVersion": 1,
"goal": "verify procfs.FS.VM in pkg:golang/github.com/prometheus/procfs@v0.22.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/procfs@v0.22.0"
],
"symbols": [
"procfs.FS.VM"
]
}
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/prometheus/procfs"
)
func main() {
// Assertion 1, 2, 3: Create fixture procfs directory with valid sysctl VM entries
tmpDir, err := os.MkdirTemp("", "procfs-contract-*")
if err != nil {
fmt.Fprintf(os.Stderr, "setup failed: %v\n", err)
os.Exit(1)
}
defer os.RemoveAll(tmpDir)
sysVmDir := filepath.Join(tmpDir, "sys", "vm")
if err := os.MkdirAll(sysVmDir, 0755); err != nil {
fmt.Fprintf(os.Stderr, "setup failed to create sys/vm dir: %v\n", err)
os.Exit(1)
}
entries := map[string]string{
"swappiness": "60\n",
"dirty_ratio": "20\n",
"dirty_background_ratio": "10\n",
"overcommit_memory": "1\n",
"max_map_count": "65530\n",
"drop_caches": "0\n",
"page-cluster": "3\n",
"vfs_cache_pressure": "100\n",
"admin_reserve_kbytes": "8192\n",
"stat_interval": "1\n",
"lowmem_reserve_ratio": "256 256 32 0 0\n",
"numa_zonelist_order": "Node\n",
}
for name, content := range entries {
filePath := filepath.Join(sysVmDir, name)
if err := os.WriteFile(filePath, []byte(content), 0644); err != nil {
fmt.Fprintf(os.Stderr, "setup failed to write file %s: %v\n", name, err)
os.Exit(1)
}
}
fs, err := procfs.NewFS(tmpDir)
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewFS failed: %v\n", err)
os.Exit(1)
}
vm, err := fs.VM()
if err != nil {
fmt.Fprintf(os.Stderr, "fs.VM() failed: %v\n", err)
os.Exit(1)
}
if vm == nil {
fmt.Fprintf(os.Stderr, "fs.VM() returned nil VM struct\n")
os.Exit(1)
}
// 1. procfs.FS.VM reads and parses numerical sysctl virtual memory parameters from sys/vm
if vm.Swappiness == nil || *vm.Swappiness != 60 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: swappiness expected 60, got %v\n", vm.Swappiness)
os.Exit(1)
}
if vm.DirtyRatio == nil || *vm.DirtyRatio != 20 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: dirty_ratio expected 20, got %v\n", vm.DirtyRatio)
os.Exit(1)
}
if vm.DirtyBackgroundRatio == nil || *vm.DirtyBackgroundRatio != 10 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: dirty_background_ratio expected 10, got %v\n", vm.DirtyBackgroundRatio)
os.Exit(1)
}
if vm.OvercommitMemory == nil || *vm.OvercommitMemory != 1 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: overcommit_memory expected 1, got %v\n", vm.OvercommitMemory)
os.Exit(1)
}
if vm.MaxMapCount == nil || *vm.MaxMapCount != 65530 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: max_map_count expected 65530, got %v\n", vm.MaxMapCount)
os.Exit(1)
}
if vm.DropCaches == nil || *vm.DropCaches != 0 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: drop_caches expected 0, got %v\n", vm.DropCaches)
os.Exit(1)
}
if vm.PageCluster == nil || *vm.PageCluster != 3 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: page-cluster expected 3, got %v\n", vm.PageCluster)
os.Exit(1)
}
if vm.VfsCachePressure == nil || *vm.VfsCachePressure != 100 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: vfs_cache_pressure expected 100, got %v\n", vm.VfsCachePressure)
os.Exit(1)
}
if vm.AdminReserveKbytes == nil || *vm.AdminReserveKbytes != 8192 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: admin_reserve_kbytes expected 8192, got %v\n", vm.AdminReserveKbytes)
os.Exit(1)
}
if vm.StatInterval == nil || *vm.StatInterval != 1 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: stat_interval expected 1, got %v\n", vm.StatInterval)
os.Exit(1)
}
// 2. procfs.FS.VM parses lowmem_reserve_ratio as an array of numerical values
if len(vm.LowmemReserveRatio) != 5 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: lowmem_reserve_ratio expected length 5, got %d\n", len(vm.LowmemReserveRatio))
os.Exit(1)
}
expectedRatios := []int64{256, 256, 32, 0, 0}
for i, expected := range expectedRatios {
if vm.LowmemReserveRatio[i] == nil || *vm.LowmemReserveRatio[i] != expected {
fmt.Fprintf(os.Stderr, "assertion 2 failed: lowmem_reserve_ratio[%d] expected %d, got %v\n", i, expected, vm.LowmemReserveRatio[i])
os.Exit(1)
}
}
// 3. procfs.FS.VM parses numa_zonelist_order as a string
if vm.NumaZonelistOrder != "Node" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: numa_zonelist_order expected 'Node', got %q\n", vm.NumaZonelistOrder)
os.Exit(1)
}
// 4. procfs.FS.VM returns an error when sys/vm does not exist or is not a directory
emptyDir, err := os.MkdirTemp("", "procfs-empty-*")
if err != nil {
fmt.Fprintf(os.Stderr, "setup for empty dir failed: %v\n", err)
os.Exit(1)
}
defer os.RemoveAll(emptyDir)
emptyFS, err := procfs.NewFS(emptyDir)
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewFS for emptyDir failed: %v\n", err)
os.Exit(1)
}
if _, err := emptyFS.VM(); err == nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected error when sys/vm does not exist, got nil\n")
os.Exit(1)
}
fileDir, err := os.MkdirTemp("", "procfs-file-*")
if err != nil {
fmt.Fprintf(os.Stderr, "setup for file dir failed: %v\n", err)
os.Exit(1)
}
defer os.RemoveAll(fileDir)
if err := os.MkdirAll(filepath.Join(fileDir, "sys"), 0755); err != nil {
fmt.Fprintf(os.Stderr, "setup for file dir sys failed: %v\n", err)
os.Exit(1)
}
if err := os.WriteFile(filepath.Join(fileDir, "sys", "vm"), []byte("not a directory"), 0644); err != nil {
fmt.Fprintf(os.Stderr, "setup for file dir sys/vm file failed: %v\n", err)
os.Exit(1)
}
fileFS, err := procfs.NewFS(fileDir)
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewFS for fileDir failed: %v\n", err)
os.Exit(1)
}
if _, err := fileFS.VM(); err == nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected error when sys/vm is not a directory, got nil\n")
os.Exit(1)
}
// 5. procfs.FS.VM returns an error when sys/vm parameter value cannot be parsed as an integer
corruptDir, err := os.MkdirTemp("", "procfs-corrupt-*")
if err != nil {
fmt.Fprintf(os.Stderr, "setup for corrupt dir failed: %v\n", err)
os.Exit(1)
}
defer os.RemoveAll(corruptDir)
corruptSysVm := filepath.Join(corruptDir, "sys", "vm")
if err := os.MkdirAll(corruptSysVm, 0755); err != nil {
fmt.Fprintf(os.Stderr, "setup for corrupt sys/vm failed: %v\n", err)
os.Exit(1)
}
if err := os.WriteFile(filepath.Join(corruptSysVm, "swappiness"), []byte("invalid_int\n"), 0644); err != nil {
fmt.Fprintf(os.Stderr, "setup for corrupt swappiness failed: %v\n", err)
os.Exit(1)
}
corruptFS, err := procfs.NewFS(corruptDir)
if err != nil {
fmt.Fprintf(os.Stderr, "procfs.NewFS for corruptDir failed: %v\n", err)
os.Exit(1)
}
if _, err := corruptFS.VM(); err == nil {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected error when swappiness is not a number, got nil\n")
os.Exit(1)
}
fmt.Println("PASS: all procfs.FS.VM contract assertions passed")
}
Origin Seeder
anonymous