CodeSampleX

Ejemplo

r-efi 6.0.0

Muestra verificada para cargo r-efi 6.0.0. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: assert Boolean represents UEFI boolean with…

sha256:9f204a811744c629e16e29bd27ea272577f640db2c206cb424b6774abe9a652c

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
1
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 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b…
2026-10-13

Caso

HOW
Objetivo
verify pkg:cargo/r-efi@6.0.0
Paquetes
Creado
2026-10-13T19:14:45Z

Contrato

  1. assert Boolean represents UEFI boolean with 1-byte size, maps 0 to FALSE and non-zero to TRUE, and compares equal to bool
  2. assert Status distinguishes SUCCESS, error codes, and warning codes with is_error and is_warning
  3. assert Status converts into Result<Status, Status> mapping errors to Err and success or warnings to Ok
  4. assert Guid from_fields and from_bytes correctly encode little-endian UEFI GUIDs and round-trip via as_fields and as_bytes
  5. assert base UEFI primitive types Char8, Char16, Handle, Event, and Guid match mandated ABI sizes and alignments

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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

[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"

[[package]]
name = "sample-r-efi"
version = "1.0.0"
dependencies = [
 "r-efi",
]
Cargo.toml
[package]
name = "sample-r-efi"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
r-efi = "=6.0.0"

[[bin]]
name = "contract"
path = "test/contract.rs"
NOTES.md
# r-efi 6.0.0 Base Environment and Status/Guid Contracts

## What `search_known_solution` answered
`search_known_solution` returned an unverified `COMPATIBLE` candidate (`glibc`/`ubuntu`) and a verified `REFERENCE_ONLY` sample from `r-efi@5.3.0` (`musl`/`alpine`).

## What a model would have written instead
A model might assume UEFI enumerations are native Rust enums rather than constants with type aliases, or assume `Guid` alignment is 8 bytes according to the UEFI specification rather than 4 bytes for EDK2 compatibility. It might also leave the host `glibc` environment in `csx.json`, which causes the `rust:1-alpine` (`musl`) container verifier to skip verification.

## How the wrong version fails
Using Rust enums fails to accommodate reserved vendor ranges. Assuming 8-byte `Guid` alignment produces layout mismatches with EDK2 structures. Specifying `glibc` in `csx.json` causes `csx sample verify` to fail at `resolve` with `verifier image rust:1-alpine provides libc "musl" and cannot satisfy "glibc"`.
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/r-efi@6.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/r-efi@6.0.0

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:f3cc3e86b3de95075ba06edac92c267c62fe8476802b191506aa0e9bc6fb6e10","contract":["assert Boolean represents UEFI boolean with 1-byte size, maps 0 to FALSE and non-zero to TRUE, and compares equal to bool","assert Status distinguishes SUCCESS, error codes, and warning codes with is_error and is_warning","assert Status converts into Result\u003cStatus, Status\u003e mapping errors to Err and success or warnings to Ok","assert Guid from_fields and from_bytes correctly encode little-endian UEFI GUIDs and round-trip via as_fields and as_bytes","assert base UEFI primitive types Char8, Char16, Handle, Event, and Guid match mandated ABI sizes and alignments"],"goal":"verify pkg:cargo/r-efi@6.0.0","kind":"HOW","packages":["pkg:cargo/r-efi@6.0.0"],"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/r-efi@6.0.0"],"schemaVersion":1,"subject":"pkg:cargo/r-efi@6.0.0","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/r-efi@6.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/r-efi@6.0.0"
  ]
}
src/lib.rs
//! Clean-room verification sample for r-efi 6.0.0.

pub use r_efi::*;
test/contract.rs
use core::mem::{align_of, size_of};
use r_efi::base::{Boolean, Char8, Char16, Event, Guid, Handle, Status};
use r_efi::efi;

fn main() {
    // 1. Boolean represents UEFI boolean with 1-byte size, maps 0 to FALSE and non-zero to TRUE, and compares equal to bool
    assert_eq!(size_of::<Boolean>(), 1);
    assert_eq!(align_of::<Boolean>(), 1);
    assert_eq!(Boolean::FALSE, false);
    assert_eq!(Boolean::TRUE, true);
    assert_ne!(Boolean::FALSE, Boolean::TRUE);
    assert_eq!(Boolean::from(0u8), Boolean::FALSE);
    assert_eq!(Boolean::from(1u8), Boolean::TRUE);
    assert_eq!(Boolean::from(42u8), Boolean::TRUE);
    assert_eq!(bool::from(Boolean::FALSE), false);
    assert_eq!(bool::from(Boolean::TRUE), true);

    // 2. Status distinguishes SUCCESS, error codes, and warning codes with is_error and is_warning
    assert_eq!(Status::SUCCESS.as_usize(), 0);
    assert!(!Status::SUCCESS.is_error());
    assert!(!Status::SUCCESS.is_warning());

    assert!(Status::INVALID_PARAMETER.is_error());
    assert!(!Status::INVALID_PARAMETER.is_warning());
    assert!(Status::UNSUPPORTED.is_error());
    assert!(Status::BUFFER_TOO_SMALL.is_error());

    assert!(!Status::WARN_BUFFER_TOO_SMALL.is_error());
    assert!(Status::WARN_BUFFER_TOO_SMALL.is_warning());

    // 3. Status converts into Result<Status, Status> mapping errors to Err and success or warnings to Ok
    let ok_res: Result<Status, Status> = Status::SUCCESS.into();
    assert_eq!(ok_res, Ok(Status::SUCCESS));

    let warn_res: Result<Status, Status> = Status::WARN_BUFFER_TOO_SMALL.into();
    assert_eq!(warn_res, Ok(Status::WARN_BUFFER_TOO_SMALL));

    let err_res: Result<Status, Status> = Status::INVALID_PARAMETER.into();
    assert_eq!(err_res, Err(Status::INVALID_PARAMETER));

    // 4. Guid from_fields and from_bytes correctly encode little-endian UEFI GUIDs and round-trip via as_fields and as_bytes
    let fields = (
        0x12345678u32,
        0xabcd,
        0xef01,
        0x23,
        0x45,
        &[0x67, 0x89, 0xab, 0xcd, 0xef, 0x01],
    );
    let guid_from_f = Guid::from_fields(fields.0, fields.1, fields.2, fields.3, fields.4, fields.5);
    let expected_bytes: [u8; 16] = [
        0x78, 0x56, 0x34, 0x12, // time_low (LE)
        0xcd, 0xab,             // time_mid (LE)
        0x01, 0xef,             // time_hi (LE)
        0x23,                   // clk_seq_hi
        0x45,                   // clk_seq_lo
        0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, // node
    ];
    let guid_from_b = Guid::from_bytes(&expected_bytes);
    assert_eq!(guid_from_f, guid_from_b);
    assert_eq!(guid_from_f.as_bytes(), &expected_bytes);
    assert_eq!(guid_from_b.as_fields(), fields);

    // 5. Base UEFI primitive types Char8, Char16, Handle, Event, and Guid match mandated ABI sizes and alignments
    assert_eq!(size_of::<Char8>(), 1);
    assert_eq!(align_of::<Char8>(), 1);
    assert_eq!(size_of::<Char16>(), 2);
    assert_eq!(align_of::<Char16>(), 2);
    assert_eq!(size_of::<Handle>(), size_of::<usize>());
    assert_eq!(align_of::<Handle>(), align_of::<usize>());
    assert_eq!(size_of::<Event>(), size_of::<usize>());
    assert_eq!(align_of::<Event>(), align_of::<usize>());
    assert_eq!(size_of::<Guid>(), 16);
    assert_eq!(align_of::<Guid>(), 4);

    // Flat efi namespace exports
    assert_eq!(efi::Status::SUCCESS, Status::SUCCESS);
    assert_eq!(efi::Boolean::TRUE, Boolean::TRUE);

    println!("All pkg:cargo/r-efi@6.0.0 contract assertions passed successfully.");
}

Seeder de origen

anónimo