CodeSampleX

Ejemplo

github.com/aws/smithy-go v1.28.1

Muestra verificada para golang github.com/aws/smithy-go v1.28.1. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.

sha256:60095abcdb2a416852c192585178c8f24d21feb22fc65df61dc047049baf7606

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-15

Caso

HOW
Objetivo
verify pkg:golang/github.com/aws/smithy-go@v1.28.1
Paquetes
Entorno
go 1.26.6
Creado
2026-10-15T20:51:45Z

Contrato

  1. smithy.NewSchema constructs structure and scalar schemas with ShapeID formatted as namespace#name
  2. Schema.AddMember registers a named member targeting another schema and preserves MemberName and TargetID
  3. smithy.TypeRegistry and smithy.RegistryEntry register and instantiate structure types by ShapeID string
  4. smithy.Properties zero-value instance stores and retrieves comparable key-value metadata via Set, Get, and Has
  5. smithy.GenericAPIError implements smithy.APIError and exposes ErrorCode, ErrorMessage, and ErrorFault
  6. smithy.InvalidParamsError aggregates smithy.NewErrParamRequired validation errors and reports count via Len

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/aws/smithy-go@v1.28.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/aws/smithy-go@v1.28.1

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:644bfd19590c3e6e5689774b2c54d7a281207baf0656b621c206f1c13f2432de","contract":["smithy.NewSchema constructs structure and scalar schemas with ShapeID formatted as namespace#name","Schema.AddMember registers a named member targeting another schema and preserves MemberName and TargetID","smithy.TypeRegistry and smithy.RegistryEntry register and instantiate structure types by ShapeID string","smithy.Properties zero-value instance stores and retrieves comparable key-value metadata via Set, Get, and Has","smithy.GenericAPIError implements smithy.APIError and exposes ErrorCode, ErrorMessage, and ErrorFault","smithy.InvalidParamsError aggregates smithy.NewErrParamRequired validation errors and reports count via Len"],"goal":"verify pkg:golang/github.com/aws/smithy-go@v1.28.1","kind":"HOW","packages":["pkg:golang/github.com/aws/smithy-go@v1.28.1"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","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/aws/smithy-go@v1.28.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/aws/smithy-go@v1.28.1","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.24

require github.com/aws/smithy-go v1.28.1
go.sum
github.com/aws/smithy-go v1.28.1 h1:R/nXH00c8qcfCzQVELtRw+eLQWtzv+VAIEFJ1/xxXlQ=
github.com/aws/smithy-go v1.28.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/aws/smithy-go@v1.28.1",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/aws/smithy-go@v1.28.1"
  ]
}
test/contract.go
package main

import (
	"errors"
	"fmt"
	"os"

	smithy "github.com/aws/smithy-go"
)

type SampleInput struct {
	Name string
}

func main() {
	// 1. Verify Schema construction and member lookup
	strSchema := smithy.NewSchema(
		smithy.ShapeID{Namespace: "example.service", Name: "String"},
		smithy.ShapeTypeString,
		0,
	)
	structSchema := smithy.NewSchema(
		smithy.ShapeID{Namespace: "example.service", Name: "SampleInput"},
		smithy.ShapeTypeStructure,
		1,
	)
	memberSchema := structSchema.AddMember("Name", strSchema)

	if got := structSchema.ID().String(); got != "example.service#SampleInput" {
		fmt.Fprintf(os.Stderr, "unexpected struct schema ID: %s\n", got)
		os.Exit(1)
	}
	if got := memberSchema.MemberName(); got != "Name" {
		fmt.Fprintf(os.Stderr, "unexpected member name: %s\n", got)
		os.Exit(1)
	}
	if structSchema.Member("Name") != memberSchema {
		fmt.Fprintln(os.Stderr, "expected Member(\"Name\") to return added member schema")
		os.Exit(1)
	}
	if memberSchema.TargetID().String() != "example.service#String" {
		fmt.Fprintf(os.Stderr, "unexpected target ID: %s\n", memberSchema.TargetID().String())
		os.Exit(1)
	}

	// 2. Verify TypeRegistry and RegistryEntry
	reg := &smithy.TypeRegistry{
		Entries: map[string]*smithy.TypeRegistryEntry{
			structSchema.ID().String(): smithy.RegistryEntry[SampleInput](structSchema),
		},
	}
	entry, ok := reg.LookupEntry("example.service#SampleInput")
	if !ok || entry.Schema != structSchema {
		fmt.Fprintln(os.Stderr, "failed to lookup registry entry")
		os.Exit(1)
	}
	if _, ok := entry.New().(*SampleInput); !ok {
		fmt.Fprintln(os.Stderr, "expected New() to return *SampleInput")
		os.Exit(1)
	}

	// 3. Verify Properties metadata store
	var props smithy.Properties
	props.Set("request-id", "req-001")
	if !props.Has("request-id") || props.Get("request-id") != "req-001" {
		fmt.Fprintln(os.Stderr, "unexpected properties behavior")
		os.Exit(1)
	}

	// 4. Verify APIError and InvalidParamsError
	var apiErr error = &smithy.GenericAPIError{
		Code:    "ValidationException",
		Message: "invalid input",
		Fault:   smithy.FaultClient,
	}
	var targetAPIErr smithy.APIError
	if !errors.As(apiErr, &targetAPIErr) || targetAPIErr.ErrorCode() != "ValidationException" || targetAPIErr.ErrorFault() != smithy.FaultClient {
		fmt.Fprintln(os.Stderr, "unexpected GenericAPIError behavior")
		os.Exit(1)
	}

	invalidParams := smithy.InvalidParamsError{Context: "SampleOperation"}
	invalidParams.Add(smithy.NewErrParamRequired("Name"))
	if invalidParams.Len() != 1 {
		fmt.Fprintf(os.Stderr, "expected 1 invalid param error, got %d\n", invalidParams.Len())
		os.Exit(1)
	}
}

Seeder de origen

anónimo