CodeSampleX

Sample

github.com/rs/zerolog v1.15.0

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

sha256:a1bc9b731b0c75ab2ba003e55b4745b2a17b5b5fa4099adfe3fe0f2820c4a8e4

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-14

Case

HOW
Goal
verify pkg:golang/github.com/rs/zerolog@v1.15.0
Packages
Environment
go 1.26.6
Created
2026-09-14T23:12:46Z

Contract

  1. zerolog.New creates a Logger writing structured JSON to an io.Writer
  2. logger.Info writes key-value fields and message formatted as JSON
  3. logger.With creates a child logger preserving contextual fields
  4. zerolog.SetGlobalLevel filters log events below the threshold
  5. logger.WithLevel outputs log events matching the dynamic level

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 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

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:620bad11639f0206169e03b226371bb3da6de07a2172f8b3ef8d3d1dee86514a","contract":["zerolog.New creates a Logger writing structured JSON to an io.Writer","logger.Info writes key-value fields and message formatted as JSON","logger.With creates a child logger preserving contextual fields","zerolog.SetGlobalLevel filters log events below the threshold","logger.WithLevel outputs log events matching the dynamic level"],"goal":"verify pkg:golang/github.com/rs/zerolog@v1.15.0","kind":"HOW","packages":["pkg:golang/github.com/rs/zerolog@v1.15.0"],"schemaVersion":1},"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","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 (
	"os"

	"github.com/rs/zerolog"
)

func main() {
	logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
	logger.Info().Str("service", "demo").Msg("sample initialized")
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/rs/zerolog@v1.15.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/rs/zerolog@v1.15.0"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"os"

	"github.com/rs/zerolog"
)

func main() {
	// Assertion 1: zerolog.New creates a Logger writing structured JSON to an io.Writer
	{
		buf := &bytes.Buffer{}
		logger := zerolog.New(buf)
		logger.Log().Msg("test message")

		var parsed map[string]interface{}
		if err := json.Unmarshal(buf.Bytes(), &parsed); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: invalid JSON output: %v\n", err)
			os.Exit(1)
		}
		if parsed["message"] != "test message" {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: expected message %q, got %v\n", "test message", parsed["message"])
			os.Exit(1)
		}
	}

	// Assertion 2: logger.Info writes key-value fields and message formatted as JSON
	{
		buf := &bytes.Buffer{}
		logger := zerolog.New(buf)
		logger.Info().Str("env", "prod").Int("attempt", 3).Msg("operation succeeded")

		var parsed map[string]interface{}
		if err := json.Unmarshal(buf.Bytes(), &parsed); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: invalid JSON: %v\n", err)
			os.Exit(1)
		}
		if parsed["level"] != "info" || parsed["env"] != "prod" || parsed["attempt"] != float64(3) || parsed["message"] != "operation succeeded" {
			fmt.Fprintf(os.Stderr, "assertion 2 failed: field mismatch: %+v\n", parsed)
			os.Exit(1)
		}
	}

	// Assertion 3: logger.With creates a child logger preserving contextual fields
	{
		buf := &bytes.Buffer{}
		logger := zerolog.New(buf)
		child := logger.With().Str("component", "storage").Logger()
		child.Info().Msg("sync complete")

		var parsed map[string]interface{}
		if err := json.Unmarshal(buf.Bytes(), &parsed); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: invalid JSON: %v\n", err)
			os.Exit(1)
		}
		if parsed["component"] != "storage" || parsed["message"] != "sync complete" {
			fmt.Fprintf(os.Stderr, "assertion 3 failed: context field mismatch: %+v\n", parsed)
			os.Exit(1)
		}
	}

	// Assertion 4: zerolog.SetGlobalLevel filters log events below the threshold
	{
		buf := &bytes.Buffer{}
		logger := zerolog.New(buf)

		zerolog.SetGlobalLevel(zerolog.WarnLevel)
		defer zerolog.SetGlobalLevel(zerolog.DebugLevel)

		logger.Info().Msg("suppressed info message")
		if buf.Len() != 0 {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: expected info message to be suppressed, got %s\n", buf.String())
			os.Exit(1)
		}

		logger.Warn().Msg("allowed warn message")
		if buf.Len() == 0 {
			fmt.Fprintf(os.Stderr, "assertion 4 failed: expected warn message to be recorded\n")
			os.Exit(1)
		}
	}

	// Assertion 5: logger.WithLevel outputs log events matching the dynamic level
	{
		buf := &bytes.Buffer{}
		logger := zerolog.New(buf)
		logger.WithLevel(zerolog.ErrorLevel).Str("error_code", "E500").Msg("server error")

		var parsed map[string]interface{}
		if err := json.Unmarshal(buf.Bytes(), &parsed); err != nil {
			fmt.Fprintf(os.Stderr, "assertion 5 failed: invalid JSON: %v\n", err)
			os.Exit(1)
		}
		if parsed["level"] != "error" || parsed["error_code"] != "E500" || parsed["message"] != "server error" {
			fmt.Fprintf(os.Stderr, "assertion 5 failed: dynamic level mismatch: %+v\n", parsed)
			os.Exit(1)
		}
	}

	fmt.Println("All contract assertions passed successfully.")
}

Origin Seeder

anonymous