Пример
go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_BoolValue
Проверенный пример — golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_BoolValue. Контракт выполнен на go 1.26 · linux debian/x64 · docker и пройден.
sha256:e43d44c62ba3a6fef8b537c0b13f3dcb9e5145535c090a55013987f78c435174
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-05 |
Кейс
HOW- Цель
- verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- Символы
-
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue
- Создан
- 2026-09-05T13:01:28Z
Контракт
- AnyValue_BoolValue wraps a boolean value and implements the isAnyValue_Value interface as a oneof variant of AnyValue.Value.
- AnyValue.GetBoolValue returns the underlying boolean value when Value is AnyValue_BoolValue, and false when Value is unset or a different variant.
- Type assertion on AnyValue.Value successfully yields *AnyValue_BoolValue and allows direct inspection and mutation of its BoolValue field.
- AnyValue containing AnyValue_BoolValue serializes to and deserializes from binary Protobuf wire format without data loss, preserving the boolean oneof variant.
- AnyValue containing AnyValue_BoolValue serializes to JSON with field name boolValue and round-trips via protojson.
- proto.Clone creates an independent deep copy of an AnyValue holding AnyValue_BoolValue.
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.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 go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue
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:cf0f9a20ffdc2bdc5ac35e407c5d594e3ca0eaf439b4de9b2bed54ea495b239e","contract":["AnyValue_BoolValue wraps a boolean value and implements the isAnyValue_Value interface as a oneof variant of AnyValue.Value.","AnyValue.GetBoolValue returns the underlying boolean value when Value is AnyValue_BoolValue, and false when Value is unset or a different variant.","Type assertion on AnyValue.Value successfully yields *AnyValue_BoolValue and allows direct inspection and mutation of its BoolValue field.","AnyValue containing AnyValue_BoolValue serializes to and deserializes from binary Protobuf wire format without data loss, preserving the boolean oneof variant.","AnyValue containing AnyValue_BoolValue serializes to JSON with field name boolValue and round-trips via protojson.","proto.Clone creates an independent deep copy of an AnyValue holding AnyValue_BoolValue."],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue"]},"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/go.opentelemetry.io/proto/otlp@v1.9.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","symbols":["go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue"],"verifierAdapter":"golang@1"}
module example.com/otlpanyvaluebool
go 1.26.6
require (
go.opentelemetry.io/proto/otlp v1.9.0
google.golang.org/protobuf v1.36.10
)
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"
],
"symbols": [
"go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue"
]
}
package main
import (
"bytes"
"fmt"
"os"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// Assertion 1: AnyValue_BoolValue wraps a boolean value and implements the isAnyValue_Value interface as a oneof variant of AnyValue.Value.
{
boolValTrue := &commonpb.AnyValue_BoolValue{BoolValue: true}
boolValFalse := &commonpb.AnyValue_BoolValue{BoolValue: false}
assert(boolValTrue.BoolValue == true, "expected true BoolValue")
assert(boolValFalse.BoolValue == false, "expected false BoolValue")
anyVal := &commonpb.AnyValue{Value: boolValTrue}
assert(anyVal.GetValue() == boolValTrue, "expected GetValue() to return boolValTrue")
}
// Assertion 2: AnyValue.GetBoolValue returns the underlying boolean value when Value is AnyValue_BoolValue, and false when Value is unset or a different variant.
{
anyTrue := &commonpb.AnyValue{Value: &commonpb.AnyValue_BoolValue{BoolValue: true}}
assert(anyTrue.GetBoolValue() == true, "expected GetBoolValue() to return true")
anyFalse := &commonpb.AnyValue{Value: &commonpb.AnyValue_BoolValue{BoolValue: false}}
assert(anyFalse.GetBoolValue() == false, "expected GetBoolValue() to return false")
anyEmpty := &commonpb.AnyValue{}
assert(anyEmpty.GetBoolValue() == false, "empty AnyValue must return false for GetBoolValue()")
anyOther := &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "hello"}}
assert(anyOther.GetBoolValue() == false, "AnyValue with StringValue must return false for GetBoolValue()")
var nilAny *commonpb.AnyValue
assert(nilAny.GetBoolValue() == false, "nil AnyValue must return false for GetBoolValue()")
}
// Assertion 3: Type assertion on AnyValue.Value successfully yields *AnyValue_BoolValue and allows direct inspection and mutation of its BoolValue field.
{
anyVal := &commonpb.AnyValue{Value: &commonpb.AnyValue_BoolValue{BoolValue: true}}
bv, ok := anyVal.GetValue().(*commonpb.AnyValue_BoolValue)
assert(ok, "expected type assertion to *AnyValue_BoolValue to succeed")
assert(bv.BoolValue == true, "expected bv.BoolValue to be true")
// direct inspection via anyVal.Value
bv2, ok2 := anyVal.Value.(*commonpb.AnyValue_BoolValue)
assert(ok2, "expected direct Value assertion to succeed")
assert(bv2.BoolValue == true, "expected bv2.BoolValue to be true")
// mutation
bv2.BoolValue = false
assert(anyVal.GetBoolValue() == false, "expected mutated BoolValue to reflect via getter")
// check mismatch
strVal := &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "test"}}
_, okMismatch := strVal.Value.(*commonpb.AnyValue_BoolValue)
assert(!okMismatch, "type assertion on StringValue to *AnyValue_BoolValue should be false")
}
// Assertion 4: AnyValue containing AnyValue_BoolValue serializes to and deserializes from binary Protobuf wire format without data loss, preserving the boolean oneof variant.
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BoolValue{BoolValue: true},
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal failed")
assert(len(wire) > 0, "marshaled wire length is 0")
unmarshaled := &commonpb.AnyValue{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, "proto.Unmarshal failed")
assert(proto.Equal(orig, unmarshaled), "proto.Equal returned false for protobuf round-trip")
bv, ok := unmarshaled.Value.(*commonpb.AnyValue_BoolValue)
assert(ok, "unmarshaled Value must be *AnyValue_BoolValue")
assert(bv.BoolValue == true, "unmarshaled BoolValue must be true")
}
// Assertion 5: AnyValue containing AnyValue_BoolValue serializes to JSON with field name boolValue and round-trips via protojson.
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BoolValue{BoolValue: true},
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, "protojson.Marshal failed")
assert(bytes.Contains(jsonBytes, []byte(`"boolValue":true`)), "json must contain '\"boolValue\":true'")
jsonUnmarshaled := &commonpb.AnyValue{}
err = protojson.Unmarshal(jsonBytes, jsonUnmarshaled)
assert(err == nil, "protojson.Unmarshal failed")
assert(proto.Equal(orig, jsonUnmarshaled), "proto.Equal returned false for protojson round-trip")
assert(jsonUnmarshaled.GetBoolValue() == true, "protojson round-trip must preserve bool value")
}
// Assertion 6: proto.Clone creates an independent deep copy of an AnyValue holding AnyValue_BoolValue.
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BoolValue{BoolValue: true},
}
cloned := proto.Clone(orig).(*commonpb.AnyValue)
assert(proto.Equal(orig, cloned), "cloned AnyValue must equal original")
// mutate clone
cloned.Value.(*commonpb.AnyValue_BoolValue).BoolValue = false
assert(cloned.GetBoolValue() == false, "cloned BoolValue must be false after mutation")
assert(orig.GetBoolValue() == true, "original BoolValue must remain true")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BoolValue contract assertions verified")
}
Исходный сидер
аноним