1use forge_engine::ForgeError;
2use forge_memory_bridge::BridgeError;
3use knowledge_runtime::RuntimeError;
4use semantic_memory::MemoryError;
5use thiserror::Error;
6use verification_policy::PermitIssuanceError;
7
8#[derive(Debug, Error)]
9pub enum PilotError {
10 #[error("runtime error: {0}")]
11 Runtime(#[from] RuntimeError),
12 #[error("memory error: {0}")]
13 Memory(#[from] MemoryError),
14 #[error("forge error: {0}")]
15 Forge(#[from] ForgeError),
16 #[error("bridge error: {0}")]
17 Bridge(#[from] BridgeError),
18 #[error("json error: {0}")]
19 Json(#[from] serde_json::Error),
20 #[error("missing kernel payload for scope {scope}")]
21 MissingKernelPayload { scope: String },
22 #[error("invalid kernel payload for scope {scope}: {reason}")]
23 InvalidKernelPayload { scope: String, reason: String },
24 #[error("missing compiled kernel context")]
25 MissingCompiledContext,
26 #[error("missing temporal replay snapshots")]
27 MissingTemporalSnapshots,
28 #[error("no executable plan available for target {target_key}")]
29 NoExecutablePlan { target_key: String },
30 #[error("unsupported patch fixture {fixture_path}")]
31 UnsupportedPatchFixture { fixture_path: String },
32 #[error("control-plane ledger replay failed: {0}")]
33 ControlPlaneReplay(String),
34 #[error("execution permit error: {0}")]
35 ExecutionPermit(#[from] PermitIssuanceError),
36 #[error("{0}")]
37 Other(String),
38}
39
40impl PilotError {
41 pub fn kind(&self) -> &'static str {
43 match self {
44 Self::Runtime(..) => "runtime",
45 Self::Memory(..) => "memory",
46 Self::Forge(..) => "forge",
47 Self::Bridge(..) => "bridge",
48 Self::Json(..) => "json",
49 Self::MissingKernelPayload { .. } => "missing_kernel_payload",
50 Self::InvalidKernelPayload { .. } => "invalid_kernel_payload",
51 Self::MissingCompiledContext => "missing_compiled_context",
52 Self::MissingTemporalSnapshots => "missing_temporal_snapshots",
53 Self::NoExecutablePlan { .. } => "no_executable_plan",
54 Self::UnsupportedPatchFixture { .. } => "unsupported_patch_fixture",
55 Self::ControlPlaneReplay(..) => "control_plane_replay",
56 Self::ExecutionPermit(..) => "execution_permit",
57 Self::Other(..) => "other",
58 }
59 }
60}