Sample
golang.org/x/net v0.23.0: html.ElementNode
Verified sample for golang golang.org/x/net v0.23.0: html.ElementNode. The contract ran on go 1.26 · linux debian/x64 · docker and passed: html.ElementNode…
sha256:05be2759ace67bb0bf9ce587b49bb3182560057442553f789c436f6a99156a20
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-04 |
Case
HOW- Goal
- verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.23.0
- Packages
- Symbols
-
- golang.org/x/net/html.ElementNode
- Created
- 2026-09-04T12:21:31Z
Contract
- html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes
- html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names
- html.ElementNode contains Attr slice representing HTML attributes with Key and Val
- html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers
- html.Render serializes a tree of ElementNode nodes back into valid HTML output
- html.ParseFragment parses HTML fragment using an ElementNode context node
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
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.ElementNode in pkg:golang/golang.org/x/net@v0.23.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.23.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.ElementNode
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:7c503efc5705f1a85821b9811d64a6375b369d44aaac56817e3b29c7fed7f6d1","contract":["html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes","html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names","html.ElementNode contains Attr slice representing HTML attributes with Key and Val","html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers","html.Render serializes a tree of ElementNode nodes back into valid HTML output","html.ParseFragment parses HTML fragment using an ElementNode context node"],"goal":"verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.23.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.23.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.ElementNode"]},"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/golang.org/x/net@v0.23.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.23.0","symbols":["golang.org/x/net/html.ElementNode"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.23.0
require golang.org/x/net v0.23.0
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
package main
import (
"bytes"
"fmt"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
rawHTML := `<div class="container" id="main"><p>CodeSampleX Demo</p></div>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
panic(err)
}
var visit func(*html.Node)
visit = func(n *html.Node) {
if n.Type == html.ElementNode {
fmt.Printf("Element: <%s>\n", n.Data)
for _, attr := range n.Attr {
fmt.Printf(" Attr: %s=%s\n", attr.Key, attr.Val)
}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
visit(c)
}
}
visit(doc)
// Create and append an ElementNode programmatically
newElem := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Span,
Data: "span",
Attr: []html.Attribute{
{Key: "class", Val: "badge"},
},
}
doc.AppendChild(newElem)
var buf bytes.Buffer
if err := html.Render(&buf, doc); err != nil {
panic(err)
}
fmt.Printf("Rendered HTML:\n%s\n", buf.String())
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.ElementNode in pkg:golang/golang.org/x/net@v0.23.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.23.0"
],
"symbols": [
"golang.org/x/net/html.ElementNode"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// 1. html.ElementNode is a NodeType distinguishing HTML element nodes from document and text nodes
if html.ElementNode == html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal DocumentNode\n")
os.Exit(1)
}
if html.ElementNode == html.TextNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal TextNode\n")
os.Exit(1)
}
if html.ElementNode == html.CommentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: ElementNode must not equal CommentNode\n")
os.Exit(1)
}
// 2. html.Parse parses HTML string into a DOM tree containing ElementNode with expected tag names
rawHTML := `<!DOCTYPE html><html><head><title>Test</title></head><body><div id="content"><p>Hello</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc == nil || doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 2 failed: root node must be DocumentNode\n")
os.Exit(1)
}
var elementTags []string
var findElements func(*html.Node)
findElements = func(n *html.Node) {
if n.Type == html.ElementNode {
elementTags = append(elementTags, n.Data)
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findElements(c)
}
}
findElements(doc)
expectedTags := []string{"html", "head", "title", "body", "div", "p"}
if len(elementTags) != len(expectedTags) {
fmt.Fprintf(os.Stderr, "Contract 2 failed: element tags length mismatch: got %v, want %v\n", elementTags, expectedTags)
os.Exit(1)
}
for i, tag := range expectedTags {
if elementTags[i] != tag {
fmt.Fprintf(os.Stderr, "Contract 2 failed: tag at %d mismatch: got %s, want %s\n", i, elementTags[i], tag)
os.Exit(1)
}
}
// 3. html.ElementNode contains Attr slice representing HTML attributes with Key and Val
var divNode *html.Node
var findDiv func(*html.Node)
findDiv = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "div" {
divNode = n
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findDiv(c)
}
}
findDiv(doc)
if divNode == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: div ElementNode not found\n")
os.Exit(1)
}
if len(divNode.Attr) != 1 || divNode.Attr[0].Key != "id" || divNode.Attr[0].Val != "content" {
fmt.Fprintf(os.Stderr, "Contract 3 failed: div Attr mismatch: got %+v\n", divNode.Attr)
os.Exit(1)
}
// 4. html.ElementNode supports tree mutation via AppendChild and RemoveChild maintaining parent and sibling pointers
parent := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Ul,
Data: "ul",
}
child1 := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Li,
Data: "li",
}
child2 := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Li,
Data: "li",
}
parent.AppendChild(child1)
parent.AppendChild(child2)
if parent.FirstChild != child1 || parent.LastChild != child2 {
fmt.Fprintf(os.Stderr, "Contract 4 failed: AppendChild pointers mismatch\n")
os.Exit(1)
}
if child1.Parent != parent || child2.Parent != parent {
fmt.Fprintf(os.Stderr, "Contract 4 failed: child Parent pointer mismatch\n")
os.Exit(1)
}
if child1.NextSibling != child2 || child2.PrevSibling != child1 {
fmt.Fprintf(os.Stderr, "Contract 4 failed: sibling pointers mismatch\n")
os.Exit(1)
}
parent.RemoveChild(child1)
if parent.FirstChild != child2 || child1.Parent != nil || child1.NextSibling != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: RemoveChild pointers mismatch\n")
os.Exit(1)
}
// 5. html.Render serializes a tree of ElementNode nodes back into valid HTML output
var renderBuf bytes.Buffer
if err := html.Render(&renderBuf, parent); err != nil {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.Render error: %v\n", err)
os.Exit(1)
}
expectedRendered := "<ul><li></li></ul>"
if renderBuf.String() != expectedRendered {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.Render mismatch: got %q, want %q\n", renderBuf.String(), expectedRendered)
os.Exit(1)
}
// 6. html.ParseFragment parses HTML fragment using an ElementNode context node
contextNode := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Div,
Data: "div",
}
fragHTML := `<span class="frag">fragment text</span>`
nodes, err := html.ParseFragment(strings.NewReader(fragHTML), contextNode)
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed: html.ParseFragment error: %v\n", err)
os.Exit(1)
}
if len(nodes) != 1 {
fmt.Fprintf(os.Stderr, "Contract 6 failed: nodes length mismatch: got %d, want 1\n", len(nodes))
os.Exit(1)
}
fragElem := nodes[0]
if fragElem.Type != html.ElementNode || fragElem.Data != "span" {
fmt.Fprintf(os.Stderr, "Contract 6 failed: fragElem mismatch: Type=%v, Data=%s\n", fragElem.Type, fragElem.Data)
os.Exit(1)
}
if len(fragElem.Attr) != 1 || fragElem.Attr[0].Key != "class" || fragElem.Attr[0].Val != "frag" {
fmt.Fprintf(os.Stderr, "Contract 6 failed: fragElem Attr mismatch: %+v\n", fragElem.Attr)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous