示例
pkg-config 0.3.34: probe_library
已验证示例 — cargo pkg-config 0.3.34: probe_library. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: pkg_config::probe_library("foo") invokes PKG_CONFIG and…
sha256:05b4e6971bedb37a87ca8f7321a07b52e515e26edf2dfc8336853607488a5053
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux x64 cargo
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify probe_library in pkg:cargo/pkg-config@0.3.34
- 符号
-
- probe_library
- 创建时间
- 2026-10-18T21:25:00Z
契约
- pkg_config::probe_library("foo") invokes PKG_CONFIG and returns Library with version "1.2.3", libs containing "foo", and defines containing FOO_ENABLED=Some("1")
- pkg_config::probe_library("nonexistent_pkg_xyz") returns Err when PKG_CONFIG exits with non-zero status
文件
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
- test/contract.sh
源代码
# 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 probe_library 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:
- probe_library
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:95355c1d51f70a0942c1148d317d551ed89a2a775bc603903f20a9cd9c2c7510","contract":["pkg_config::probe_library(\"foo\") invokes PKG_CONFIG and returns Library with version \"1.2.3\", libs containing \"foo\", and defines containing FOO_ENABLED=Some(\"1\")","pkg_config::probe_library(\"nonexistent_pkg_xyz\") returns Err when PKG_CONFIG exits with non-zero status"],"goal":"verify probe_library in pkg:cargo/pkg-config@0.3.34","kind":"HOW","packages":["pkg:cargo/pkg-config@0.3.34"],"schemaVersion":1,"symbols":["probe_library"]},"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":["probe_library"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify probe_library in pkg:cargo/pkg-config@0.3.34",
"kind": "HOW",
"packages": [
"pkg:cargo/pkg-config@0.3.34"
],
"symbols": [
"probe_library"
]
}
use std::env;
use std::fs;
use std::os::unix::fs::PermissionsExt;
fn main() {
let tmp_dir = env::temp_dir().join("pkg_config_sample_test");
let _ = fs::remove_dir_all(&tmp_dir);
fs::create_dir_all(&tmp_dir).expect("failed to create temp dir");
let lib_dir = tmp_dir.join("lib");
let inc_dir = tmp_dir.join("include");
let fake_pkg_config = tmp_dir.join("fake-pkg-config.sh");
let script = format!(
"#!/bin/sh
for last; do :; done
if [ \"$last\" != \"foo\" ]; then
exit 1
fi
case \"$*\" in
*--modversion*)
echo \"1.2.3\"
;;
*--libs*--cflags*)
echo \"-L{} -lfoo -I{}/foo -DFOO_ENABLED=1\"
;;
*--variable=prefix*)
echo \"{}\"
;;
*)
echo \"\"
;;
esac
",
lib_dir.display(),
inc_dir.display(),
tmp_dir.display()
);
fs::write(&fake_pkg_config, script).expect("failed to write fake pkg-config");
let mut perms = fs::metadata(&fake_pkg_config)
.expect("failed to get metadata")
.permissions();
perms.set_mode(0o755);
fs::set_permissions(&fake_pkg_config, perms).expect("failed to set permissions");
env::set_var("PKG_CONFIG", &fake_pkg_config);
env::set_var("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1");
env::set_var("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", "1");
env::set_var("TARGET", "x86_64-unknown-linux-gnu");
env::set_var("HOST", "x86_64-unknown-linux-gnu");
env::set_var("OUT_DIR", &tmp_dir);
let lib = pkg_config::probe_library("foo").expect("probe_library should succeed for foo");
assert_eq!(lib.version, "1.2.3");
assert!(lib.libs.iter().any(|l| l == "foo"));
assert_eq!(lib.defines.get("FOO_ENABLED"), Some(&Some("1".to_string())));
let missing = pkg_config::probe_library("nonexistent_pkg_xyz");
assert!(missing.is_err());
let _ = fs::remove_dir_all(&tmp_dir);
}
#!/bin/sh
set -e
cargo run --offline
原始种子者
匿名