CodeSampleX

Sample

golang.org/x/term v0.0.0-20210927222741-03fcf44c2211: IsTerminal

Verified sample for golang golang.org/x/term v0.0.0-20210927222741-03fcf44c2211: IsTerminal. The contract ran on go 1.26 · linux alpine/x64 · docker and…

sha256:38c145bd2255afe98fbcf0759d22bdc628680de1feea8c5b169042b4eeeddb22

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

Case

HOW
Goal
verify term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
Packages
Symbols
  • term.IsTerminal
Created
2026-08-29T14:03:53Z

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 term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
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:9758649c2562b71492f13867887dbdfaebc975602ef89d1c607d4895070e6f40","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 term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211","kind":"HOW","packages":["pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211"],"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.0.0-20210927222741-03fcf44c2211"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211","symbols":["term.IsTerminal"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.0

require golang.org/x/term v0.0.0-20210927222741-03fcf44c2211

require golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
go.sum
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
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 term.IsTerminal in pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211"
  ],
  "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