CodeSampleX

Ejemplo

google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda

Muestra verificada para golang google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda. El contrato se ejecutó en go 1.26 · linux…

sha256:ce1b78205e8018aa177148010312892b137e000562a3a5710f9fcc3a37b1fb80

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 linux 24 · ubuntu · glibc 2.39 x64 go

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

Caso

HOW
Objetivo
verify pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda
Paquetes
Creado
2026-10-11T06:17:25Z

Contrato

  1. LaunchStage enum constants map to defined numeric values from UNSPECIFIED (0) through PRELAUNCH (7)
  2. LaunchStage.String() returns canonical string representations matching enum names
  3. LaunchStage.Number() returns protoreflect.EnumNumber matching the underlying int32 value
  4. LaunchStage.Enum() returns a typed pointer referencing the current LaunchStage value
  5. LaunchStage.Descriptor() provides valid protoreflect.EnumDescriptor with name 'LaunchStage' containing 8 defined values
  6. GetLaunchStageName and IsGA helper functions correctly evaluate LaunchStage values

Archivos

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

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

Código fuente

NOTES.md
# Google APIs LaunchStage Enum Verification

This sample verifies the enum values, reflection behavior, and descriptor properties of `google.golang.org/genproto/googleapis/api.LaunchStage` in `google.golang.org/genproto/googleapis/api` at version `v0.0.0-20251029180050-ab9386a59fda`.

## Observed Behavior

1. **Enum Value Mapping**:
   - `LaunchStage_LAUNCH_STAGE_UNSPECIFIED` = 0
   - `LaunchStage_EARLY_ACCESS` = 1
   - `LaunchStage_ALPHA` = 2
   - `LaunchStage_BETA` = 3
   - `LaunchStage_GA` = 4
   - `LaunchStage_DEPRECATED` = 5
   - `LaunchStage_UNIMPLEMENTED` = 6
   - `LaunchStage_PRELAUNCH` = 7

2. **String and Protoreflect Integration**:
   - `LaunchStage.String()` returns canonical string representations matching the protobuf enum value names without the `LaunchStage_` prefix.
   - `LaunchStage.Number()` returns a `protoreflect.EnumNumber` equal to the underlying integer value.
   - `LaunchStage.Enum()` returns a typed pointer referencing the current `LaunchStage` value.

3. **Descriptor Inspection**:
   - `LaunchStage.Descriptor()` returns the protobuf enum descriptor with name `LaunchStage` containing all 8 defined value descriptors.
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/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda

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:164d7fea06785fca459db8f4f08a439ba5d64083935b2826054fda560ae4f047","contract":["LaunchStage enum constants map to defined numeric values from UNSPECIFIED (0) through PRELAUNCH (7)","LaunchStage.String() returns canonical string representations matching enum names","LaunchStage.Number() returns protoreflect.EnumNumber matching the underlying int32 value","LaunchStage.Enum() returns a typed pointer referencing the current LaunchStage value","LaunchStage.Descriptor() provides valid protoreflect.EnumDescriptor with name 'LaunchStage' containing 8 defined values","GetLaunchStageName and IsGA helper functions correctly evaluate LaunchStage values"],"goal":"verify pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda"],"schemaVersion":1},"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/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.24.0

require (
	google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda
	google.golang.org/protobuf v1.36.10
)
go.sum
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda h1:+2XxjfsAu6vqFxwGBRcHiMaDCuZiqXGDUDVWVtrFAnE=
google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
launch_stage.go
package sample

import (
	"google.golang.org/genproto/googleapis/api"
)

// GetLaunchStageName returns the canonical string name of a LaunchStage.
func GetLaunchStageName(stage api.LaunchStage) string {
	return stage.String()
}

// IsGA returns true if the launch stage is GA.
func IsGA(stage api.LaunchStage) bool {
	return stage == api.LaunchStage_GA
}

// IsEarlyAccess returns true if the launch stage is EARLY_ACCESS.
func IsEarlyAccess(stage api.LaunchStage) bool {
	return stage == api.LaunchStage_EARLY_ACCESS
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20251029180050-ab9386a59fda"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/api"
	"google.golang.org/protobuf/reflect/protoreflect"
	"sample"
)

func main() {
	// Assertion 1: LaunchStage enum constants map to defined numeric values from UNSPECIFIED (0) through PRELAUNCH (7)
	testCases := []struct {
		stage    api.LaunchStage
		expected int32
		strName  string
	}{
		{api.LaunchStage_LAUNCH_STAGE_UNSPECIFIED, 0, "LAUNCH_STAGE_UNSPECIFIED"},
		{api.LaunchStage_EARLY_ACCESS, 1, "EARLY_ACCESS"},
		{api.LaunchStage_ALPHA, 2, "ALPHA"},
		{api.LaunchStage_BETA, 3, "BETA"},
		{api.LaunchStage_GA, 4, "GA"},
		{api.LaunchStage_DEPRECATED, 5, "DEPRECATED"},
		{api.LaunchStage_UNIMPLEMENTED, 6, "UNIMPLEMENTED"},
		{api.LaunchStage_PRELAUNCH, 7, "PRELAUNCH"},
	}

	for _, tc := range testCases {
		if int32(tc.stage) != tc.expected {
			fmt.Fprintf(os.Stderr, "expected int32 value %d for %s, got %d\n", tc.expected, tc.strName, int32(tc.stage))
			os.Exit(1)
		}

		// Assertion 2: LaunchStage.String() returns canonical string representations matching enum names
		if tc.stage.String() != tc.strName {
			fmt.Fprintf(os.Stderr, "expected String() %q for stage %d, got %q\n", tc.strName, tc.expected, tc.stage.String())
			os.Exit(1)
		}

		// Assertion 3: LaunchStage.Number() returns protoreflect.EnumNumber matching the underlying int32 value
		if tc.stage.Number() != protoreflect.EnumNumber(tc.expected) {
			fmt.Fprintf(os.Stderr, "expected Number() %d for %s, got %d\n", tc.expected, tc.strName, tc.stage.Number())
			os.Exit(1)
		}

		// Assertion 4: LaunchStage.Enum() returns a typed pointer referencing the current LaunchStage value
		enumPtr := tc.stage.Enum()
		if enumPtr == nil || *enumPtr != tc.stage {
			fmt.Fprintf(os.Stderr, "expected Enum() pointer to hold %v, got %v\n", tc.stage, enumPtr)
			os.Exit(1)
		}
	}

	// Assertion 5: LaunchStage.Descriptor() provides valid protoreflect.EnumDescriptor with name 'LaunchStage' containing 8 defined values
	desc := api.LaunchStage_GA.Descriptor()
	if desc == nil {
		fmt.Fprintf(os.Stderr, "expected non-nil EnumDescriptor from LaunchStage.Descriptor()\n")
		os.Exit(1)
	}
	if desc.Name() != "LaunchStage" {
		fmt.Fprintf(os.Stderr, "expected EnumDescriptor name 'LaunchStage', got %q\n", desc.Name())
		os.Exit(1)
	}
	values := desc.Values()
	if values.Len() != 8 {
		fmt.Fprintf(os.Stderr, "expected 8 enum values in descriptor, got %d\n", values.Len())
		os.Exit(1)
	}

	// Assertion 6: GetLaunchStageName and IsGA helper functions correctly evaluate LaunchStage values
	if name := sample.GetLaunchStageName(api.LaunchStage_GA); name != "GA" {
		fmt.Fprintf(os.Stderr, "expected 'GA', got %q\n", name)
		os.Exit(1)
	}
	if !sample.IsGA(api.LaunchStage_GA) {
		fmt.Fprintf(os.Stderr, "expected IsGA to be true for LaunchStage_GA\n")
		os.Exit(1)
	}
	if sample.IsGA(api.LaunchStage_BETA) {
		fmt.Fprintf(os.Stderr, "expected IsGA to be false for LaunchStage_BETA\n")
		os.Exit(1)
	}

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

Seeder de origen

anónimo