use std::fmt;
use pointlock_ir::{AlignmentReport, Hash, StepId};
use pointlock_provider_kit::ProviderError;
use pointlock_store::StoreError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BlockedReason {
RequiresHuman {
call_id: String,
detail: String,
},
Drifted {
step_id: String,
detail: String,
},
}
impl fmt::Display for BlockedReason {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BlockedReason::RequiresHuman { call_id, detail } => {
write!(
f,
"requires human adjudication (callId {call_id}): {detail}"
)
}
BlockedReason::Drifted { step_id, detail } => {
write!(
f,
"drifted: preflight of step '{step_id}' did not hold: {detail} \
(no onResumeDrift disposition remained — declare one, or repair \
the world and resume)"
)
}
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum RunnerError {
#[error("irHash mismatch: declared {declared}, computed {computed}")]
IrHashMismatch {
declared: Hash,
computed: Hash,
},
#[error("step '{step_id}': stored {domain}Hash {declared} != computed {computed}")]
StepHashMismatch {
step_id: StepId,
domain: &'static str,
declared: Hash,
computed: Hash,
},
#[error("not in the M0 subset: {construct} (step: {step_id:?})")]
NotInM0Subset {
step_id: Option<StepId>,
construct: String,
},
#[error("human step '{step_id}' is invalid: {reason}")]
InvalidHumanStep {
step_id: StepId,
reason: String,
},
#[error("call depth {depth} exceeds maxCallDepth {max} (07 §1.3)")]
CallDepthExceeded {
depth: usize,
max: usize,
},
#[error("subflow registry: {detail}")]
SubflowRegistry {
detail: String,
},
#[error(
"capability drift: IR lockfileDigest {expected} != session attestation {attested}; \
refusing to run"
)]
CapabilityDrift {
expected: Hash,
attested: Hash,
},
#[error("invalid params: {reason}")]
InvalidParams {
reason: String,
},
#[error(
"old FlowIR mismatch: the run executed irHash {expected}, supplied IR computes {computed}"
)]
OldIrMismatch {
expected: Hash,
computed: Hash,
},
#[error(
"resume requires explicit confirmation for {} mutating step(s) (07 §5.4); \
authorize each with --allow-mutating-reexec <stepId>",
report.requires_confirmation.len()
)]
RequiresConfirmation {
report: Box<AlignmentReport>,
},
#[error("not supported in M0: {detail}")]
M0Unsupported {
detail: String,
},
#[error(
"evidence integrity failure for asset {asset_id}: sha256 {actual} != declared {expected}"
)]
EvidenceIntegrity {
asset_id: String,
expected: String,
actual: String,
},
#[error(transparent)]
Store(#[from] StoreError),
#[error(transparent)]
Provider(#[from] ProviderError),
}