Exemplo
github.com/pkg/sftp v1.10.1: Client
Amostra verificada para golang github.com/pkg/sftp v1.10.1: Client. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:4369bf5c6bd6dba8c1398521b90329fbb5c248965e57f76c558a8a0c4d9b7a42
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-10-20 |
Caso
HOW- Objetivo
- verify github.com/pkg/sftp.Client in pkg:golang/github.com/pkg/sftp@v1.10.1
- Pacotes
- Símbolos
-
- github.com/pkg/sftp.Client
- Criado
- 2026-10-20T14:01:14Z
Contrato
- sftp.NewClientPipe(rd, wr, sftp.MaxPacket(32768)) returns a connected *sftp.Client over an in-memory net.Pipe paired with sftp.NewRequestServer(conn, sftp.InMemHandler())
- Client.Mkdir("/data") and Client.Create("/data/hello.txt") create a directory and remote file whose written payload is persisted in the server handler
- Client.Stat("/data/hello.txt") returns os.FileInfo with Name() == "hello.txt", Size() == 17, and IsDir() == false
- Client.Open("/data/hello.txt") reads back the exact bytes written and Client.ReadDir("/data") lists the file entry
- Client.Rename("/data/hello.txt", "/data/renamed.txt"), Client.Lstat("/data/renamed.txt"), and Client.Remove("/data/renamed.txt") rename, inspect, and delete the file so a subsequent Client.Stat reports os.IsNotExist(err) == true
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- 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 github.com/pkg/sftp.Client in pkg:golang/github.com/pkg/sftp@v1.10.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/pkg/sftp@v1.10.1
Demonstrate these symbols/APIs:
- github.com/pkg/sftp.Client
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:03d948deba54d8e9d9ff12ffc6d09bb9c6219e65795a2ab21d4aa00d3ff383b9","contract":["sftp.NewClientPipe(rd, wr, sftp.MaxPacket(32768)) returns a connected *sftp.Client over an in-memory net.Pipe paired with sftp.NewRequestServer(conn, sftp.InMemHandler())","Client.Mkdir(\"/data\") and Client.Create(\"/data/hello.txt\") create a directory and remote file whose written payload is persisted in the server handler","Client.Stat(\"/data/hello.txt\") returns os.FileInfo with Name() == \"hello.txt\", Size() == 17, and IsDir() == false","Client.Open(\"/data/hello.txt\") reads back the exact bytes written and Client.ReadDir(\"/data\") lists the file entry","Client.Rename(\"/data/hello.txt\", \"/data/renamed.txt\"), Client.Lstat(\"/data/renamed.txt\"), and Client.Remove(\"/data/renamed.txt\") rename, inspect, and delete the file so a subsequent Client.Stat reports os.IsNotExist(err) == true"],"goal":"verify github.com/pkg/sftp.Client in pkg:golang/github.com/pkg/sftp@v1.10.1","kind":"HOW","packages":["pkg:golang/github.com/pkg/sftp@v1.10.1"],"schemaVersion":1,"symbols":["github.com/pkg/sftp.Client"]},"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/pkg/sftp@v1.10.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/pkg/sftp@v1.10.1","symbols":["github.com/pkg/sftp.Client"],"verifierAdapter":"golang@1"}
module sample
go 1.20
require github.com/pkg/sftp v1.10.1
require (
github.com/kr/fs v0.1.0 // indirect
github.com/pkg/errors v0.8.1 // indirect
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 // indirect
golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect
)
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1 h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 h1:7KByu05hhLed2MO29w7p1XfZvZ13m8mub3shuVftRs0=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
{
"schemaVersion": 1,
"goal": "verify github.com/pkg/sftp.Client in pkg:golang/github.com/pkg/sftp@v1.10.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/pkg/sftp@v1.10.1"
],
"symbols": [
"github.com/pkg/sftp.Client"
]
}
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"github.com/pkg/sftp"
)
func assert(cond bool, msg string) {
if !cond {
fmt.Fprintln(os.Stderr, "assertion failed:", msg)
os.Exit(1)
}
}
func main() {
serverConn, clientConn := net.Pipe()
defer serverConn.Close()
defer clientConn.Close()
server := sftp.NewRequestServer(serverConn, sftp.InMemHandler())
serverDone := make(chan error, 1)
go func() {
serverDone <- server.Serve()
}()
var client *sftp.Client
var err error
client, err = sftp.NewClientPipe(clientConn, clientConn, sftp.MaxPacket(32768))
assert(err == nil && client != nil, "NewClientPipe creates an sftp.Client")
// 1. Mkdir and Create/Write file via sftp.Client
err = client.Mkdir("/data")
assert(err == nil, "Client.Mkdir creates directory /data")
f, err := client.Create("/data/hello.txt")
assert(err == nil && f != nil, "Client.Create opens remote file for writing")
payload := []byte("hello sftp client")
n, err := f.Write(payload)
assert(err == nil && n == len(payload), "File.Write writes full payload")
assert(f.Close() == nil, "File.Close succeeds after write")
// 2. Stat and Open/Read via sftp.Client
info, err := client.Stat("/data/hello.txt")
assert(err == nil, "Client.Stat succeeds on created file")
assert(info.Name() == "hello.txt", "Client.Stat returns expected base name")
assert(info.Size() == int64(len(payload)), "Client.Stat returns expected file size")
assert(!info.IsDir(), "Client.Stat reports regular file")
rf, err := client.Open("/data/hello.txt")
assert(err == nil && rf != nil, "Client.Open opens existing remote file")
readBack, err := ioutil.ReadAll(rf)
assert(err == nil && string(readBack) == string(payload), "Client.Open reads back exact file contents")
assert(rf.Close() == nil, "File.Close succeeds after read")
// 3. ReadDir, Rename, Lstat, Remove via sftp.Client
entries, err := client.ReadDir("/data")
assert(err == nil && len(entries) == 1 && entries[0].Name() == "hello.txt", "Client.ReadDir lists directory entries")
err = client.Rename("/data/hello.txt", "/data/renamed.txt")
assert(err == nil, "Client.Rename renames remote file")
linfo, err := client.Lstat("/data/renamed.txt")
assert(err == nil && linfo.Size() == int64(len(payload)), "Client.Lstat finds renamed file")
err = client.Remove("/data/renamed.txt")
assert(err == nil, "Client.Remove deletes remote file")
_, err = client.Stat("/data/renamed.txt")
assert(os.IsNotExist(err), "Client.Stat returns os.ErrNotExist after Remove")
// 4. Close client and verify server shuts down cleanly
assert(client.Close() == nil, "Client.Close closes session cleanly")
srvErr := <-serverDone
assert(srvErr == nil || srvErr == io.EOF, "RequestServer.Serve finishes cleanly on client close")
}
Seeder de origem
anônimo