Sample
golang.org/x/net v0.41.0: html.Node
Verified sample for golang golang.org/x/net v0.41.0: html.Node. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:a65697420d1aa01520aa447289b5289f8d2040a89f92883602d6bfb757e09b32
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-10-14 |
Case
HOW- Goal
- verify golang.org/x/net/html.Node in pkg:golang/golang.org/x/net@v0.41.0
- Packages
- Symbols
-
- golang.org/x/net/html.Node
- Created
- 2026-10-14T18:27:45Z
Contract
- html.Parse parses HTML documents into a DocumentNode tree maintaining hierarchical Parent, FirstChild, LastChild, PrevSibling, and NextSibling pointer links.
- html.Node represents HTML elements, text, and comments with accurate NodeType, DataAtom, Data, and slice of Attribute key-value pairs.
- html.Node DOM manipulation methods (InsertBefore, AppendChild, RemoveChild) update child lists and bidirectional sibling links.
- html.Render serializes an html.Node subtree back to standard HTML matching in-memory DOM mutations.
- html.ParseFragment parses HTML fragments within a specified context html.Node, returning isolated root nodes.
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.Node in pkg:golang/golang.org/x/net@v0.41.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.41.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.Node
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:f827b41a69b31e27f018a7178df8f240a711a170727a9dfd10843bb42d0736c2","contract":["html.Parse parses HTML documents into a DocumentNode tree maintaining hierarchical Parent, FirstChild, LastChild, PrevSibling, and NextSibling pointer links.","html.Node represents HTML elements, text, and comments with accurate NodeType, DataAtom, Data, and slice of Attribute key-value pairs.","html.Node DOM manipulation methods (InsertBefore, AppendChild, RemoveChild) update child lists and bidirectional sibling links.","html.Render serializes an html.Node subtree back to standard HTML matching in-memory DOM mutations.","html.ParseFragment parses HTML fragments within a specified context html.Node, returning isolated root nodes."],"goal":"verify golang.org/x/net/html.Node in pkg:golang/golang.org/x/net@v0.41.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.41.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.Node"]},"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.41.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.41.0","symbols":["golang.org/x/net/html.Node"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.23.0
require golang.org/x/net v0.41.0
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
package main
import (
"bytes"
"fmt"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
raw := `<!DOCTYPE html><html><head><title>Page</title></head><body><div id="main"><p>First</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(raw))
if err != nil {
panic(err)
}
var div *html.Node
var findDiv func(*html.Node)
findDiv = func(n *html.Node) {
if n.Type == html.ElementNode && n.DataAtom == atom.Div {
div = n
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findDiv(c)
if div != nil {
return
}
}
}
findDiv(doc)
secondP := &html.Node{
Type: html.ElementNode,
DataAtom: atom.P,
Data: "p",
Attr: []html.Attribute{{Key: "class", Val: "note"}},
}
secondP.AppendChild(&html.Node{
Type: html.TextNode,
Data: "Second",
})
div.AppendChild(secondP)
var buf bytes.Buffer
if err := html.Render(&buf, div); err != nil {
panic(err)
}
fmt.Println(buf.String())
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.Node in pkg:golang/golang.org/x/net@v0.41.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.41.0"
],
"symbols": [
"golang.org/x/net/html.Node"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func findElement(n *html.Node, tag string) *html.Node {
if n == nil {
return nil
}
if n.Type == html.ElementNode && n.Data == tag {
return n
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
if found := findElement(c, tag); found != nil {
return found
}
}
return nil
}
func main() {
// 1. html.Parse builds a DocumentNode tree with accurate Parent, FirstChild, LastChild, PrevSibling, and NextSibling links
rawHTML := `<!DOCTYPE html><html><head><title>Title</title></head><body><div id="container" class="box"><p>Alpha</p><p>Beta</p></div></body></html>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
fmt.Fprintf(os.Stderr, "Contract 1 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected DocumentNode, got %v\n", doc.Type)
os.Exit(1)
}
doctype := doc.FirstChild
if doctype == nil || doctype.Type != html.DoctypeNode || doctype.Data != "html" {
fmt.Fprintf(os.Stderr, "Contract 1 failed: expected html DoctypeNode as first child\n")
os.Exit(1)
}
htmlElem := doctype.NextSibling
if htmlElem == nil || htmlElem.Type != html.ElementNode || htmlElem.Data != "html" || htmlElem.Parent != doc {
fmt.Fprintf(os.Stderr, "Contract 1 failed: unexpected html element or parent link\n")
os.Exit(1)
}
headElem := htmlElem.FirstChild
bodyElem := htmlElem.LastChild
if headElem == nil || bodyElem == nil || headElem.NextSibling != bodyElem || bodyElem.PrevSibling != headElem {
fmt.Fprintf(os.Stderr, "Contract 1 failed: head and body sibling links broken\n")
os.Exit(1)
}
// 2. html.Node stores element Type, DataAtom, Data, and Attribute key-value pairs accurately
divNode := findElement(doc, "div")
if divNode == nil || divNode.DataAtom != atom.Div || len(divNode.Attr) != 2 {
fmt.Fprintf(os.Stderr, "Contract 2 failed: div node or attributes not parsed properly\n")
os.Exit(1)
}
if divNode.Attr[0].Key != "id" || divNode.Attr[0].Val != "container" || divNode.Attr[1].Key != "class" || divNode.Attr[1].Val != "box" {
fmt.Fprintf(os.Stderr, "Contract 2 failed: unexpected div attributes: %+v\n", divNode.Attr)
os.Exit(1)
}
firstP := divNode.FirstChild
lastP := divNode.LastChild
if firstP == nil || firstP.FirstChild == nil || firstP.FirstChild.Type != html.TextNode || firstP.FirstChild.Data != "Alpha" {
fmt.Fprintf(os.Stderr, "Contract 2 failed: unexpected first paragraph text node\n")
os.Exit(1)
}
// 3. html.Node manipulation methods (InsertBefore, AppendChild, RemoveChild) update tree pointers consistently
midP := &html.Node{
Type: html.ElementNode,
DataAtom: atom.P,
Data: "p",
Attr: []html.Attribute{{Key: "id", Val: "mid"}},
}
midP.AppendChild(&html.Node{
Type: html.TextNode,
Data: "Middle",
})
divNode.InsertBefore(midP, lastP)
if midP.Parent != divNode || midP.PrevSibling != firstP || midP.NextSibling != lastP || firstP.NextSibling != midP || lastP.PrevSibling != midP {
fmt.Fprintf(os.Stderr, "Contract 3 failed: InsertBefore did not link siblings properly\n")
os.Exit(1)
}
tailSpan := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Span,
Data: "span",
}
tailSpan.AppendChild(&html.Node{
Type: html.TextNode,
Data: "Tail",
})
divNode.AppendChild(tailSpan)
if divNode.LastChild != tailSpan || tailSpan.PrevSibling != lastP || lastP.NextSibling != tailSpan {
fmt.Fprintf(os.Stderr, "Contract 3 failed: AppendChild did not update LastChild links\n")
os.Exit(1)
}
divNode.RemoveChild(midP)
if midP.Parent != nil || midP.PrevSibling != nil || midP.NextSibling != nil || firstP.NextSibling != lastP || lastP.PrevSibling != firstP {
fmt.Fprintf(os.Stderr, "Contract 3 failed: RemoveChild did not detach node or repair sibling links\n")
os.Exit(1)
}
// 4. html.Render serializes an html.Node subtree reflecting in-memory DOM modifications
var buf bytes.Buffer
if err := html.Render(&buf, divNode); err != nil {
fmt.Fprintf(os.Stderr, "Contract 4 failed: html.Render error: %v\n", err)
os.Exit(1)
}
expectedRendered := `<div id="container" class="box"><p>Alpha</p><p>Beta</p><span>Tail</span></div>`
if buf.String() != expectedRendered {
fmt.Fprintf(os.Stderr, "Contract 4 failed: expected %q, got %q\n", expectedRendered, buf.String())
os.Exit(1)
}
// 5. html.ParseFragment parses HTML fragments in the context of a parent html.Node
ctxNode := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Tbody,
Data: "tbody",
}
parts, err := html.ParseFragment(strings.NewReader(`<tr><td>Cell</td></tr><!--end-->`), ctxNode)
if err != nil || len(parts) != 2 {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.ParseFragment err=%v, len=%d\n", err, len(parts))
os.Exit(1)
}
if parts[0].Type != html.ElementNode || parts[0].Data != "tr" || parts[1].Type != html.CommentNode || parts[1].Data != "end" {
fmt.Fprintf(os.Stderr, "Contract 5 failed: unexpected fragment node types\n")
os.Exit(1)
}
fmt.Println("PASS")
}
Origin Seeder
anonymous