CodeSampleX

Sample

serde_derive 1.0.229

Verified sample for cargo serde_derive 1.0.229. The contract ran on rust 1 · linux alpine/x64 · docker and passed: #[derive(Serialize, Deserialize)]…

sha256:84042027cfd19f67c2637017ddf24a6299e86e9f6918da48f1544aa3a43dd81c

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-14

Case

HOW
Goal
verify pkg:cargo/serde_derive@1.0.229
Packages
Created
2026-09-14T20:59:56Z

Contract

  1. #[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields
  2. serde field attributes rename, default, and skip alter struct field serialization and deserialization
  3. serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation
  4. #[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants

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 = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"

[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"

[[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-serde-derive"
version = "1.0.0"
dependencies = [
 "serde",
 "serde_derive",
 "serde_json",
]

[[package]]
name = "serde"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
dependencies = [
 "serde_core",
]

[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
 "serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "serde_json"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
dependencies = [
 "itoa",
 "memchr",
 "serde",
 "serde_core",
 "zmij",
]

[[package]]
name = "syn"
version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"

[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
Cargo.toml
[package]
name = "sample-serde-derive"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
serde_derive = "=1.0.229"
serde = "=1.0.229"
serde_json = "=1.0.151"

[[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/serde_derive@1.0.229
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/serde_derive@1.0.229

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:b1b7ecb9f3967cb896ec068941dfda5b34ba163b3b0edface3803fd426bc620d","contract":["#[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields","serde field attributes rename, default, and skip alter struct field serialization and deserialization","serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation","#[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants"],"goal":"verify pkg:cargo/serde_derive@1.0.229","kind":"HOW","packages":["pkg:cargo/serde_derive@1.0.229"],"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/serde_derive@1.0.229"],"schemaVersion":1,"subject":"pkg:cargo/serde_derive@1.0.229","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/serde_derive@1.0.229",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/serde_derive@1.0.229"
  ]
}
src/lib.rs
//! Clean-room verification sample for serde_derive.

pub use serde_derive::*;
test/contract.rs
use serde_derive::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct User {
    id: u64,
    name: String,
    active: bool,
}

fn default_port() -> u16 {
    8080
}

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct FieldConfig {
    #[serde(rename = "config_id")]
    id: u32,
    #[serde(default = "default_port")]
    port: u16,
    #[serde(skip)]
    internal_flag: bool,
}

#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
struct ServerSettings {
    host_name: String,
    max_conns: usize,
}

#[derive(Serialize, Deserialize, Debug, PartialEq)]
enum Action {
    Quit,
    Move { x: i32, y: i32 },
    Write(String),
}

fn main() {
    // 1. #[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields
    let user = User {
        id: 1001,
        name: "test_user".to_string(),
        active: true,
    };
    let user_json = serde_json::to_string(&user).expect("serialize User");
    assert_eq!(user_json, r#"{"id":1001,"name":"test_user","active":true}"#);
    let user_de: User = serde_json::from_str(&user_json).expect("deserialize User");
    assert_eq!(user, user_de);

    // 2. serde field attributes rename, default, and skip alter struct field serialization and deserialization
    let config = FieldConfig {
        id: 42,
        port: 9000,
        internal_flag: true,
    };
    let config_json = serde_json::to_string(&config).expect("serialize FieldConfig");
    assert_eq!(config_json, r#"{"config_id":42,"port":9000}"#);
    let config_de: FieldConfig =
        serde_json::from_str(r#"{"config_id":42}"#).expect("deserialize FieldConfig with default");
    assert_eq!(config_de.id, 42);
    assert_eq!(config_de.port, 8080);
    assert!(!config_de.internal_flag);

    // 3. serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation
    let settings = ServerSettings {
        host_name: "127.0.0.1".to_string(),
        max_conns: 128,
    };
    let settings_json = serde_json::to_string(&settings).expect("serialize ServerSettings");
    assert_eq!(settings_json, r#"{"host-name":"127.0.0.1","max-conns":128}"#);
    let settings_de: ServerSettings =
        serde_json::from_str(&settings_json).expect("deserialize ServerSettings");
    assert_eq!(settings, settings_de);
    let unknown_field_res: Result<ServerSettings, _> =
        serde_json::from_str(r#"{"host-name":"127.0.0.1","max-conns":128,"unexpected":true}"#);
    assert!(
        unknown_field_res.is_err(),
        "deny_unknown_fields must reject unexpected fields"
    );

    // 4. #[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants
    let quit = Action::Quit;
    let quit_json = serde_json::to_string(&quit).expect("serialize Action::Quit");
    assert_eq!(quit_json, r#""Quit""#);
    let quit_de: Action = serde_json::from_str(&quit_json).expect("deserialize Action::Quit");
    assert_eq!(quit, quit_de);

    let mv = Action::Move { x: 10, y: -5 };
    let mv_json = serde_json::to_string(&mv).expect("serialize Action::Move");
    assert_eq!(mv_json, r#"{"Move":{"x":10,"y":-5}}"#);
    let mv_de: Action = serde_json::from_str(&mv_json).expect("deserialize Action::Move");
    assert_eq!(mv, mv_de);

    let write = Action::Write("payload".to_string());
    let write_json = serde_json::to_string(&write).expect("serialize Action::Write");
    assert_eq!(write_json, r#"{"Write":"payload"}"#);
    let write_de: Action = serde_json::from_str(&write_json).expect("deserialize Action::Write");
    assert_eq!(write, write_de);

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

Origin Seeder

anonymous