//! Runtime traits for VM execution, proving, and deployment.
//!
//! Trident is the weapon. Warriors wield it. Trident defines these
//! traits; warriors implement them. A warrior is a target-specific
//! tool (separate crate) that takes compiled Trident output and
//! handles execution, proving, and deployment for a particular
//! VM+OS combination.
//!
//! Example: **Trisha** (Triton + Neptune warrior) implements `Runner`
//! via `triton_vm::simulate()`, `Prover` via `triton_vm::prove()`,
//! and `Deployer` via Neptune RPC โ€” all using Trident's `PrimeField`,
//! `Poseidon2`, and `Claim` primitives from `crate::field`.
//!
//! No heavy dependencies here โ€” only the interface contract and
//! the serializable `ProgramBundle` artifact format.

pub mod artifact;

use crate::field::proof::Claim;
pub use artifact::ProgramBundle;

// โ”€โ”€โ”€ Types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

/// VM execution result.
#[derive(Clone, Debug)]
pub struct ExecutionResult {
    /// Output field elements (from `write_io` instructions).
    pub output: Vec<u64>,
    /// Number of VM cycles consumed.
    pub cycle_count: u64,
}

/// Proof artifact: claim + opaque proof bytes.
///
/// The `claim` is universal (defined in `field::proof`). The
/// `proof_bytes` are warrior-specific โ€” their format depends on
/// the proving system (STARK, SNARK, etc.).
#[derive(Clone, Debug)]
pub struct ProofData {
    /// What the proof asserts (program hash, input, output).
    pub claim: Claim,
    /// Serialized proof (format is warrior-specific).
    pub proof_bytes: Vec<u8>,
    /// Proof system identifier (e.g. "stark-triton-v2", "groth16-bn254").
    pub format: String,
}

/// Input specification for program execution.
#[derive(Clone, Debug, Default)]
pub struct ProgramInput {
    /// Public input field elements (read via `read_io`).
    pub public: Vec<u64>,
    /// Secret/divine input field elements (read via `divine`).
    pub secret: Vec<u64>,
    /// Nondeterministic digests for `merkle_step` (each is 5 field elements).
    pub digests: Vec<[u64; 5]>,
}

// โ”€โ”€โ”€ Warrior Traits โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

/// Run a compiled program on a VM.
///
/// Warriors implement this to execute TASM (or other target assembly)
/// using the actual VM runtime.
pub trait Runner {
    /// Execute the program with the given inputs, returning output
    /// values and cycle count.
    fn run(&self, bundle: &ProgramBundle, input: &ProgramInput) -> Result<ExecutionResult, String>;
}

/// Generate a proof of correct execution.
///
/// Warriors implement this to produce a cryptographic proof that the
/// program executed correctly on the given inputs.
pub trait Prover {
    /// Execute and prove, returning the proof artifact.
    fn prove(&self, bundle: &ProgramBundle, input: &ProgramInput) -> Result<ProofData, String>;
}

/// Verify a proof against its claim.
///
/// Warriors implement this to check that a proof is valid for its
/// claimed program, input, and output.
pub trait Verifier {
    /// Returns true if the proof is valid.
    fn verify(&self, proof: &ProofData) -> Result<bool, String>;
}

/// Search for a nonce that satisfies a difficulty target.
///
/// Warriors implement this to find a nonce such that
/// `hash(message ++ nonce) < target`. Used for proof-of-work
/// mining and computational puzzles.
pub trait Guesser {
    /// Search for a valid nonce. Returns the nonce, digest, and
    /// number of attempts if found within `max_attempts`.
    fn guess(
        &self,
        bundle: &ProgramBundle,
        input: &ProgramInput,
        difficulty: u64,
        max_attempts: u64,
    ) -> Result<GuessResult, String>;
}

/// Result of a successful nonce search.
#[derive(Clone, Debug)]
pub struct GuessResult {
    /// The winning nonce value.
    pub nonce: u64,
    /// The resulting digest elements.
    pub digest: Vec<u64>,
    /// Total nonces attempted before finding the solution.
    pub attempts: u64,
}

/// Deploy a program to a chain or runtime.
///
/// Warriors implement this for chain-specific deployment (e.g.,
/// constructing Neptune LockScript/TypeScript, broadcasting
/// transactions via RPC).
pub trait Deployer {
    /// Deploy the program, optionally with a proof.
    /// Returns a deployment identifier (tx hash, contract address, etc.).
    fn deploy(&self, bundle: &ProgramBundle, proof: Option<&ProofData>) -> Result<String, String>;
}

Dimensions

trident/src/diagnostic/mod.rs
trident/src/ir/mod.rs
trident/src/deploy/mod.rs
trident/src/syntax/mod.rs
trident/src/api/mod.rs
nebu/rs/extension/mod.rs
optica/src/render/mod.rs
trident/src/config/mod.rs
trident/src/field/mod.rs
trident/src/cli/mod.rs
optica/src/parser/mod.rs
trident/src/neural/mod.rs
trident/src/cost/mod.rs
trident/src/typecheck/mod.rs
optica/src/server/mod.rs
trident/src/package/mod.rs
optica/src/scanner/mod.rs
optica/src/output/mod.rs
trident/src/verify/mod.rs
optica/src/graph/mod.rs
trident/src/ast/mod.rs
trident/src/lsp/mod.rs
trident/src/gpu/mod.rs
optica/src/query/mod.rs
trident/src/lsp/semantic/mod.rs
trident/src/verify/equiv/mod.rs
trident/src/package/hash/mod.rs
trident/src/neural/training/mod.rs
trident/src/verify/synthesize/mod.rs
trident/src/ir/tir/mod.rs
rs/macros/src/addressed/mod.rs
trident/src/package/registry/mod.rs
rs/rsc/src/lints/mod.rs
trident/src/verify/report/mod.rs
trident/src/config/resolve/mod.rs
trident/src/verify/solve/mod.rs
rs/macros/src/registers/mod.rs
trident/src/verify/smt/mod.rs
rs/macros/src/cell/mod.rs
rs/core/src/fixed_point/mod.rs
trident/src/neural/data/mod.rs
rs/core/src/bounded/mod.rs
trident/src/lsp/util/mod.rs
trident/src/typecheck/tests/mod.rs
trident/src/neural/model/mod.rs
trident/src/cost/stack_verifier/mod.rs
trident/src/syntax/grammar/mod.rs
trident/src/package/manifest/mod.rs
trident/src/syntax/parser/mod.rs
trident/src/ir/kir/mod.rs
trident/src/neural/inference/mod.rs
trident/src/syntax/lexer/mod.rs
trident/src/cost/model/mod.rs
trident/src/ir/lir/mod.rs
trident/src/syntax/format/mod.rs
trident/src/config/scaffold/mod.rs
trident/src/verify/sym/mod.rs
trident/src/api/tests/mod.rs
trident/src/package/store/mod.rs
trident/src/ir/tree/mod.rs
trident/src/ir/kir/lower/mod.rs
trident/src/ir/lir/lower/mod.rs
trident/src/ir/tir/lower/mod.rs
trident/src/ir/tir/builder/mod.rs
trident/src/ir/tir/neural/mod.rs
trident/src/neural/data/tir_graph/mod.rs
trident/src/syntax/parser/tests/mod.rs
cw-cyber/packages/cyber-std/src/tokenfactory/mod.rs
trident/src/ir/tree/lower/mod.rs
trident/src/ir/tir/stack/mod.rs
cw-cyber/contracts/cybernet/src/tests/mod.rs
trident/src/ir/tir/optimize/mod.rs

Local Graph