CodeSampleX

Beispiel

golang.org/x/net v0.61.0: atom.H5

Verifiziertes Beispiel für golang golang.org/x/net v0.61.0: atom.H5. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.

sha256:e0d6be6a3f29049426d1eb4b867c188f9ed3f71dec2238d8e5a4e46b0fd5b09a

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 go

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-12

Fall

HOW
Ziel
verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.61.0
Pakete
Symbole
  • golang.org/x/net/html/atom.H5
Erstellt
2026-10-12T05:28:02Z

Contract

  1. atom.H5 is a non-zero Atom constant whose String() method returns "h5"
  2. atom.Lookup on byte slice "h5" returns atom.H5
  3. atom.String on byte slice "h5" returns "h5"
  4. atom.H5 is distinct from other heading atoms such as atom.H1, atom.H2, atom.H3, atom.H4, and atom.H6
  5. html.Parse on HTML containing <h5> tag yields an ElementNode with DataAtom equal to atom.H5
  6. explicitly created html.Node with DataAtom atom.H5 and Data "h5" renders as an <h5> element

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/atom.H5 in pkg:golang/golang.org/x/net@v0.61.0
Kind: HOW

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

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:da7b10180063c911dde10786e8cef197c0810040e49ccdd9b2dc55694152d745","contract":["atom.H5 is a non-zero Atom constant whose String() method returns \"h5\"","atom.Lookup on byte slice \"h5\" returns atom.H5","atom.String on byte slice \"h5\" returns \"h5\"","atom.H5 is distinct from other heading atoms such as atom.H1, atom.H2, atom.H3, atom.H4, and atom.H6","html.Parse on HTML containing \u003ch5\u003e tag yields an ElementNode with DataAtom equal to atom.H5","explicitly created html.Node with DataAtom atom.H5 and Data \"h5\" renders as an \u003ch5\u003e element"],"goal":"verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.61.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.61.0"],"schemaVersion":1,"symbols":["golang.org/x/net/html/atom.H5"]},"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.61.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.61.0","symbols":["golang.org/x/net/html/atom.H5"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.0

require golang.org/x/net v0.61.0
go.sum
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
main.go
package main

import (
	"bytes"
	"fmt"
	"strings"

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

func main() {
	fmt.Printf("atom: %s (value: %d)\n", atom.H5, atom.H5)

	lookup := atom.Lookup([]byte("h5"))
	fmt.Printf("atom.Lookup(\"h5\") == atom.H5: %t\n", lookup == atom.H5)

	doc, err := html.Parse(strings.NewReader("<h5>Heading</h5>"))
	if err != nil {
		panic(err)
	}

	var found bool
	var walk func(*html.Node)
	walk = func(n *html.Node) {
		if n.Type == html.ElementNode && n.DataAtom == atom.H5 {
			found = true
			return
		}
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			walk(c)
		}
	}
	walk(doc)
	fmt.Printf("Found atom.H5 in parsed HTML: %t\n", found)

	node := &html.Node{
		Type:     html.ElementNode,
		DataAtom: atom.H5,
		Data:     atom.H5.String(),
	}
	var buf bytes.Buffer
	if err := html.Render(&buf, node); err != nil {
		panic(err)
	}
	fmt.Printf("Rendered element: %s\n", buf.String())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.61.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.61.0"
  ],
  "symbols": [
    "golang.org/x/net/html/atom.H5"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"fmt"
	"os"
	"strings"

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

func main() {
	// 1. atom.H5 is a non-zero Atom constant whose String() method returns "h5"
	if atom.H5 == 0 {
		fmt.Fprintf(os.Stderr, "assertion failed: atom.H5 should not be 0\n")
		os.Exit(1)
	}
	if atom.H5.String() != "h5" {
		fmt.Fprintf(os.Stderr, "assertion failed: atom.H5.String() = %q, want %q\n", atom.H5.String(), "h5")
		os.Exit(1)
	}

	// 2. atom.Lookup on byte slice "h5" returns atom.H5
	if got := atom.Lookup([]byte("h5")); got != atom.H5 {
		fmt.Fprintf(os.Stderr, "assertion failed: atom.Lookup(\"h5\") = %v, want %v\n", got, atom.H5)
		os.Exit(1)
	}

	// 3. atom.String on byte slice "h5" returns "h5"
	if got := atom.String([]byte("h5")); got != "h5" {
		fmt.Fprintf(os.Stderr, "assertion failed: atom.String(\"h5\") = %q, want %q\n", got, "h5")
		os.Exit(1)
	}

	// 4. atom.H5 is distinct from other heading atoms such as atom.H1, atom.H2, atom.H3, atom.H4, and atom.H6
	headings := []struct {
		name string
		a    atom.Atom
	}{
		{"H1", atom.H1},
		{"H2", atom.H2},
		{"H3", atom.H3},
		{"H4", atom.H4},
		{"H6", atom.H6},
	}
	for _, h := range headings {
		if atom.H5 == h.a {
			fmt.Fprintf(os.Stderr, "assertion failed: atom.H5 unexpectedly equals atom.%s\n", h.name)
			os.Exit(1)
		}
	}

	// 5. html.Parse on HTML containing <h5> tag yields an ElementNode with DataAtom equal to atom.H5
	doc, err := html.Parse(strings.NewReader("<!DOCTYPE html><html><body><h5>Heading 5</h5></body></html>"))
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion failed: html.Parse error: %v\n", err)
		os.Exit(1)
	}
	var h5Found bool
	var walk func(*html.Node)
	walk = func(n *html.Node) {
		if n.Type == html.ElementNode && n.DataAtom == atom.H5 {
			if n.Data != "h5" {
				fmt.Fprintf(os.Stderr, "assertion failed: expected element Data to be \"h5\", got %q\n", n.Data)
				os.Exit(1)
			}
			h5Found = true
			return
		}
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			walk(c)
		}
	}
	walk(doc)
	if !h5Found {
		fmt.Fprintf(os.Stderr, "assertion failed: <h5> tag with DataAtom == atom.H5 not found\n")
		os.Exit(1)
	}

	// 6. explicitly created html.Node with DataAtom atom.H5 and Data "h5" renders as an <h5> element
	node := &html.Node{
		Type:     html.ElementNode,
		DataAtom: atom.H5,
		Data:     atom.H5.String(),
	}
	node.AppendChild(&html.Node{
		Type: html.TextNode,
		Data: "Test Content",
	})
	var buf bytes.Buffer
	if err := html.Render(&buf, node); err != nil {
		fmt.Fprintf(os.Stderr, "assertion failed: html.Render error: %v\n", err)
		os.Exit(1)
	}
	expectedHTML := "<h5>Test Content</h5>"
	if buf.String() != expectedHTML {
		fmt.Fprintf(os.Stderr, "assertion failed: html.Render output = %q, want %q\n", buf.String(), expectedHTML)
		os.Exit(1)
	}

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

Ursprungs-Seeder

anonym