M2a: server workspace, kvitt-domain, skeleton routes, OpenAPI match, Dockerfile

Cargo workspace (kvitt-domain, kvitt-server, kvitt-import), Rust 1.99.1 pinned.
kvitt-domain passes every Rust vector and adds next_occurrence_date (D-015).
kvitt-server: config, SQLite pool (WAL, §8.9 pragmas), migration 0001 identical to
the contract schema, error type for all 25 codes, auth extractor and protocol
layer, all 33 routes (E-1/E-2 implemented, the rest 501), utoipa document equal
to contracts/openapi.yaml, seams for M3/M4/M9, serve/migrate/healthcheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 21:25:35 +02:00
parent c277ee37c2
commit 06f48ef9e9
71 changed files with 9187 additions and 0 deletions
@@ -0,0 +1,66 @@
//! The push notification seam (SPEC §14.6). M2a defines the trait and a no-op; M4 owns `src/push/**` and replaces
//! the implementation with the bounded queue and FCM sender.
//!
//! [`PushQueue::enqueue`] never blocks and never fails the caller: sending happens on a background task and never
//! delays an HTTP response (SPEC §14.6). Call it after the write transaction has committed.
use uuid::Uuid;
/// The notification types of SPEC §14.6 (exhaustive).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum PushType {
ExpenseCreated,
ExpenseUpdated,
ExpenseDeleted,
SettlementCreated,
SettlementUpdated,
SettlementDeleted,
RecurringExpenseCreated,
SyncBatch,
}
impl PushType {
/// The `type` value of the data message.
pub fn as_str(self) -> &'static str {
match self {
Self::ExpenseCreated => "expense_created",
Self::ExpenseUpdated => "expense_updated",
Self::ExpenseDeleted => "expense_deleted",
Self::SettlementCreated => "settlement_created",
Self::SettlementUpdated => "settlement_updated",
Self::SettlementDeleted => "settlement_deleted",
Self::RecurringExpenseCreated => "recurring_expense_created",
Self::SyncBatch => "sync_batch",
}
}
}
/// One notification to send. Ids only, never personal content (SPEC §8.7).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PushMessage {
pub push_type: PushType,
/// `None` for `sync_batch` (sent as `""` with `entity_type` `""`).
pub entity_id: Option<Uuid>,
/// The creator, editor, deleter, template creator or pusher.
pub actor_user_id: Uuid,
/// 1, or the number of notifiable changes for `sync_batch`.
pub count: u32,
}
/// Queues notifications for the background sender, which resolves the target devices per SPEC §14.6.
pub trait PushQueue: Send + Sync + 'static {
fn enqueue(&self, message: PushMessage);
}
/// Drops every message. Used until M4 lands the sender, and when push is disabled.
#[derive(Debug, Clone, Copy, Default)]
pub struct NoopPushQueue;
impl PushQueue for NoopPushQueue {
fn enqueue(&self, message: PushMessage) {
tracing::debug!(
push_type = message.push_type.as_str(),
"push disabled, message dropped"
);
}
}