Exemplo
github.com/kr/pty v1.1.8: pty
Amostra verificada para golang github.com/kr/pty v1.1.8: pty. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:f9d84a3ba6e10d54d89d67b4e49e8fe5a0c2530b3ef6aaf25eb664785d7ced78
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-15 |
Caso
HOW- Objetivo
- verify pty in pkg:golang/github.com/kr/pty@v1.1.8
- Pacotes
- Símbolos
-
- pty
- Criado
- 2026-09-15T00:05:28Z
Contrato
- pty.Open returns non-nil pty master and pts slave terminal files
- pty.Setsize and pty.Getsize configure and report terminal window rows and columns
- pty.GetsizeFull returns Winsize matching configured rows and columns
- pty.InheritSize propagates window dimensions from pty master to slave
- data written to slave terminal is received on pty master
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código-fonte
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 pty in pkg:golang/github.com/kr/pty@v1.1.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/kr/pty@v1.1.8
Demonstrate these symbols/APIs:
- pty
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:934ec249eb61c1b4087a0381f5533535861bf452645516259d56087276ebda94","contract":["pty.Open returns non-nil pty master and pts slave terminal files","pty.Setsize and pty.Getsize configure and report terminal window rows and columns","pty.GetsizeFull returns Winsize matching configured rows and columns","pty.InheritSize propagates window dimensions from pty master to slave","data written to slave terminal is received on pty master"],"goal":"verify pty in pkg:golang/github.com/kr/pty@v1.1.8","kind":"HOW","packages":["pkg:golang/github.com/kr/pty@v1.1.8"],"schemaVersion":1,"symbols":["pty"]},"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/kr/pty@v1.1.8"],"schemaVersion":1,"subject":"pkg:golang/github.com/kr/pty@v1.1.8","symbols":["pty"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/kr/pty v1.1.8
require (
github.com/creack/pty v1.1.7 // indirect
golang.org/x/sys v0.48.0 // indirect
)
github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
package main
import (
"fmt"
"os"
"github.com/kr/pty"
)
func main() {
ptmx, pts, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "failed to open pty: %v\n", err)
os.Exit(1)
}
defer ptmx.Close()
defer pts.Close()
size := &pty.Winsize{Rows: 24, Cols: 80}
if err := pty.Setsize(ptmx, size); err != nil {
fmt.Fprintf(os.Stderr, "failed to set size: %v\n", err)
os.Exit(1)
}
rows, cols, err := pty.Getsize(ptmx)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to get size: %v\n", err)
os.Exit(1)
}
fmt.Printf("pty window size: rows=%d, cols=%d\n", rows, cols)
message := []byte("hello from pty\n")
if _, err := pts.Write(message); err != nil {
fmt.Fprintf(os.Stderr, "failed to write to slave: %v\n", err)
os.Exit(1)
}
buf := make([]byte, 64)
n, err := ptmx.Read(buf)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to read from master: %v\n", err)
os.Exit(1)
}
fmt.Printf("received on master: %s", string(buf[:n]))
}
{
"schemaVersion": 1,
"goal": "verify pty in pkg:golang/github.com/kr/pty@v1.1.8",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/kr/pty@v1.1.8"
],
"symbols": [
"pty"
]
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/kr/pty"
)
func main() {
if err := runContractTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
func runContractTests() error {
// 1. pty.Open returns non-nil pty master and pts slave terminal files
ptmx, pts, err := pty.Open()
if err != nil {
return fmt.Errorf("pty.Open failed: %w", err)
}
defer ptmx.Close()
defer pts.Close()
if ptmx == nil || pts == nil {
return fmt.Errorf("pty.Open returned nil file descriptor")
}
if ptmx.Fd() == 0 || pts.Fd() == 0 {
return fmt.Errorf("invalid file descriptor returned")
}
// 2. pty.Setsize and pty.Getsize configure and report terminal window rows and columns
initialSize := &pty.Winsize{Rows: 30, Cols: 100, X: 0, Y: 0}
if err := pty.Setsize(ptmx, initialSize); err != nil {
return fmt.Errorf("pty.Setsize failed: %w", err)
}
rows, cols, err := pty.Getsize(ptmx)
if err != nil {
return fmt.Errorf("pty.Getsize failed: %w", err)
}
if rows != 30 || cols != 100 {
return fmt.Errorf("expected rows=30, cols=100; got rows=%d, cols=%d", rows, cols)
}
// 3. pty.GetsizeFull returns Winsize matching configured rows and columns
fullSize, err := pty.GetsizeFull(ptmx)
if err != nil {
return fmt.Errorf("pty.GetsizeFull failed: %w", err)
}
if fullSize.Rows != 30 || fullSize.Cols != 100 {
return fmt.Errorf("expected fullSize rows=30, cols=100; got rows=%d, cols=%d", fullSize.Rows, fullSize.Cols)
}
// 4. pty.InheritSize propagates window dimensions from pty master to slave
newSize := &pty.Winsize{Rows: 48, Cols: 132, X: 1280, Y: 800}
if err := pty.Setsize(ptmx, newSize); err != nil {
return fmt.Errorf("pty.Setsize newSize failed: %w", err)
}
if err := pty.InheritSize(ptmx, pts); err != nil {
return fmt.Errorf("pty.InheritSize failed: %w", err)
}
slaveRows, slaveCols, err := pty.Getsize(pts)
if err != nil {
return fmt.Errorf("pty.Getsize(pts) failed: %w", err)
}
if slaveRows != 48 || slaveCols != 132 {
return fmt.Errorf("expected slave rows=48, cols=132; got rows=%d, cols=%d", slaveRows, slaveCols)
}
// 5. data written to slave terminal is received on pty master
payload := []byte("CodeSampleX verification payload\n")
if _, err := pts.Write(payload); err != nil {
return fmt.Errorf("pts.Write failed: %w", err)
}
buf := make([]byte, 128)
n, err := ptmx.Read(buf)
if err != nil {
return fmt.Errorf("ptmx.Read failed: %w", err)
}
if !bytes.Contains(buf[:n], []byte("CodeSampleX verification payload")) {
return fmt.Errorf("expected ptmx buffer to contain payload, got: %q", string(buf[:n]))
}
return nil
}
Seeder de origem
anônimo