Пример
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Post
Проверенный пример — golang google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Post. Контракт выполнен на go…
sha256:d8d609617d07c54d9b8f6f6997eca56bfc09551a7683f4386685feb6c9ea0297
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
Кейс
HOW- Цель
- verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
- Символы
-
- google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post
- Создан
- 2026-08-27T12:08:57Z
Контракт
- annotations.HttpRule_Post encapsulates the POST URL template for HttpRule
- annotations.HttpRule configured with HttpRule_Post returns POST URL via GetPost and GetPattern
- annotations.HttpRule.GetPattern resolves to *annotations.HttpRule_Post via type assertion
- annotations.HttpRule with HttpRule_Post serializes and deserializes accurately with protobuf wire format
Файлы
- 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/api/annotations.HttpRule_Post in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: esm
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:be9e862f3332350c2c83a2864858e95cb7aa6a2593e0e6f1b5b00ecf8514b59f","contract":["annotations.HttpRule_Post encapsulates the POST URL template for HttpRule","annotations.HttpRule configured with HttpRule_Post returns POST URL via GetPost and GetPattern","annotations.HttpRule.GetPattern resolves to *annotations.HttpRule_Post via type assertion","annotations.HttpRule with HttpRule_Post serializes and deserializes accurately with protobuf wire format"],"goal":"verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post"]},"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-20241007155032-5fefd90f89a9"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9","symbols":["google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require (
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.35.1
)
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg=
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
package main
import (
"fmt"
"log"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/protobuf/proto"
)
func main() {
postPattern := &annotations.HttpRule_Post{
Post: "/v1/{parent=publishers/*}/books",
}
rule := &annotations.HttpRule{
Selector: "google.example.library.v1.LibraryService.CreateBook",
Pattern: postPattern,
Body: "book",
}
data, err := proto.Marshal(rule)
if err != nil {
log.Fatalf("failed to marshal HttpRule: %v", err)
}
var decoded annotations.HttpRule
if err := proto.Unmarshal(data, &decoded); err != nil {
log.Fatalf("failed to unmarshal HttpRule: %v", err)
}
fmt.Printf("Selector: %s\n", decoded.GetSelector())
fmt.Printf("HTTP POST Pattern: %s\n", decoded.GetPost())
fmt.Printf("Body: %s\n", decoded.GetBody())
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9"
],
"symbols": [
"google.golang.org/genproto/googleapis/api/annotations.HttpRule_Post"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "esm",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/api/annotations"
"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() {
// 1. HttpRule_Post encapsulates the POST URL template for HttpRule
postPattern := &annotations.HttpRule_Post{
Post: "/v1/{parent=publishers/*}/books",
}
assert(postPattern.Post == "/v1/{parent=publishers/*}/books", "Post field must match initialized value")
// 2. HttpRule configured with HttpRule_Post returns POST URL via GetPost and GetPattern
rule := &annotations.HttpRule{
Selector: "google.example.library.v1.LibraryService.CreateBook",
Pattern: postPattern,
Body: "book",
}
assert(rule.GetSelector() == "google.example.library.v1.LibraryService.CreateBook", "selector must match")
assert(rule.GetPost() == "/v1/{parent=publishers/*}/books", "GetPost must return configured POST path")
assert(rule.GetGet() == "", "GetGet must return empty string for POST rule")
assert(rule.GetBody() == "book", "body mapping must match")
// 3. Pattern interface resolves to *annotations.HttpRule_Post via type assertion
switch p := rule.GetPattern().(type) {
case *annotations.HttpRule_Post:
assert(p.Post == "/v1/{parent=publishers/*}/books", "type assertion to *HttpRule_Post must match path")
default:
assert(false, "pattern must be of type *annotations.HttpRule_Post")
}
// 4. HttpRule with HttpRule_Post marshals and unmarshals accurately with protobuf wire format
data, err := proto.Marshal(rule)
assert(err == nil, "proto.Marshal must succeed")
assert(len(data) > 0, "marshaled bytes must not be empty")
var decoded annotations.HttpRule
err = proto.Unmarshal(data, &decoded)
assert(err == nil, "proto.Unmarshal must succeed")
assert(decoded.GetSelector() == rule.GetSelector(), "decoded selector must match")
assert(decoded.GetPost() == "/v1/{parent=publishers/*}/books", "decoded GetPost must match")
assert(decoded.GetBody() == "book", "decoded body must match")
// Verify decoded pattern type
if postDecoded, ok := decoded.GetPattern().(*annotations.HttpRule_Post); ok {
assert(postDecoded.Post == "/v1/{parent=publishers/*}/books", "decoded pattern Post field must match")
} else {
assert(false, "decoded pattern must be *annotations.HttpRule_Post")
}
fmt.Println("All contract assertions for annotations.HttpRule_Post passed successfully.")
}
Исходный сидер
аноним