Ejemplo
modernc.org/ccgo/v4 v4.34.6: lib.NewTask
Muestra verificada para golang modernc.org/ccgo/v4 v4.34.6: lib.NewTask. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.
sha256:c9a43a0a275c7d48141e724e60cae3222e8f0973e404ec5858c7220b3feccc9b
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-16 |
Caso
HOW- Objetivo
- verify modernc.org/ccgo/v4/lib.NewTask in pkg:golang/modernc.org/ccgo/v4@v4.34.6
- Paquetes
- Símbolos
-
- modernc.org/ccgo/v4/lib.NewTask
- Entorno
- go 1.26.6
- Creado
- 2026-09-16T01:55:12Z
Contrato
- NewTask returns a non-nil Task configured with target OS and architecture
- NewTask parses command line define and include flags into Task fields
- NewTask parses undefine, optimization, and preprocessing flags
- NewTask executes C preprocessing on virtual filesystem source and routes output to stdout
- NewTask captures errors when preprocessing invalid or missing source files
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
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 modernc.org/ccgo/v4/lib.NewTask in pkg:golang/modernc.org/ccgo/v4@v4.34.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/modernc.org/ccgo/v4@v4.34.6
Demonstrate these symbols/APIs:
- modernc.org/ccgo/v4/lib.NewTask
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:521a21b888698d6fa6dce51980f5f8960d54e43084283e90f03710359c15d0c5","contract":["NewTask returns a non-nil Task configured with target OS and architecture","NewTask parses command line define and include flags into Task fields","NewTask parses undefine, optimization, and preprocessing flags","NewTask executes C preprocessing on virtual filesystem source and routes output to stdout","NewTask captures errors when preprocessing invalid or missing source files"],"goal":"verify modernc.org/ccgo/v4/lib.NewTask in pkg:golang/modernc.org/ccgo/v4@v4.34.6","kind":"HOW","packages":["pkg:golang/modernc.org/ccgo/v4@v4.34.6"],"schemaVersion":1,"symbols":["modernc.org/ccgo/v4/lib.NewTask"]},"contractCommand":["go","run","./test"],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/modernc.org/ccgo/v4@v4.34.6"],"schemaVersion":1,"subject":"pkg:golang/modernc.org/ccgo/v4@v4.34.6","symbols":["modernc.org/ccgo/v4/lib.NewTask"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/mod v0.37.0 // indirect
golang.org/x/sync v0.21.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/tools v0.46.0 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/cc/v4 v4.29.0 // indirect
modernc.org/ccgo/v3 v3.17.0 // indirect
modernc.org/ccgo/v4 v4.34.6 // indirect
modernc.org/gc/v2 v2.6.5 // indirect
modernc.org/gc/v3 v3.1.4 // indirect
modernc.org/libc v1.73.5 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/opt v0.2.0 // indirect
modernc.org/sortutil v1.2.1 // indirect
modernc.org/strutil v1.2.1 // indirect
modernc.org/token v1.1.0 // indirect
)
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk=
golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.41.0 h1:QoR1Sn3YWlmA1T4vLaKZfawdVtSiGx8H+cEojbC7v1Q=
modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y=
modernc.org/cc/v4 v4.29.0 h1:CXgwL8cvxmyzBQZzbSl/6xFtMCryb6u8IOqDci39cgc=
modernc.org/cc/v4 v4.29.0/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
modernc.org/ccgo/v3 v3.17.0 h1:o3OmOqx4/OFnl4Vm3G8Bgmqxnvxnh0nbxeT5p/dWChA=
modernc.org/ccgo/v3 v3.17.0/go.mod h1:Sg3fwVpmLvCUTaqEUjiBDAvshIaKDB0RXaf+zgqFu8I=
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
modernc.org/libc v1.73.5 h1:G34rN/cRqL+zOUnrbz9uPq/+OxJ8/vzQ2CQwTJ42Wmw=
modernc.org/libc v1.73.5/go.mod h1:+Aoyx4M0etg6GikzCrip1VtvAtUlMlo2Aq+GHwQSqOA=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
package main
import (
"bytes"
"fmt"
"os"
"testing/fstest"
ccgo "modernc.org/ccgo/v4/lib"
)
func main() {
// Provide in-memory C source code to ccgo
mfs := fstest.MapFS{
"sample.c": &fstest.MapFile{
Data: []byte("#define BUFFER_CAPACITY 1024\nint default_capacity = BUFFER_CAPACITY;\n"),
},
}
var stdout, stderr bytes.Buffer
args := []string{"ccgo", "-E", "sample.c"}
// Create a new compilation task targeting linux/amd64
task := ccgo.NewTask("linux", "amd64", args, &stdout, &stderr, mfs)
if task == nil {
fmt.Fprintln(os.Stderr, "failed to create task")
os.Exit(1)
}
// Run preprocessing
if err := task.Main(); err != nil {
fmt.Fprintf(os.Stderr, "preprocessing failed: %v\n", err)
os.Exit(1)
}
fmt.Println("Preprocessing completed successfully:")
fmt.Print(stdout.String())
}
{
"schemaVersion": 1,
"goal": "verify modernc.org/ccgo/v4/lib.NewTask in pkg:golang/modernc.org/ccgo/v4@v4.34.6",
"kind": "HOW",
"packages": [
"pkg:golang/modernc.org/ccgo/v4@v4.34.6"
],
"symbols": [
"modernc.org/ccgo/v4/lib.NewTask"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"testing/fstest"
ccgo "modernc.org/ccgo/v4/lib"
)
func main() {
// Assertion 1: NewTask returns a non-nil Task configured with target OS and architecture
{
var stdout, stderr bytes.Buffer
task := ccgo.NewTask("linux", "amd64", []string{"ccgo"}, &stdout, &stderr, nil)
if task == nil {
fmt.Fprintln(os.Stderr, "assertion 1 failed: NewTask returned nil")
os.Exit(1)
}
}
// Assertion 2: NewTask parses command line define and include flags into Task fields
{
mfs := fstest.MapFS{
"dummy.c": &fstest.MapFile{Data: []byte("int dummy = 1;\n")},
}
var stdout, stderr bytes.Buffer
args := []string{"ccgo", "-D", "CONFIG_FLAG=1", "-I", "include/path", "-E", "dummy.c"}
task := ccgo.NewTask("linux", "amd64", args, &stdout, &stderr, mfs)
if task == nil {
fmt.Fprintln(os.Stderr, "assertion 2 failed: NewTask returned nil")
os.Exit(1)
}
if err := task.Main(); err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: task.Main error: %v\n", err)
os.Exit(1)
}
foundD := false
for _, d := range task.D {
if strings.Contains(d, "CONFIG_FLAG=1") {
foundD = true
break
}
}
if !foundD {
fmt.Fprintf(os.Stderr, "assertion 2 failed: define flag not found in task.D: %v\n", task.D)
os.Exit(1)
}
foundI := false
for _, i := range task.I {
if i == "include/path" {
foundI = true
break
}
}
if !foundI {
fmt.Fprintf(os.Stderr, "assertion 2 failed: include flag not found in task.I: %v\n", task.I)
os.Exit(1)
}
}
// Assertion 3: NewTask parses undefine, optimization, and preprocessing flags
{
mfs := fstest.MapFS{
"dummy.c": &fstest.MapFile{Data: []byte("int dummy = 2;\n")},
}
var stdout, stderr bytes.Buffer
args := []string{"ccgo", "-U", "LEGACY_MODE", "-O2", "-E", "dummy.c"}
task := ccgo.NewTask("linux", "amd64", args, &stdout, &stderr, mfs)
if task == nil {
fmt.Fprintln(os.Stderr, "assertion 3 failed: NewTask returned nil")
os.Exit(1)
}
if err := task.Main(); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: task.Main error: %v\n", err)
os.Exit(1)
}
foundU := false
for _, u := range task.U {
if strings.Contains(u, "LEGACY_MODE") {
foundU = true
break
}
}
if !foundU {
fmt.Fprintf(os.Stderr, "assertion 3 failed: undefine flag not found in task.U: %v\n", task.U)
os.Exit(1)
}
if task.O != "-O2" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: unexpected optimization flag: %q\n", task.O)
os.Exit(1)
}
if !task.E {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected task.E to be true\n")
os.Exit(1)
}
}
// Assertion 4: NewTask executes C preprocessing on virtual filesystem source and routes output to stdout
{
mfs := fstest.MapFS{
"input.c": &fstest.MapFile{
Data: []byte("#define BUFFER_LEN 512\nint capacity = BUFFER_LEN;\n"),
},
}
var stdout, stderr bytes.Buffer
args := []string{"ccgo", "-E", "input.c"}
task := ccgo.NewTask("linux", "amd64", args, &stdout, &stderr, mfs)
if task == nil {
fmt.Fprintln(os.Stderr, "assertion 4 failed: NewTask returned nil")
os.Exit(1)
}
if err := task.Main(); err != nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: task.Main error: %v\n", err)
os.Exit(1)
}
if !strings.Contains(stdout.String(), "int capacity = 512;") {
fmt.Fprintf(os.Stderr, "assertion 4 failed: output missing expanded macro: %q\n", stdout.String())
os.Exit(1)
}
}
// Assertion 5: NewTask captures errors when preprocessing invalid or missing source files
{
mfs := fstest.MapFS{}
var stdout, stderr bytes.Buffer
args := []string{"ccgo", "-E", "nonexistent.c"}
task := ccgo.NewTask("linux", "amd64", args, &stdout, &stderr, mfs)
if task == nil {
fmt.Fprintln(os.Stderr, "assertion 5 failed: NewTask returned nil")
os.Exit(1)
}
err := task.Main()
if err == nil {
fmt.Fprintln(os.Stderr, "assertion 5 failed: expected error for missing file, got nil")
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
Seeder de origen
anónimo