CodeSampleX

Sample

github.com/go-stack/stack v1.8.0: Call.Frame

Verified sample for golang github.com/go-stack/stack v1.8.0: Call.Frame. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:1d6cdebbffb4c845593a2e42b282c60f94ac49a81fa0444537d7f25224bb9410

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
1
Signing keys that built it
1
Declared environment go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1

Verification-run environments

Environment Contract Stages Run
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-03

Case

HOW
Goal
verify pkg:golang/github.com/go-stack/stack@v1.8.0
Packages
Symbols
  • stack.Call.Frame
Environment
go 1.26.6
Created
2026-09-03T17:53:52Z

Contract

  1. stack.Call.Frame returns runtime.Frame with valid PC, entry point, function name, file and line
  2. stack.Call.Frame extracts runtime.Frame directly from a Call without string parsing
  3. stack.Call.Frame matches call.PC program counter value
  4. stack.Call.Frame on zero-value Call returns empty runtime.Frame

Files

  • PROMPT.md
  • contract_test.go
  • csx.json
  • go.mod
  • go.sum
  • sample.go
  • spec.json

Download the source artifact (tar.gz)

Source

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 pkg:golang/github.com/go-stack/stack@v1.8.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/go-stack/stack@v1.8.0
Demonstrate these symbols/APIs:
  - stack.Call.Frame

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.
contract_test.go
package sample

import (
	"runtime"
	"strings"
	"testing"

	"github.com/go-stack/stack"
)

func levelA() (stack.Call, runtime.Frame) {
	c := stack.Caller(0)
	return c, c.Frame()
}

func levelB() runtime.Frame {
	return GetCallerFrame(0)
}

func TestContractCallFrame(t *testing.T) {
	call, frame := levelA()

	// 1. Verify PC matches call.PC() and is non-zero
	if frame.PC == 0 {
		t.Fatalf("expected non-zero PC in runtime.Frame")
	}
	if frame.PC != call.PC() {
		t.Fatalf("expected frame.PC == call.PC(), got %d != %d", frame.PC, call.PC())
	}

	// 2. Verify Function name contains the function symbol
	if !strings.HasSuffix(frame.Function, "levelA") {
		t.Fatalf("expected frame.Function ending with 'levelA', got %q", frame.Function)
	}

	// 3. Verify File path contains contract_test.go
	if !strings.HasSuffix(frame.File, "contract_test.go") {
		t.Fatalf("expected frame.File ending with 'contract_test.go', got %q", frame.File)
	}

	// 4. Verify Line number is positive
	if frame.Line <= 0 {
		t.Fatalf("expected positive line number, got %d", frame.Line)
	}

	// 5. Verify Entry point is valid
	if frame.Entry == 0 {
		t.Fatalf("expected non-zero entry point in runtime.Frame")
	}

	// 6. Verify caller frame via GetCallerFrame helper
	frameB := levelB()
	if !strings.HasSuffix(frameB.Function, "levelB") {
		t.Fatalf("expected frameB.Function ending with 'levelB', got %q", frameB.Function)
	}

	// 7. Verify GetFrameFromCall matches call.Frame()
	extracted := GetFrameFromCall(call)
	if extracted != frame {
		t.Fatalf("expected extracted frame to match direct call.Frame()")
	}

	// 8. Verify zero-value Call returns empty runtime.Frame
	var zero stack.Call
	if zero.Frame() != (runtime.Frame{}) {
		t.Fatalf("expected empty runtime.Frame for zero-value Call, got %+v", zero.Frame())
	}
}
csx.json
{"case":{"caseId":"case:sha256:57642afdd39dcede28959f74dc611256022b14f47ad77707078ac6ee7c422ed8","contract":["stack.Call.Frame returns runtime.Frame with valid PC, entry point, function name, file and line","stack.Call.Frame extracts runtime.Frame directly from a Call without string parsing","stack.Call.Frame matches call.PC program counter value","stack.Call.Frame on zero-value Call returns empty runtime.Frame"],"goal":"verify pkg:golang/github.com/go-stack/stack@v1.8.0","kind":"HOW","packages":["pkg:golang/github.com/go-stack/stack@v1.8.0"],"schemaVersion":1,"symbols":["stack.Call.Frame"]},"contractCommand":["go","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/github.com/go-stack/stack@v1.8.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/go-stack/stack@v1.8.0","symbols":["stack.Call.Frame"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require github.com/go-stack/stack v1.8.0
go.sum
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
sample.go
package sample

import (
	"runtime"

	"github.com/go-stack/stack"
)

// GetCallerFrame returns the runtime.Frame of the caller at the given skip depth.
func GetCallerFrame(skip int) runtime.Frame {
	call := stack.Caller(skip + 1)
	return call.Frame()
}

// GetFrameFromCall extracts the runtime.Frame directly from a stack.Call record.
func GetFrameFromCall(c stack.Call) runtime.Frame {
	return c.Frame()
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/go-stack/stack@v1.8.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/go-stack/stack@v1.8.0"
  ],
  "symbols": [
    "stack.Call.Frame"
  ]
}

Origin Seeder

anonymous