Пример
google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: attribute_context.AttributeContext_Resource
Проверенный пример — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5: attribute_context.AttributeContext_Resource.…
sha256:98ba0ce406ace3276a1c26200cf08fb669ee66c0d0297662b0df2945c2b1353c
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-04 |
Кейс
HOW- Цель
- verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Resource in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20260825221802-da73d73af1c5
- Символы
-
- google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Resource
- Создан
- 2026-09-04T13:12:08Z
Контракт
- AttributeContext_Resource field values and getter methods return configured attributes including Service, Name, Type, Uid, DisplayName, Etag, Location, Labels, and Annotations.
- AttributeContext_Resource nil pointer receiver methods return zero values without panicking.
- AttributeContext_Resource marshals to and unmarshals from protocol buffer wire format with field equivalence.
- AttributeContext_Resource marshals to JSON using protojson with camelCase field keys and unmarshals back to identical values.
- AttributeContext_Resource Reset clears all fields to their zero values and ProtoReflect returns descriptor matching google.rpc.context.AttributeContext.Resource.
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Исходный код
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_Resource 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_Resource
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:cbdfcda1256f2d88680a59d9a7657728a1325a61dc3914c0de0c622d7af001cd","contract":["AttributeContext_Resource field values and getter methods return configured attributes including Service, Name, Type, Uid, DisplayName, Etag, Location, Labels, and Annotations.","AttributeContext_Resource nil pointer receiver methods return zero values without panicking.","AttributeContext_Resource marshals to and unmarshals from protocol buffer wire format with field equivalence.","AttributeContext_Resource marshals to JSON using protojson with camelCase field keys and unmarshals back to identical values.","AttributeContext_Resource Reset clears all fields to their zero values and ProtoReflect returns descriptor matching google.rpc.context.AttributeContext.Resource."],"goal":"verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Resource 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_Resource"]},"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/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_Resource"],"verifierAdapter":"golang@1"}
module sample
go 1.25.0
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/types/known/timestamppb"
)
// NewSampleResource constructs an AttributeContext_Resource instance.
func NewSampleResource(service, name, resType, uid, displayName, location string) *attribute_context.AttributeContext_Resource {
return &attribute_context.AttributeContext_Resource{
Service: service,
Name: name,
Type: resType,
Uid: uid,
DisplayName: displayName,
Location: location,
CreateTime: timestamppb.Now(),
Labels: map[string]string{
"env": "production",
},
}
}
func main() {
res := NewSampleResource(
"storage.googleapis.com",
"//storage.googleapis.com/projects/_/buckets/sample-bucket",
"storage.googleapis.com/Bucket",
"res-uuid-001",
"Sample Storage Bucket",
"us-central1",
)
fmt.Printf("Resource initialized: %s (%s)\n", res.GetName(), res.GetType())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/context/attribute_context.AttributeContext_Resource 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_Resource"
]
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/rpc/context/attribute_context"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)
func main() {
now := timestamppb.Now()
// 1. AttributeContext_Resource field values and getter methods return configured attributes including Service, Name, Type, Uid, DisplayName, Etag, Location, Labels, and Annotations.
{
res := &attribute_context.AttributeContext_Resource{
Service: "storage.googleapis.com",
Name: "//storage.googleapis.com/projects/_/buckets/sample-bucket",
Type: "storage.googleapis.com/Bucket",
Labels: map[string]string{"env": "prod", "tier": "frontend"},
Uid: "uuid-9876-abcd",
Annotations: map[string]string{"managed-by": "automation"},
DisplayName: "Production Storage Bucket",
CreateTime: now,
UpdateTime: now,
Etag: "etag-v1",
Location: "us-central1",
}
if res.GetService() != "storage.googleapis.com" {
fmt.Fprintf(os.Stderr, "FAIL: GetService returned %q\n", res.GetService())
os.Exit(1)
}
if res.GetName() != "//storage.googleapis.com/projects/_/buckets/sample-bucket" {
fmt.Fprintf(os.Stderr, "FAIL: GetName returned %q\n", res.GetName())
os.Exit(1)
}
if res.GetType() != "storage.googleapis.com/Bucket" {
fmt.Fprintf(os.Stderr, "FAIL: GetType returned %q\n", res.GetType())
os.Exit(1)
}
if res.GetUid() != "uuid-9876-abcd" {
fmt.Fprintf(os.Stderr, "FAIL: GetUid returned %q\n", res.GetUid())
os.Exit(1)
}
if res.GetDisplayName() != "Production Storage Bucket" {
fmt.Fprintf(os.Stderr, "FAIL: GetDisplayName returned %q\n", res.GetDisplayName())
os.Exit(1)
}
if res.GetEtag() != "etag-v1" {
fmt.Fprintf(os.Stderr, "FAIL: GetEtag returned %q\n", res.GetEtag())
os.Exit(1)
}
if res.GetLocation() != "us-central1" {
fmt.Fprintf(os.Stderr, "FAIL: GetLocation returned %q\n", res.GetLocation())
os.Exit(1)
}
if res.GetLabels()["env"] != "prod" || res.GetLabels()["tier"] != "frontend" {
fmt.Fprintf(os.Stderr, "FAIL: GetLabels unexpected: %v\n", res.GetLabels())
os.Exit(1)
}
if res.GetAnnotations()["managed-by"] != "automation" {
fmt.Fprintf(os.Stderr, "FAIL: GetAnnotations unexpected: %v\n", res.GetAnnotations())
os.Exit(1)
}
if res.GetCreateTime().GetSeconds() != now.GetSeconds() {
fmt.Fprintf(os.Stderr, "FAIL: GetCreateTime mismatch\n")
os.Exit(1)
}
if res.GetUpdateTime().GetSeconds() != now.GetSeconds() {
fmt.Fprintf(os.Stderr, "FAIL: GetUpdateTime mismatch\n")
os.Exit(1)
}
if res.GetDeleteTime() != nil {
fmt.Fprintf(os.Stderr, "FAIL: GetDeleteTime expected nil\n")
os.Exit(1)
}
}
// 2. AttributeContext_Resource nil pointer receiver methods return zero values without panicking.
{
var nilRes *attribute_context.AttributeContext_Resource
if nilRes.GetService() != "" ||
nilRes.GetName() != "" ||
nilRes.GetType() != "" ||
nilRes.GetUid() != "" ||
nilRes.GetDisplayName() != "" ||
nilRes.GetEtag() != "" ||
nilRes.GetLocation() != "" ||
nilRes.GetLabels() != nil ||
nilRes.GetAnnotations() != nil ||
nilRes.GetCreateTime() != nil ||
nilRes.GetUpdateTime() != nil ||
nilRes.GetDeleteTime() != nil {
fmt.Fprintf(os.Stderr, "FAIL: nil receiver methods returned non-zero value\n")
os.Exit(1)
}
}
// 3. AttributeContext_Resource marshals to and unmarshals from protocol buffer wire format with field equivalence.
{
original := &attribute_context.AttributeContext_Resource{
Service: "compute.googleapis.com",
Name: "//compute.googleapis.com/projects/example-project/zones/us-central1-a/instances/vm-1",
Type: "compute.googleapis.com/Instance",
Uid: "uuid-compute-1",
DisplayName: "Primary VM",
Location: "us-central1-a",
CreateTime: now,
Labels: map[string]string{"role": "worker"},
}
wireBytes, err := proto.Marshal(original)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: proto.Marshal error: %v\n", err)
os.Exit(1)
}
var restored attribute_context.AttributeContext_Resource
if err := proto.Unmarshal(wireBytes, &restored); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: proto.Unmarshal error: %v\n", err)
os.Exit(1)
}
if !proto.Equal(original, &restored) {
fmt.Fprintf(os.Stderr, "FAIL: restored proto does not match original\n")
os.Exit(1)
}
}
// 4. AttributeContext_Resource marshals to JSON using protojson with camelCase field keys and unmarshals back to identical values.
{
original := &attribute_context.AttributeContext_Resource{
Service: "pubsub.googleapis.com",
Name: "//pubsub.googleapis.com/projects/example-project/topics/notifications",
Type: "pubsub.googleapis.com/Topic",
DisplayName: "Topic Notifications",
Location: "global",
CreateTime: now,
}
jsonData, err := protojson.Marshal(original)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: protojson.Marshal error: %v\n", err)
os.Exit(1)
}
var jsonRestored attribute_context.AttributeContext_Resource
if err := protojson.Unmarshal(jsonData, &jsonRestored); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: protojson.Unmarshal error: %v\n", err)
os.Exit(1)
}
if !proto.Equal(original, &jsonRestored) {
fmt.Fprintf(os.Stderr, "FAIL: JSON restored proto does not match original\n")
os.Exit(1)
}
}
// 5. AttributeContext_Resource Reset clears all fields to their zero values and ProtoReflect returns descriptor matching google.rpc.context.AttributeContext.Resource.
{
res := &attribute_context.AttributeContext_Resource{
Service: "logging.googleapis.com",
Name: "//logging.googleapis.com/projects/example-project/logs/syslog",
Type: "logging.googleapis.com/LogSink",
DisplayName: "Syslog Sink",
Location: "global",
Labels: map[string]string{"tier": "audit"},
}
clone := proto.Clone(res).(*attribute_context.AttributeContext_Resource)
clone.Reset()
if clone.GetService() != "" ||
clone.GetName() != "" ||
clone.GetType() != "" ||
clone.GetDisplayName() != "" ||
clone.GetLabels() != nil {
fmt.Fprintf(os.Stderr, "FAIL: Reset did not clear all fields to zero values\n")
os.Exit(1)
}
descriptor := res.ProtoReflect().Descriptor()
if string(descriptor.FullName()) != "google.rpc.context.AttributeContext.Resource" {
fmt.Fprintf(os.Stderr, "FAIL: unexpected descriptor full name: %s\n", descriptor.FullName())
os.Exit(1)
}
}
fmt.Println("All contracts verified successfully.")
}
Исходный сидер
аноним