src/pqc_ai_governance/errors.py
| 1 | """Exception hierarchy for pqc-ai-governance.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | |
| 6 | class GovernanceError(Exception): |
| 7 | """Base exception for all pqc-ai-governance errors.""" |
| 8 | |
| 9 | |
| 10 | class InvalidProposalError(GovernanceError): |
| 11 | """Raised when a governance proposal is structurally invalid or fails signature verification.""" |
| 12 | |
| 13 | |
| 14 | class InvalidVoteError(GovernanceError): |
| 15 | """Raised when a vote is structurally invalid or its signature fails to verify.""" |
| 16 | |
| 17 | |
| 18 | class InsufficientQuorumError(GovernanceError): |
| 19 | """Raised when the participation threshold for a consensus round is not met.""" |
| 20 | |
| 21 | |
| 22 | class ConsensusFailedError(GovernanceError): |
| 23 | """Raised when a consensus round cannot reach a decision.""" |
| 24 | |
| 25 | |
| 26 | class UnknownNodeError(GovernanceError): |
| 27 | """Raised when a referenced node DID is not present in the NodeRegistry.""" |
| 28 | |
| 29 | |
| 30 | class ByzantineDetectedError(GovernanceError): |
| 31 | """Raised when a node exhibits Byzantine behaviour (e.g., double-voting with conflicting decisions).""" |
| 32 | |
| 33 | |
| 34 | class ProposalExpiredError(GovernanceError): |
| 35 | """Raised when a vote is cast on a proposal whose TTL has already elapsed.""" |
| 36 | |