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 #[error("search index error: {0}")]
42 SearchIndex(String),
43
44 #[error("gate {gate} failed: {reason}")]
46 GateFailed { gate: u8, reason: String },
47
48 #[error("OKF frontmatter error in {file}: {reason}")]
50 OkfFrontmatter { file: String, reason: String },
51
52 #[error("broken OKF link in {file}: target '{target}' not found")]
53 OkfBrokenLink { file: String, target: String },
54
55 #[error("source_ref '{source_ref}' in {asset} does not resolve to sources.csv")]
57 UnresolvedSourceRef { source_ref: String, asset: String },
58
59 #[error("archive error: {0}")]
61 Archive(String),
62
63 #[error("config error: {0}")]
65 Config(String),
66
67 #[error("procedure '{id}' not found in pack '{pack}'")]
69 ProcedureNotFound { id: String, pack: String },
70
71 #[error("procedure '{id}' has no executable (.wasm absent, no entry_point declared)")]
72 ProcedureNoExecutable { id: String },
73
74 #[error("procedure '{id}' exceeded {limit_ms}ms wall-clock timeout")]
75 ProcedureTimeout { id: String, limit_ms: u64 },
76
77 #[error("procedure '{id}' produced invalid JSON output: {reason}")]
78 ProcedureInvalidOutput { id: String, reason: String },
79
80 #[error("procedure '{id}' trapped during execution: {message}")]
81 ProcedureTrap { id: String, message: String },
82
83 #[error("cannot satisfy procedure_capabilities constraint '{constraint}' for '{id}'")]
84 ProcedureConstraintUnsatisfied { id: String, constraint: String },
85
86 #[error("procedure schema '{id}' is not valid JSON Schema: {message}")]
87 ProcedureSchemaInvalid { id: String, message: String },
88
89 #[error("procedure '{id}' is a non-WASM executable and cannot be run from an unsigned bundle (pass --allow-unsigned to override)")]
90 ProcedureUnsignedSubprocess { id: String },
91
92 #[error("registry error: {0}")]
94 Registry(String),
95
96 #[error("IO error: {0}")]
98 Io(#[from] std::io::Error),
99
100 #[error("JSON error: {0}")]
101 Json(#[from] serde_json::Error),
102}
103
104pub type DkpResult<T> = Result<T, DkpError>;