CodeSampleX

Sample

serde_derive 1.0.229: serde_derive::Deserialize

Verified sample for cargo serde_derive 1.0.229: serde_derive::Deserialize. The contract ran on rust 1 · linux alpine/x64 · docker and passed.

sha256:d40d08e463c09d9d498e1de750542871c30c6ee1aae8cc4b72d8cafd22a6bc06

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 serde_derive::Deserialize in pkg:cargo/serde_derive@1.0.229
Packages
Symbols
  • serde_derive::Deserialize
Created
2026-09-14T21:49:07Z

Contract

  1. #[derive(Deserialize)] deserializes structs with primitive, string, and boolean named fields
  2. #[derive(Deserialize)] deserializes enums with unit, tuple, and struct variants
  3. serde field attributes rename, default, and alias alter struct field deserialization behavior
  4. serde container attribute deny_unknown_fields rejects unexpected fields during deserialization

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 serde_derive::Deserialize in pkg:cargo/serde_derive@1.0.229
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/serde_derive@1.0.229
Demonstrate these symbols/APIs:
  - serde_derive::Deserialize

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:aeb4b97cd1582111cf6a0bd93670420db770d3c58ac6a2d625a929c894d56393","contract":["#[derive(Deserialize)] deserializes structs with primitive, string, and boolean named fields","#[derive(Deserialize)] deserializes enums with unit, tuple, and struct variants","serde field attributes rename, default, and alias alter struct field deserialization behavior","serde container attribute deny_unknown_fields rejects unexpected fields during deserialization"],"goal":"verify serde_derive::Deserialize in pkg:cargo/serde_derive@1.0.229","kind":"HOW","packages":["pkg:cargo/serde_derive@1.0.229"],"schemaVersion":1,"symbols":["serde_derive::Deserialize"]},"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","symbols":["serde_derive::Deserialize"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify serde_derive::Deserialize in pkg:cargo/serde_derive@1.0.229",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/serde_derive@1.0.229"
  ],
  "symbols": [
    "serde_derive::Deserialize"
  ]
}
src/lib.rs
//! Clean-room verification sample for serde_derive::Deserialize.

pub use serde_derive::Deserialize;
test/contract.rs
use serde_derive::Deserialize;

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

fn default_port() -> u16 {
    8080
}

#[derive(Deserialize, Debug, PartialEq)]
struct ServerConfig {
    #[serde(rename = "server_port", alias = "port")]
    #[serde(default = "default_port")]
    port: u16,
    host: String,
}

#[derive(Deserialize, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
struct StrictConfig {
    endpoint: String,
}

#[derive(Deserialize, Debug, PartialEq)]
enum Message {
    Ping,
    Text(String),
    Command { code: i32 },
}

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

    // 2. #[derive(Deserialize)] deserializes enums with unit, tuple, and struct variants
    let ping: Message = serde_json::from_str(r#""Ping""#).expect("deserialize Message::Ping");
    assert_eq!(ping, Message::Ping);

    let text: Message = serde_json::from_str(r#"{"Text":"hello"}"#).expect("deserialize Message::Text");
    assert_eq!(text, Message::Text("hello".to_string()));

    let cmd: Message = serde_json::from_str(r#"{"Command":{"code":42}}"#).expect("deserialize Message::Command");
    assert_eq!(cmd, Message::Command { code: 42 });

    // 3. serde field attributes rename, default, and alias alter struct field deserialization behavior
    let config_with_rename: ServerConfig =
        serde_json::from_str(r#"{"server_port":9000,"host":"localhost"}"#).expect("deserialize with rename");
    assert_eq!(
        config_with_rename,
        ServerConfig {
            port: 9000,
            host: "localhost".to_string(),
        }
    );

    let config_with_default: ServerConfig =
        serde_json::from_str(r#"{"host":"localhost"}"#).expect("deserialize with default");
    assert_eq!(
        config_with_default,
        ServerConfig {
            port: 8080,
            host: "localhost".to_string(),
        }
    );

    let config_with_alias: ServerConfig =
        serde_json::from_str(r#"{"port":7070,"host":"localhost"}"#).expect("deserialize with alias");
    assert_eq!(
        config_with_alias,
        ServerConfig {
            port: 7070,
            host: "localhost".to_string(),
        }
    );

    // 4. serde container attribute deny_unknown_fields rejects unexpected fields during deserialization
    let valid_strict: StrictConfig =
        serde_json::from_str(r#"{"endpoint":"api.example.com"}"#).expect("deserialize valid strict");
    assert_eq!(
        valid_strict,
        StrictConfig {
            endpoint: "api.example.com".to_string(),
        }
    );

    let invalid_strict: Result<StrictConfig, _> =
        serde_json::from_str(r#"{"endpoint":"api.example.com","extra":true}"#);
    assert!(
        invalid_strict.is_err(),
        "deny_unknown_fields must reject unexpected fields"
    );

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

Origin Seeder

anonymous