Exemplo
pkg-config 0.3.34: probe_library
Amostra verificada para cargo pkg-config 0.3.34: probe_library. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou.
sha256:05b4e6971bedb37a87ca8f7321a07b52e515e26edf2dfc8336853607488a5053
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux x64 cargo
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify probe_library in pkg:cargo/pkg-config@0.3.34
- Pacotes
- Símbolos
-
- probe_library
- Criado
- 2026-10-18T21:25:00Z
Contrato
- 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
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
- test/contract.sh
Código-fonte
# 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
Seeder de origem
anônimo