Sample
golang.org/x/net v0.24.0: html.DocumentNode
Verified sample for golang golang.org/x/net v0.24.0: html.DocumentNode. The contract ran on go 1.26 · linux debian/x64 · docker and passed: html.DocumentNode…
sha256:b845c2c184d6fe78b064a99daf71b81e8255174c1b848ea0871bcf6e682d3033
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.DocumentNode in pkg:golang/golang.org/x/net@v0.24.0
- Packages
- Symbols
-
- golang.org/x/net/html.DocumentNode
- Created
- 2026-09-04T13:00:01Z
Contract
- html.DocumentNode is a distinct NodeType constant distinguishing document root nodes from element, text, and comment nodes
- html.Parse returns a root Node whose Type is html.DocumentNode with nil Parent and empty Data
- html.Parse produces DocumentNode whose top-level children point back to it as Parent
- html.DocumentNode can be constructed programmatically and populated with children using AppendChild
- html.Render serializes all top-level children of a DocumentNode into formatted HTML output
- Traversing Parent pointers from any descendant node terminates at the DocumentNode root
- html.DocumentNode supports child removal via RemoveChild updating FirstChild and LastChild
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.DocumentNode in pkg:golang/golang.org/x/net@v0.24.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.24.0
Demonstrate these symbols/APIs:
- golang.org/x/net/html.DocumentNode
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:3d8e9c66427d004c9fb9e3a30e8158109f88323716ff5d6891fe628d42aef0c7","contract":["html.DocumentNode is a distinct NodeType constant distinguishing document root nodes from element, text, and comment nodes","html.Parse returns a root Node whose Type is html.DocumentNode with nil Parent and empty Data","html.Parse produces DocumentNode whose top-level children point back to it as Parent","html.DocumentNode can be constructed programmatically and populated with children using AppendChild","html.Render serializes all top-level children of a DocumentNode into formatted HTML output","Traversing Parent pointers from any descendant node terminates at the DocumentNode root","html.DocumentNode supports child removal via RemoveChild updating FirstChild and LastChild"],"goal":"verify golang.org/x/net/html.DocumentNode in pkg:golang/golang.org/x/net@v0.24.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.24.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.DocumentNode"]},"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.24.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.24.0","symbols":["golang.org/x/net/html.DocumentNode"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.25.0
require golang.org/x/net v0.24.0
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
package main
import (
"bytes"
"fmt"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
rawHTML := `<!DOCTYPE html><html><head><title>CodeSampleX</title></head><body><h1>Hello</h1></body></html>`
doc, err := html.Parse(strings.NewReader(rawHTML))
if err != nil {
panic(err)
}
if doc.Type == html.DocumentNode {
fmt.Println("Parsed document root is a DocumentNode")
}
for c := doc.FirstChild; c != nil; c = c.NextSibling {
fmt.Printf("Top-level node type: %v, data: %q\n", c.Type, c.Data)
}
// Programmatic DocumentNode construction
customDoc := &html.Node{
Type: html.DocumentNode,
}
htmlElem := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Html,
Data: "html",
}
bodyElem := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Body,
Data: "body",
}
textElem := &html.Node{
Type: html.TextNode,
Data: "DocumentNode content",
}
bodyElem.AppendChild(textElem)
htmlElem.AppendChild(bodyElem)
customDoc.AppendChild(htmlElem)
var buf bytes.Buffer
if err := html.Render(&buf, customDoc); err != nil {
panic(err)
}
fmt.Printf("Rendered document: %s\n", buf.String())
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.DocumentNode in pkg:golang/golang.org/x/net@v0.24.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.24.0"
],
"symbols": [
"golang.org/x/net/html.DocumentNode"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func main() {
// 1. html.DocumentNode is a distinct NodeType constant distinguishing document root nodes from element, text, and comment nodes
if html.DocumentNode == html.ElementNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: DocumentNode must not equal ElementNode\n")
os.Exit(1)
}
if html.DocumentNode == html.TextNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: DocumentNode must not equal TextNode\n")
os.Exit(1)
}
if html.DocumentNode == html.CommentNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: DocumentNode must not equal CommentNode\n")
os.Exit(1)
}
if html.DocumentNode == html.DoctypeNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: DocumentNode must not equal DoctypeNode\n")
os.Exit(1)
}
if html.DocumentNode == html.ErrorNode {
fmt.Fprintf(os.Stderr, "Contract 1 failed: DocumentNode must not equal ErrorNode\n")
os.Exit(1)
}
// 2. html.Parse returns a root Node whose Type is html.DocumentNode with nil Parent and empty Data
rawHTML := `<!DOCTYPE html><html><head><title>Sample</title></head><body><p id="para">Text</p></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 {
fmt.Fprintf(os.Stderr, "Contract 2 failed: doc is nil\n")
os.Exit(1)
}
if doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 2 failed: doc.Type is %v, want DocumentNode\n", doc.Type)
os.Exit(1)
}
if doc.Parent != nil {
fmt.Fprintf(os.Stderr, "Contract 2 failed: doc.Parent is not nil\n")
os.Exit(1)
}
if doc.Data != "" {
fmt.Fprintf(os.Stderr, "Contract 2 failed: doc.Data is not empty: %q\n", doc.Data)
os.Exit(1)
}
// 3. html.Parse produces DocumentNode whose top-level children point back to it as Parent
if doc.FirstChild == nil {
fmt.Fprintf(os.Stderr, "Contract 3 failed: doc has no children\n")
os.Exit(1)
}
childCount := 0
for c := doc.FirstChild; c != nil; c = c.NextSibling {
childCount++
if c.Parent != doc {
fmt.Fprintf(os.Stderr, "Contract 3 failed: child %d parent is not doc\n", childCount)
os.Exit(1)
}
}
if childCount < 2 {
fmt.Fprintf(os.Stderr, "Contract 3 failed: expected at least 2 top-level children, got %d\n", childCount)
os.Exit(1)
}
// 4. html.DocumentNode can be constructed programmatically and populated with children using AppendChild
customDoc := &html.Node{
Type: html.DocumentNode,
}
div := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Div,
Data: "div",
}
span := &html.Node{
Type: html.ElementNode,
DataAtom: atom.Span,
Data: "span",
}
customDoc.AppendChild(div)
customDoc.AppendChild(span)
if customDoc.FirstChild != div || customDoc.LastChild != span {
fmt.Fprintf(os.Stderr, "Contract 4 failed: customDoc children pointers mismatch\n")
os.Exit(1)
}
if div.Parent != customDoc || span.Parent != customDoc {
fmt.Fprintf(os.Stderr, "Contract 4 failed: customDoc children Parent pointer mismatch\n")
os.Exit(1)
}
if div.NextSibling != span || span.PrevSibling != div {
fmt.Fprintf(os.Stderr, "Contract 4 failed: sibling pointers mismatch\n")
os.Exit(1)
}
// 5. html.Render serializes all top-level children of a DocumentNode into formatted HTML output
var renderBuf bytes.Buffer
if err := html.Render(&renderBuf, customDoc); err != nil {
fmt.Fprintf(os.Stderr, "Contract 5 failed: html.Render error: %v\n", err)
os.Exit(1)
}
expectedRendered := "<div></div><span></span>"
if renderBuf.String() != expectedRendered {
fmt.Fprintf(os.Stderr, "Contract 5 failed: rendered HTML mismatch: got %q, want %q\n", renderBuf.String(), expectedRendered)
os.Exit(1)
}
// 6. Traversing Parent pointers from any descendant node terminates at the DocumentNode root
var paraNode *html.Node
var findPara func(*html.Node)
findPara = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "p" {
paraNode = n
return
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
findPara(c)
}
}
findPara(doc)
if paraNode == nil {
fmt.Fprintf(os.Stderr, "Contract 6 failed: p node not found\n")
os.Exit(1)
}
curr := paraNode
for curr.Parent != nil {
curr = curr.Parent
}
if curr != doc || curr.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "Contract 6 failed: traversal did not terminate at DocumentNode root\n")
os.Exit(1)
}
// 7. html.DocumentNode supports child removal via RemoveChild updating FirstChild and LastChild
customDoc.RemoveChild(span)
if customDoc.FirstChild != div || customDoc.LastChild != div {
fmt.Fprintf(os.Stderr, "Contract 7 failed: after RemoveChild FirstChild/LastChild mismatch\n")
os.Exit(1)
}
if span.Parent != nil || span.PrevSibling != nil || span.NextSibling != nil {
fmt.Fprintf(os.Stderr, "Contract 7 failed: removed span pointers not cleared\n")
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous