Sample
github.com/slackhq/nebula v1.6.1: header.NewHeader
Verified sample for golang github.com/slackhq/nebula v1.6.1: header.NewHeader. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:d7255ede5393f78503467e38666e07df7945b46cc2c69aee7bdaf233463f16a7
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
- 3
- 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 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-02 |
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-02 |
| 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-02 |
Case
HOW- Goal
- verify github.com/slackhq/nebula/header.NewHeader in pkg:golang/github.com/slackhq/nebula@v1.6.1
- Packages
- Symbols
-
- github.com/slackhq/nebula/header.NewHeader
- Created
- 2026-09-02T14:35:03Z
Contract
- NewHeader parses valid 16-byte raw header bytes into an H struct with matching Version, Type, Subtype, RemoteIndex, and MessageCounter.
- NewHeader returns ErrHeaderTooShort when input buffer is shorter than 16 bytes.
- H.Encode serializes header fields into a 16-byte slice that round-trips identically through NewHeader and H.Parse.
- H.Encode returns an error when invoked on a nil header pointer.
- H.TypeName and H.SubTypeName map standard message types and subtypes to expected strings and return unknown for unrecognized values.
- H.MarshalJSON serializes header metadata into JSON containing version, type, subType, reserved, remoteIndex, and messageCounter.
- H.String formats header fields into a descriptive human-readable summary string, returning <nil> for a nil receiver.
- header.Encode directly serializes version, type, subtype, remote index, and counter into a preallocated byte slice.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
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 github.com/slackhq/nebula/header.NewHeader in pkg:golang/github.com/slackhq/nebula@v1.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/slackhq/nebula@v1.6.1
Demonstrate these symbols/APIs:
- github.com/slackhq/nebula/header.NewHeader
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:3582b811b59a62539302c3cc73ccb88d0f535621e964363e3a96383664314bfa","contract":["NewHeader parses valid 16-byte raw header bytes into an H struct with matching Version, Type, Subtype, RemoteIndex, and MessageCounter.","NewHeader returns ErrHeaderTooShort when input buffer is shorter than 16 bytes.","H.Encode serializes header fields into a 16-byte slice that round-trips identically through NewHeader and H.Parse.","H.Encode returns an error when invoked on a nil header pointer.","H.TypeName and H.SubTypeName map standard message types and subtypes to expected strings and return unknown for unrecognized values.","H.MarshalJSON serializes header metadata into JSON containing version, type, subType, reserved, remoteIndex, and messageCounter.","H.String formats header fields into a descriptive human-readable summary string, returning \u003cnil\u003e for a nil receiver.","header.Encode directly serializes version, type, subtype, remote index, and counter into a preallocated byte slice."],"goal":"verify github.com/slackhq/nebula/header.NewHeader in pkg:golang/github.com/slackhq/nebula@v1.6.1","kind":"HOW","packages":["pkg:golang/github.com/slackhq/nebula@v1.6.1"],"schemaVersion":1,"symbols":["github.com/slackhq/nebula/header.NewHeader"]},"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/github.com/slackhq/nebula@v1.6.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/slackhq/nebula@v1.6.1","symbols":["github.com/slackhq/nebula/header.NewHeader"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/slackhq/nebula v1.6.1
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/slackhq/nebula v1.6.1 h1:/OCTR3abj0Sbf2nGoLUrdDXImrCv0ZVFpVPP5qa0DsM=
github.com/slackhq/nebula v1.6.1/go.mod h1:UmkqnXe4O53QwToSl/gG7sM4BroQwAB7dd4hUaT6MlI=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/slackhq/nebula/header"
)
func main() {
// 1. Construct a header using package-level Encode
rawBuf := make([]byte, header.Len)
header.Encode(
rawBuf,
header.Version,
header.Message,
header.MessageNone,
1024,
42,
)
fmt.Printf("Encoded raw header bytes: %x\n", rawBuf)
// 2. Parse raw bytes into *header.H using NewHeader
h, err := header.NewHeader(rawBuf)
if err != nil {
log.Fatalf("failed to parse header: %v", err)
}
fmt.Printf("Parsed Header: Version=%d, Type=%s (%d), Subtype=%s (%d), RemoteIndex=%d, MessageCounter=%d\n",
h.Version, h.TypeName(), h.Type, h.SubTypeName(), h.Subtype, h.RemoteIndex, h.MessageCounter)
// 3. Modify header and encode back to bytes using a preallocated buffer
h.MessageCounter++
encodedBuf := make([]byte, header.Len)
encoded, err := h.Encode(encodedBuf)
if err != nil {
log.Fatalf("failed to encode header: %v", err)
}
fmt.Printf("Re-encoded header bytes: %x\n", encoded)
// 4. Serialize to JSON
jsonBytes, err := json.Marshal(h)
if err != nil {
log.Fatalf("failed to marshal JSON: %v", err)
}
fmt.Printf("Header JSON: %s\n", string(jsonBytes))
// 5. Parse into another Header instance using Parse
var h2 header.H
if err := h2.Parse(encoded); err != nil {
log.Fatalf("failed to parse into h2: %v", err)
}
fmt.Printf("Parsed h2: %s\n", h2.String())
}
{
"schemaVersion": 1,
"goal": "verify github.com/slackhq/nebula/header.NewHeader in pkg:golang/github.com/slackhq/nebula@v1.6.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/slackhq/nebula@v1.6.1"
],
"symbols": [
"github.com/slackhq/nebula/header.NewHeader"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"os"
"github.com/slackhq/nebula/header"
)
func main() {
// Assertion 1: NewHeader parses valid 16-byte raw header bytes into an H struct with matching Version, Type, Subtype, RemoteIndex, and MessageCounter.
buf := make([]byte, header.Len)
header.Encode(buf, header.Version, header.Message, header.MessageNone, 5001, 100002)
h, err := header.NewHeader(buf)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: NewHeader failed on valid buffer: %v\n", err)
os.Exit(1)
}
if h.Version != header.Version || h.Type != header.Message || h.Subtype != header.MessageNone || h.RemoteIndex != 5001 || h.MessageCounter != 100002 {
fmt.Fprintf(os.Stderr, "FAIL: NewHeader parsed fields mismatch: %+v\n", h)
os.Exit(1)
}
// Assertion 2: NewHeader returns ErrHeaderTooShort when input buffer is shorter than 16 bytes.
shortBuf := make([]byte, 15)
_, err = header.NewHeader(shortBuf)
if !errors.Is(err, header.ErrHeaderTooShort) {
fmt.Fprintf(os.Stderr, "FAIL: NewHeader did not return ErrHeaderTooShort for 15-byte buffer: got %v\n", err)
os.Exit(1)
}
var parseH header.H
if err := parseH.Parse(shortBuf); !errors.Is(err, header.ErrHeaderTooShort) {
fmt.Fprintf(os.Stderr, "FAIL: H.Parse did not return ErrHeaderTooShort for short buffer: got %v\n", err)
os.Exit(1)
}
// Assertion 3: H.Encode serializes header fields into a 16-byte slice that round-trips identically through NewHeader and H.Parse.
origH := &header.H{
Version: header.Version,
Type: header.Handshake,
Subtype: header.HandshakeIXPSK0,
Reserved: 0,
RemoteIndex: 9999,
MessageCounter: 123456789,
}
encodeBuf := make([]byte, header.Len)
encoded, err := origH.Encode(encodeBuf)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: H.Encode failed: %v\n", err)
os.Exit(1)
}
if len(encoded) != header.Len {
fmt.Fprintf(os.Stderr, "FAIL: H.Encode length mismatch: got %d, want %d\n", len(encoded), header.Len)
os.Exit(1)
}
roundTripH, err := header.NewHeader(encoded)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: NewHeader failed on re-encoded bytes: %v\n", err)
os.Exit(1)
}
if *roundTripH != *origH {
fmt.Fprintf(os.Stderr, "FAIL: round-trip header mismatch: got %+v, want %+v\n", roundTripH, origH)
os.Exit(1)
}
var parsedH header.H
if err := parsedH.Parse(encoded); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: H.Parse failed on re-encoded bytes: %v\n", err)
os.Exit(1)
}
if parsedH != *origH {
fmt.Fprintf(os.Stderr, "FAIL: H.Parse round-trip mismatch: got %+v, want %+v\n", parsedH, *origH)
os.Exit(1)
}
// Assertion 4: H.Encode returns an error when invoked on a nil header pointer.
var nilH *header.H
if _, err := nilH.Encode(encodeBuf); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: nilH.Encode should return an error\n")
os.Exit(1)
}
// Assertion 5: H.TypeName and H.SubTypeName map standard message types and subtypes to expected strings and return unknown for unrecognized values.
testCases := []struct {
msgType header.MessageType
msgSubtype header.MessageSubType
wantType string
wantSubtype string
}{
{header.Handshake, header.HandshakeIXPSK0, "handshake", "ix_psk0"},
{header.Message, header.MessageNone, "message", "none"},
{header.Message, header.MessageRelay, "message", "relay"},
{header.RecvError, header.MessageNone, "recvError", "none"},
{header.LightHouse, header.MessageNone, "lightHouse", "none"},
{header.Test, header.TestRequest, "test", "testRequest"},
{header.Test, header.TestReply, "test", "testReply"},
{header.CloseTunnel, header.MessageNone, "closeTunnel", "none"},
{header.Control, header.MessageNone, "control", "none"},
{header.MessageType(99), header.MessageSubType(99), "unknown", "unknown"},
}
for _, tc := range testCases {
h := &header.H{Type: tc.msgType, Subtype: tc.msgSubtype}
if got := h.TypeName(); got != tc.wantType {
fmt.Fprintf(os.Stderr, "FAIL: TypeName(%d) = %q; want %q\n", tc.msgType, got, tc.wantType)
os.Exit(1)
}
if got := h.SubTypeName(); got != tc.wantSubtype {
fmt.Fprintf(os.Stderr, "FAIL: SubTypeName(%d, %d) = %q; want %q\n", tc.msgType, tc.msgSubtype, got, tc.wantSubtype)
os.Exit(1)
}
}
// Assertion 6: H.MarshalJSON serializes header metadata into JSON containing version, type, subType, reserved, remoteIndex, and messageCounter.
sampleH := &header.H{
Version: 1,
Type: header.Message,
Subtype: header.MessageRelay,
Reserved: 0,
RemoteIndex: 777,
MessageCounter: 888,
}
jsonBytes, err := sampleH.MarshalJSON()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalJSON failed: %v\n", err)
os.Exit(1)
}
var jsonMap map[string]interface{}
if err := json.Unmarshal(jsonBytes, &jsonMap); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: unmarshaling MarshalJSON output failed: %v\n", err)
os.Exit(1)
}
if jsonMap["type"] != "message" || jsonMap["subType"] != "relay" || jsonMap["remoteIndex"] != float64(777) || jsonMap["messageCounter"] != float64(888) {
fmt.Fprintf(os.Stderr, "FAIL: unexpected JSON content: %s\n", string(jsonBytes))
os.Exit(1)
}
// Assertion 7: H.String formats header fields into a descriptive human-readable summary string, returning <nil> for a nil receiver.
str := sampleH.String()
if !bytes.Contains([]byte(str), []byte("type=message")) || !bytes.Contains([]byte(str), []byte("subtype=relay")) {
fmt.Fprintf(os.Stderr, "FAIL: H.String output unexpected: %s\n", str)
os.Exit(1)
}
if nilH.String() != "<nil>" {
fmt.Fprintf(os.Stderr, "FAIL: nil receiver String() should return <nil>, got %s\n", nilH.String())
os.Exit(1)
}
// Assertion 8: header.Encode directly serializes version, type, subtype, remote index, and counter into a preallocated byte slice.
directBuf := make([]byte, header.Len)
res := header.Encode(directBuf, 1, header.Test, header.TestRequest, 1234, 5678)
if len(res) != header.Len {
fmt.Fprintf(os.Stderr, "FAIL: header.Encode result length mismatch: got %d\n", len(res))
os.Exit(1)
}
hDirect, err := header.NewHeader(res)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: NewHeader on direct encode result failed: %v\n", err)
os.Exit(1)
}
if hDirect.Type != header.Test || hDirect.Subtype != header.TestRequest || hDirect.RemoteIndex != 1234 || hDirect.MessageCounter != 5678 {
fmt.Fprintf(os.Stderr, "FAIL: header.Encode direct values mismatch: %+v\n", hDirect)
os.Exit(1)
}
fmt.Println("PASS: all NewHeader contract assertions passed.")
}
Origin Seeder
anonymous