Exemplo
tracing 0.1.41: tracing::callsite::Callsite
Amostra verificada para cargo tracing 0.1.41: tracing::callsite::Callsite. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou.
sha256:441b20b53e9e8a064a8f2cf148275c514d4adfd4df9b62a10afd814db84250a7
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-11-03 |
Caso
HOW- Objetivo
- verify tracing::callsite::Callsite in pkg:cargo/tracing@0.1.41
- Pacotes
- Símbolos
-
- tracing::callsite::Callsite
- Criado
- 2026-11-03T00:46:39Z
Contrato
- Implementing tracing::callsite::Callsite on a Sync type provides metadata(&self) -> &Metadata<'_> and set_interest(&self, Interest)
- Callsite::metadata returns the static Metadata associated with the callsite including name, target, level, kind (EVENT/SPAN), and FieldSet
- Callsite::set_interest receives Interest::never(), Interest::sometimes(), or Interest::always() and updates the callsite's cached interest state
- tracing::callsite::register(&'static dyn Callsite) and rebuild_interest_cache() query the active Subscriber::register_callsite with Callsite::metadata and pass the resulting Interest to Callsite::set_interest
- tracing::callsite::DefaultCallsite implements Callsite and tracing::callsite::Identifier(&'static dyn Callsite) compares callsites by pointer identity
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
Código-fonte
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sample-tracing-callsite"
version = "0.1.0"
dependencies = [
"tracing",
]
[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tracing"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[package]
name = "sample-tracing-callsite"
version = "0.1.0"
edition = "2021"
[dependencies]
tracing = "=0.1.41"
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 tracing::callsite::Callsite in pkg:cargo/tracing@0.1.41
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tracing@0.1.41
Demonstrate these symbols/APIs:
- tracing::callsite::Callsite
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:14a4b4bf795da04aa5c17f59d54d393b12d8b78e4148f974aaac64d33ee6e177","contract":["Implementing tracing::callsite::Callsite on a Sync type provides metadata(\u0026self) -\u003e \u0026Metadata\u003c'_\u003e and set_interest(\u0026self, Interest)","Callsite::metadata returns the static Metadata associated with the callsite including name, target, level, kind (EVENT/SPAN), and FieldSet","Callsite::set_interest receives Interest::never(), Interest::sometimes(), or Interest::always() and updates the callsite's cached interest state","tracing::callsite::register(\u0026'static dyn Callsite) and rebuild_interest_cache() query the active Subscriber::register_callsite with Callsite::metadata and pass the resulting Interest to Callsite::set_interest","tracing::callsite::DefaultCallsite implements Callsite and tracing::callsite::Identifier(\u0026'static dyn Callsite) compares callsites by pointer identity"],"goal":"verify tracing::callsite::Callsite in pkg:cargo/tracing@0.1.41","kind":"HOW","packages":["pkg:cargo/tracing@0.1.41"],"schemaVersion":1,"symbols":["tracing::callsite::Callsite"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tracing@0.1.41"],"schemaVersion":1,"subject":"pkg:cargo/tracing@0.1.41","symbols":["tracing::callsite::Callsite"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify tracing::callsite::Callsite in pkg:cargo/tracing@0.1.41",
"kind": "HOW",
"packages": [
"pkg:cargo/tracing@0.1.41"
],
"symbols": [
"tracing::callsite::Callsite"
]
}
use std::sync::atomic::{AtomicUsize, Ordering};
use tracing::callsite::{self, Callsite, DefaultCallsite};
use tracing::field::FieldSet;
use tracing::metadata::Kind;
use tracing::span;
use tracing::subscriber::{Interest, Subscriber};
use tracing::{Event, Level, Metadata};
struct CustomCallsite {
interest_state: AtomicUsize,
metadata: &'static Metadata<'static>,
}
impl Callsite for CustomCallsite {
fn set_interest(&self, interest: Interest) {
let code = if interest.is_never() {
1
} else if interest.is_sometimes() {
2
} else if interest.is_always() {
3
} else {
0
};
self.interest_state.store(code, Ordering::SeqCst);
}
fn metadata(&self) -> &Metadata<'_> {
self.metadata
}
}
struct AlwaysSubscriber;
impl Subscriber for AlwaysSubscriber {
fn enabled(&self, _metadata: &Metadata<'_>) -> bool {
true
}
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
if metadata.name() == "custom_event" {
Interest::always()
} else {
Interest::sometimes()
}
}
fn new_span(&self, _span: &span::Attributes<'_>) -> span::Id {
span::Id::from_u64(1)
}
fn record(&self, _span: &span::Id, _values: &span::Record<'_>) {}
fn record_follows_from(&self, _span: &span::Id, _follows: &span::Id) {}
fn event(&self, _event: &Event<'_>) {}
fn enter(&self, _span: &span::Id) {}
fn exit(&self, _span: &span::Id) {}
}
static FIELD_NAMES: &[&str] = &["message"];
static CUSTOM_META: Metadata<'static> = Metadata::new(
"custom_event",
"sample_tracing_callsite",
Level::INFO,
Some("src/main.rs"),
Some(10),
Some("sample_tracing_callsite"),
FieldSet::new(FIELD_NAMES, callsite::Identifier(&CUSTOM_CALLSITE)),
Kind::EVENT,
);
static CUSTOM_CALLSITE: CustomCallsite = CustomCallsite {
interest_state: AtomicUsize::new(0),
metadata: &CUSTOM_META,
};
static DEFAULT_META: Metadata<'static> = Metadata::new(
"default_span",
"sample_tracing_callsite",
Level::DEBUG,
Some("src/main.rs"),
Some(20),
Some("sample_tracing_callsite"),
FieldSet::new(FIELD_NAMES, callsite::Identifier(&DEFAULT_CALLSITE)),
Kind::SPAN,
);
static DEFAULT_CALLSITE: DefaultCallsite = DefaultCallsite::new(&DEFAULT_META);
pub fn verify_callsite() {
// 1. Verify Callsite::metadata(&self) returns the associated static Metadata
let meta = Callsite::metadata(&CUSTOM_CALLSITE);
assert_eq!(meta.name(), "custom_event");
assert_eq!(meta.target(), "sample_tracing_callsite");
assert_eq!(*meta.level(), Level::INFO);
assert!(meta.is_event());
assert_eq!(meta.fields().len(), 1);
assert!(meta.fields().field("message").is_some());
// 2. Verify Callsite::set_interest(&self, Interest) stores never/sometimes/always states
Callsite::set_interest(&CUSTOM_CALLSITE, Interest::always());
assert_eq!(CUSTOM_CALLSITE.interest_state.load(Ordering::SeqCst), 3);
Callsite::set_interest(&CUSTOM_CALLSITE, Interest::sometimes());
assert_eq!(CUSTOM_CALLSITE.interest_state.load(Ordering::SeqCst), 2);
Callsite::set_interest(&CUSTOM_CALLSITE, Interest::never());
assert_eq!(CUSTOM_CALLSITE.interest_state.load(Ordering::SeqCst), 1);
// 3. Verify callsite::register(&'static dyn Callsite) and rebuild_interest_cache()
// invoke Callsite::metadata and Callsite::set_interest through an active Subscriber
tracing::subscriber::with_default(AlwaysSubscriber, || {
callsite::register(&CUSTOM_CALLSITE);
callsite::rebuild_interest_cache();
assert_eq!(CUSTOM_CALLSITE.interest_state.load(Ordering::SeqCst), 3);
});
// 4. Verify DefaultCallsite implements Callsite
let default_meta = Callsite::metadata(&DEFAULT_CALLSITE);
assert_eq!(default_meta.name(), "default_span");
assert_eq!(*default_meta.level(), Level::DEBUG);
assert!(default_meta.is_span());
Callsite::set_interest(&DEFAULT_CALLSITE, Interest::always());
assert_eq!(
callsite::Identifier(&CUSTOM_CALLSITE),
callsite::Identifier(&CUSTOM_CALLSITE)
);
assert_ne!(
callsite::Identifier(&CUSTOM_CALLSITE),
callsite::Identifier(&DEFAULT_CALLSITE)
);
}
fn main() {
verify_callsite();
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn contract_callsite_trait_and_registration() {
verify_callsite();
}
}
Seeder de origem
anônimo