CodeSampleX

Sample

want 0.3.1

Verified sample for cargo want 0.3.1. The contract ran on rust 1 · linux alpine/x64 · docker and passed: want::new creates a channel pair where Giver…

sha256:ba70fd71b980be60ede2ec4e74925e542e4cda0a96e3edb712384520935c0eef

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 · alpine · musl x64 cargo

Verification-run environments

Environment Contract Stages Run
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-09-19

Case

HOW
Goal
verify pkg:cargo/want@0.3.1
Packages
Created
2026-09-19T03:30:54Z

Contract

  1. want::new creates a channel pair where Giver initially is neither wanting nor canceled
  2. Taker::want signals interest making Giver::is_wanting true
  3. Giver::give acknowledges want returning true and resets is_wanting to false
  4. Taker::cancel marks the channel as canceled making Giver::is_canceled true
  5. Dropping Taker implicitly cancels the channel making Giver::is_canceled true
  6. SharedGiver shares wanting and cancellation states and implements Clone
  7. Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Download the source artifact (tar.gz)

Source

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "sample-want"
version = "1.0.0"
dependencies = [
 "want",
]

[[package]]
name = "try-lock"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"

[[package]]
name = "want"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
dependencies = [
 "try-lock",
]
Cargo.toml
[package]
name = "sample-want"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
want = "=0.3.1"

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
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/want@0.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/want@0.3.1

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.
csx.json
{"case":{"caseId":"case:sha256:fba624fefd7abc33b5313727804c64587ee2d9c35170000ba71b3d58d193df35","contract":["want::new creates a channel pair where Giver initially is neither wanting nor canceled","Taker::want signals interest making Giver::is_wanting true","Giver::give acknowledges want returning true and resets is_wanting to false","Taker::cancel marks the channel as canceled making Giver::is_canceled true","Dropping Taker implicitly cancels the channel making Giver::is_canceled true","SharedGiver shares wanting and cancellation states and implements Clone","Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled"],"goal":"verify pkg:cargo/want@0.3.1","kind":"HOW","packages":["pkg:cargo/want@0.3.1"],"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/want@0.3.1"],"schemaVersion":1,"subject":"pkg:cargo/want@0.3.1","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/want@0.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/want@0.3.1"
  ]
}
src/lib.rs
//! Clean-room verification sample for want.

pub use want::*;
test/contract.rs
use std::task::{Context, Poll, Waker};
use want::{new, SharedGiver};

fn main() {
    // 1. want::new creates a channel pair where Giver initially is neither wanting nor canceled
    let (gv, mut tk) = new();
    assert!(!gv.is_wanting(), "initial is_wanting should be false");
    assert!(!gv.is_canceled(), "initial is_canceled should be false");

    // 2. Taker::want signals interest making Giver::is_wanting true
    tk.want();
    assert!(gv.is_wanting(), "is_wanting should be true after tk.want()");
    assert!(!gv.is_canceled(), "is_canceled should remain false after tk.want()");

    // 3. Giver::give acknowledges want returning true and resets is_wanting to false
    assert!(gv.give(), "give should return true when wanting");
    assert!(!gv.is_wanting(), "is_wanting should be false after give");
    assert!(!gv.give(), "give should return false when already idle");

    // 4. Taker::cancel marks the channel as canceled making Giver::is_canceled true
    let (gv2, mut tk2) = new();
    assert!(!gv2.is_canceled());
    tk2.cancel();
    assert!(gv2.is_canceled(), "is_canceled should be true after tk.cancel()");

    // 5. Dropping Taker implicitly cancels the channel making Giver::is_canceled true
    let (gv3, tk3) = new();
    assert!(!gv3.is_canceled());
    drop(tk3);
    assert!(gv3.is_canceled(), "is_canceled should be true after dropping Taker");

    // 6. SharedGiver shares wanting and cancellation states and implements Clone
    let (gv4, mut tk4) = new();
    let shared: SharedGiver = gv4.shared();
    let shared_clone = shared.clone();
    assert!(!shared.is_wanting());
    assert!(!shared.is_canceled());
    assert!(!shared_clone.is_wanting());
    assert!(!shared_clone.is_canceled());

    tk4.want();
    assert!(shared.is_wanting());
    assert!(shared_clone.is_wanting());

    tk4.cancel();
    assert!(shared.is_canceled());
    assert!(shared_clone.is_canceled());

    // 7. Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled
    let waker = Waker::noop();
    let mut cx = Context::from_waker(&waker);

    let (mut gv5, mut tk5) = new();
    // Initially not wanting, so poll_want would park (returns Poll::Pending)
    assert!(matches!(gv5.poll_want(&mut cx), Poll::Pending));

    // When wanting, returns Poll::Ready(Ok(()))
    tk5.want();
    assert!(matches!(gv5.poll_want(&mut cx), Poll::Ready(Ok(()))));

    // When canceled, returns Poll::Ready(Err(_))
    let (mut gv6, mut tk6) = new();
    tk6.cancel();
    assert!(matches!(gv6.poll_want(&mut cx), Poll::Ready(Err(_))));

    println!("All want contract assertions passed successfully.");
}

Origin Seeder

anonymous