CodeSampleX

Sample

golang.org/x/term v0.42.0: IsTerminal

Verified sample for golang golang.org/x/term v0.42.0: IsTerminal. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:8003580c522d4dfd130a0aedc0c3c2c776a7d010d50dfe13080a8773ee9ba257

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

Case

HOW
Goal
verify pkg:golang/golang.org/x/term@v0.42.0
Packages
Symbols
  • term.IsTerminal
Created
2026-09-18T13:46:52Z

Contract

  1. term.IsTerminal returns false for invalid file descriptors
  2. term.IsTerminal returns false for regular file descriptors
  3. term.IsTerminal returns false for pipe file descriptors
  4. term.IsTerminal evaluates standard stream file descriptors without panicking

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 pkg:golang/golang.org/x/term@v0.42.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/term@v0.42.0
Demonstrate these symbols/APIs:
  - term.IsTerminal

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:c64541ce1fbb061af44c2e98241668524b47a0aae11b67548a98a4d79313c9d4","contract":["term.IsTerminal returns false for invalid file descriptors","term.IsTerminal returns false for regular file descriptors","term.IsTerminal returns false for pipe file descriptors","term.IsTerminal evaluates standard stream file descriptors without panicking"],"goal":"verify pkg:golang/golang.org/x/term@v0.42.0","kind":"HOW","packages":["pkg:golang/golang.org/x/term@v0.42.0"],"schemaVersion":1,"symbols":["term.IsTerminal"]},"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/term@v0.42.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/term@v0.42.0","symbols":["term.IsTerminal"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/term v0.42.0

require golang.org/x/sys v0.43.0 // indirect
go.sum
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
main.go
package main

import (
	"fmt"
	"os"

	"golang.org/x/term"
)

// CheckTerminal checks whether the provided file descriptor refers to a terminal.
func CheckTerminal(fd int) bool {
	return term.IsTerminal(fd)
}

func main() {
	stdinFd := int(os.Stdin.Fd())
	stdoutFd := int(os.Stdout.Fd())
	stderrFd := int(os.Stderr.Fd())

	fmt.Printf("Stdin (fd=%d) is terminal: %v\n", stdinFd, CheckTerminal(stdinFd))
	fmt.Printf("Stdout (fd=%d) is terminal: %v\n", stdoutFd, CheckTerminal(stdoutFd))
	fmt.Printf("Stderr (fd=%d) is terminal: %v\n", stderrFd, CheckTerminal(stderrFd))
	fmt.Printf("Invalid fd (-1) is terminal: %v\n", CheckTerminal(-1))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/golang.org/x/term@v0.42.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/term@v0.42.0"
  ],
  "symbols": [
    "term.IsTerminal"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"golang.org/x/term"
)

func main() {
	// Assertion 1: term.IsTerminal returns false for invalid file descriptors
	if term.IsTerminal(-1) {
		fmt.Fprintf(os.Stderr, "FAIL: expected false for fd=-1, got true\n")
		os.Exit(1)
	}
	if term.IsTerminal(-999) {
		fmt.Fprintf(os.Stderr, "FAIL: expected false for fd=-999, got true\n")
		os.Exit(1)
	}

	// Assertion 2: term.IsTerminal returns false for regular file descriptors
	tmpFile, err := os.CreateTemp("", "contract_term_test_*")
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: failed to create temporary file: %v\n", err)
		os.Exit(1)
	}
	defer os.Remove(tmpFile.Name())
	defer tmpFile.Close()

	if term.IsTerminal(int(tmpFile.Fd())) {
		fmt.Fprintf(os.Stderr, "FAIL: expected false for regular file fd, got true\n")
		os.Exit(1)
	}

	// Assertion 3: term.IsTerminal returns false for pipe file descriptors
	r, w, err := os.Pipe()
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: failed to create pipe: %v\n", err)
		os.Exit(1)
	}
	defer r.Close()
	defer w.Close()

	if term.IsTerminal(int(r.Fd())) {
		fmt.Fprintf(os.Stderr, "FAIL: expected false for pipe reader fd, got true\n")
		os.Exit(1)
	}
	if term.IsTerminal(int(w.Fd())) {
		fmt.Fprintf(os.Stderr, "FAIL: expected false for pipe writer fd, got true\n")
		os.Exit(1)
	}

	// Assertion 4: term.IsTerminal evaluates standard stream file descriptors without panicking
	_ = term.IsTerminal(int(os.Stdin.Fd()))
	_ = term.IsTerminal(int(os.Stdout.Fd()))
	_ = term.IsTerminal(int(os.Stderr.Fd()))

	fmt.Println("PASS: term.IsTerminal contract verified")
}

Origin Seeder

anonymous