Sample
bumpalo 3.20.4: Bump::reset
Verified sample for cargo bumpalo 3.20.4: Bump::reset. The contract ran on rust 1 · linux alpine/x64 · docker and passed: Bump::reset on an empty Bump::new()…
sha256:12f64ae82a8fb13dbe0dabe36284f0c92451c2a8d578e1136b10117953337493
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 rust cargo
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-23 |
Case
HOW- Goal
- verify Bump::reset in pkg:cargo/bumpalo@3.20.4
- Packages
- Symbols
-
- Bump::reset
- Created
- 2026-11-23T16:38:17Z
Contract
- Bump::reset on an empty Bump::new() arena is a safe no-op that keeps allocated_bytes() at 0 and allows subsequent allocations
- Bump::reset rewinds the bump pointer so subsequent allocations reuse the same memory address within the retained chunk without increasing allocated_bytes()
- Bump::reset deallocates all secondary chunks and retains only the largest chunk, strictly reducing allocated_bytes() after multi-chunk growth
- Repeated allocate-and-reset cycles reuse the retained chunk without increasing allocated_bytes()
- Bump::reset does not execute Drop implementations on values previously allocated in the arena
Files
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
[[package]]
name = "sample-bumpalo-reset"
version = "0.1.0"
dependencies = [
"bumpalo",
]
[package]
name = "sample-bumpalo-reset"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
bumpalo = "=3.20.4"
[[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 Bump::reset in pkg:cargo/bumpalo@3.20.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/bumpalo@3.20.4
Demonstrate these symbols/APIs:
- Bump::reset
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:53b2845ceee9dd6b252d32ae33d87a1b66f55e5360ad29ff7c9a27a8b4d3a8c2","contract":["Bump::reset on an empty Bump::new() arena is a safe no-op that keeps allocated_bytes() at 0 and allows subsequent allocations","Bump::reset rewinds the bump pointer so subsequent allocations reuse the same memory address within the retained chunk without increasing allocated_bytes()","Bump::reset deallocates all secondary chunks and retains only the largest chunk, strictly reducing allocated_bytes() after multi-chunk growth","Repeated allocate-and-reset cycles reuse the retained chunk without increasing allocated_bytes()","Bump::reset does not execute Drop implementations on values previously allocated in the arena"],"goal":"verify Bump::reset in pkg:cargo/bumpalo@3.20.4","kind":"HOW","packages":["pkg:cargo/bumpalo@3.20.4"],"schemaVersion":1,"symbols":["Bump::reset"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","language":"rust","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/bumpalo@3.20.4"],"schemaVersion":1,"subject":"pkg:cargo/bumpalo@3.20.4","symbols":["Bump::reset"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify Bump::reset in pkg:cargo/bumpalo@3.20.4",
"kind": "HOW",
"packages": [
"pkg:cargo/bumpalo@3.20.4"
],
"symbols": [
"Bump::reset"
]
}
//! Clean-room verification sample for `Bump::reset` in `bumpalo`.
pub use bumpalo::Bump;
use std::cell::Cell;
use bumpalo::Bump;
struct DropCounter<'a>(&'a Cell<usize>);
impl Drop for DropCounter<'_> {
fn drop(&mut self) {
self.0.set(self.0.get() + 1);
}
}
fn main() {
// 1. Resetting an empty Bump is a safe no-op and leaves the arena usable.
let mut empty = Bump::new();
assert_eq!(empty.allocated_bytes(), 0);
empty.reset();
assert_eq!(empty.allocated_bytes(), 0);
let val = empty.alloc(42u64);
assert_eq!(*val, 42);
assert!(empty.allocated_bytes() > 0);
// 2. Bump::reset resets the bump pointer and reuses the retained chunk without growing allocated_bytes.
let mut bump = Bump::with_capacity(1024);
let first_addr = {
let x = bump.alloc(123u64);
assert_eq!(*x, 123);
x as *const u64 as usize
};
let bytes_after_first = bump.allocated_bytes();
assert!(bytes_after_first >= 1024);
bump.reset();
assert_eq!(bump.allocated_bytes(), bytes_after_first);
let second_addr = {
let y = bump.alloc(456u64);
assert_eq!(*y, 456);
y as *const u64 as usize
};
assert_eq!(
second_addr, first_addr,
"reset must rewind the bump pointer to reuse the same address in the retained chunk"
);
assert_eq!(bump.allocated_bytes(), bytes_after_first);
// 3. Bump::reset frees secondary chunks while retaining the largest chunk for reuse.
let mut multi = Bump::with_capacity(256);
for i in 0..8usize {
let slice = multi.alloc_slice_fill_copy(1024 * (i + 1), i as u8);
assert_eq!(slice.len(), 1024 * (i + 1));
}
let bytes_multi_chunk = multi.allocated_bytes();
assert!(
bytes_multi_chunk > 30_000,
"expected multiple chunks totaling > 30KB, got {}",
bytes_multi_chunk
);
multi.reset();
let bytes_after_reset = multi.allocated_bytes();
assert!(
bytes_after_reset > 0 && bytes_after_reset < bytes_multi_chunk,
"reset must deallocate smaller chunks and retain only the largest chunk: before={}, after={}",
bytes_multi_chunk,
bytes_after_reset
);
// Reusing the arena after reset across many cycles must not grow allocated_bytes.
for round in 0..20u32 {
let s = multi.alloc_str("reused-chunk-payload");
assert_eq!(s, "reused-chunk-payload");
let n = multi.alloc(round);
assert_eq!(*n, round);
multi.reset();
}
assert_eq!(
multi.allocated_bytes(),
bytes_after_reset,
"repeated small allocations + reset must reuse the retained chunk without growing"
);
// 4. Bump::reset does not run Drop implementations on allocated values.
let drops = Cell::new(0usize);
let mut drop_arena = Bump::new();
{
let _g1 = drop_arena.alloc(DropCounter(&drops));
let _g2 = drop_arena.alloc(DropCounter(&drops));
}
drop_arena.reset();
assert_eq!(
drops.get(),
0,
"Bump::reset must not execute Drop for values allocated in the arena"
);
println!("All Bump::reset contract assertions passed.");
}
Origin Seeder
anonymous