CodeSampleX

Sample

github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74: None

Verified sample for golang github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74: None. The contract ran on go 1.26 · linux debian/x64 · docker and…

sha256:4de3624efed7a1cd98187a8a446c975a5ec57b0b230fd170374be312e98e670c

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-03

Case

HOW
Goal
verify github.com/vishvananda/netns.None in pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74
Packages
Symbols
  • github.com/vishvananda/netns.None
Created
2026-09-03T04:10:13Z

Contract

  1. netns.None returns a sentinel NsHandle with file descriptor value -1
  2. netns.None sentinel reports IsOpen as false
  3. netns.None returns "NS(none)" from UniqueId and "NS(None)" from String
  4. netns.None equals another netns.None handle but does not equal an active namespace handle
  5. netns.Set fails with an error when called with netns.None

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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 github.com/vishvananda/netns.None in pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74
Demonstrate these symbols/APIs:
  - github.com/vishvananda/netns.None

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.
csx.json
{"case":{"caseId":"case:sha256:c7b469a763711708c28463e38c3a5d7ebdfff18b662db35b1e51b195538d3b25","contract":["netns.None returns a sentinel NsHandle with file descriptor value -1","netns.None sentinel reports IsOpen as false","netns.None returns \"NS(none)\" from UniqueId and \"NS(None)\" from String","netns.None equals another netns.None handle but does not equal an active namespace handle","netns.Set fails with an error when called with netns.None"],"goal":"verify github.com/vishvananda/netns.None in pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74","kind":"HOW","packages":["pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74"],"schemaVersion":1,"symbols":["github.com/vishvananda/netns.None"]},"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/vishvananda/netns@v0.0.0-20211101163701-50045581ed74"],"schemaVersion":1,"subject":"pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74","symbols":["github.com/vishvananda/netns.None"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74

require golang.org/x/sys v0.2.0 // indirect
go.sum
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
main.go
package main

import (
	"fmt"
	"os"

	"github.com/vishvananda/netns"
)

// DemonstrateSentinelUsage prints the characteristics of netns.None().
func DemonstrateSentinelUsage() {
	none := netns.None()
	fmt.Printf("Sentinel handle descriptor: %d\n", int(none))
	fmt.Printf("Is sentinel handle open: %v\n", none.IsOpen())
	fmt.Printf("Sentinel UniqueId: %s\n", none.UniqueId())
	fmt.Printf("Sentinel String representation: %s\n", none.String())
}

func main() {
	DemonstrateSentinelUsage()

	none := netns.None()
	if none.IsOpen() {
		fmt.Fprintf(os.Stderr, "Error: None handle must not be open\n")
		os.Exit(1)
	}

	anotherNone := netns.None()
	if !none.Equal(anotherNone) {
		fmt.Fprintf(os.Stderr, "Error: None handles must be equal to each other\n")
		os.Exit(1)
	}

	err := netns.Set(none)
	if err == nil {
		fmt.Fprintf(os.Stderr, "Error: setting netns.None should fail\n")
		os.Exit(1)
	}
	fmt.Println("Demonstration finished successfully")
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/vishvananda/netns.None in pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/vishvananda/netns@v0.0.0-20211101163701-50045581ed74"
  ],
  "symbols": [
    "github.com/vishvananda/netns.None"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/vishvananda/netns"
)

func main() {
	// Assertion 1: netns.None returns a sentinel NsHandle with file descriptor value -1
	none := netns.None()
	if int(none) != -1 {
		fmt.Fprintf(os.Stderr, "FAIL: expected netns.None() to have int value -1, got %d\n", int(none))
		os.Exit(1)
	}

	// Assertion 2: netns.None sentinel reports IsOpen as false
	if none.IsOpen() {
		fmt.Fprintf(os.Stderr, "FAIL: expected netns.None().IsOpen() to be false, got true\n")
		os.Exit(1)
	}

	// Assertion 3: netns.None returns "NS(none)" from UniqueId and "NS(None)" from String
	if uid := none.UniqueId(); uid != "NS(none)" {
		fmt.Fprintf(os.Stderr, "FAIL: expected netns.None().UniqueId() == \"NS(none)\", got %q\n", uid)
		os.Exit(1)
	}
	if str := none.String(); str != "NS(None)" {
		fmt.Fprintf(os.Stderr, "FAIL: expected netns.None().String() == \"NS(None)\", got %q\n", str)
		os.Exit(1)
	}

	// Assertion 4: netns.None equals another netns.None handle but does not equal an active namespace handle
	secondNone := netns.None()
	if !none.Equal(secondNone) {
		fmt.Fprintf(os.Stderr, "FAIL: expected two netns.None handles to be equal\n")
		os.Exit(1)
	}
	curNs, err := netns.Get()
	if err == nil {
		defer curNs.Close()
		if none.Equal(curNs) {
			fmt.Fprintf(os.Stderr, "FAIL: netns.None must not equal an open namespace handle\n")
			os.Exit(1)
		}
		if curNs.Equal(none) {
			fmt.Fprintf(os.Stderr, "FAIL: open namespace handle must not equal netns.None\n")
			os.Exit(1)
		}
	}

	// Assertion 5: netns.Set fails with an error when called with netns.None
	if err := netns.Set(none); err == nil {
		fmt.Fprintf(os.Stderr, "FAIL: expected netns.Set(netns.None()) to fail, but succeeded\n")
		os.Exit(1)
	}

	fmt.Println("PASS: netns.None contract passed")
}

Origin Seeder

anonymous