Sample
golang.org/x/net v0.23.0: html.NodeType
Verified sample for golang golang.org/x/net v0.23.0: html.NodeType. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:decdaefa121d6b5ed1408a850e6bf440f73e2ff6200f47b2cc545dffa55fc5f1
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.NodeType in pkg:golang/golang.org/x/net@v0.23.0
- Packages
- Symbols
-
- golang.org/x/net/html.NodeType
- Created
- 2026-09-04T17:12:38Z
Contract
- html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode
- html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value
- A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation
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.NodeType 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.NodeType
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:d3c0204aa54db6439999a537491a54b7f33a63c4d5bb8be1e43c0fb118de2d77","contract":["html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode","html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value","A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation"],"goal":"verify golang.org/x/net/html.NodeType 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.NodeType"]},"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.NodeType"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22.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 (
"fmt"
"log"
"strings"
"golang.org/x/net/html"
)
// ClassifyNodeType returns a human-readable name for an html.NodeType.
func ClassifyNodeType(nt html.NodeType) string {
switch nt {
case html.ErrorNode:
return "ErrorNode"
case html.TextNode:
return "TextNode"
case html.DocumentNode:
return "DocumentNode"
case html.ElementNode:
return "ElementNode"
case html.CommentNode:
return "CommentNode"
case html.DoctypeNode:
return "DoctypeNode"
case html.RawNode:
return "RawNode"
default:
return fmt.Sprintf("NodeType(%d)", nt)
}
}
// CountNodeTypes traverses an HTML document tree and returns a map of NodeType to count.
func CountNodeTypes(n *html.Node) map[html.NodeType]int {
counts := make(map[html.NodeType]int)
var walk func(*html.Node)
walk = func(curr *html.Node) {
if curr == nil {
return
}
counts[curr.Type]++
for c := curr.FirstChild; c != nil; c = c.NextSibling {
walk(c)
}
}
walk(n)
return counts
}
func main() {
sampleHTML := `<!DOCTYPE html><html><!-- sample comment --><body><h1>Hello World</h1></body></html>`
doc, err := html.Parse(strings.NewReader(sampleHTML))
if err != nil {
log.Fatalf("failed to parse HTML: %v", err)
}
counts := CountNodeTypes(doc)
fmt.Printf("Root node type: %s\n", ClassifyNodeType(doc.Type))
for nt, count := range counts {
fmt.Printf(" %s: %d\n", ClassifyNodeType(nt), count)
}
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.NodeType 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.NodeType"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
)
func main() {
// Assertion 1: html.NodeType constants identify the distinct kinds of DOM nodes including DocumentNode, ElementNode, TextNode, CommentNode, and DoctypeNode
expectedConstants := map[html.NodeType]uint32{
html.ErrorNode: 0,
html.TextNode: 1,
html.DocumentNode: 2,
html.ElementNode: 3,
html.CommentNode: 4,
html.DoctypeNode: 5,
html.RawNode: 6,
}
for nt, val := range expectedConstants {
if uint32(nt) != val {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected NodeType %d to have value %d, got %d\n", nt, val, uint32(nt))
os.Exit(1)
}
}
types := []html.NodeType{
html.ErrorNode,
html.TextNode,
html.DocumentNode,
html.ElementNode,
html.CommentNode,
html.DoctypeNode,
html.RawNode,
}
seen := make(map[html.NodeType]bool)
for _, t := range types {
if seen[t] {
fmt.Fprintf(os.Stderr, "assertion 1 failed: duplicate NodeType %d\n", t)
os.Exit(1)
}
seen[t] = true
}
// Assertion 2: html.Parse populates the Type field of each node in the parsed tree with the corresponding html.NodeType value
htmlDoc := `<!DOCTYPE html><html><!-- comment --><body><p>Sample Text</p></body></html>`
doc, err := html.Parse(strings.NewReader(htmlDoc))
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: html.Parse error: %v\n", err)
os.Exit(1)
}
if doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected root Type DocumentNode, got %v\n", doc.Type)
os.Exit(1)
}
nodeTypeCounts := make(map[html.NodeType]int)
var collectTypes func(*html.Node)
collectTypes = func(n *html.Node) {
if n == nil {
return
}
nodeTypeCounts[n.Type]++
for c := n.FirstChild; c != nil; c = c.NextSibling {
collectTypes(c)
}
}
collectTypes(doc)
if nodeTypeCounts[html.DocumentNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 DocumentNode, got %d\n", nodeTypeCounts[html.DocumentNode])
os.Exit(1)
}
if nodeTypeCounts[html.DoctypeNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 DoctypeNode, got %d\n", nodeTypeCounts[html.DoctypeNode])
os.Exit(1)
}
if nodeTypeCounts[html.CommentNode] != 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 1 CommentNode, got %d\n", nodeTypeCounts[html.CommentNode])
os.Exit(1)
}
if nodeTypeCounts[html.ElementNode] < 4 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected at least 4 ElementNodes, got %d\n", nodeTypeCounts[html.ElementNode])
os.Exit(1)
}
if nodeTypeCounts[html.TextNode] < 1 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected at least 1 TextNode, got %d\n", nodeTypeCounts[html.TextNode])
os.Exit(1)
}
// Assertion 3: A programmatically created html.Node retains its assigned html.NodeType during tree construction and manipulation
customElement := &html.Node{
Type: html.ElementNode,
Data: "div",
}
customText := &html.Node{
Type: html.TextNode,
Data: "Dynamic Content",
}
customComment := &html.Node{
Type: html.CommentNode,
Data: "Dynamic Comment",
}
customElement.AppendChild(customComment)
customElement.AppendChild(customText)
if customElement.Type != html.ElementNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected ElementNode, got %v\n", customElement.Type)
os.Exit(1)
}
if customElement.FirstChild.Type != html.CommentNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected CommentNode, got %v\n", customElement.FirstChild.Type)
os.Exit(1)
}
if customElement.LastChild.Type != html.TextNode {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected TextNode, got %v\n", customElement.LastChild.Type)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous