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("manifest.json domain '{domain}' is invalid: {reason}")]
20 ManifestDomainInvalid { domain: String, reason: String },
21
22 #[error("failed to parse {asset}: {source}")]
24 AssetParse {
25 asset: String,
26 #[source]
27 source: serde_json::Error,
28 },
29
30 #[error("invalid JSONL in {file} at line {line}: {reason}")]
31 JsonlParse {
32 file: String,
33 line: usize,
34 reason: String,
35 },
36
37 #[error("schema validation failed for {asset}: {violations}")]
38 SchemaValidation { asset: String, violations: String },
39
40 #[cfg(feature = "search")]
42 #[error("search index error: {0}")]
43 SearchIndex(String),
44
45 #[error("gate {gate} failed: {reason}")]
47 GateFailed { gate: u8, reason: String },
48
49 #[error("OKF frontmatter error in {file}: {reason}")]
51 OkfFrontmatter { file: String, reason: String },
52
53 #[error("broken OKF link in {file}: target '{target}' not found")]
54 OkfBrokenLink { file: String, target: String },
55
56 #[error("source_ref '{source_ref}' in {asset} does not resolve to sources.csv")]
58 UnresolvedSourceRef { source_ref: String, asset: String },
59
60 #[error("archive error: {0}")]
62 Archive(String),
63
64 #[error("config error: {0}")]
66 Config(String),
67
68 #[error("procedure '{id}' not found in pack '{pack}'")]
70 ProcedureNotFound { id: String, pack: String },
71
72 #[error("procedure '{id}' has no executable (.wasm absent, no entry_point declared)")]
73 ProcedureNoExecutable { id: String },
74
75 #[error("procedure '{id}' exceeded {limit_ms}ms wall-clock timeout")]
76 ProcedureTimeout { id: String, limit_ms: u64 },
77
78 #[error("procedure '{id}' produced invalid JSON output: {reason}")]
79 ProcedureInvalidOutput { id: String, reason: String },
80
81 #[error("procedure '{id}' trapped during execution: {message}")]
82 ProcedureTrap { id: String, message: String },
83
84 #[error("cannot satisfy procedure_capabilities constraint '{constraint}' for '{id}'")]
85 ProcedureConstraintUnsatisfied { id: String, constraint: String },
86
87 #[error("procedure schema '{id}' is not valid JSON Schema: {message}")]
88 ProcedureSchemaInvalid { id: String, message: String },
89
90 #[error("procedure '{id}' is a non-WASM executable and cannot be run from an unsigned bundle (pass --allow-unsigned to override)")]
91 ProcedureUnsignedSubprocess { id: String },
92
93 #[error("registry error: {0}")]
95 Registry(String),
96
97 #[error("IO error: {0}")]
99 Io(#[from] std::io::Error),
100
101 #[error("JSON error: {0}")]
102 Json(#[from] serde_json::Error),
103}
104
105pub type DkpResult<T> = Result<T, DkpError>;