Exemple
golang.org/x/net v0.29.0: atom.Body
Échantillon vérifié pour golang golang.org/x/net v0.29.0: atom.Body. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a réussi.
sha256:0c5377be58024c2c1b80a079dfba22649da936649068e1d4499323a23227f6d2
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
- 2
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | FAIL | compile:SKIPPED · contract:FAIL · load:SKIPPED · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-30 |
| go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-30 |
Cas
HOW- Objectif
- verify golang.org/x/net/html/atom.Body in pkg:golang/golang.org/x/net@v0.29.0
- Paquets
- Symboles
-
- golang.org/x/net/html/atom.Body
- Environnement
- go 1.26.6
- Créé
- 2026-08-30T16:33:27Z
Contrat
- atom.Body String() returns "body"
- atom.Lookup resolves []byte("body") to atom.Body
- html.Parse assigns atom.Body as DataAtom for body elements
- atom.Body distinguishes body element from other elements in parsed HTML tree
Fichiers
- PROMPT.md
- atom.go
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
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 golang.org/x/net/html/atom.Body in pkg:golang/golang.org/x/net@v0.29.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.29.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html/atom.Body
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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.
package sample
import (
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
// IsBodyAtom checks whether an atom represents the <body> tag.
func IsBodyAtom(a atom.Atom) bool {
return a == atom.Body
}
// LookupBodyAtom resolves a tag name byte slice to atom.Body.
func LookupBodyAtom(tag []byte) (atom.Atom, bool) {
a := atom.Lookup(tag)
return a, a == atom.Body
}
// FindBodyNode finds the first <body> element node in the parsed HTML node tree.
func FindBodyNode(n *html.Node) *html.Node {
if n == nil {
return nil
}
if n.Type == html.ElementNode && n.DataAtom == atom.Body {
return n
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
if found := FindBodyNode(c); found != nil {
return found
}
}
return nil
}
// ExtractBodyText parses an HTML document string and extracts inner text from the <body> element.
func ExtractBodyText(htmlStr string) (string, error) {
doc, err := html.Parse(strings.NewReader(htmlStr))
if err != nil {
return "", err
}
bodyNode := FindBodyNode(doc)
if bodyNode == nil {
return "", nil
}
var sb strings.Builder
var collectText func(*html.Node)
collectText = func(n *html.Node) {
if n.Type == html.TextNode {
sb.WriteString(n.Data)
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
collectText(c)
}
}
collectText(bodyNode)
return strings.TrimSpace(sb.String()), nil
}
package sample
import (
"strings"
"testing"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func TestContractAtomBody(t *testing.T) {
// 1. Verify atom.Body string representation
if atom.Body.String() != "body" {
t.Fatalf("expected atom.Body.String() == \"body\", got %q", atom.Body.String())
}
if !IsBodyAtom(atom.Body) {
t.Fatalf("expected IsBodyAtom(atom.Body) == true")
}
if IsBodyAtom(atom.Head) {
t.Fatalf("expected IsBodyAtom(atom.Head) == false")
}
// 2. Verify atom.Lookup resolves byte slice to atom.Body
lookedUp, isBody := LookupBodyAtom([]byte("body"))
if !isBody || lookedUp != atom.Body {
t.Fatalf("expected LookupBodyAtom([]byte(\"body\")) == (atom.Body, true), got (%v, %v)", lookedUp, isBody)
}
// 3. Verify html.Parse sets DataAtom to atom.Body for <body> element
htmlContent := `<!DOCTYPE html><html><head><title>Sample</title></head><body><div class="content"><p>Hello CodeSampleX</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(htmlContent))
if err != nil {
t.Fatalf("html.Parse failed: %v", err)
}
body := FindBodyNode(doc)
if body == nil {
t.Fatalf("expected FindBodyNode to find body node")
}
if body.DataAtom != atom.Body {
t.Fatalf("expected body.DataAtom == atom.Body, got %v", body.DataAtom)
}
if body.Data != "body" {
t.Fatalf("expected body.Data == \"body\", got %q", body.Data)
}
// 4. Verify extracting text from body node
text, err := ExtractBodyText(htmlContent)
if err != nil {
t.Fatalf("ExtractBodyText failed: %v", err)
}
if text != "Hello CodeSampleX" {
t.Fatalf("expected extracted text \"Hello CodeSampleX\", got %q", text)
}
}
{"case":{"caseId":"case:sha256:798ef5491a1f155cf90d830cd751ccb7cb24ec7038fdd3cb3901fd50cd7a418d","contract":["atom.Body String() returns \"body\"","atom.Lookup resolves []byte(\"body\") to atom.Body","html.Parse assigns atom.Body as DataAtom for body elements","atom.Body distinguishes body element from other elements in parsed HTML tree"],"goal":"verify golang.org/x/net/html/atom.Body in pkg:golang/golang.org/x/net@v0.29.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.29.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html/atom.Body"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/net@v0.29.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.29.0","symbols":["golang.org/x/net/html/atom.Body"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require golang.org/x/net v0.29.0
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html/atom.Body in pkg:golang/golang.org/x/net@v0.29.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.29.0"
],
"symbols": [
"golang.org/x/net/html/atom.Body"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
Seeder d'origine
anonyme