#![allow(missing_docs)]
use chrono::{DateTime, Utc};
use mempill_types::{AgentId, AdjudicationRequest, ClaimRef};
#[derive(Debug, Clone)]
pub struct PendingAdjudicationRow {
pub handle_id: uuid::Uuid,
pub agent_id: AgentId,
pub subject: String,
pub predicate: String,
pub challenger_claim_ref: ClaimRef,
pub incumbent_claim_ref: ClaimRef,
pub request_payload: AdjudicationRequest,
pub queued_at: DateTime<Utc>,
pub expires_at: Option<DateTime<Utc>>,
pub status: String,
}
pub trait PendingAdjudicationPort: Send + Sync + 'static {
type Error: std::error::Error + Send + Sync + 'static;
fn insert_pending(&self, row: &PendingAdjudicationRow) -> Result<(), Self::Error>;
fn get_pending(&self, handle_id: uuid::Uuid) -> Result<Option<PendingAdjudicationRow>, Self::Error>;
fn list_pending(&self, agent_id: Option<&AgentId>) -> Result<Vec<PendingAdjudicationRow>, Self::Error>;
fn list_expired(&self, now: DateTime<Utc>) -> Result<Vec<PendingAdjudicationRow>, Self::Error>;
fn mark_resolved(&self, handle_id: uuid::Uuid) -> Result<(), Self::Error>;
fn mark_expired(&self, handle_id: uuid::Uuid) -> Result<(), Self::Error>;
fn list_queued_orphan_claims(&self) -> Result<Vec<OrphanedQueuedClaim>, Self::Error>;
}
#[derive(Debug, Clone)]
pub struct OrphanedQueuedClaim {
pub agent_id: AgentId,
pub challenger_claim_ref: ClaimRef,
pub incumbent_claim_ref: Option<ClaimRef>,
pub subject: String,
pub predicate: String,
}
#[derive(Debug)]
pub struct NoPendingStore;
#[derive(Debug)]
pub enum NoPendingStoreError {}
impl std::fmt::Display for NoPendingStoreError {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
unreachable!()
}
}
impl std::error::Error for NoPendingStoreError {}
impl PendingAdjudicationPort for NoPendingStore {
type Error = NoPendingStoreError;
fn insert_pending(&self, _row: &PendingAdjudicationRow) -> Result<(), Self::Error> {
unreachable!("NoPendingStore::insert_pending must never be called (pending_store is None in EngineHandle)")
}
fn get_pending(&self, _handle_id: uuid::Uuid) -> Result<Option<PendingAdjudicationRow>, Self::Error> {
unreachable!("NoPendingStore::get_pending must never be called")
}
fn list_pending(&self, _agent_id: Option<&AgentId>) -> Result<Vec<PendingAdjudicationRow>, Self::Error> {
unreachable!("NoPendingStore::list_pending must never be called")
}
fn list_expired(&self, _now: DateTime<Utc>) -> Result<Vec<PendingAdjudicationRow>, Self::Error> {
unreachable!("NoPendingStore::list_expired must never be called")
}
fn mark_resolved(&self, _handle_id: uuid::Uuid) -> Result<(), Self::Error> {
unreachable!("NoPendingStore::mark_resolved must never be called")
}
fn mark_expired(&self, _handle_id: uuid::Uuid) -> Result<(), Self::Error> {
unreachable!("NoPendingStore::mark_expired must never be called")
}
fn list_queued_orphan_claims(&self) -> Result<Vec<OrphanedQueuedClaim>, Self::Error> {
unreachable!("NoPendingStore::list_queued_orphan_claims must never be called")
}
}