CodeSampleX

Exemplo

anstyle-parse 1.0.0

Amostra verificada para cargo anstyle-parse 1.0.0. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou: Parser advances through ASCII text and…

sha256:d3809dab58e8c3c84d6cd81c8878221dc96e1eb88229d63de0abedd3ad9f1d23

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux · alpine · musl x64 cargo

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify pkg:cargo/anstyle-parse@1.0.0
Pacotes
Criado
2026-09-19T02:23:33Z

Contrato

  1. Parser advances through ASCII text and dispatches characters via Perform::print
  2. Parser decodes UTF-8 multi-byte sequences into unicode codepoints via Perform::print
  3. Parser dispatches CSI sequences with parameters, intermediates, and final action via Perform::csi_dispatch
  4. Parser executes C0 control characters via Perform::execute
  5. Parser dispatches OSC sequences with parameters and bell termination via Perform::osc_dispatch

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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

[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
 "utf8parse",
]

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

[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
Cargo.toml
[package]
name = "sample-anstyle-parse"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
anstyle-parse = "=1.0.0"

[[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/anstyle-parse@1.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/anstyle-parse@1.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:4da294b99e85b603a4428ee7b4ff8debf74e1e61608dcf893964a0aeb2f24ff1","contract":["Parser advances through ASCII text and dispatches characters via Perform::print","Parser decodes UTF-8 multi-byte sequences into unicode codepoints via Perform::print","Parser dispatches CSI sequences with parameters, intermediates, and final action via Perform::csi_dispatch","Parser executes C0 control characters via Perform::execute","Parser dispatches OSC sequences with parameters and bell termination via Perform::osc_dispatch"],"goal":"verify pkg:cargo/anstyle-parse@1.0.0","kind":"HOW","packages":["pkg:cargo/anstyle-parse@1.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/anstyle-parse@1.0.0"],"schemaVersion":1,"subject":"pkg:cargo/anstyle-parse@1.0.0","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/anstyle-parse@1.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/anstyle-parse@1.0.0"
  ]
}
src/lib.rs
//! Clean-room verification sample for anstyle-parse.

pub use anstyle_parse::*;
test/contract.rs
use anstyle_parse::{DefaultCharAccumulator, Params, Parser, Perform};

#[derive(Default)]
struct PerformerCollector {
    prints: Vec<char>,
    executes: Vec<u8>,
    csi_dispatches: Vec<(Vec<Vec<u16>>, Vec<u8>, bool, u8)>,
    esc_dispatches: Vec<(Vec<u8>, bool, u8)>,
    osc_dispatches: Vec<(Vec<Vec<u8>>, bool)>,
}

impl Perform for PerformerCollector {
    fn print(&mut self, c: char) {
        self.prints.push(c);
    }

    fn execute(&mut self, byte: u8) {
        self.executes.push(byte);
    }

    fn csi_dispatch(&mut self, params: &Params, intermediates: &[u8], ignore: bool, action: u8) {
        let param_list: Vec<Vec<u16>> = params.iter().map(|p| p.to_vec()).collect();
        self.csi_dispatches.push((param_list, intermediates.to_vec(), ignore, action));
    }

    fn esc_dispatch(&mut self, intermediates: &[u8], ignore: bool, byte: u8) {
        self.esc_dispatches.push((intermediates.to_vec(), ignore, byte));
    }

    fn osc_dispatch(&mut self, params: &[&[u8]], bell_terminated: bool) {
        let param_list: Vec<Vec<u8>> = params.iter().map(|p| p.to_vec()).collect();
        self.osc_dispatches.push((param_list, bell_terminated));
    }
}

fn parse_bytes(input: &[u8]) -> PerformerCollector {
    let mut parser = Parser::<DefaultCharAccumulator>::new();
    let mut performer = PerformerCollector::default();
    for &b in input {
        parser.advance(&mut performer, b);
    }
    performer
}

fn main() {
    // 1. Parser advances through ASCII text and dispatches characters via Perform::print
    let collector = parse_bytes(b"Hello");
    assert_eq!(collector.prints, vec!['H', 'e', 'l', 'l', 'o']);
    assert!(collector.executes.is_empty());
    assert!(collector.csi_dispatches.is_empty());

    // 2. Parser decodes UTF-8 multi-byte sequences into unicode codepoints via Perform::print
    let collector = parse_bytes("안녕, 世界! 🦀".as_bytes());
    assert_eq!(collector.prints, vec!['안', '녕', ',', ' ', '世', '界', '!', ' ', '🦀']);

    // 3. Parser dispatches CSI sequences with parameters, intermediates, and final action via Perform::csi_dispatch
    let collector = parse_bytes(b"\x1b[31;1m");
    assert_eq!(collector.csi_dispatches.len(), 1);
    let (ref params, ref intermediates, ignore, action) = collector.csi_dispatches[0];
    assert_eq!(params, &vec![vec![31], vec![1]]);
    assert!(intermediates.is_empty());
    assert!(!ignore);
    assert_eq!(action, b'm');

    // 4. Parser executes C0 control characters via Perform::execute
    let collector = parse_bytes(b"\r\n\t");
    assert_eq!(collector.executes, vec![b'\r', b'\n', b'\t']);

    // 5. Parser dispatches OSC sequences with parameters and bell termination via Perform::osc_dispatch
    let collector = parse_bytes(b"\x1b]0;terminal-title\x07");
    assert_eq!(collector.osc_dispatches.len(), 1);
    let (ref osc_params, bell_terminated) = collector.osc_dispatches[0];
    assert_eq!(osc_params, &vec![b"0".to_vec(), b"terminal-title".to_vec()]);
    assert!(bell_terminated);

    println!("All anstyle-parse contract assertions passed successfully.");
}

Seeder de origem

anônimo