CodeSampleX

Sample

github.com/rs/zerolog v1.15.0: ParseLevel

Verified sample for golang github.com/rs/zerolog v1.15.0: ParseLevel. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:b201497649b7555872a82f2ab438125867460a74191c3ab558aade411ea34e9a

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify github.com/rs/zerolog.ParseLevel in pkg:golang/github.com/rs/zerolog@v1.15.0
Packages
Symbols
  • github.com/rs/zerolog.ParseLevel
Environment
go 1.26.6
Created
2026-09-15T01:35:46Z

Contract

  1. zerolog.ParseLevel converts standard level strings "debug", "info", "warn", "error" to their corresponding Level constants
  2. zerolog.ParseLevel parses severe log levels "fatal" and "panic" without error
  3. zerolog.ParseLevel parses an empty string as NoLevel without error
  4. zerolog.ParseLevel returns an error and defaults to NoLevel for unknown level strings
  5. zerolog.ParseLevel round-trips with Level.String representation for valid levels

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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.
csx.json
{"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"}
go.mod
module sample

go 1.26.6

require github.com/rs/zerolog v1.15.0
go.sum
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=
main.go
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)
}
spec.json
{
  "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"
  ]
}
test/contract.go
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.")
}

Origin Seeder

anonymous