CodeSampleX

Пример

golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914: atom.H5

Проверенный пример — golang golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914: atom.H5. Контракт выполнен на go 1.26 · linux debian/x64 · docker и пройден.

sha256:5c302ebfaad55bec3181a53716062c7d26cbeea4e0db8b7b7f42bc2eb881fb4f

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 go

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-28

Кейс

HOW
Цель
verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
Пакеты
Символы
  • golang.org/x/net/html/atom.H5
Создан
2026-10-28T10:57:36Z

Контракт

  1. atom.H5 is a non-zero Atom constant whose String() method returns "h5"
  2. atom.Lookup([]byte("h5")) returns atom.H5
  3. atom.String([]byte("h5")) returns "h5"
  4. atom.Lookup([]byte("H5")) returns 0 (case-sensitive)
  5. atom.H5 is distinct from atom.H1, atom.H2, atom.H3, atom.H4, and atom.H6
  6. html.Parse on HTML containing <h5> yields an ElementNode with DataAtom equal to atom.H5

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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.0.0-20191119073136-fc4aabc6c914
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914
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:b23ab02f4d1efd712551f1dbcc484c8e62060b50e5369210d25936c635beeda2","contract":["atom.H5 is a non-zero Atom constant whose String() method returns \"h5\"","atom.Lookup([]byte(\"h5\")) returns atom.H5","atom.String([]byte(\"h5\")) returns \"h5\"","atom.Lookup([]byte(\"H5\")) returns 0 (case-sensitive)","atom.H5 is distinct from atom.H1, atom.H2, atom.H3, atom.H4, and atom.H6","html.Parse on HTML containing \u003ch5\u003e yields an ElementNode with DataAtom equal to atom.H5"],"goal":"verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914"],"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.0.0-20191119073136-fc4aabc6c914"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914","symbols":["golang.org/x/net/html/atom.H5"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914
go.sum
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4=
golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
main.go
package main

import (
	"fmt"

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

func main() {
	a := atom.H5
	fmt.Printf("atom.H5: %s (code: %#x)\n", a.String(), uint32(a))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/html/atom.H5 in pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.0.0-20191119073136-fc4aabc6c914"
  ],
  "symbols": [
    "golang.org/x/net/html/atom.H5"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"strings"

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

func main() {
	if atom.H5 == 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected atom.H5 to be non-zero\n")
		os.Exit(1)
	}

	if s := atom.H5.String(); s != "h5" {
		fmt.Fprintf(os.Stderr, "FAIL: expected atom.H5.String() == %q, got %q\n", "h5", s)
		os.Exit(1)
	}

	if a := atom.Lookup([]byte("h5")); a != atom.H5 {
		fmt.Fprintf(os.Stderr, "FAIL: expected atom.Lookup([]byte(\"h5\")) == atom.H5, got %v\n", a)
		os.Exit(1)
	}

	if s := atom.String([]byte("h5")); s != "h5" {
		fmt.Fprintf(os.Stderr, "FAIL: expected atom.String([]byte(\"h5\")) == %q, got %q\n", "h5", s)
		os.Exit(1)
	}

	if a := atom.Lookup([]byte("H5")); a != 0 {
		fmt.Fprintf(os.Stderr, "FAIL: expected case-sensitive atom.Lookup([]byte(\"H5\")) == 0, got %v\n", a)
		os.Exit(1)
	}

	for _, other := range []atom.Atom{atom.H1, atom.H2, atom.H3, atom.H4, atom.H6} {
		if atom.H5 == other {
			fmt.Fprintf(os.Stderr, "FAIL: expected atom.H5 to be distinct from %v\n", other)
			os.Exit(1)
		}
	}

	doc, err := html.Parse(strings.NewReader("<!DOCTYPE html><html><body><h5>Heading 5</h5></body></html>"))
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: html.Parse failed: %v\n", err)
		os.Exit(1)
	}

	var found bool
	var walk func(*html.Node)
	walk = func(n *html.Node) {
		if n.Type == html.ElementNode && n.DataAtom == atom.H5 && n.Data == "h5" {
			found = true
			return
		}
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			walk(c)
		}
	}
	walk(doc)
	if !found {
		fmt.Fprintf(os.Stderr, "FAIL: did not find parsed <h5> ElementNode with DataAtom == atom.H5\n")
		os.Exit(1)
	}

	fmt.Println("PASS: all contract assertions passed")
}

Исходный сидер

аноним