Exemplo
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e: html.DoctypeNode
Amostra verificada para golang golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e: html.DoctypeNode. O contrato rodou em go 1.26 · linux debian/x64 · docker…
sha256:b5b7c8672114495dbbcbcf660672981968481813aff029b0b9a6dc48321e44ff
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-21 |
Caso
HOW- Objetivo
- verify golang.org/x/net/html.DoctypeNode in pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e
- Símbolos
-
- golang.org/x/net/html.DoctypeNode
- Criado
- 2026-10-21T11:48:25Z
Contrato
- html.DoctypeNode is a NodeType constant
- html.DoctypeNode is distinct from other NodeType values
- html.Parse parses DOCTYPE declaration as an html.DoctypeNode
- html.Parse extracts system and public attributes on html.DoctypeNode
- html.Render outputs valid DOCTYPE markup for an html.DoctypeNode
Arquivos
- PROMPT.md
- csx.json
- doctype.go
- go.mod
- go.sum
- spec.json
- test/contract.go
Código-fonte
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.DoctypeNode in pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e
Demonstrate these symbols/APIs:
- golang.org/x/net/html.DoctypeNode
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:ad78ff901a559600a52c39ac5afa52934c6eb89d168ff1f1460a1b9522d440d9","contract":["html.DoctypeNode is a NodeType constant","html.DoctypeNode is distinct from other NodeType values","html.Parse parses DOCTYPE declaration as an html.DoctypeNode","html.Parse extracts system and public attributes on html.DoctypeNode","html.Render outputs valid DOCTYPE markup for an html.DoctypeNode"],"goal":"verify golang.org/x/net/html.DoctypeNode in pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e"],"schemaVersion":1,"symbols":["golang.org/x/net/html.DoctypeNode"]},"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-20200324143707-d3edc9973b7e"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e","symbols":["golang.org/x/net/html.DoctypeNode"],"verifierAdapter":"golang@1"}
package sample
import (
"bytes"
"golang.org/x/net/html"
)
// FindDoctype traverses the direct children of the given document node
// and returns the first node with Type == html.DoctypeNode, or nil if none is found.
func FindDoctype(doc *html.Node) *html.Node {
if doc == nil {
return nil
}
for c := doc.FirstChild; c != nil; c = c.NextSibling {
if c.Type == html.DoctypeNode {
return c
}
}
return nil
}
// IsDoctype returns true if the node is non-nil and its Type is html.DoctypeNode.
func IsDoctype(n *html.Node) bool {
return n != nil && n.Type == html.DoctypeNode
}
// NewDoctype constructs a new html.Node representing a DOCTYPE declaration.
func NewDoctype(name, publicID, systemID string) *html.Node {
n := &html.Node{
Type: html.DoctypeNode,
Data: name,
}
if publicID != "" {
n.Attr = append(n.Attr, html.Attribute{Key: "public", Val: publicID})
}
if systemID != "" {
n.Attr = append(n.Attr, html.Attribute{Key: "system", Val: systemID})
}
return n
}
// RenderDoctype serializes a DoctypeNode into its HTML string representation.
func RenderDoctype(n *html.Node) (string, error) {
var buf bytes.Buffer
if err := html.Render(&buf, n); err != nil {
return "", err
}
return buf.String(), nil
}
module sample
go 1.26.6
require golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
{
"schemaVersion": 1,
"goal": "verify golang.org/x/net/html.DoctypeNode in pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.0.0-20200324143707-d3edc9973b7e"
],
"symbols": [
"golang.org/x/net/html.DoctypeNode"
]
}
package main
import (
"fmt"
"os"
"strings"
"golang.org/x/net/html"
"sample"
)
func main() {
// Assertion 1: html.DoctypeNode is a NodeType constant
var nodeType html.NodeType = html.DoctypeNode
if nodeType != html.DoctypeNode {
fmt.Fprintf(os.Stderr, "expected nodeType to match html.DoctypeNode\n")
os.Exit(1)
}
// Assertion 2: html.DoctypeNode is distinct from other NodeType values
if html.DoctypeNode == html.ErrorNode ||
html.DoctypeNode == html.TextNode ||
html.DoctypeNode == html.DocumentNode ||
html.DoctypeNode == html.ElementNode ||
html.DoctypeNode == html.CommentNode {
fmt.Fprintf(os.Stderr, "expected html.DoctypeNode to be distinct from other NodeType values\n")
os.Exit(1)
}
// Assertion 3: html.Parse parses DOCTYPE declaration as an html.DoctypeNode
htmlDoc := "<!DOCTYPE html><html><head></head><body><p>Hello</p></body></html>"
doc, err := html.Parse(strings.NewReader(htmlDoc))
if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse HTML: %v\n", err)
os.Exit(1)
}
if doc.Type != html.DocumentNode {
fmt.Fprintf(os.Stderr, "expected root node to be DocumentNode, got %v\n", doc.Type)
os.Exit(1)
}
dtNode := sample.FindDoctype(doc)
if dtNode == nil {
fmt.Fprintf(os.Stderr, "expected doctype node not found\n")
os.Exit(1)
}
if dtNode.Type != html.DoctypeNode {
fmt.Fprintf(os.Stderr, "expected doctype node to have Type html.DoctypeNode, got %v\n", dtNode.Type)
os.Exit(1)
}
if dtNode.Data != "html" {
fmt.Fprintf(os.Stderr, "expected doctype node data to be 'html', got %q\n", dtNode.Data)
os.Exit(1)
}
if !sample.IsDoctype(dtNode) {
fmt.Fprintf(os.Stderr, "expected sample.IsDoctype to return true\n")
os.Exit(1)
}
// Assertion 4: html.Parse extracts system and public attributes on html.DoctypeNode
htmlWithSystem := `<!DOCTYPE html SYSTEM "about:legacy-compat"><html><body></body></html>`
docWithSystem, err := html.Parse(strings.NewReader(htmlWithSystem))
if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse HTML with system doctype: %v\n", err)
os.Exit(1)
}
dtSystem := sample.FindDoctype(docWithSystem)
if dtSystem == nil || dtSystem.Type != html.DoctypeNode {
fmt.Fprintf(os.Stderr, "expected DoctypeNode in docWithSystem\n")
os.Exit(1)
}
foundSystem := false
for _, attr := range dtSystem.Attr {
if attr.Key == "system" && attr.Val == "about:legacy-compat" {
foundSystem = true
}
}
if !foundSystem {
fmt.Fprintf(os.Stderr, "expected system attribute on DoctypeNode\n")
os.Exit(1)
}
// Assertion 5: html.Render outputs valid DOCTYPE markup for an html.DoctypeNode
manualDoctype := sample.NewDoctype("html", "", "")
rendered, err := sample.RenderDoctype(manualDoctype)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to render DoctypeNode: %v\n", err)
os.Exit(1)
}
if rendered != "<!DOCTYPE html>" {
fmt.Fprintf(os.Stderr, "expected '<!DOCTYPE html>', got %q\n", rendered)
os.Exit(1)
}
manualWithSystem := sample.NewDoctype("html", "", "about:legacy-compat")
renderedSystem, err := sample.RenderDoctype(manualWithSystem)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to render DoctypeNode with system: %v\n", err)
os.Exit(1)
}
if renderedSystem != `<!DOCTYPE html SYSTEM "about:legacy-compat">` {
fmt.Fprintf(os.Stderr, "expected '<!DOCTYPE html SYSTEM \"about:legacy-compat\">', got %q\n", renderedSystem)
os.Exit(1)
}
fmt.Println("All html.DoctypeNode contract assertions passed.")
}
Seeder de origem
anônimo