Sample
pkg-config 0.3.34: get_variable
Verified sample for cargo pkg-config 0.3.34: get_variable. The contract ran on rust 1 · linux alpine/x64 · docker and passed…
sha256:78da2d6443ad89f0e443c3891152ad599879778f2c422d83a4e2de1eff566b83
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
linux x64 cargo
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-10-18 |
Case
HOW- Goal
- verify get_variable in pkg:cargo/pkg-config@0.3.34
- Packages
- Symbols
-
- get_variable
- Created
- 2026-10-18T21:14:26Z
Contract
- pkg_config::get_variable(package, variable) invokes the configured PKG_CONFIG executable with --variable=<variable> and returns the trimmed stdout as Ok(String)
- pkg_config::get_variable passes PKG_CONFIG_PATH to the pkg-config process so package .pc files in that directory are queried
- pkg_config::get_variable returns Ok("".to_string()) when the queried variable output is empty
- pkg_config::get_variable returns Err(pkg_config::Error::Failure { .. }) when the pkg-config process exits with a non-zero status for an unknown package
Files
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- mock-pkg-config.sh
- pc/demo.pc
- spec.json
- src/main.rs
Source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "pkg-config"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
[[package]]
name = "sample-pkg-config"
version = "0.1.0"
dependencies = [
"pkg-config",
]
[package]
name = "sample-pkg-config"
version = "0.1.0"
edition = "2021"
[dependencies]
pkg-config = "=0.3.34"
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 get_variable in pkg:cargo/pkg-config@0.3.34
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/pkg-config@0.3.34
Demonstrate these symbols/APIs:
- get_variable
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:a2896f67044e66ce8ef33484b00fcf59183ff877851ce22d89adcb8022e7a07e","contract":["pkg_config::get_variable(package, variable) invokes the configured PKG_CONFIG executable with --variable=\u003cvariable\u003e and returns the trimmed stdout as Ok(String)","pkg_config::get_variable passes PKG_CONFIG_PATH to the pkg-config process so package .pc files in that directory are queried","pkg_config::get_variable returns Ok(\"\".to_string()) when the queried variable output is empty","pkg_config::get_variable returns Err(pkg_config::Error::Failure { .. }) when the pkg-config process exits with a non-zero status for an unknown package"],"goal":"verify get_variable in pkg:cargo/pkg-config@0.3.34","kind":"HOW","packages":["pkg:cargo/pkg-config@0.3.34"],"schemaVersion":1,"symbols":["get_variable"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/pkg-config@0.3.34"],"schemaVersion":1,"subject":"pkg:cargo/pkg-config@0.3.34","symbols":["get_variable"],"verifierAdapter":"cargo@1"}
#!/bin/sh
var=""
pkg=""
for arg in "$@"; do
case "$arg" in
--variable=*)
var="${arg#--variable=}"
;;
--*)
;;
*)
pkg="$arg"
;;
esac
done
pc_file="${PKG_CONFIG_PATH:-.}/${pkg}.pc"
if [ ! -f "$pc_file" ]; then
echo "Package $pkg was not found in the pkg-config search path." >&2
exit 1
fi
if [ -n "$var" ]; then
val=$(sed -n "s/^${var}=//p" "$pc_file" | head -n 1)
printf "%s\n" "$val"
exit 0
fi
exit 0
prefix=demo_root
libdir=demo_root_lib
includedir=demo_root_include
custom_feature=enabled
Name: demo
Description: Demo package for pkg-config get_variable verification
Version: 1.2.3
Libs: -ldemo
Cflags: -DDEMO=1
{
"schemaVersion": 1,
"goal": "verify get_variable in pkg:cargo/pkg-config@0.3.34",
"kind": "HOW",
"packages": [
"pkg:cargo/pkg-config@0.3.34"
],
"symbols": [
"get_variable"
]
}
use std::env;
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
fn main() {
let pc_dir = Path::new("pc")
.canonicalize()
.expect("pc directory must exist");
env::set_var("PKG_CONFIG_PATH", &pc_dir);
let mock_bin = Path::new("mock-pkg-config.sh")
.canonicalize()
.expect("mock-pkg-config.sh must exist");
let mut perms = fs::metadata(&mock_bin)
.expect("metadata must succeed")
.permissions();
perms.set_mode(0o755);
fs::set_permissions(&mock_bin, perms).expect("set_permissions must succeed");
env::set_var("PKG_CONFIG", &mock_bin);
let prefix = pkg_config::get_variable("demo", "prefix").expect("should retrieve prefix");
assert_eq!(prefix, "demo_root");
let libdir = pkg_config::get_variable("demo", "libdir").expect("should retrieve libdir");
assert_eq!(libdir, "demo_root_lib");
let custom =
pkg_config::get_variable("demo", "custom_feature").expect("should retrieve custom_feature");
assert_eq!(custom, "enabled");
let missing_var = pkg_config::get_variable("demo", "nonexistent_var")
.expect("missing var returns empty string");
assert_eq!(missing_var, "");
let missing_pkg = pkg_config::get_variable("nonexistent_pkg", "prefix");
assert!(matches!(missing_pkg, Err(pkg_config::Error::Failure { .. })));
#[allow(deprecated)]
let cfg_var = pkg_config::Config::get_variable("demo", "includedir")
.expect("Config::get_variable should retrieve includedir");
assert_eq!(cfg_var, "demo_root_include");
}
Origin Seeder
anonymous