Sample
github.com/chzyer/readline v1.5.1: Config
Verified sample for golang github.com/chzyer/readline v1.5.1: Config. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:9759d6707465ad5c5b3b8959b93809f94a69abeef62bcac92be2c0a4ce17db37
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-06 |
Case
HOW- Goal
- verify github.com/chzyer/readline.Config in pkg:golang/github.com/chzyer/readline@v1.5.1
- Packages
- Symbols
-
- github.com/chzyer/readline.Config
- Created
- 2026-09-06T01:39:30Z
Contract
- readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts
- readline.Config.Clone yields an independent configuration instance preserving settings
- readline.Config.SetListener registers custom input event hook callback on configuration
- readline.Config.SetPainter attaches custom syntax and display painter to configuration
- readline.Config with FuncFilterInputRune intercepts and transforms input stream runes
- readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags
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.Config 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.Config
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:8147b984c3d370f75f75cefb91211372b6b35dcb735d68320e53e642d5c60701","contract":["readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts","readline.Config.Clone yields an independent configuration instance preserving settings","readline.Config.SetListener registers custom input event hook callback on configuration","readline.Config.SetPainter attaches custom syntax and display painter to configuration","readline.Config with FuncFilterInputRune intercepts and transforms input stream runes","readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags"],"goal":"verify github.com/chzyer/readline.Config 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.Config"]},"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/chzyer/readline@v1.5.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/chzyer/readline@v1.5.1","symbols":["github.com/chzyer/readline.Config"],"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"
)
// HighlightPainter implements readline.Painter to format line input.
type HighlightPainter struct{}
func (hp *HighlightPainter) Paint(line []rune, pos int) []rune {
return line
}
func main() {
// Configure readline instance with custom settings
cfg := &readline.Config{
Prompt: "demo> ",
HistoryLimit: 100,
DisableAutoSaveHistory: true,
Stdin: io.NopCloser(strings.NewReader("hello readline\n")),
Stdout: &bytes.Buffer{},
FuncFilterInputRune: func(r rune) (rune, bool) {
return r, true
},
}
cfg.SetPainter(&HighlightPainter{})
cfg.SetListener(func(line []rune, pos int, key rune) ([]rune, int, bool) {
return line, pos, true
})
rl, err := readline.NewEx(cfg)
if err != nil {
fmt.Printf("Initialization failed: %v\n", err)
return
}
defer rl.Close()
line, err := rl.Readline()
if err != nil {
fmt.Printf("Readline error: %v\n", err)
return
}
fmt.Printf("Read: %s\n", line)
}
{
"schemaVersion": 1,
"goal": "verify github.com/chzyer/readline.Config 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.Config"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
"github.com/chzyer/readline"
)
type customPainter struct {
paintCallCount int
}
func (cp *customPainter) Paint(line []rune, pos int) []rune {
cp.paintCallCount++
return []rune(strings.ToUpper(string(line)))
}
func main() {
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All readline.Config contract assertions passed successfully.")
}
func runContract() error {
// Assertion 1: readline.Config.Init establishes default parameters including HistoryLimit and interrupt prompts
cfg := &readline.Config{}
if err := cfg.Init(); err != nil {
return fmt.Errorf("cfg.Init() failed: %w", err)
}
if cfg.HistoryLimit != 500 {
return fmt.Errorf("expected default HistoryLimit=500, got %d", cfg.HistoryLimit)
}
if cfg.InterruptPrompt != "^C" {
return fmt.Errorf("expected default InterruptPrompt='^C', got %q", cfg.InterruptPrompt)
}
if cfg.EOFPrompt != "^D" {
return fmt.Errorf("expected default EOFPrompt='^D', got %q", cfg.EOFPrompt)
}
if cfg.AutoComplete == nil {
return fmt.Errorf("expected non-nil default AutoComplete")
}
// Assertion 2: readline.Config.Clone yields an independent configuration instance preserving settings
baseCfg := &readline.Config{
Prompt: "prompt1> ",
HistoryLimit: 250,
VimMode: true,
}
clonedCfg := baseCfg.Clone()
if clonedCfg.Prompt != "prompt1> " || clonedCfg.HistoryLimit != 250 || !clonedCfg.VimMode {
return fmt.Errorf("cloned config values do not match original")
}
baseCfg.Prompt = "prompt2> "
if clonedCfg.Prompt != "prompt1> " {
return fmt.Errorf("modifying base config affected cloned config prompt")
}
// Assertion 3: readline.Config.SetListener registers custom input event hook callback on configuration
listenerCfg := &readline.Config{}
var listenerInvoked bool
listenerCfg.SetListener(func(line []rune, pos int, key rune) ([]rune, int, bool) {
listenerInvoked = true
return append(line, '+'), pos + 1, true
})
if listenerCfg.Listener == nil {
return fmt.Errorf("expected listenerCfg.Listener to be non-nil after SetListener")
}
newLine, newPos, ok := listenerCfg.Listener.OnChange([]rune("cmd"), 3, 'x')
if !ok || !listenerInvoked || string(newLine) != "cmd+" || newPos != 4 {
return fmt.Errorf("listener execution failed or produced unexpected state")
}
// Assertion 4: readline.Config.SetPainter attaches custom syntax and display painter to configuration
painterCfg := &readline.Config{}
p := &customPainter{}
painterCfg.SetPainter(p)
if painterCfg.Painter != p {
return fmt.Errorf("expected painterCfg.Painter to equal set painter")
}
painted := painterCfg.Painter.Paint([]rune("syntax"), 0)
if string(painted) != "SYNTAX" || p.paintCallCount != 1 {
return fmt.Errorf("custom painter output or call count mismatch")
}
// Assertion 5: readline.Config with FuncFilterInputRune intercepts and transforms input stream runes
var filterStdout bytes.Buffer
filterCfg := &readline.Config{
Prompt: "> ",
Stdin: io.NopCloser(strings.NewReader("a#b#c\n")),
Stdout: &filterStdout,
Stderr: io.Discard,
FuncFilterInputRune: func(r rune) (rune, bool) {
if r == '#' {
return 0, false // drop '#'
}
if r >= 'a' && r <= 'z' {
return r - 32, true // convert to uppercase
}
return r, true
},
}
filterRl, err := readline.NewEx(filterCfg)
if err != nil {
return fmt.Errorf("failed to create readline with FuncFilterInputRune: %w", err)
}
defer filterRl.Close()
filteredLine, err := filterRl.Readline()
if err != nil {
return fmt.Errorf("Readline with FuncFilterInputRune failed: %w", err)
}
if filteredLine != "ABC" {
return fmt.Errorf("expected 'ABC', got %q", filteredLine)
}
// Assertion 6: readline.Config with UniqueEditLine and VimMode configures editor mode and line persistence flags
var flagStdout bytes.Buffer
flagCfg := &readline.Config{
Prompt: "flags> ",
Stdin: io.NopCloser(strings.NewReader("command\n")),
Stdout: &flagStdout,
Stderr: io.Discard,
UniqueEditLine: true,
VimMode: true,
DisableAutoSaveHistory: true,
HistorySearchFold: true,
}
if !flagCfg.UniqueEditLine || !flagCfg.VimMode || !flagCfg.DisableAutoSaveHistory || !flagCfg.HistorySearchFold {
return fmt.Errorf("configuration flags not retained on Config struct")
}
flagRl, err := readline.NewEx(flagCfg)
if err != nil {
return fmt.Errorf("NewEx failed with custom editor and history flags: %w", err)
}
defer flagRl.Close()
flagLine, err := flagRl.Readline()
if err != nil {
return fmt.Errorf("Readline failed with custom flags: %w", err)
}
if flagLine != "command" {
return fmt.Errorf("expected 'command', got %q", flagLine)
}
return nil
}
Origin Seeder
anonymous