CodeSampleX

Exemple

github.com/google/uuid v1.6.0

Échantillon vérifié pour golang github.com/google/uuid v1.6.0. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a réussi.

sha256:40e31ec292ca9704e42ea297fa880c783e4f51e4318ffc7b2015bcc3a758e4b5

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
4
Clés de signature qui l’ont compilé
1
Environnement déclaré host 1.27 windows 10 x64 go 1.27 go go 1 vm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · golang@1
2026-08-23
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · golang@1
2026-08-23
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-23
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · golang@1
2026-09-07

Cas

HOW
Objectif
verify pkg:golang/github.com/google/uuid@v1.6.0
Paquets
Environnement
host 1.27.0
Créé
2026-08-20T01:45:42Z

Contrat

  1. GenerateV4 returns a valid RFC4122 version 4 UUID with length 36
  2. GenerateV7 returns a valid RFC4122 version 7 UUID
  3. ParseUUID parses canonical UUID strings and round-trips with FormatUUID
  4. ParseUUID returns an error when given invalid UUID strings

Fichiers

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract_test.go
  • uuid_sample.go

Télécharger l’artefact source (tar.gz)

Code 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/google/uuid@v1.6.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/google/uuid@v1.6.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@11.17.0
  - runtime: node@24.19.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:b59a5f38f65cc98b422ddba1765e18fcc527f2fbad770ecbb1320b157306a58e","constraints":{"executionContext":"host"},"contract":["GenerateV4 returns a valid RFC4122 version 4 UUID with length 36","GenerateV7 returns a valid RFC4122 version 7 UUID","ParseUUID parses canonical UUID strings and round-trips with FormatUUID","ParseUUID returns an error when given invalid UUID strings"],"goal":"verify pkg:golang/github.com/google/uuid@v1.6.0","kind":"HOW","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","ecosystem":"golang","executionContext":"host","language":"go","moduleSystem":"module","os":"windows","osVersionBucket":"10","packageManager":"go","packageManagerVersion":"1.27.0","runtime":"go","runtimeVersion":"1.27.0","schemaVersion":1,"virtualization":"vm"},"license":"MIT-0","packages":["pkg:golang/github.com/google/uuid@v1.6.0"],"schemaVersion":1,"verifierAdapter":"golang@1"}
go.mod
module example.com/uuid-sample

go 1.22.0

require github.com/google/uuid v1.6.0
go.sum
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/google/uuid@v1.6.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/google/uuid@v1.6.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@11.17.0",
    "runtime": "node@24.19.0"
  }
}
test/contract_test.go
package test

import (
	"testing"

	sample "example.com/uuid-sample"
	"github.com/google/uuid"
)

func TestUUIDV4Generation(t *testing.T) {
	u, err := sample.GenerateV4()
	if err != nil {
		t.Fatalf("unexpected error generating v4 UUID: %v", err)
	}
	if u.Version() != 4 {
		t.Fatalf("expected UUID version 4, got %v", u.Version())
	}
	if u.Variant() != uuid.RFC4122 {
		t.Fatalf("expected RFC4122 variant, got %v", u.Variant())
	}
	if len(u.String()) != 36 {
		t.Fatalf("expected string length 36, got %d", len(u.String()))
	}
}

func TestUUIDV7Generation(t *testing.T) {
	u, err := sample.GenerateV7()
	if err != nil {
		t.Fatalf("unexpected error generating v7 UUID: %v", err)
	}
	if u.Version() != 7 {
		t.Fatalf("expected UUID version 7, got %v", u.Version())
	}
	if u.Variant() != uuid.RFC4122 {
		t.Fatalf("expected RFC4122 variant, got %v", u.Variant())
	}
}

func TestUUIDParseAndFormat(t *testing.T) {
	raw := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
	u, err := sample.ParseUUID(raw)
	if err != nil {
		t.Fatalf("failed to parse valid UUID: %v", err)
	}
	formatted := sample.FormatUUID(u)
	if formatted != raw {
		t.Fatalf("expected round-trip formatted %s, got %s", raw, formatted)
	}
}

func TestUUIDInvalidParsing(t *testing.T) {
	invalid := "not-a-valid-uuid"
	_, err := sample.ParseUUID(invalid)
	if err == nil {
		t.Fatalf("expected error parsing invalid UUID, got nil")
	}
}
uuid_sample.go
package sample

import (
	"github.com/google/uuid"
)

// GenerateV4 generates a new random UUID (version 4).
func GenerateV4() (uuid.UUID, error) {
	return uuid.NewRandom()
}

// GenerateV7 generates a new time-ordered UUID (version 7).
func GenerateV7() (uuid.UUID, error) {
	return uuid.NewV7()
}

// ParseUUID parses a canonical UUID string representation.
func ParseUUID(s string) (uuid.UUID, error) {
	return uuid.Parse(s)
}

// FormatUUID returns the canonical string representation of a UUID.
func FormatUUID(u uuid.UUID) string {
	return u.String()
}

Seeder d'origine

anonyme