Exemplo
golang.org/x/net v0.29.0: atom.Body
Amostra verificada para golang golang.org/x/net v0.29.0: atom.Body. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou.
sha256:0c5377be58024c2c1b80a079dfba22649da936649068e1d4499323a23227f6d2
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 2
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify golang.org/x/net/html/atom.Body in pkg:golang/golang.org/x/net@v0.29.0
- Pacotes
- Símbolos
-
- golang.org/x/net/html/atom.Body
- Ambiente
- go 1.26.6
- Criado
- 2026-08-30T16:33:27Z
Contrato
- 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
Arquivos
- PROMPT.md
- atom.go
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
Código-fonte
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 de origem
anônimo