Exemple
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Patch
Échantillon vérifié pour golang google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9: annotations.HttpRule_Patch. Le contrat s'est…
sha256:5ab63333ab0599ffb64ee257147cee8cb191f1b6a206b6619e2f768e87439db4
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Patch in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20241007155032-5fefd90f89a9
- Symboles
-
- google.golang.org/genproto/googleapis/api/annotations.HttpRule_Patch
- Créé
- 2026-08-27T12:06:46Z
Contrat
- annotations.HttpRule_Patch binds HTTP PATCH endpoint pattern to HttpRule
- annotations.HttpRule.GetPatch returns pattern string when Pattern is HttpRule_Patch and empty string otherwise
- annotations.HttpRule with HttpRule_Patch roundtrips through protobuf wire format preservation
- annotations.HttpRule_Patch is supported in HttpRule.AdditionalBindings for alternative PATCH routes
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code 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/api/annotations.HttpRule_Patch 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_Patch
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:78fde0c70dcc188662ecde27151fdb985ab077d9282f27fb120240ac94f83b62","contract":["annotations.HttpRule_Patch binds HTTP PATCH endpoint pattern to HttpRule","annotations.HttpRule.GetPatch returns pattern string when Pattern is HttpRule_Patch and empty string otherwise","annotations.HttpRule with HttpRule_Patch roundtrips through protobuf wire format preservation","annotations.HttpRule_Patch is supported in HttpRule.AdditionalBindings for alternative PATCH routes"],"goal":"verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Patch 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_Patch"]},"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_Patch"],"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() {
// Configure an HTTP PATCH transcoding rule for a REST endpoint
rule := &annotations.HttpRule{
Selector: "google.example.library.v1.LibraryService.UpdateBook",
Pattern: &annotations.HttpRule_Patch{
Patch: "/v1/{book.name=publishers/*/books/*}",
},
Body: "book",
AdditionalBindings: []*annotations.HttpRule{
{
Pattern: &annotations.HttpRule_Patch{
Patch: "/v1/{book.name=authors/*/books/*}",
},
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 PATCH Pattern: %s\n", decoded.GetPatch())
fmt.Printf("Body: %s\n", decoded.GetBody())
if len(decoded.GetAdditionalBindings()) > 0 {
fmt.Printf("Additional Binding PATCH: %s\n", decoded.GetAdditionalBindings()[0].GetPatch())
}
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/api/annotations.HttpRule_Patch 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_Patch"
],
"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. annotations.HttpRule_Patch binds HTTP PATCH endpoint pattern to HttpRule
patchPattern := &annotations.HttpRule_Patch{
Patch: "/v1/{book.name=publishers/*/books/*}",
}
assert(patchPattern.Patch == "/v1/{book.name=publishers/*/books/*}", "patch field must match initialized value")
patchRule := &annotations.HttpRule{
Selector: "google.example.library.v1.LibraryService.UpdateBook",
Pattern: patchPattern,
Body: "book",
}
assert(patchRule.GetSelector() == "google.example.library.v1.LibraryService.UpdateBook", "selector must match")
assert(patchRule.GetPatch() == "/v1/{book.name=publishers/*/books/*}", "get patch must match patch string")
assert(patchRule.GetBody() == "book", "body mapping must match")
// Type assertion on Pattern interface
extractedPattern, isPatch := patchRule.GetPattern().(*annotations.HttpRule_Patch)
assert(isPatch, "pattern must be of type *annotations.HttpRule_Patch")
assert(extractedPattern.Patch == "/v1/{book.name=publishers/*/books/*}", "extracted patch pattern must match")
// 2. annotations.HttpRule.GetPatch returns pattern string when Pattern is HttpRule_Patch and empty string otherwise
var nilRule *annotations.HttpRule
assert(nilRule.GetPatch() == "", "nil HttpRule GetPatch must return empty string")
emptyRule := &annotations.HttpRule{}
assert(emptyRule.GetPatch() == "", "HttpRule without pattern GetPatch must return empty string")
getRule := &annotations.HttpRule{
Pattern: &annotations.HttpRule_Get{
Get: "/v1/books",
},
}
assert(getRule.GetPatch() == "", "HttpRule with Get pattern GetPatch must return empty string")
assert(patchRule.GetPatch() == "/v1/{book.name=publishers/*/books/*}", "HttpRule with Patch pattern GetPatch must return patch string")
// 3. annotations.HttpRule with HttpRule_Patch roundtrips through protobuf wire format preservation
data, err := proto.Marshal(patchRule)
assert(err == nil, "proto.Marshal(patchRule) must succeed")
assert(len(data) > 0, "marshaled payload must not be empty")
var decoded annotations.HttpRule
err = proto.Unmarshal(data, &decoded)
assert(err == nil, "proto.Unmarshal(data) must succeed")
assert(decoded.GetSelector() == patchRule.GetSelector(), "decoded selector must match")
assert(decoded.GetPatch() == patchRule.GetPatch(), "decoded patch pattern must match")
assert(decoded.GetBody() == patchRule.GetBody(), "decoded body must match")
decodedPattern, ok := decoded.GetPattern().(*annotations.HttpRule_Patch)
assert(ok, "decoded pattern must be *annotations.HttpRule_Patch")
assert(decodedPattern.Patch == patchPattern.Patch, "decoded pattern patch string must match original")
// 4. annotations.HttpRule_Patch is supported in HttpRule.AdditionalBindings for alternative PATCH routes
compositeRule := &annotations.HttpRule{
Selector: "google.example.library.v1.LibraryService.UpdateBook",
Pattern: &annotations.HttpRule_Patch{
Patch: "/v1/{book.name=publishers/*/books/*}",
},
Body: "book",
AdditionalBindings: []*annotations.HttpRule{
{
Pattern: &annotations.HttpRule_Patch{
Patch: "/v1/{book.name=authors/*/books/*}",
},
Body: "book",
},
},
}
assert(len(compositeRule.GetAdditionalBindings()) == 1, "additional bindings count must be 1")
assert(compositeRule.GetAdditionalBindings()[0].GetPatch() == "/v1/{book.name=authors/*/books/*}", "additional binding patch pattern must match")
assert(compositeRule.GetAdditionalBindings()[0].GetBody() == "book", "additional binding body must match")
compData, err := proto.Marshal(compositeRule)
assert(err == nil, "proto.Marshal(compositeRule) must succeed")
var compDecoded annotations.HttpRule
err = proto.Unmarshal(compData, &compDecoded)
assert(err == nil, "proto.Unmarshal(compData) must succeed")
assert(compDecoded.GetPatch() == "/v1/{book.name=publishers/*/books/*}", "decoded primary patch pattern must match")
assert(len(compDecoded.GetAdditionalBindings()) == 1, "decoded additional bindings count must be 1")
assert(compDecoded.GetAdditionalBindings()[0].GetPatch() == "/v1/{book.name=authors/*/books/*}", "decoded additional binding patch pattern must match")
fmt.Println("All contract assertions for annotations.HttpRule_Patch passed successfully.")
}
Seeder d'origine
anonyme