Beispiel
github.com/beorn7/perks v1.0.1: quantile.Samples
Verifiziertes Beispiel für golang github.com/beorn7/perks v1.0.1: quantile.Samples. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:82a944be7a5f9d6be7df33c67e0e20238a88d4d590a2869e0158c5bf6b5c5446
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-06 |
Fall
HOW- Ziel
- verify github.com/beorn7/perks/quantile.Samples in pkg:golang/github.com/beorn7/perks@v1.0.1
- Symbole
-
- github.com/beorn7/perks/quantile.Samples
- Erstellt
- 2026-09-06T04:38:22Z
Contract
- quantile.Samples represents a slice of Sample items containing Value, Width, and Delta
- quantile.Samples implements sort.Interface methods Len, Less, and Swap
- sort.Sort reorders quantile.Samples in ascending order by Value
- sort.IsSorted validates sorted order of quantile.Samples
- Stream.Samples returns a quantile.Samples slice representing retained stream observations
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
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 github.com/beorn7/perks/quantile.Samples in pkg:golang/github.com/beorn7/perks@v1.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/beorn7/perks@v1.0.1
Demonstrate these symbols/APIs:
- github.com/beorn7/perks/quantile.Samples
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:5dbaa8ded5387644f2e179bd90544a22926e005b073e7c97555eefeaf3b45977","contract":["quantile.Samples represents a slice of Sample items containing Value, Width, and Delta","quantile.Samples implements sort.Interface methods Len, Less, and Swap","sort.Sort reorders quantile.Samples in ascending order by Value","sort.IsSorted validates sorted order of quantile.Samples","Stream.Samples returns a quantile.Samples slice representing retained stream observations"],"goal":"verify github.com/beorn7/perks/quantile.Samples in pkg:golang/github.com/beorn7/perks@v1.0.1","kind":"HOW","packages":["pkg:golang/github.com/beorn7/perks@v1.0.1"],"schemaVersion":1,"symbols":["github.com/beorn7/perks/quantile.Samples"]},"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/github.com/beorn7/perks@v1.0.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/beorn7/perks@v1.0.1","symbols":["github.com/beorn7/perks/quantile.Samples"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/beorn7/perks v1.0.1
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
package main
import (
"fmt"
"sort"
"github.com/beorn7/perks/quantile"
)
func main() {
// Construct a quantile.Samples slice directly
samples := quantile.Samples{
{Value: 42.0, Width: 1.0, Delta: 0.0},
{Value: 10.5, Width: 1.0, Delta: 0.0},
{Value: 99.9, Width: 2.0, Delta: 0.0},
{Value: 3.14, Width: 1.0, Delta: 0.0},
}
fmt.Printf("Initial samples count: %d\n", samples.Len())
fmt.Printf("Is sorted initially: %v\n", sort.IsSorted(samples))
// Sort samples using standard library sort.Sort
sort.Sort(samples)
fmt.Printf("Is sorted after sort.Sort: %v\n", sort.IsSorted(samples))
for i, s := range samples {
fmt.Printf("Sample %d: Value=%.2f Width=%.1f Delta=%.1f\n", i, s.Value, s.Width, s.Delta)
}
// Obtain quantile.Samples from an active Stream
stream := quantile.NewTargeted(map[float64]float64{0.50: 0.01, 0.90: 0.01})
for i := 1; i <= 100; i++ {
stream.Insert(float64(i))
}
streamSamples := stream.Samples()
fmt.Printf("Stream retained samples count: %d\n", streamSamples.Len())
}
{
"schemaVersion": 1,
"goal": "verify github.com/beorn7/perks/quantile.Samples in pkg:golang/github.com/beorn7/perks@v1.0.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/beorn7/perks@v1.0.1"
],
"symbols": [
"github.com/beorn7/perks/quantile.Samples"
]
}
package main
import (
"fmt"
"os"
"sort"
"github.com/beorn7/perks/quantile"
)
func main() {
// Assertion 1: quantile.Samples represents a slice of Sample items containing Value, Width, and Delta
{
s := quantile.Samples{
{Value: 15.5, Width: 1.0, Delta: 0.0},
{Value: 3.2, Width: 2.0, Delta: 0.5},
}
if len(s) != 2 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected length 2, got %d\n", len(s))
os.Exit(1)
}
if s[0].Value != 15.5 || s[0].Width != 1.0 || s[0].Delta != 0.0 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected sample values at index 0\n")
os.Exit(1)
}
if s[1].Value != 3.2 || s[1].Width != 2.0 || s[1].Delta != 0.5 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected sample values at index 1\n")
os.Exit(1)
}
}
// Assertion 2: quantile.Samples implements sort.Interface methods Len, Less, and Swap
{
var _ sort.Interface = quantile.Samples{}
s := quantile.Samples{
{Value: 50.0, Width: 1.0, Delta: 0.0},
{Value: 20.0, Width: 1.0, Delta: 0.0},
{Value: 80.0, Width: 1.0, Delta: 0.0},
}
if s.Len() != 3 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected Len() == 3, got %d\n", s.Len())
os.Exit(1)
}
if s.Less(0, 1) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected Less(0, 1) to be false (50 < 20)\n")
os.Exit(1)
}
if !s.Less(1, 0) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected Less(1, 0) to be true (20 < 50)\n")
os.Exit(1)
}
s.Swap(0, 1)
if s[0].Value != 20.0 || s[1].Value != 50.0 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: Swap did not swap elements correctly\n")
os.Exit(1)
}
}
// Assertion 3: sort.Sort reorders quantile.Samples in ascending order by Value
{
s := quantile.Samples{
{Value: 45.0, Width: 1.0, Delta: 0.0},
{Value: 12.0, Width: 2.0, Delta: 0.1},
{Value: 99.0, Width: 1.0, Delta: 0.0},
{Value: 5.5, Width: 1.0, Delta: 0.0},
{Value: 33.3, Width: 3.0, Delta: 0.2},
}
sort.Sort(s)
for i := 1; i < len(s); i++ {
if s[i-1].Value > s[i].Value {
fmt.Fprintf(os.Stderr, "assertion 3 failed: not sorted at index %d (%f > %f)\n", i, s[i-1].Value, s[i].Value)
os.Exit(1)
}
}
if s[0].Value != 5.5 || s[len(s)-1].Value != 99.0 {
fmt.Fprintf(os.Stderr, "assertion 3 failed: unexpected min/max after sort: min=%f, max=%f\n", s[0].Value, s[len(s)-1].Value)
os.Exit(1)
}
}
// Assertion 4: sort.IsSorted validates sorted order of quantile.Samples
{
unsorted := quantile.Samples{
{Value: 10.0},
{Value: 5.0},
}
if sort.IsSorted(unsorted) {
fmt.Fprintf(os.Stderr, "assertion 4 failed: unsorted samples reported as sorted\n")
os.Exit(1)
}
sorted := quantile.Samples{
{Value: 1.0},
{Value: 2.0},
{Value: 3.0},
}
if !sort.IsSorted(sorted) {
fmt.Fprintf(os.Stderr, "assertion 4 failed: sorted samples reported as unsorted\n")
os.Exit(1)
}
}
// Assertion 5: Stream.Samples returns a quantile.Samples slice representing retained stream observations
{
stream := quantile.NewTargeted(map[float64]float64{0.50: 0.01})
for i := 1; i <= 200; i++ {
stream.Insert(float64(i))
}
var samples quantile.Samples = stream.Samples()
if len(samples) == 0 {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected non-empty samples from stream\n")
os.Exit(1)
}
for _, sample := range samples {
if sample.Value < 1.0 || sample.Value > 200.0 {
fmt.Fprintf(os.Stderr, "assertion 5 failed: sample value %f out of range [1, 200]\n", sample.Value)
os.Exit(1)
}
if sample.Width <= 0 {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected positive sample width, got %f\n", sample.Width)
os.Exit(1)
}
}
}
fmt.Println("All contract assertions passed successfully.")
}
Ursprungs-Seeder
anonym