1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum DkpError {
6 #[error("pack not found: {0}")]
8 PackNotFound(PathBuf),
9
10 #[error("manifest.json missing from pack at {0}")]
11 ManifestMissing(PathBuf),
12
13 #[error("manifest.json invalid: {reason}")]
14 ManifestInvalid { reason: String },
15
16 #[error("required field '{field}' missing or empty in manifest.json")]
17 ManifestFieldMissing { field: &'static str },
18
19 #[error("failed to parse {asset}: {source}")]
21 AssetParse {
22 asset: String,
23 #[source]
24 source: serde_json::Error,
25 },
26
27 #[error("invalid JSONL in {file} at line {line}: {reason}")]
28 JsonlParse {
29 file: String,
30 line: usize,
31 reason: String,
32 },
33
34 #[error("schema validation failed for {asset}: {violations}")]
35 SchemaValidation { asset: String, violations: String },
36
37 #[error("search index error: {0}")]
39 SearchIndex(String),
40
41 #[error("gate {gate} failed: {reason}")]
43 GateFailed { gate: u8, reason: String },
44
45 #[error("OKF frontmatter error in {file}: {reason}")]
47 OkfFrontmatter { file: String, reason: String },
48
49 #[error("broken OKF link in {file}: target '{target}' not found")]
50 OkfBrokenLink { file: String, target: String },
51
52 #[error("source_ref '{source_ref}' in {asset} does not resolve to sources.csv")]
54 UnresolvedSourceRef { source_ref: String, asset: String },
55
56 #[error("archive error: {0}")]
58 Archive(String),
59
60 #[error("config error: {0}")]
62 Config(String),
63
64 #[error("procedure '{id}' not found in pack '{pack}'")]
66 ProcedureNotFound { id: String, pack: String },
67
68 #[error("procedure '{id}' has no executable (.wasm absent, no entry_point declared)")]
69 ProcedureNoExecutable { id: String },
70
71 #[error("procedure '{id}' exceeded {limit_ms}ms wall-clock timeout")]
72 ProcedureTimeout { id: String, limit_ms: u64 },
73
74 #[error("procedure '{id}' produced invalid JSON output: {reason}")]
75 ProcedureInvalidOutput { id: String, reason: String },
76
77 #[error("procedure '{id}' trapped during execution: {message}")]
78 ProcedureTrap { id: String, message: String },
79
80 #[error("cannot satisfy procedure_capabilities constraint '{constraint}' for '{id}'")]
81 ProcedureConstraintUnsatisfied { id: String, constraint: String },
82
83 #[error("procedure schema '{id}' is not valid JSON Schema: {message}")]
84 ProcedureSchemaInvalid { id: String, message: String },
85
86 #[error("procedure '{id}' is a non-WASM executable and cannot be run from an unsigned bundle (pass --allow-unsigned to override)")]
87 ProcedureUnsignedSubprocess { id: String },
88
89 #[error("registry error: {0}")]
91 Registry(String),
92
93 #[error("IO error: {0}")]
95 Io(#[from] std::io::Error),
96
97 #[error("JSON error: {0}")]
98 Json(#[from] serde_json::Error),
99}
100
101pub type DkpResult<T> = Result<T, DkpError>;