CodeSampleX

Sample

google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7: serviceconfig.Service

Verified sample for golang google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7: serviceconfig.Service. The contract ran on go 1.26 …

sha256:e8acf53eecd350d0aed42ea2723a806861d7fdc8478230ab3a508c34bee2c9fd

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

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

Case

HOW
Goal
verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
Packages
Symbols
  • google.golang.org/genproto/googleapis/api/serviceconfig.Service
Created
2026-09-01T11:32:24Z

Contract

  1. serviceconfig.Service can be instantiated with Name, Title, Id, and ProducerProjectId
  2. Service.GetName returns the configured service name
  3. Service.GetTitle returns the configured service title
  4. Service.GetId returns the configured service ID
  5. Service.GetProducerProjectId returns the configured producer project ID
  6. NewService helper creates a configured serviceconfig.Service
  7. GetServiceName, GetServiceTitle, GetServiceId, and GetProducerProjectId return the respective field values
  8. GetServiceName returns empty string on nil service

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • service.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 google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
Demonstrate these symbols/APIs:
  - google.golang.org/genproto/googleapis/api/serviceconfig.Service

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:c975b0f430bdffcfc2e2e41ca03289c26283265e4216cb3acd857d822ec40008","contract":["serviceconfig.Service can be instantiated with Name, Title, Id, and ProducerProjectId","Service.GetName returns the configured service name","Service.GetTitle returns the configured service title","Service.GetId returns the configured service ID","Service.GetProducerProjectId returns the configured producer project ID","NewService helper creates a configured serviceconfig.Service","GetServiceName, GetServiceTitle, GetServiceId, and GetProducerProjectId return the respective field values","GetServiceName returns empty string on nil service"],"goal":"verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/api/serviceconfig.Service"]},"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-20240826202546-f6391c0de4c7"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7","symbols":["google.golang.org/genproto/googleapis/api/serviceconfig.Service"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.22

require google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7

require google.golang.org/protobuf v1.34.2 // indirect
go.sum
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
service.go
package sample

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

// NewService creates a new serviceconfig.Service instance with provided metadata.
func NewService(name, title, id, producerProjectId string) *serviceconfig.Service {
	return &serviceconfig.Service{
		Name:              name,
		Title:             title,
		Id:                id,
		ProducerProjectId: producerProjectId,
	}
}

// GetServiceName returns the name of the service using GetName().
func GetServiceName(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetName()
}

// GetServiceTitle returns the title of the service using GetTitle().
func GetServiceTitle(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetTitle()
}

// GetServiceId returns the ID of the service using GetId().
func GetServiceId(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetId()
}

// GetProducerProjectId returns the producer project ID of the service using GetProducerProjectId().
func GetProducerProjectId(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetProducerProjectId()
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7"
  ],
  "symbols": [
    "google.golang.org/genproto/googleapis/api/serviceconfig.Service"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/api/serviceconfig"
	"sample"
)

func main() {
	// Assertion 1: instantiate serviceconfig.Service directly
	svc := &serviceconfig.Service{
		Name:              "endpoints.example.com",
		Title:             "Example API",
		Id:                "2024-08-26r0",
		ProducerProjectId: "example-project-123",
	}

	// Assertion 2: GetName returns the service name
	if got := svc.GetName(); got != "endpoints.example.com" {
		fmt.Fprintf(os.Stderr, "expected GetName() to return %q, got %q\n", "endpoints.example.com", got)
		os.Exit(1)
	}

	// Assertion 3: GetTitle returns the service title
	if got := svc.GetTitle(); got != "Example API" {
		fmt.Fprintf(os.Stderr, "expected GetTitle() to return %q, got %q\n", "Example API", got)
		os.Exit(1)
	}

	// Assertion 4: GetId returns the service ID
	if got := svc.GetId(); got != "2024-08-26r0" {
		fmt.Fprintf(os.Stderr, "expected GetId() to return %q, got %q\n", "2024-08-26r0", got)
		os.Exit(1)
	}

	// Assertion 5: GetProducerProjectId returns the producer project ID
	if got := svc.GetProducerProjectId(); got != "example-project-123" {
		fmt.Fprintf(os.Stderr, "expected GetProducerProjectId() to return %q, got %q\n", "example-project-123", got)
		os.Exit(1)
	}

	// Assertion 6: Helper NewService initializes fields properly
	helperSvc := sample.NewService("endpoints.example.com", "Example API", "2024-08-26r0", "example-project-123")
	if helperSvc == nil {
		fmt.Fprintf(os.Stderr, "expected NewService to return non-nil\n")
		os.Exit(1)
	}

	// Assertion 7: Helper functions extract correct field values
	if got := sample.GetServiceName(helperSvc); got != "endpoints.example.com" {
		fmt.Fprintf(os.Stderr, "expected GetServiceName() to return %q, got %q\n", "endpoints.example.com", got)
		os.Exit(1)
	}
	if got := sample.GetServiceTitle(helperSvc); got != "Example API" {
		fmt.Fprintf(os.Stderr, "expected GetServiceTitle() to return %q, got %q\n", "Example API", got)
		os.Exit(1)
	}
	if got := sample.GetServiceId(helperSvc); got != "2024-08-26r0" {
		fmt.Fprintf(os.Stderr, "expected GetServiceId() to return %q, got %q\n", "2024-08-26r0", got)
		os.Exit(1)
	}
	if got := sample.GetProducerProjectId(helperSvc); got != "example-project-123" {
		fmt.Fprintf(os.Stderr, "expected GetProducerProjectId() to return %q, got %q\n", "example-project-123", got)
		os.Exit(1)
	}

	// Assertion 8: Nil safety in helper functions
	if got := sample.GetServiceName(nil); got != "" {
		fmt.Fprintf(os.Stderr, "expected GetServiceName(nil) to return empty string, got %q\n", got)
		os.Exit(1)
	}

	fmt.Println("All google.golang.org/genproto/googleapis/api/serviceconfig.Service contract assertions passed.")
}

Origin Seeder

anonymous