Exemple
github.com/rs/zerolog v1.15.0: ParseLevel
Échantillon vérifié pour golang github.com/rs/zerolog v1.15.0: ParseLevel. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a réussi.
sha256:b201497649b7555872a82f2ab438125867460a74191c3ab558aade411ea34e9a
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é
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
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-09-15 |
Cas
HOW- Objectif
- verify github.com/rs/zerolog.ParseLevel in pkg:golang/github.com/rs/zerolog@v1.15.0
- Paquets
- Symboles
-
- github.com/rs/zerolog.ParseLevel
- Environnement
- go 1.26.6
- Créé
- 2026-09-15T01:35:46Z
Contrat
- zerolog.ParseLevel converts standard level strings "debug", "info", "warn", "error" to their corresponding Level constants
- zerolog.ParseLevel parses severe log levels "fatal" and "panic" without error
- zerolog.ParseLevel parses an empty string as NoLevel without error
- zerolog.ParseLevel returns an error and defaults to NoLevel for unknown level strings
- zerolog.ParseLevel round-trips with Level.String representation for valid levels
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 github.com/rs/zerolog.ParseLevel in pkg:golang/github.com/rs/zerolog@v1.15.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/rs/zerolog@v1.15.0
Demonstrate these symbols/APIs:
- github.com/rs/zerolog.ParseLevel
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:b017404e254c5005ea051f7c4a3efc6e234ac19fd5aedc63b53f6e34499ac175","contract":["zerolog.ParseLevel converts standard level strings \"debug\", \"info\", \"warn\", \"error\" to their corresponding Level constants","zerolog.ParseLevel parses severe log levels \"fatal\" and \"panic\" without error","zerolog.ParseLevel parses an empty string as NoLevel without error","zerolog.ParseLevel returns an error and defaults to NoLevel for unknown level strings","zerolog.ParseLevel round-trips with Level.String representation for valid levels"],"goal":"verify github.com/rs/zerolog.ParseLevel in pkg:golang/github.com/rs/zerolog@v1.15.0","kind":"HOW","packages":["pkg:golang/github.com/rs/zerolog@v1.15.0"],"schemaVersion":1,"symbols":["github.com/rs/zerolog.ParseLevel"]},"contractCommand":["go","run","./test"],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","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/rs/zerolog@v1.15.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/rs/zerolog@v1.15.0","symbols":["github.com/rs/zerolog.ParseLevel"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/rs/zerolog v1.15.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
package main
import (
"fmt"
"github.com/rs/zerolog"
)
func main() {
levelStr := "info"
lvl, err := zerolog.ParseLevel(levelStr)
if err != nil {
fmt.Printf("failed to parse level %q: %v\n", levelStr, err)
return
}
fmt.Printf("Parsed level: %s (value: %d)\n", lvl.String(), lvl)
}
{
"schemaVersion": 1,
"goal": "verify github.com/rs/zerolog.ParseLevel in pkg:golang/github.com/rs/zerolog@v1.15.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/rs/zerolog@v1.15.0"
],
"symbols": [
"github.com/rs/zerolog.ParseLevel"
]
}
package main
import (
"fmt"
"os"
"github.com/rs/zerolog"
)
func main() {
// Assertion 1: zerolog.ParseLevel converts standard level strings "debug", "info", "warn", "error" to their corresponding Level constants
{
standards := []struct {
input string
expected zerolog.Level
}{
{"debug", zerolog.DebugLevel},
{"info", zerolog.InfoLevel},
{"warn", zerolog.WarnLevel},
{"error", zerolog.ErrorLevel},
}
for _, tc := range standards {
lvl, err := zerolog.ParseLevel(tc.input)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected error for %q: %v\n", tc.input, err)
os.Exit(1)
}
if lvl != tc.expected {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected %v, got %v for %q\n", tc.expected, lvl, tc.input)
os.Exit(1)
}
}
}
// Assertion 2: zerolog.ParseLevel parses severe log levels "fatal" and "panic" without error
{
severe := []struct {
input string
expected zerolog.Level
}{
{"fatal", zerolog.FatalLevel},
{"panic", zerolog.PanicLevel},
}
for _, tc := range severe {
lvl, err := zerolog.ParseLevel(tc.input)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: unexpected error for %q: %v\n", tc.input, err)
os.Exit(1)
}
if lvl != tc.expected {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %v, got %v for %q\n", tc.expected, lvl, tc.input)
os.Exit(1)
}
}
}
// Assertion 3: zerolog.ParseLevel parses an empty string as NoLevel without error
{
lvl, err := zerolog.ParseLevel("")
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: unexpected error for empty string: %v\n", err)
os.Exit(1)
}
if lvl != zerolog.NoLevel {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected NoLevel (%v), got %v\n", zerolog.NoLevel, lvl)
os.Exit(1)
}
}
// Assertion 4: zerolog.ParseLevel returns an error and defaults to NoLevel for unknown level strings
{
invalidInputs := []string{"invalid", "unknown", "DEBUG", "TRACE"}
for _, input := range invalidInputs {
lvl, err := zerolog.ParseLevel(input)
if err == nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected error for invalid level %q, got nil\n", input)
os.Exit(1)
}
if lvl != zerolog.NoLevel {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected default NoLevel (%v) for %q, got %v\n", zerolog.NoLevel, input, lvl)
os.Exit(1)
}
}
}
// Assertion 5: zerolog.ParseLevel round-trips with Level.String representation for valid levels
{
levels := []zerolog.Level{
zerolog.DebugLevel,
zerolog.InfoLevel,
zerolog.WarnLevel,
zerolog.ErrorLevel,
zerolog.FatalLevel,
zerolog.PanicLevel,
}
for _, l := range levels {
str := l.String()
parsed, err := zerolog.ParseLevel(str)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 5 failed: failed to re-parse level string %q: %v\n", str, err)
os.Exit(1)
}
if parsed != l {
fmt.Fprintf(os.Stderr, "assertion 5 failed: round-trip mismatch: original %v, parsed %v\n", l, parsed)
os.Exit(1)
}
}
}
fmt.Println("All contract assertions passed successfully.")
}
Seeder d'origine
anonyme