샘플
github.com/kr/pty v1.1.8
검증된 샘플 — golang github.com/kr/pty v1.1.8. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: pty.Open opens a connected pseudo-terminal master and…
sha256:5eec50dc9e5762039dbc8a22dbd833e5fbfc52814156dcba806d8462b7bc3650
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-14 |
케이스
HOW- 목표
- verify pkg:golang/github.com/kr/pty@v1.1.8
- 환경
- go 1.26.6
- 생성일
- 2026-09-14T23:31:03Z
컨트랙트
- pty.Open opens a connected pseudo-terminal master and slave pair returning valid file descriptors
- pty.Setsize configures terminal window dimensions and pty.Getsize retrieves the rows and columns
- pty.GetsizeFull retrieves complete terminal size description including row, column, and pixel dimensions
- pty.InheritSize propagates terminal window dimensions from pty master to slave tty
- pty.Winsize defines terminal geometry with rows, columns, and graphic pixel dimensions
- pty.Open enables attaching slave tty to command standard streams and capturing output from master pty
- pty.Start returns an error on modern Go runtimes due to child file descriptor constraints
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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/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
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:b528b3906f4734c3c368636cd416d00ec894dd64e287c6105cbe818abe43b2ba","contract":["pty.Open opens a connected pseudo-terminal master and slave pair returning valid file descriptors","pty.Setsize configures terminal window dimensions and pty.Getsize retrieves the rows and columns","pty.GetsizeFull retrieves complete terminal size description including row, column, and pixel dimensions","pty.InheritSize propagates terminal window dimensions from pty master to slave tty","pty.Winsize defines terminal geometry with rows, columns, and graphic pixel dimensions","pty.Open enables attaching slave tty to command standard streams and capturing output from master pty","pty.Start returns an error on modern Go runtimes due to child file descriptor constraints"],"goal":"verify pkg:golang/github.com/kr/pty@v1.1.8","kind":"HOW","packages":["pkg:golang/github.com/kr/pty@v1.1.8"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","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/kr/pty@v1.1.8"],"schemaVersion":1,"subject":"pkg:golang/github.com/kr/pty@v1.1.8","verifierAdapter":"golang@1"}
module 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 (
"bytes"
"fmt"
"io"
"os/exec"
"github.com/kr/pty"
)
func runCommandInPty(name string, args ...string) (string, error) {
master, slave, err := pty.Open()
if err != nil {
return "", err
}
defer master.Close()
size := &pty.Winsize{
Rows: 24,
Cols: 80,
}
if err := pty.Setsize(master, size); err != nil {
slave.Close()
return "", err
}
cmd := exec.Command(name, args...)
cmd.Stdin = slave
cmd.Stdout = slave
cmd.Stderr = slave
if err := cmd.Start(); err != nil {
slave.Close()
return "", err
}
// Close slave in parent so EOF is triggered when command completes
slave.Close()
var buf bytes.Buffer
_, _ = io.Copy(&buf, master)
_ = cmd.Wait()
return buf.String(), nil
}
func main() {
// Demonstrate opening a standalone pty pair
master, slave, err := pty.Open()
if err != nil {
fmt.Printf("failed to open pty: %v\n", err)
return
}
defer master.Close()
defer slave.Close()
size := &pty.Winsize{Rows: 30, Cols: 100}
if err := pty.Setsize(master, size); err != nil {
fmt.Printf("failed to set size: %v\n", err)
return
}
rows, cols, err := pty.Getsize(master)
if err != nil {
fmt.Printf("failed to get size: %v\n", err)
return
}
fmt.Printf("PTY initialized: %dx%d\n", rows, cols)
// Run a command inside a pty
output, err := runCommandInPty("echo", "hello from pty")
if err != nil {
fmt.Printf("command failed: %v\n", err)
return
}
fmt.Printf("Command output: %s", output)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/kr/pty@v1.1.8",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/kr/pty@v1.1.8"
]
}
package main
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"
"github.com/kr/pty"
)
func main() {
// Assertion 1: pty.Open opens a connected pseudo-terminal master and slave pair returning valid file descriptors
{
ptyFile, ttyFile, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: Open returned error: %v\n", err)
os.Exit(1)
}
if ptyFile == nil || ttyFile == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: nil file pointer\n")
os.Exit(1)
}
if ptyFile.Fd() == 0 || ttyFile.Fd() == 0 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: invalid file descriptor\n")
os.Exit(1)
}
ptyFile.Close()
ttyFile.Close()
}
// Assertion 2: pty.Setsize configures terminal window dimensions and pty.Getsize retrieves the rows and columns
{
ptyFile, ttyFile, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Open returned error: %v\n", err)
os.Exit(1)
}
defer ptyFile.Close()
defer ttyFile.Close()
ws := &pty.Winsize{Rows: 24, Cols: 80}
if err := pty.Setsize(ptyFile, ws); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Setsize returned error: %v\n", err)
os.Exit(1)
}
rows, cols, err := pty.Getsize(ptyFile)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Getsize returned error: %v\n", err)
os.Exit(1)
}
if rows != 24 || cols != 80 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 24x80, got %dx%d\n", rows, cols)
os.Exit(1)
}
}
// Assertion 3: pty.GetsizeFull retrieves complete terminal size description including row, column, and pixel dimensions
{
ptyFile, ttyFile, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: Open returned error: %v\n", err)
os.Exit(1)
}
defer ptyFile.Close()
defer ttyFile.Close()
ws := &pty.Winsize{Rows: 30, Cols: 100, X: 800, Y: 600}
if err := pty.Setsize(ptyFile, ws); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: Setsize returned error: %v\n", err)
os.Exit(1)
}
fullSize, err := pty.GetsizeFull(ptyFile)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: GetsizeFull returned error: %v\n", err)
os.Exit(1)
}
if fullSize == nil || fullSize.Rows != 30 || fullSize.Cols != 100 || fullSize.X != 800 || fullSize.Y != 600 {
fmt.Fprintf(os.Stderr, "assertion 3 failed: unexpected full size: %+v\n", fullSize)
os.Exit(1)
}
}
// Assertion 4: pty.InheritSize propagates terminal window dimensions from pty master to slave tty
{
ptyFile, ttyFile, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: Open returned error: %v\n", err)
os.Exit(1)
}
defer ptyFile.Close()
defer ttyFile.Close()
ws := &pty.Winsize{Rows: 40, Cols: 120}
if err := pty.Setsize(ptyFile, ws); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: Setsize returned error: %v\n", err)
os.Exit(1)
}
if err := pty.InheritSize(ptyFile, ttyFile); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: InheritSize returned error: %v\n", err)
os.Exit(1)
}
rows, cols, err := pty.Getsize(ttyFile)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: Getsize on tty returned error: %v\n", err)
os.Exit(1)
}
if rows != 40 || cols != 120 {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected 40x120 on tty, got %dx%d\n", rows, cols)
os.Exit(1)
}
}
// Assertion 5: pty.Winsize defines terminal geometry with rows, columns, and graphic pixel dimensions
{
ws := pty.Winsize{
Rows: 25,
Cols: 80,
X: 640,
Y: 480,
}
if ws.Rows != 25 || ws.Cols != 80 || ws.X != 640 || ws.Y != 480 {
fmt.Fprintf(os.Stderr, "assertion 5 failed: Winsize field mismatch: %+v\n", ws)
os.Exit(1)
}
}
// Assertion 6: pty.Open enables attaching slave tty to command standard streams and capturing output from master pty
{
ptyFile, ttyFile, err := pty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 6 failed: Open returned error: %v\n", err)
os.Exit(1)
}
defer ptyFile.Close()
cmd := exec.Command("echo", "contract-test-output")
cmd.Stdin = ttyFile
cmd.Stdout = ttyFile
cmd.Stderr = ttyFile
if err := cmd.Start(); err != nil {
ttyFile.Close()
fmt.Fprintf(os.Stderr, "assertion 6 failed: cmd.Start returned error: %v\n", err)
os.Exit(1)
}
// Close tty in parent process so slave descriptor is exclusively owned by child,
// allowing EOF to be detected on ptyFile when child terminates.
ttyFile.Close()
var buf bytes.Buffer
_, _ = io.Copy(&buf, ptyFile)
if err := cmd.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "assertion 6 failed: cmd.Wait returned error: %v\n", err)
os.Exit(1)
}
output := buf.String()
if !strings.Contains(output, "contract-test-output") {
fmt.Fprintf(os.Stderr, "assertion 6 failed: output %q did not contain expected text\n", output)
os.Exit(1)
}
}
// Assertion 7: pty.Start returns an error on modern Go runtimes due to child file descriptor constraints
{
cmd := exec.Command("echo", "test-pty-start")
f, err := pty.Start(cmd)
if err == nil {
f.Close()
fmt.Fprintf(os.Stderr, "assertion 7 failed: expected pty.Start to return error on Go 1.15+\n")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
오리진 시더
익명