gaze_token_bridge/error.rs
1//! Error and deny taxonomy.
2//!
3//! `DenyReason` is `#[non_exhaustive]`: callers should keep wildcard match arms.
4//! Every deny is typed and audited;
5//! the agent-facing surface must never reveal which variant fired (no oracle).
6
7use serde::{Deserialize, Serialize};
8
9/// Owner-side construction/configuration error (policy load, session, key material).
10/// Distinct from [`DenyReason`], which is the per-request authorization outcome.
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub enum BridgeError {
13 /// Policy/registry/key configuration problem.
14 Policy(String),
15 /// Underlying gaze session error.
16 Session(String),
17}
18
19/// Why a bridge request or handle execution was denied. All paths fail closed.
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21#[non_exhaustive]
22pub enum DenyReason {
23 /// Source token is not a well-formed gaze token.
24 MalformedToken,
25 /// Token is well-formed but absent from the active session manifest.
26 UnknownToken,
27 /// Principal tenant/workspace does not match the request or target domain.
28 TenantOrWorkspaceMismatch,
29 /// Target domain is not registered.
30 DomainNotFound,
31 /// Principal lacks a role the domain allows.
32 PrincipalNotAllowed,
33 /// Entity class is not bridgeable into the target domain.
34 ClassNotAllowed,
35 /// No allow rule matched (default-deny).
36 NoMatchingAllowRule,
37 /// Cross-domain search attempted without elevated, mutually-allowing policy.
38 CrossDomainDenied,
39 /// SearchHandle is past its expiry tick.
40 ExpiredHandle,
41 /// SearchHandle nonce was already consumed (replay).
42 ReplayedHandle,
43 /// Handle's entity_ref domain does not match its target domain.
44 HandleDomainMismatch,
45 /// Requested entity_ref does not match the entity_ref the handle was minted for.
46 EntityRefMismatch,
47 /// Session is bound to a different principal than the requester.
48 SessionPrincipalMismatch,
49 /// Domain forbids returning snippets.
50 SnippetsDisabled,
51 /// Response translation could not map all index aliases to session tokens.
52 TranslatorFailed,
53}