Sample
github.com/chzyer/readline v1.5.1: NewEx
Verified sample for golang github.com/chzyer/readline v1.5.1: NewEx. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:2e8b97f27f0e940b10efa0c3e2729d0d9357aa6ac69f1f737418786e6fb57a0c
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
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
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-06 |
Case
HOW- Goal
- verify github.com/chzyer/readline.NewEx in pkg:golang/github.com/chzyer/readline@v1.5.1
- Packages
- Symbols
-
- github.com/chzyer/readline.NewEx
- Environment
- go 1.26.6
- Created
- 2026-09-06T02:27:53Z
Contract
- readline.NewEx creates a valid Instance from a custom Config with specified Prompt and streams
- readline.NewEx reads sequential lines from configured custom Stdin
- readline.NewEx returns io.EOF on Readline when configured Stdin is exhausted
- readline.NewEx instance allows dynamic prompt updates via SetPrompt
- readline.NewEx accepts AutoComplete prefix completer in Config
- readline.NewEx instance generates masked password config via GenPasswordConfig
- readline.NewEx instance Close method cleanly releases terminal resources
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 github.com/chzyer/readline.NewEx in pkg:golang/github.com/chzyer/readline@v1.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/chzyer/readline@v1.5.1
Demonstrate these symbols/APIs:
- github.com/chzyer/readline.NewEx
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:6141b1523971cc4fcb4ae0e32f7205e17c1b945aae27e1ef4108dfd98b49aedd","contract":["readline.NewEx creates a valid Instance from a custom Config with specified Prompt and streams","readline.NewEx reads sequential lines from configured custom Stdin","readline.NewEx returns io.EOF on Readline when configured Stdin is exhausted","readline.NewEx instance allows dynamic prompt updates via SetPrompt","readline.NewEx accepts AutoComplete prefix completer in Config","readline.NewEx instance generates masked password config via GenPasswordConfig","readline.NewEx instance Close method cleanly releases terminal resources"],"goal":"verify github.com/chzyer/readline.NewEx in pkg:golang/github.com/chzyer/readline@v1.5.1","kind":"HOW","packages":["pkg:golang/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1,"symbols":["github.com/chzyer/readline.NewEx"]},"contractCommand":["go","run","./test"],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/chzyer/readline@v1.5.1","symbols":["github.com/chzyer/readline.NewEx"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/chzyer/readline v1.5.1
require golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
package main
import (
"bytes"
"fmt"
"io"
"strings"
"github.com/chzyer/readline"
)
func main() {
// Demonstrates configuring and using readline.NewEx with custom parameters
completer := readline.NewPrefixCompleter(
readline.PcItem("help"),
readline.PcItem("version"),
readline.PcItem("exit"),
)
// In an interactive shell os.Stdin and os.Stdout are typically used,
// but NewEx allows supplying custom io.ReadCloser and io.Writer streams.
input := strings.NewReader("help\nversion\nexit\n")
output := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "demo> ",
Stdin: io.NopCloser(input),
Stdout: output,
AutoComplete: completer,
HistoryLimit: 100,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Printf("failed to initialize readline instance: %v\n", err)
return
}
defer rl.Close()
for {
line, err := rl.Readline()
if err != nil {
if err == io.EOF {
break
}
fmt.Printf("read error: %v\n", err)
break
}
fmt.Printf("received line: %s\n", line)
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/chzyer/readline.NewEx in pkg:golang/github.com/chzyer/readline@v1.5.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/chzyer/readline@v1.5.1"
],
"symbols": [
"github.com/chzyer/readline.NewEx"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
"github.com/chzyer/readline"
)
func main() {
// Contract 1: readline.NewEx creates a valid Instance from a custom Config with specified Prompt and streams
{
in := io.NopCloser(strings.NewReader("ping\npong\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "prompt> ",
Stdin: in,
Stdout: out,
HistoryLimit: 50,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 1 failed: readline.NewEx returned error: %v\n", err)
os.Exit(1)
}
if rl == nil {
fmt.Fprintln(os.Stderr, "Contract 1 failed: readline.NewEx returned nil instance")
os.Exit(1)
}
if rl.Config == nil || rl.Config.Prompt != "prompt> " {
fmt.Fprintf(os.Stderr, "Contract 1 failed: rl.Config.Prompt got %q, want %q\n", rl.Config.Prompt, "prompt> ")
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 2: readline.NewEx reads sequential lines from configured custom Stdin
{
in := io.NopCloser(strings.NewReader("first line\nsecond line\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "> ",
Stdin: in,
Stdout: out,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed: NewEx error: %v\n", err)
os.Exit(1)
}
line1, err := rl.Readline()
if err != nil || line1 != "first line" {
fmt.Fprintf(os.Stderr, "Contract 2 failed: line 1 got %q (err: %v), want %q\n", line1, err, "first line")
_ = rl.Close()
os.Exit(1)
}
line2, err := rl.Readline()
if err != nil || line2 != "second line" {
fmt.Fprintf(os.Stderr, "Contract 2 failed: line 2 got %q (err: %v), want %q\n", line2, err, "second line")
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 3: readline.NewEx returns io.EOF on Readline when configured Stdin is exhausted
{
in := io.NopCloser(strings.NewReader("only-one\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "> ",
Stdin: in,
Stdout: out,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: NewEx error: %v\n", err)
os.Exit(1)
}
_, err = rl.Readline()
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: first read error: %v\n", err)
_ = rl.Close()
os.Exit(1)
}
_, err = rl.Readline()
if err != io.EOF {
fmt.Fprintf(os.Stderr, "Contract 3 failed: expected io.EOF, got: %v\n", err)
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 4: readline.NewEx instance allows dynamic prompt updates via SetPrompt
{
in := io.NopCloser(strings.NewReader("sample\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "initial> ",
Stdin: in,
Stdout: out,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: NewEx error: %v\n", err)
os.Exit(1)
}
rl.SetPrompt("updated> ")
line, err := rl.Readline()
if err != nil || line != "sample" {
fmt.Fprintf(os.Stderr, "Contract 4 failed: Readline after SetPrompt failed: %v\n", err)
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 5: readline.NewEx accepts AutoComplete prefix completer in Config
{
completer := readline.NewPrefixCompleter(
readline.PcItem("get"),
readline.PcItem("set"),
)
in := io.NopCloser(strings.NewReader("get\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "> ",
Stdin: in,
Stdout: out,
AutoComplete: completer,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 5 failed: NewEx with AutoComplete failed: %v\n", err)
os.Exit(1)
}
if rl.Config.AutoComplete == nil {
fmt.Fprintln(os.Stderr, "Contract 5 failed: AutoComplete is nil in rl.Config")
_ = rl.Close()
os.Exit(1)
}
line, err := rl.Readline()
if err != nil || line != "get" {
fmt.Fprintf(os.Stderr, "Contract 5 failed: Readline got %q, want 'get'\n", line)
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 6: readline.NewEx instance generates masked password config via GenPasswordConfig
{
in := io.NopCloser(strings.NewReader("data\n"))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "pass> ",
Stdin: in,
Stdout: out,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed: NewEx error: %v\n", err)
os.Exit(1)
}
pwdCfg := rl.GenPasswordConfig()
if pwdCfg == nil {
fmt.Fprintln(os.Stderr, "Contract 6 failed: GenPasswordConfig returned nil")
_ = rl.Close()
os.Exit(1)
}
if !pwdCfg.EnableMask {
fmt.Fprintln(os.Stderr, "Contract 6 failed: EnableMask should be true in GenPasswordConfig")
_ = rl.Close()
os.Exit(1)
}
_ = rl.Close()
}
// Contract 7: readline.NewEx instance Close method cleanly releases terminal resources
{
in := io.NopCloser(strings.NewReader(""))
out := &bytes.Buffer{}
cfg := &readline.Config{
Prompt: "> ",
Stdin: in,
Stdout: out,
DisableAutoSaveHistory: true,
}
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 7 failed: NewEx error: %v\n", err)
os.Exit(1)
}
if err := rl.Close(); err != nil {
fmt.Fprintf(os.Stderr, "Contract 7 failed: rl.Close returned error: %v\n", err)
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
Origin Seeder
anonymous