use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum Error {
#[error(
"IR inlining cycle at operation `{op_id}`. Fix: remove the recursive Expr::Call chain or split the recursive algorithm into an explicit bounded Loop."
)]
InlineCycle {
op_id: String,
},
#[error(
"IR inlining could not resolve operation `{op_id}`. Fix: register a Category A operation with this id before lowering or replace the call with inline IR."
)]
InlineUnknownOp {
op_id: String,
},
#[error(
"IR inlining rejected non-inlinable operation `{op_id}`. Fix: this op processes buffer inputs and must be dispatched as a separate kernel, not composed via Expr::Call."
)]
InlineNonInlinable {
op_id: String,
},
#[error(
"IR inlining argument count mismatch for operation `{op_id}`: expected {expected}, got {got}. Fix: pass exactly one argument for each ReadOnly or Uniform input buffer declared by the callee program."
)]
InlineArgCountMismatch {
op_id: String,
expected: usize,
got: usize,
},
#[error(
"IR inlining found no output write for operation `{op_id}`. Fix: Ensure the op's program() body writes to its output buffer at least once."
)]
InlineNoOutput {
op_id: String,
},
#[error(
"IR inlining found {got} declared output buffers for operation `{op_id}`. Fix: mark exactly one result buffer with BufferDecl::output(...)."
)]
InlineOutputCountMismatch {
op_id: String,
got: usize,
},
#[error(
"Wire-format validation failed: {message}. Fix: recompile the frontend program set and ensure the compiler only emits valid instructions."
)]
WireFormatValidation {
message: String,
},
#[error("vyre WGSL lowering: {message}")]
Lowering {
message: String,
},
#[error("vyre reference interpreter: {message}")]
Interp {
message: String,
},
#[error(
"GPU pipeline failed: {message}. Fix: verify wgpu is available and the compiled buffers fit the target adapter limits."
)]
Gpu {
message: String,
},
#[error(
"Decode configuration failed: {message}. Fix: provide valid TOML and non-zero decode thresholds."
)]
DecodeConfig {
message: String,
},
#[error(
"Decode pipeline failed: {message}. Fix: inspect shader output sizing and source-region validation."
)]
Decode {
message: String,
},
#[error(
"Decompression pipeline failed: {message}. Fix: validate frame metadata, split oversized payloads, and inspect GPU decompression status words."
)]
Decompress {
message: String,
},
#[error(
"DFA pipeline failed: {message}. Fix: validate DFA transition tables, output links, and target adapter limits."
)]
Dfa {
message: String,
},
#[error(
"Dataflow pipeline failed: {message}. Fix: validate graph inputs, buffer sizing, and target adapter limits."
)]
Dataflow {
message: String,
},
#[error(
"Prefix construction failed: {message}. Fix: split the input before building prefix arrays or reduce per-file scan size."
)]
Prefix {
message: String,
},
#[error(
"CSR graph construction failed: {message}. Fix: cap graph size and ensure every edge endpoint is within node_count."
)]
Csr {
message: String,
},
#[error(
"Serialization failed: {message}. Fix: verify the wire payload is not truncated or corrupted."
)]
Serialization {
message: String,
},
#[error(
"Rule evaluation failed: {message}. Fix: validate rule pattern ids, thresholds, and verdict buffer sizing before lowering."
)]
RuleEval {
message: String,
},
}
impl Error {
#[must_use]
pub fn lowering(message: impl Into<String>) -> Self {
Self::Lowering {
message: message.into(),
}
}
#[must_use]
pub fn interp(message: impl Into<String>) -> Self {
Self::Interp {
message: message.into(),
}
}
}