Ejemplo
once_cell_polyfill 1.70.2
Muestra verificada para cargo once_cell_polyfill 1.70.2. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: OnceLock::new creates an empty…
sha256:bc79d8900cdf2e7f659e122f39640c35a168a5e9d4c09883f0a953aeb228a7bf
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux · alpine · musl x64 cargo
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-10-11 |
| 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-11 |
Caso
HOW- Objetivo
- verify pkg:cargo/once_cell_polyfill@1.70.2
- Paquetes
- Creado
- 2026-10-11T15:40:00Z
Contrato
- OnceLock::new creates an empty uninitialized cell and get returns None
- OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets
- OnceLock::get_or_init computes and caches the value on first call
- OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell
- OnceLock::into_inner consumes the cell and returns the contained value
- OnceLock implements From, Default, Clone, and PartialEq
- OnceLock safely coordinates concurrent initialization across threads
Archivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código fuente
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "sample-once-cell-polyfill"
version = "1.0.0"
dependencies = [
"once_cell_polyfill",
]
[package]
name = "sample-once-cell-polyfill"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
once_cell_polyfill = "=1.70.2"
[[bin]]
name = "contract"
path = "test/contract.rs"
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:cargo/once_cell_polyfill@1.70.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/once_cell_polyfill@1.70.2
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:cfd7d6f03993bbc7b7c8f737fec03dde014089015ba9aad4db0f3629c4852f5f","contract":["OnceLock::new creates an empty uninitialized cell and get returns None","OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets","OnceLock::get_or_init computes and caches the value on first call","OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell","OnceLock::into_inner consumes the cell and returns the contained value","OnceLock implements From, Default, Clone, and PartialEq","OnceLock safely coordinates concurrent initialization across threads"],"goal":"verify pkg:cargo/once_cell_polyfill@1.70.2","kind":"HOW","packages":["pkg:cargo/once_cell_polyfill@1.70.2"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/once_cell_polyfill@1.70.2"],"schemaVersion":1,"subject":"pkg:cargo/once_cell_polyfill@1.70.2","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/once_cell_polyfill@1.70.2",
"kind": "HOW",
"packages": [
"pkg:cargo/once_cell_polyfill@1.70.2"
]
}
//! Clean-room verification sample for once_cell_polyfill.
pub use once_cell_polyfill::*;
use once_cell_polyfill::sync::OnceLock;
use std::sync::Arc;
use std::thread;
fn main() {
// 1. OnceLock::new creates an empty uninitialized cell and get returns None
let cell: OnceLock<u32> = OnceLock::new();
assert!(cell.get().is_none());
// 2. OnceLock::set sets the value and returns Ok, but returns Err on subsequent sets
let cell: OnceLock<u32> = OnceLock::new();
assert_eq!(cell.set(42), Ok(()));
assert_eq!(cell.get(), Some(&42));
assert_eq!(cell.set(99), Err(99));
assert_eq!(cell.get(), Some(&42));
// 3. OnceLock::get_or_init computes and caches the value on first call
let cell: OnceLock<String> = OnceLock::new();
let mut init_count = 0;
let val1 = cell.get_or_init(|| {
init_count += 1;
"computed".to_string()
});
assert_eq!(val1, "computed");
assert_eq!(init_count, 1);
let val2 = cell.get_or_init(|| {
init_count += 1;
"other".to_string()
});
assert_eq!(val2, "computed");
assert_eq!(init_count, 1);
// 4. OnceLock::get_mut and take allow mutating or extracting the value from an unshared cell
let mut cell: OnceLock<i32> = OnceLock::new();
cell.set(10).unwrap();
if let Some(val) = cell.get_mut() {
*val += 5;
}
assert_eq!(cell.get(), Some(&15));
let taken = cell.take();
assert_eq!(taken, Some(15));
assert!(cell.get().is_none());
// 5. OnceLock::into_inner consumes the cell and returns the contained value
let cell: OnceLock<String> = OnceLock::new();
cell.set("hello".to_string()).unwrap();
assert_eq!(cell.into_inner(), Some("hello".to_string()));
let empty: OnceLock<i32> = OnceLock::new();
assert_eq!(empty.into_inner(), None);
// 6. OnceLock implements From, Default, Clone, and PartialEq
let from_cell: OnceLock<i32> = OnceLock::from(100);
assert_eq!(from_cell.get(), Some(&100));
let default_cell: OnceLock<i32> = OnceLock::default();
assert!(default_cell.get().is_none());
let cloned = from_cell.clone();
assert_eq!(cloned.get(), Some(&100));
assert_eq!(from_cell, cloned);
// 7. OnceLock safely coordinates concurrent initialization across threads
let thread_cell = Arc::new(OnceLock::new());
let mut handles = Vec::new();
for _ in 0..10 {
let cell_clone = Arc::clone(&thread_cell);
handles.push(thread::spawn(move || {
*cell_clone.get_or_init(|| 42)
}));
}
for h in handles {
let res = h.join().unwrap();
assert_eq!(res, 42);
}
assert_eq!(thread_cell.get(), Some(&42));
println!("All once_cell_polyfill contract assertions passed successfully.");
}
Seeder de origen
anónimo