Sample
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: attribute_context.AttributeContext_Api
Verified sample for golang google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: attribute_context.AttributeContext_Api. The contract…
sha256:420bbe1137cfcdea01d05ab8660d42530e1c22e9a8b37a923ba172433669dc2e
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
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
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-07 |
Case
HOW- Goal
- verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
- Symbols
-
- google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api
- Environment
- go 1.26.6
- Created
- 2026-09-07T06:25:19Z
Contract
- AttributeContext_Api getters return empty strings for a nil receiver and return configured field values when set
- AttributeContext_Api serializes and deserializes accurately using proto.Marshal and proto.Unmarshal preserving all attributes
- AttributeContext_Api.Reset resets all fields to empty string zero values
- AttributeContext.GetApi returns nil for uninitialized context and returns the configured AttributeContext_Api instance when set
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
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/rpc/context/attribute_context.AttributeContext_Api in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api
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.
{"case":{"caseId":"case:sha256:36427265c5e5e508d4374aad5040259fb814ec3fc3170e61a6fd8f35d478699f","contract":["AttributeContext_Api getters return empty strings for a nil receiver and return configured field values when set","AttributeContext_Api serializes and deserializes accurately using proto.Marshal and proto.Unmarshal preserving all attributes","AttributeContext_Api.Reset resets all fields to empty string zero values","AttributeContext.GetApi returns nil for uninitialized context and returns the configured AttributeContext_Api instance when set"],"goal":"verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api"]},"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/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5","symbols":["google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5
google.golang.org/protobuf v1.36.12
)
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/rpc v0.0.0-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package main
import (
"fmt"
"google.golang.org/genproto/googleapis/rpc/context/attribute_context"
"google.golang.org/protobuf/proto"
)
func main() {
api := &attribute_context.AttributeContext_Api{
Service: "example.com",
Operation: "ExampleService.Echo",
Protocol: "grpc",
Version: "v1",
}
fmt.Printf("Service: %s\n", api.GetService())
fmt.Printf("Operation: %s\n", api.GetOperation())
fmt.Printf("Protocol: %s\n", api.GetProtocol())
fmt.Printf("Version: %s\n", api.GetVersion())
attrCtx := &attribute_context.AttributeContext{
Api: api,
}
fmt.Printf("Context Api Service: %s\n", attrCtx.GetApi().GetService())
data, err := proto.Marshal(api)
if err != nil {
panic(err)
}
var decoded attribute_context.AttributeContext_Api
if err := proto.Unmarshal(data, &decoded); err != nil {
panic(err)
}
fmt.Printf("Decoded service: %s\n", decoded.GetService())
api.Reset()
fmt.Printf("After reset service: %q\n", api.GetService())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Api"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/rpc/context/attribute_context"
"google.golang.org/protobuf/proto"
)
func main() {
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: %v\n", err)
os.Exit(1)
}
fmt.Println("PASS: all contract assertions satisfied")
}
func runContract() error {
// 1. AttributeContext_Api getters return empty strings for a nil receiver and return configured field values when set
var nilApi *attribute_context.AttributeContext_Api
if got := nilApi.GetService(); got != "" {
return fmt.Errorf("nilApi.GetService() = %q, want empty", got)
}
if got := nilApi.GetOperation(); got != "" {
return fmt.Errorf("nilApi.GetOperation() = %q, want empty", got)
}
if got := nilApi.GetProtocol(); got != "" {
return fmt.Errorf("nilApi.GetProtocol() = %q, want empty", got)
}
if got := nilApi.GetVersion(); got != "" {
return fmt.Errorf("nilApi.GetVersion() = %q, want empty", got)
}
api := &attribute_context.AttributeContext_Api{
Service: "example.com",
Operation: "ExampleService.Echo",
Protocol: "grpc",
Version: "v1",
}
if api.GetService() != "example.com" {
return fmt.Errorf("api.GetService() = %q, want %q", api.GetService(), "example.com")
}
if api.GetOperation() != "ExampleService.Echo" {
return fmt.Errorf("api.GetOperation() = %q, want %q", api.GetOperation(), "ExampleService.Echo")
}
if api.GetProtocol() != "grpc" {
return fmt.Errorf("api.GetProtocol() = %q, want %q", api.GetProtocol(), "grpc")
}
if api.GetVersion() != "v1" {
return fmt.Errorf("api.GetVersion() = %q, want %q", api.GetVersion(), "v1")
}
// 2. AttributeContext_Api serializes and deserializes accurately using proto.Marshal and proto.Unmarshal preserving all attributes
data, err := proto.Marshal(api)
if err != nil {
return fmt.Errorf("proto.Marshal failed: %w", err)
}
var decoded attribute_context.AttributeContext_Api
if err := proto.Unmarshal(data, &decoded); err != nil {
return fmt.Errorf("proto.Unmarshal failed: %w", err)
}
if decoded.GetService() != "example.com" || decoded.GetOperation() != "ExampleService.Echo" ||
decoded.GetProtocol() != "grpc" || decoded.GetVersion() != "v1" {
return fmt.Errorf("deserialized api mismatch: %+v", decoded)
}
// 3. AttributeContext_Api.Reset resets all fields to empty string zero values
cloneApi := &attribute_context.AttributeContext_Api{
Service: "service.example.com",
Operation: "Op",
Protocol: "http",
Version: "v2",
}
cloneApi.Reset()
if cloneApi.GetService() != "" || cloneApi.GetOperation() != "" ||
cloneApi.GetProtocol() != "" || cloneApi.GetVersion() != "" {
return fmt.Errorf("after Reset(), api not cleared: %+v", cloneApi)
}
// 4. AttributeContext.GetApi returns nil for uninitialized context and returns the configured AttributeContext_Api instance when set
var nilCtx *attribute_context.AttributeContext
if got := nilCtx.GetApi(); got != nil {
return fmt.Errorf("nilCtx.GetApi() = %v, want nil", got)
}
emptyCtx := &attribute_context.AttributeContext{}
if got := emptyCtx.GetApi(); got != nil {
return fmt.Errorf("emptyCtx.GetApi() = %v, want nil", got)
}
ctxWithApi := &attribute_context.AttributeContext{
Api: api,
}
if got := ctxWithApi.GetApi(); got != api {
return fmt.Errorf("ctxWithApi.GetApi() = %v, want %v", got, api)
}
return nil
}
Origin Seeder
anonymous