Exemple
google.golang.org/grpc v1.82.0: codes.FailedPrecondition
Échantillon vérifié pour golang google.golang.org/grpc v1.82.0: codes.FailedPrecondition. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et…
sha256:220dd7382b520a3a0c57dd0ad0132bbaf03dcd11ce336b227cc3d036f8bc6810
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-12 |
Cas
HOW- Objectif
- verify google.golang.org/grpc/codes.FailedPrecondition in pkg:golang/google.golang.org/grpc@v1.82.0
- Paquets
- Symboles
-
- google.golang.org/grpc/codes.FailedPrecondition
- Créé
- 2026-10-12T09:33:00Z
Contrat
- codes.FailedPrecondition has integer code value 9 and String() representation "FailedPrecondition".
- status.New creates a status error with codes.FailedPrecondition and the specified message.
- status.Code extracts codes.FailedPrecondition from status errors created with codes.FailedPrecondition.
- codes.Code unmarshals the JSON string "FAILED_PRECONDITION" and integer 9 into codes.FailedPrecondition.
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code 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 google.golang.org/grpc/codes.FailedPrecondition in pkg:golang/google.golang.org/grpc@v1.82.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/grpc@v1.82.0
Demonstrate these symbols/APIs:
- google.golang.org/grpc/codes.FailedPrecondition
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:35377df26c419878e9355349568c378858b59713349618480f108a8b066f7721","contract":["codes.FailedPrecondition has integer code value 9 and String() representation \"FailedPrecondition\".","status.New creates a status error with codes.FailedPrecondition and the specified message.","status.Code extracts codes.FailedPrecondition from status errors created with codes.FailedPrecondition.","codes.Code unmarshals the JSON string \"FAILED_PRECONDITION\" and integer 9 into codes.FailedPrecondition."],"goal":"verify google.golang.org/grpc/codes.FailedPrecondition in pkg:golang/google.golang.org/grpc@v1.82.0","kind":"HOW","packages":["pkg:golang/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"symbols":["google.golang.org/grpc/codes.FailedPrecondition"]},"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/google.golang.org/grpc@v1.82.0"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/grpc@v1.82.0","symbols":["google.golang.org/grpc/codes.FailedPrecondition"],"verifierAdapter":"golang@1"}
module example.com/failedprecondition
go 1.26.6
require google.golang.org/grpc v1.82.0
require (
golang.org/x/sys v0.43.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
google.golang.org/protobuf v1.36.11 // indirect
)
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package main
import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func main() {
code := codes.FailedPrecondition
fmt.Printf("Code: %d, Name: %s\n", code, code.String())
err := status.Error(codes.FailedPrecondition, "resource state does not satisfy operation prerequisites")
fmt.Printf("Status error: %v, Code: %v\n", err, status.Code(err))
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/grpc/codes.FailedPrecondition in pkg:golang/google.golang.org/grpc@v1.82.0",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/grpc@v1.82.0"
],
"symbols": [
"google.golang.org/grpc/codes.FailedPrecondition"
]
}
package main
import (
"encoding/json"
"fmt"
"os"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func main() {
// Assertion 1: codes.FailedPrecondition has integer code value 9 and String() representation "FailedPrecondition".
if uint32(codes.FailedPrecondition) != 9 {
fmt.Fprintf(os.Stderr, "FAIL: expected codes.FailedPrecondition value 9, got %d\n", uint32(codes.FailedPrecondition))
os.Exit(1)
}
if codes.FailedPrecondition.String() != "FailedPrecondition" {
fmt.Fprintf(os.Stderr, "FAIL: expected String() 'FailedPrecondition', got %q\n", codes.FailedPrecondition.String())
os.Exit(1)
}
// Assertion 2: status.New creates a status error with codes.FailedPrecondition and the specified message.
msg := "precondition verification failed"
st := status.New(codes.FailedPrecondition, msg)
if st.Code() != codes.FailedPrecondition {
fmt.Fprintf(os.Stderr, "FAIL: expected status Code() FailedPrecondition, got %v\n", st.Code())
os.Exit(1)
}
if st.Message() != msg {
fmt.Fprintf(os.Stderr, "FAIL: expected status Message() %q, got %q\n", msg, st.Message())
os.Exit(1)
}
// Assertion 3: status.Code extracts codes.FailedPrecondition from status errors created with codes.FailedPrecondition.
err := st.Err()
if status.Code(err) != codes.FailedPrecondition {
fmt.Fprintf(os.Stderr, "FAIL: expected status.Code(err) FailedPrecondition, got %v\n", status.Code(err))
os.Exit(1)
}
errDirect := status.Error(codes.FailedPrecondition, "direct error")
if status.Code(errDirect) != codes.FailedPrecondition {
fmt.Fprintf(os.Stderr, "FAIL: expected status.Code(errDirect) FailedPrecondition, got %v\n", status.Code(errDirect))
os.Exit(1)
}
// Assertion 4: codes.Code unmarshals the JSON string "FAILED_PRECONDITION" and integer 9 into codes.FailedPrecondition.
var codeFromString codes.Code
if err := json.Unmarshal([]byte(`"FAILED_PRECONDITION"`), &codeFromString); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to unmarshal 'FAILED_PRECONDITION': %v\n", err)
os.Exit(1)
}
if codeFromString != codes.FailedPrecondition {
fmt.Fprintf(os.Stderr, "FAIL: expected codes.FailedPrecondition from string, got %v\n", codeFromString)
os.Exit(1)
}
var codeFromInt codes.Code
if err := json.Unmarshal([]byte(`9`), &codeFromInt); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: failed to unmarshal 9: %v\n", err)
os.Exit(1)
}
if codeFromInt != codes.FailedPrecondition {
fmt.Fprintf(os.Stderr, "FAIL: expected codes.FailedPrecondition from int 9, got %v\n", codeFromInt)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Seeder d'origine
anonyme