CodeSampleX

Exemple

github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b: Name

Échantillon vérifié pour golang github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b: Name. Le contrat s'est exécuté sur go 1.26 · linux…

sha256:0f8cd26be78e3cf1a62eac4e953715e9da52e6462300a7f7abced59064d1a4c7

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

Cas

HOW
Objectif
verify github.com/ianlancetaylor/demangle.Name in pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b
Paquets
Symboles
  • github.com/ianlancetaylor/demangle.Name
Créé
2026-10-13T23:04:01Z

Contrat

  1. demangle.ToAST("_Z3foov", demangle.NoParams) returns *demangle.Name with Name == "foo"
  2. (*demangle.Name).GoString() returns "Name: foo" and demangle.ASTToString returns "foo"
  3. (*demangle.Name).Traverse invokes the callback with the *demangle.Name node
  4. (*demangle.Name).Copy returns the transformed AST when skip is false and nil when skip is true

Fichiers

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract.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 github.com/ianlancetaylor/demangle.Name in pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b
Demonstrate these symbols/APIs:
  - github.com/ianlancetaylor/demangle.Name

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:f0e6f53ca5ec98855f4d0d4e18b5eafa05dd521d9f6ed776f955aa303da9ddab","contract":["demangle.ToAST(\"_Z3foov\", demangle.NoParams) returns *demangle.Name with Name == \"foo\"","(*demangle.Name).GoString() returns \"Name: foo\" and demangle.ASTToString returns \"foo\"","(*demangle.Name).Traverse invokes the callback with the *demangle.Name node","(*demangle.Name).Copy returns the transformed AST when skip is false and nil when skip is true"],"goal":"verify github.com/ianlancetaylor/demangle.Name in pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b","kind":"HOW","packages":["pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b"],"schemaVersion":1,"symbols":["github.com/ianlancetaylor/demangle.Name"]},"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/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b"],"schemaVersion":1,"subject":"pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b","symbols":["github.com/ianlancetaylor/demangle.Name"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b
go.sum
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b h1:ogbOPx86mIhFy764gGkqnkFC8m5PJA7sPzlk9ppLVQA=
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/ianlancetaylor/demangle.Name in pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/ianlancetaylor/demangle@v0.0.0-20250417193237-f615e6bd150b"
  ],
  "symbols": [
    "github.com/ianlancetaylor/demangle.Name"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/ianlancetaylor/demangle"
)

func main() {
	ast, err := demangle.ToAST("_Z3foov", demangle.NoParams)
	if err != nil {
		fmt.Fprintf(os.Stderr, "unexpected ToAST error: %v\n", err)
		os.Exit(1)
	}

	parsedName, ok := ast.(*demangle.Name)
	if !ok {
		fmt.Fprintf(os.Stderr, "expected *demangle.Name, got %T\n", ast)
		os.Exit(1)
	}
	if parsedName.Name != "foo" {
		fmt.Fprintf(os.Stderr, "expected Name field to be 'foo', got %q\n", parsedName.Name)
		os.Exit(1)
	}

	if got := parsedName.GoString(); got != "Name: foo" {
		fmt.Fprintf(os.Stderr, "expected GoString 'Name: foo', got %q\n", got)
		os.Exit(1)
	}

	if got := demangle.ASTToString(parsedName); got != "foo" {
		fmt.Fprintf(os.Stderr, "expected ASTToString 'foo', got %q\n", got)
		os.Exit(1)
	}

	var visited []string
	parsedName.Traverse(func(a demangle.AST) bool {
		if n, ok := a.(*demangle.Name); ok {
			visited = append(visited, n.Name)
		}
		return true
	})
	if len(visited) != 1 || visited[0] != "foo" {
		fmt.Fprintf(os.Stderr, "unexpected Traverse result: %v\n", visited)
		os.Exit(1)
	}

	copied := parsedName.Copy(
		func(a demangle.AST) demangle.AST {
			return &demangle.Name{Name: "bar"}
		},
		func(a demangle.AST) bool {
			return false
		},
	)
	copiedName, ok := copied.(*demangle.Name)
	if !ok || copiedName.Name != "bar" {
		fmt.Fprintf(os.Stderr, "unexpected Copy result: %#v\n", copied)
		os.Exit(1)
	}

	skipped := parsedName.Copy(
		func(a demangle.AST) demangle.AST {
			return &demangle.Name{Name: "bar"}
		},
		func(a demangle.AST) bool {
			return true
		},
	)
	if skipped != nil {
		fmt.Fprintf(os.Stderr, "expected nil when skip returns true, got %#v\n", skipped)
		os.Exit(1)
	}
}

Seeder d'origine

anonyme