Пример
github.com/spf13/afero v1.15.0
Проверенный пример — golang github.com/spf13/afero v1.15.0. Контракт выполнен на go 1.26 · linux debian/x64 · docker и пройден.
sha256:0de8df1625798f1c110e2b7573f79857baafc7ef0dd25c754581af3e724f1a90
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-19 |
Кейс
HOW- Цель
- verify pkg:golang/github.com/spf13/afero@v1.15.0
- Окружение
- go 1.26.6
- Создан
- 2026-09-19T12:49:07Z
Контракт
- afero.NewMemMapFs creates an in-memory filesystem implementing afero.Fs
- afero.WriteFile and afero.ReadFile write and read data in an afero.Fs
- afero.Exists and afero.DirExists correctly detect files and directories
- afero.NewBasePathFs restricts filesystem operations to a base directory
- afero.NewReadOnlyFs prevents mutating write operations
Файлы
- 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/spf13/afero@v1.15.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/spf13/afero@v1.15.0
Required runtime conditions:
- ecosystem: golang
- language: go
- packageManager: go@1.26.6
- runtime: go@1.26.6
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:b2d0e1278e3702096bfe604260c845e10f61131362456763e460d5ae4d365be6","contract":["afero.NewMemMapFs creates an in-memory filesystem implementing afero.Fs","afero.WriteFile and afero.ReadFile write and read data in an afero.Fs","afero.Exists and afero.DirExists correctly detect files and directories","afero.NewBasePathFs restricts filesystem operations to a base directory","afero.NewReadOnlyFs prevents mutating write operations"],"goal":"verify pkg:golang/github.com/spf13/afero@v1.15.0","kind":"HOW","packages":["pkg:golang/github.com/spf13/afero@v1.15.0"],"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/spf13/afero@v1.15.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/spf13/afero@v1.15.0","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/spf13/afero v1.15.0
require golang.org/x/text v0.28.0 // indirect
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
package main
import (
"fmt"
"os"
"github.com/spf13/afero"
)
func main() {
fs := afero.NewMemMapFs()
filePath := "example.txt"
data := []byte("afero in-memory filesystem")
if err := afero.WriteFile(fs, filePath, data, 0644); err != nil {
fmt.Fprintf(os.Stderr, "failed to write file: %v\n", err)
os.Exit(1)
}
readBytes, err := afero.ReadFile(fs, filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to read file: %v\n", err)
os.Exit(1)
}
fmt.Printf("File content: %s\n", string(readBytes))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/spf13/afero@v1.15.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/spf13/afero@v1.15.0"
],
"runtimeConditions": {
"ecosystem": "golang",
"language": "go",
"packageManager": "go@1.26.6",
"runtime": "go@1.26.6"
}
}
package main
import (
"bytes"
"fmt"
"os"
"github.com/spf13/afero"
)
func main() {
// 1. afero.NewMemMapFs creates an in-memory filesystem implementing afero.Fs
fs := afero.NewMemMapFs()
if fs == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: NewMemMapFs returned nil\n")
os.Exit(1)
}
var _ afero.Fs = fs
// 2. afero.WriteFile and afero.ReadFile write and read data in an afero.Fs
filePath := "data/test.txt"
expectedData := []byte("contract-test-content")
if err := afero.WriteFile(fs, filePath, expectedData, 0644); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: WriteFile returned error: %v\n", err)
os.Exit(1)
}
readData, err := afero.ReadFile(fs, filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: ReadFile returned error: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(readData, expectedData) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %q, got %q\n", string(expectedData), string(readData))
os.Exit(1)
}
// 3. afero.Exists and afero.DirExists correctly detect files and directories
exists, err := afero.Exists(fs, filePath)
if err != nil || !exists {
fmt.Fprintf(os.Stderr, "assertion 3 failed: Exists(%q) = (%v, %v), expected (true, nil)\n", filePath, exists, err)
os.Exit(1)
}
notExists, err := afero.Exists(fs, "data/nonexistent.txt")
if err != nil || notExists {
fmt.Fprintf(os.Stderr, "assertion 3 failed: Exists on nonexistent returned (%v, %v), expected (false, nil)\n", notExists, err)
os.Exit(1)
}
dirExists, err := afero.DirExists(fs, "data")
if err != nil || !dirExists {
fmt.Fprintf(os.Stderr, "assertion 3 failed: DirExists(\"data\") = (%v, %v), expected (true, nil)\n", dirExists, err)
os.Exit(1)
}
fileNotDir, err := afero.DirExists(fs, filePath)
if err != nil || fileNotDir {
fmt.Fprintf(os.Stderr, "assertion 3 failed: DirExists on file returned (%v, %v), expected (false, nil)\n", fileNotDir, err)
os.Exit(1)
}
// 4. afero.NewBasePathFs restricts filesystem operations to a base directory
baseFs := afero.NewBasePathFs(fs, "data")
baseRead, err := afero.ReadFile(baseFs, "test.txt")
if err != nil || !bytes.Equal(baseRead, expectedData) {
fmt.Fprintf(os.Stderr, "assertion 4 failed: ReadFile on BasePathFs returned %q, error: %v\n", string(baseRead), err)
os.Exit(1)
}
if err := afero.WriteFile(baseFs, "nested.txt", []byte("nested-data"), 0644); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: WriteFile on BasePathFs returned error: %v\n", err)
os.Exit(1)
}
rootHasNested, err := afero.Exists(fs, "data/nested.txt")
if err != nil || !rootHasNested {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected file at \"data/nested.txt\" on root fs: %v\n", err)
os.Exit(1)
}
// 5. afero.NewReadOnlyFs prevents mutating write operations
roFs := afero.NewReadOnlyFs(fs)
roData, err := afero.ReadFile(roFs, "data/test.txt")
if err != nil || !bytes.Equal(roData, expectedData) {
fmt.Fprintf(os.Stderr, "assertion 5 failed: ReadFile on ReadOnlyFs failed: %v\n", err)
os.Exit(1)
}
if err := afero.WriteFile(roFs, "data/ro_fail.txt", []byte("should-fail"), 0644); err == nil {
fmt.Fprintf(os.Stderr, "assertion 5 failed: WriteFile on ReadOnlyFs expected error, got nil\n")
os.Exit(1)
}
fmt.Println("All contract assertions passed successfully.")
}
Исходный сидер
аноним