Skip to main content

heartbit_core/store/
mod.rs

1//! Task and audit record persistence (in-memory and PostgreSQL backends).
2
3#![allow(missing_docs)]
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6use uuid::Uuid;
7
8/// Task record stored in a task store.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct TaskRecord {
11    pub id: Uuid,
12    pub status: String,
13    pub task_input: String,
14    pub config_name: Option<String>,
15    pub result: Option<String>,
16    pub error: Option<String>,
17    pub token_usage: Option<serde_json::Value>,
18    pub created_at: DateTime<Utc>,
19    pub completed_at: Option<DateTime<Utc>>,
20}
21
22/// Audit log entry stored in an audit trail.
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct AuditEntry {
25    pub id: i64,
26    pub task_id: Uuid,
27    pub agent_name: String,
28    pub event_type: String,
29    pub payload: serde_json::Value,
30    pub tokens_in: Option<i32>,
31    pub tokens_out: Option<i32>,
32    pub created_at: DateTime<Utc>,
33    /// Tenant that owns this audit entry. `None` for single-tenant deployments.
34    #[serde(default)]
35    pub tenant_id: Option<String>,
36    /// User who triggered the action. `None` when identity is unavailable.
37    #[serde(default)]
38    pub user_id: Option<String>,
39}