CodeSampleX

Sample

golang.org/x/net v0.51.0: html.TokenType

Verified sample for golang golang.org/x/net v0.51.0: html.TokenType. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:bc6eb2be93b3fd0d749768c7d9d8a10bdd69ec4680859684dfdde38916760f51

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-07

Case

HOW
Goal
verify golang.org/x/net/html.TokenType in pkg:golang/golang.org/x/net@v0.51.0
Packages
Symbols
  • golang.org/x/net/html.TokenType
Created
2026-09-07T03:07:31Z

Contract

  1. TokenType String method returns expected string representation for all standard token types
  2. html.NewTokenizer Next method parses HTML and produces expected TokenType sequence
  3. SelfClosingTagToken is returned when tokenizer encounters self-closing void elements
  4. CommentToken and DoctypeToken are correctly identified by tokenizer
  5. ErrorToken is returned at end of input with io.EOF error

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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.TokenType in pkg:golang/golang.org/x/net@v0.51.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.51.0
Demonstrate these symbols/APIs:
  - golang.org/x/net/html.TokenType

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.
csx.json
{"case":{"caseId":"case:sha256:d8c27e7831be56d7f4584f5dcd514a2cf4b50e911ed667a99be1ed3e3165d3dd","contract":["TokenType String method returns expected string representation for all standard token types","html.NewTokenizer Next method parses HTML and produces expected TokenType sequence","SelfClosingTagToken is returned when tokenizer encounters self-closing void elements","CommentToken and DoctypeToken are correctly identified by tokenizer","ErrorToken is returned at end of input with io.EOF error"],"goal":"verify golang.org/x/net/html.TokenType in pkg:golang/golang.org/x/net@v0.51.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.51.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html.TokenType"]},"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.51.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.51.0","symbols":["golang.org/x/net/html.TokenType"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require golang.org/x/net v0.51.0
go.sum
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
main.go
package main

import (
	"fmt"
	"io"
	"strings"

	"golang.org/x/net/html"
)

func main() {
	rawHTML := `<!DOCTYPE html><html><body><!-- comment --><p>Hello</p><br/></body></html>`
	z := html.NewTokenizer(strings.NewReader(rawHTML))

	for {
		tt := z.Next()
		if tt == html.ErrorToken {
			err := z.Err()
			if err == io.EOF {
				fmt.Println("End of tokens")
				break
			}
			fmt.Printf("Error: %v\n", err)
			break
		}
		fmt.Printf("Token: %s -> %s\n", tt.String(), z.Token().Data)
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html.TokenType in pkg:golang/golang.org/x/net@v0.51.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.51.0"
  ],
  "symbols": [
    "golang.org/x/net/html.TokenType"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"io"
	"os"
	"strings"

	"golang.org/x/net/html"
)

func main() {
	// Assertion 1: TokenType String method returns expected string representation for all standard token types
	expectedStrings := map[html.TokenType]string{
		html.ErrorToken:          "Error",
		html.TextToken:           "Text",
		html.StartTagToken:       "StartTag",
		html.EndTagToken:         "EndTag",
		html.SelfClosingTagToken: "SelfClosingTag",
		html.CommentToken:        "Comment",
		html.DoctypeToken:        "Doctype",
	}

	for tt, expected := range expectedStrings {
		if tt.String() != expected {
			fmt.Fprintf(os.Stderr, "assertion failed: expected TokenType(%d).String() == %q, got %q\n", tt, expected, tt.String())
			os.Exit(1)
		}
	}

	// Assertion 2: html.NewTokenizer Next method parses HTML and produces expected TokenType sequence
	rawHTML := `<!DOCTYPE html><html><body><!-- sample comment --><p>Sample Text</p><img src="example.png"/></body></html>`
	z := html.NewTokenizer(strings.NewReader(rawHTML))

	expectedTokens := []struct {
		tokenType html.TokenType
		data      string
	}{
		{html.DoctypeToken, "html"},
		{html.StartTagToken, "html"},
		{html.StartTagToken, "body"},
		{html.CommentToken, " sample comment "},
		{html.StartTagToken, "p"},
		{html.TextToken, "Sample Text"},
		{html.EndTagToken, "p"},
		{html.SelfClosingTagToken, "img"},
		{html.EndTagToken, "body"},
		{html.EndTagToken, "html"},
	}

	for i, exp := range expectedTokens {
		tt := z.Next()
		if tt != exp.tokenType {
			fmt.Fprintf(os.Stderr, "assertion failed at index %d: expected TokenType %s, got %s\n", i, exp.tokenType.String(), tt.String())
			os.Exit(1)
		}
		tok := z.Token()
		if tok.Type != exp.tokenType {
			fmt.Fprintf(os.Stderr, "assertion failed at index %d: expected Token.Type %s, got %s\n", i, exp.tokenType.String(), tok.Type.String())
			os.Exit(1)
		}
		if tok.Data != exp.data {
			fmt.Fprintf(os.Stderr, "assertion failed at index %d: expected Token.Data %q, got %q\n", i, exp.data, tok.Data)
			os.Exit(1)
		}
	}

	// Assertion 3: SelfClosingTagToken is returned when tokenizer encounters self-closing void elements
	zImg := html.NewTokenizer(strings.NewReader(`<img src="example.png"/>`))
	if tt := zImg.Next(); tt != html.SelfClosingTagToken {
		fmt.Fprintf(os.Stderr, "assertion failed: expected SelfClosingTagToken, got %s\n", tt.String())
		os.Exit(1)
	}

	// Assertion 4: CommentToken and DoctypeToken are correctly identified by tokenizer
	zDoc := html.NewTokenizer(strings.NewReader(`<!DOCTYPE html>`))
	if tt := zDoc.Next(); tt != html.DoctypeToken {
		fmt.Fprintf(os.Stderr, "assertion failed: expected DoctypeToken, got %s\n", tt.String())
		os.Exit(1)
	}
	zCom := html.NewTokenizer(strings.NewReader(`<!-- notice -->`))
	if tt := zCom.Next(); tt != html.CommentToken {
		fmt.Fprintf(os.Stderr, "assertion failed: expected CommentToken, got %s\n", tt.String())
		os.Exit(1)
	}

	// Assertion 5: ErrorToken is returned at end of input with io.EOF error
	ttEOF := z.Next()
	if ttEOF != html.ErrorToken {
		fmt.Fprintf(os.Stderr, "assertion failed: expected ErrorToken at end of input, got %s\n", ttEOF.String())
		os.Exit(1)
	}
	if z.Err() != io.EOF {
		fmt.Fprintf(os.Stderr, "assertion failed: expected io.EOF, got %v\n", z.Err())
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed successfully.")
}

Origin Seeder

anonymous