diff --git a/README.md b/README.md index efd22f7..5bf1e59 100644 --- a/README.md +++ b/README.md @@ -4565,7 +4565,7 @@ losing races at one process. Every invariant is therefore guarded where the database itself decides the winner. Three tiers: 1. **Single-row conditional writes** — compare-and-set (`save_if_unchanged`), - `UPDATE … WHERE`, stored counters (`domain::cap`). A single-record write is + `UPDATE … WHERE`, stored counters (`db::cap`). A single-record write is atomic, so of N concurrent tasks exactly the allowed number get a non-empty result: the database decides the winner, the loser retries (`CAS_UPDATE_RETRIES`) or gets a 409. diff --git a/src/constant.rs b/src/constant.rs index 8fc008b..ac4e782 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -921,13 +921,13 @@ pub const BOARD_STROKE_TABLE: &str = "board_stroke"; pub const BADGE_AWARD_TABLE: &str = "badge_award"; /// One row per *name* the school's settings offer, keyed by the name itself: /// how many rows still reference it, and whether it has been retired out of the -/// list (see the reference counters in [`crate::domain::cap`]). +/// list (see the reference counters in [`crate::db::cap`]). pub const KIND_REF_TABLE: &str = "kind_ref"; pub const SLOT_REF_TABLE: &str = "slot_ref"; // --- stored cap counters ------------------------------------------------- -/// The counter columns behind the count caps (see [`crate::domain::cap`]). +/// The counter columns behind the count caps (see [`crate::db::cap`]). /// Each one lives on the *parent* row, because a single-record conditional /// `UPDATE` is the only guard a concurrent writer cannot outrun (a lock is /// released around the round trip). Spelled here rather than at the call site @@ -970,7 +970,7 @@ pub const CHATBOT_THREAD_COUNT_FIELD: &str = "chatbot_thread_count"; /// The column a *grant* claim moves and puts back, so its transaction writes /// the holder's own `user` record — the one key /// [`crate::domain::user::User::set_role`] writes (see -/// [`crate::domain::cap::role_claim`]). Any `option` on the row would do: +/// [`crate::db::cap::role_claim`]). Any `option` on the row would do: /// the claim nets zero and never reads it, so this is an alias rather than a /// column of its own — a new one would mean a migration on a SCHEMAFULL table /// for a value nothing ever observes. diff --git a/src/database.rs b/src/database.rs index 90de618..e570eff 100644 --- a/src/database.rs +++ b/src/database.rs @@ -283,7 +283,7 @@ pub async fn init_mem_tenants() -> Result { /// that is dropped and re-made on every call. For the tests whose subject is /// the store's own conflict detection, which [`init_mem`]'s embedded engine /// does not have: it drops one of two concurrent writes to a record and answers -/// `Ok` to both (see [`crate::domain::cap`]), which *forges* the very +/// `Ok` to both (see [`crate::db::cap`]), which *forges* the very /// integrity failure those tests exist to catch — measured 2026-07-30 at 2 /// failed runs in 36 on `memory`, against 0 in 10 000 rounds here. /// diff --git a/src/domain/cap.rs b/src/db/cap.rs similarity index 99% rename from src/domain/cap.rs rename to src/db/cap.rs index 33eb708..3ea51ad 100644 --- a/src/domain/cap.rs +++ b/src/db/cap.rs @@ -58,7 +58,7 @@ use crate::error::AppError; static CLAIM_LOCK: Mutex<()> = Mutex::const_new(()); /// [`CLAIM_LOCK`], for a counter write that rides someone else's transaction -/// instead of [`write`]'s — [`crate::domain::field_update::FieldUpdate`]'s term +/// instead of [`write`]'s — [`crate::db::field_update::FieldUpdate`]'s term /// move claims and releases inside the very `UPDATE`'s transaction, and still /// owes the process one counter write at a time. /// diff --git a/src/domain/field_update.rs b/src/db/field_update.rs similarity index 99% rename from src/domain/field_update.rs rename to src/db/field_update.rs index 595e91b..b7b74f7 100644 --- a/src/domain/field_update.rs +++ b/src/db/field_update.rs @@ -25,7 +25,7 @@ use surrealdb::types::{RecordId, SurrealValue, Value}; use crate::database::{Database, transaction_with_retry, write_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::error::AppError; /// The `THROW` markers [`FieldUpdate::refcount`]'s transaction aborts with: the @@ -131,7 +131,7 @@ impl FieldUpdate { /// count is what a delete guard reads, so the stranded one makes its parent /// undeletable forever. `refused` is the answer when the claimed row is gone /// (the conditional write doubles as the existence check, as in - /// [`crate::domain::cap`]); the transaction then aborts, so the release and + /// [`crate::db::cap`]); the transaction then aborts, so the release and /// the row write never happened either. /// /// Only ever called alongside a `.set()` of the very column that carries the diff --git a/src/db/mod.rs b/src/db/mod.rs new file mode 100644 index 0000000..229aa07 --- /dev/null +++ b/src/db/mod.rs @@ -0,0 +1,5 @@ +//! The only layer that executes queries. + +pub mod cap; +pub mod field_update; +pub mod page; diff --git a/src/domain/page.rs b/src/db/page.rs similarity index 100% rename from src/domain/page.rs rename to src/db/page.rs diff --git a/src/domain/appointment.rs b/src/domain/appointment.rs index f52a2df..542404e 100644 --- a/src/domain/appointment.rs +++ b/src/domain/appointment.rs @@ -5,7 +5,7 @@ //! Two *cross-record* invariants live here, guarded very differently: //! //! - **One live booking per slot** — the `occupied` counter on the slot row, a -//! [`cap`](crate::domain::cap) of one. Booking claims it *with* the booking +//! [`cap`](crate::db::cap) of one. Booking claims it *with* the booking //! row ([`claim_and_create`](cap::claim_and_create)); //! rejecting or cancelling gives it back in the *same transaction* as the //! status flip, so the slot frees itself with nothing to sweep. Both are @@ -41,8 +41,8 @@ use crate::constant::{ }; use crate::database::{Database, lost_the_race}; use crate::domain::appointment_slot::{AppointmentSlot, AppointmentSlotId}; -use crate::domain::cap; -use crate::domain::page::PagedList; +use crate::db::cap; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/appointment_slot.rs b/src/domain/appointment_slot.rs index 921fc98..89bfad9 100644 --- a/src/domain/appointment_slot.rs +++ b/src/domain/appointment_slot.rs @@ -1,6 +1,6 @@ //! A teacher's published availability: "I am free here, book me". A slot is //! nearly pure calendar: the one piece of booking state it carries is the -//! `occupied` counter (a [`cap`](crate::domain::cap) of one), taken when a +//! `occupied` counter (a [`cap`](crate::db::cap) of one), taken when a //! booking is made and given back in the same transaction as the reject or //! cancel that settles it — so the slot frees itself again, and unlike a UNIQUE //! index it does not keep a dead booking's seat. Stored rather than counted @@ -19,7 +19,7 @@ use crate::constant::{ }; use crate::database::{Database, transaction_with_retry}; use crate::domain::appointment::{APPOINTMENT_LOCK, Appointment}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::monotonic_id::next_ulid; use crate::domain::role::Role; use crate::domain::timestamp::Timestamp; @@ -579,7 +579,7 @@ impl AppointmentSlot { mod tests { use super::*; use crate::constant::{MILLIS_PER_DAY, SLOT_OCCUPIED_FIELD}; - use crate::domain::cap; + use crate::db::cap; fn at(millis: i64) -> Timestamp { Timestamp::from_millis(millis) diff --git a/src/domain/attendance.rs b/src/domain/attendance.rs index efcc410..9950f5a 100644 --- a/src/domain/attendance.rs +++ b/src/domain/attendance.rs @@ -3,7 +3,7 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{ATTENDANCE_TABLE, REGISTRATION_COUNT_FIELD}; use crate::database::{Database, transaction_with_retry}; use crate::domain::event::EventId; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/board.rs b/src/domain/board.rs index c3101ff..217db83 100644 --- a/src/domain/board.rs +++ b/src/domain/board.rs @@ -20,9 +20,9 @@ use crate::constant::{ USER_BOARD_COUNT_FIELD, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/board_stroke.rs b/src/domain/board_stroke.rs index b342300..fcdf10f 100644 --- a/src/domain/board_stroke.rs +++ b/src/domain/board_stroke.rs @@ -26,9 +26,9 @@ use crate::constant::{ }; use crate::database::{Database, transaction_with_retry}; use crate::domain::board::{Board, BoardId}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::AppError; diff --git a/src/domain/chatbot_message.rs b/src/domain/chatbot_message.rs index 6ebae83..fd14f85 100644 --- a/src/domain/chatbot_message.rs +++ b/src/domain/chatbot_message.rs @@ -19,7 +19,7 @@ use crate::constant::{ }; use crate::database::Database; use crate::domain::chatbot_thread::{ChatbotThreadId, touch_and_write}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/chatbot_thread.rs b/src/domain/chatbot_thread.rs index 2d44c7e..e62582b 100644 --- a/src/domain/chatbot_thread.rs +++ b/src/domain/chatbot_thread.rs @@ -10,9 +10,9 @@ use crate::constant::{ MAX_CHATBOT_THREAD_TITLE_LEN, SETTINGS_KEY, SETTINGS_TABLE, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/class_blueprint.rs b/src/domain/class_blueprint.rs index 6edd9a3..878b0d8 100644 --- a/src/domain/class_blueprint.rs +++ b/src/domain/class_blueprint.rs @@ -42,7 +42,7 @@ use crate::domain::class_course::ClassCourse; use crate::domain::class_group::{ClassGrade, ClassGroup, ClassGroupId}; use crate::domain::class_pump::{Attached, Axis, detach}; use crate::domain::course::CourseId; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/class_course.rs b/src/domain/class_course.rs index bc3f04c..837613f 100644 --- a/src/domain/class_course.rs +++ b/src/domain/class_course.rs @@ -12,7 +12,7 @@ use crate::domain::class_blueprint::ClassBlueprintId; use crate::domain::class_group::ClassGroupId; use crate::domain::class_pump::{Attached, Axis, attach, detach, link_id}; use crate::domain::course::CourseId; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::AppError; diff --git a/src/domain/class_group.rs b/src/domain/class_group.rs index d9e4fb2..9b5aca2 100644 --- a/src/domain/class_group.rs +++ b/src/domain/class_group.rs @@ -17,10 +17,10 @@ use crate::constant::{ MAX_CLASS_NAME_LEN, TERM_CLASS_COUNT_FIELD, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; -use crate::domain::field_update::FieldUpdate; +use crate::db::cap; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::term::{self, TermId}; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; @@ -87,7 +87,7 @@ impl ClassGrade { /// One class. `creator` is who made it; the two refcounts behind the delete /// guard are database-side columns only, so no whole-row save can clobber one -/// (see [`crate::domain::cap`]). +/// (see [`crate::db::cap`]). /// /// `teacher` is the section's homeroom teacher (sınıf öğretmeni): optional, not /// refcounted, and merely a label pointing at a teacher-or-higher account — the @@ -415,7 +415,7 @@ mod tests { } /// The stored counter, re-read — never off a return value, which the - /// in-memory engine forges wins on (see [`crate::domain::cap`]). + /// in-memory engine forges wins on (see [`crate::db::cap`]). async fn stored_count(sql: &str, db: &Database) -> i64 { let mut result = db.query(sql).await.unwrap().check().unwrap(); result diff --git a/src/domain/class_member.rs b/src/domain/class_member.rs index acd717a..dfd2132 100644 --- a/src/domain/class_member.rs +++ b/src/domain/class_member.rs @@ -11,7 +11,7 @@ use crate::constant::{CLASS_MEMBER_TABLE, MAX_CLASS_COURSES, MAX_CLASS_MEMBERS}; use crate::database::Database; use crate::domain::class_group::ClassGroupId; use crate::domain::class_pump::{Attached, Axis, attach, detach, link_id}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; @@ -252,7 +252,7 @@ pub(crate) mod tests { } /// A counter, re-read out of the store — never off a return value, which - /// the in-memory engine forges wins on (see [`crate::domain::cap`]). + /// the in-memory engine forges wins on (see [`crate::db::cap`]). pub(crate) async fn counter(field: &str, of: RecordId, db: &Database) -> i64 { let mut result = db .query(format!("SELECT VALUE {field} ?? 0 FROM $of")) diff --git a/src/domain/class_pump.rs b/src/domain/class_pump.rs index 34f08e5..ceae88c 100644 --- a/src/domain/class_pump.rs +++ b/src/domain/class_pump.rs @@ -18,7 +18,7 @@ //! a direction flag would be one function containing two, so the seam stays //! where the SQL puts it. //! -//! Everything here writes counters the way [`crate::domain::cap`] does — a +//! Everything here writes counters the way [`crate::db::cap`] does — a //! single-record conditional `UPDATE`, never a count-then-write — and every //! `??` is parenthesized, because `n ?? 0 < $cap` parses as `n ?? (0 < $cap)` //! and is truthy for every row. @@ -30,7 +30,7 @@ use crate::constant::{ ENROLLMENT_COUNT_FIELD, ENROLLMENT_TABLE, MAX_CLASS_COURSES, MAX_CLASS_MEMBERS, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::class_group::{ClassGroup, ClassGroupId}; use crate::error::AppError; diff --git a/src/domain/course.rs b/src/domain/course.rs index 6e89298..9c34eec 100644 --- a/src/domain/course.rs +++ b/src/domain/course.rs @@ -5,10 +5,10 @@ use crate::constant::{ MAX_COURSE_DESCRIPTION_LEN, MAX_COURSE_TITLE_LEN, REF_COUNT_FIELD, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; -use crate::domain::field_update::FieldUpdate; +use crate::db::cap; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::term::{self, TermId}; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/course_note.rs b/src/domain/course_note.rs index 7c1e1b5..c5e5ff3 100644 --- a/src/domain/course_note.rs +++ b/src/domain/course_note.rs @@ -4,12 +4,12 @@ use crate::constant::{ COURSE_NOTE_TABLE, ENROLLMENT_COUNT_FIELD, MAX_NOTE_CONTENT_LEN, MAX_NOTE_TITLE_LEN, }; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; use crate::domain::course_note_file::CourseNoteFile; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; use crate::validate::{validate_optional, validate_required}; diff --git a/src/domain/course_note_file.rs b/src/domain/course_note_file.rs index 2121539..e6a7586 100644 --- a/src/domain/course_note_file.rs +++ b/src/domain/course_note_file.rs @@ -15,10 +15,10 @@ use crate::constant::{ COURSE_NOTE_FILE_COUNT_FIELD, COURSE_NOTE_FILE_TABLE, MAX_COURSE_NOTE_FILES, }; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course_note::CourseNoteId; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::error::AppError; #[derive(Debug, Clone, PartialEq, Eq, SurrealValue)] diff --git a/src/domain/course_session.rs b/src/domain/course_session.rs index c6a5e98..0e5778b 100644 --- a/src/domain/course_session.rs +++ b/src/domain/course_session.rs @@ -2,11 +2,11 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{COURSE_SESSION_TABLE, ENROLLMENT_COUNT_FIELD, MAX_SESSION_TOPIC_LEN}; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::{Timestamp, range_error}; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/dietary_profile.rs b/src/domain/dietary_profile.rs index c5995e3..87051b9 100644 --- a/src/domain/dietary_profile.rs +++ b/src/domain/dietary_profile.rs @@ -14,7 +14,7 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{DIETARY_PROFILE_TABLE, MAX_DIETARY_NOTE_LEN, MAX_DIETARY_TAGS}; use crate::database::Database; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/enrollment.rs b/src/domain/enrollment.rs index e79db94..b0b192d 100644 --- a/src/domain/enrollment.rs +++ b/src/domain/enrollment.rs @@ -2,10 +2,10 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{ENROLLMENT_COUNT_FIELD, ENROLLMENT_TABLE}; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::class_group::ClassGroupId; use crate::domain::course::{Course, CourseId}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::role::Role; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/event.rs b/src/domain/event.rs index df4cbd7..c85681c 100644 --- a/src/domain/event.rs +++ b/src/domain/event.rs @@ -8,7 +8,7 @@ use crate::domain::class_group::ClassGroupId; use crate::domain::class_member::{ClassMember, ClassMemberId}; use crate::domain::course::CourseId; use crate::domain::enrollment::Enrollment; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; use crate::domain::registration::Registration; use crate::domain::role::Role; diff --git a/src/domain/exam.rs b/src/domain/exam.rs index 313c554..7f081b8 100644 --- a/src/domain/exam.rs +++ b/src/domain/exam.rs @@ -5,7 +5,7 @@ use crate::constant::{ UNLIMITED_EXAM_ATTEMPTS, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; use crate::domain::monotonic_id::next_ulid; use crate::domain::settings::ExamKindDef; diff --git a/src/domain/exam_attempt.rs b/src/domain/exam_attempt.rs index bba8d8f..9d100e0 100644 --- a/src/domain/exam_attempt.rs +++ b/src/domain/exam_attempt.rs @@ -6,7 +6,8 @@ use crate::domain::exam::Exam; use crate::domain::exam::ExamId; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; -use crate::domain::{badge, cap, key}; +use crate::db::cap; +use crate::domain::{badge, key}; use crate::error::AppError; /// The `THROW` marker the freeze gate aborts with, and the one 409 both it and @@ -426,7 +427,7 @@ impl ExamAttempt { // // corner-cut: the count and a concurrent `CREATE exam_attempt` are still not // serialized against each other — SurrealDB does not conflict-check a - // cross-record count (the write skew `domain::cap` exists for), so an + // cross-record count (the write skew `db::cap` exists for), so an // attempt landing in the same instant as an edit can still interleave // either way. The mutex this replaces closed that inside one process only, // and there are two, so nothing is lost. Closing it properly means the diff --git a/src/domain/exam_question.rs b/src/domain/exam_question.rs index 6a066ff..ce371e6 100644 --- a/src/domain/exam_question.rs +++ b/src/domain/exam_question.rs @@ -9,11 +9,11 @@ use crate::constant::{ }; use crate::database::Database; use crate::domain::bank_question::BankQuestionId; -use crate::domain::cap; +use crate::db::cap; use crate::domain::exam::ExamId; use crate::domain::exam_attempt::ExamAttempt; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::subject::SubjectId; use crate::error::{AppError, ValidationError}; use crate::validate::{validate_question_kind, validate_question_points, validate_required}; @@ -569,7 +569,7 @@ impl ExamQuestion { // undeletable forever). // // The two are armed on *different* conditions, which is the whole of - // the rule ([`crate::domain::field_update::FieldUpdate::refcount`] states + // the rule ([`crate::db::field_update::FieldUpdate::refcount`] states // it the same way): the counter statements only when the link actually // changes, but the CAS whenever this write *carries* the link — and it // always does, because the handler fills an omitted `subject_id` from diff --git a/src/domain/exam_result.rs b/src/domain/exam_result.rs index ba877a6..cbd5a98 100644 --- a/src/domain/exam_result.rs +++ b/src/domain/exam_result.rs @@ -7,7 +7,7 @@ use crate::constant::{ KIND_REF_TABLE, MARKS_GIVEN_TOTAL_FIELD, REF_COUNT_FIELD, REF_RETIRED_FIELD, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; use crate::domain::exam::ExamId; use crate::domain::key; @@ -23,7 +23,7 @@ pub(crate) fn draft_error() -> AppError { /// The reference counter for one exam kind — how many marks are written under /// that name, and whether the school has retired it (see -/// [`crate::domain::cap`]). Keyed by the name itself: the kind is snapshotted +/// [`crate::db::cap`]). Keyed by the name itself: the kind is snapshotted /// text on the exam, and this row is what makes "a kind nothing is graded under /// may be removed" a decision the database takes, not a count a concurrent mark /// can invalidate. diff --git a/src/domain/fee_plan.rs b/src/domain/fee_plan.rs index a271511..55a1bd9 100644 --- a/src/domain/fee_plan.rs +++ b/src/domain/fee_plan.rs @@ -20,9 +20,9 @@ use crate::constant::{ FEE_PLAN_TABLE, FEE_PLAN_UNASSIGNED_GUARD, MAX_FEE_PLAN_INSTALLMENTS, MAX_FEE_PLAN_NAME_LEN, }; use crate::database::{Database, write_with_retry}; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::payment_ledger::LedgerAmount; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; diff --git a/src/domain/fee_plan_assignment.rs b/src/domain/fee_plan_assignment.rs index adb0d8d..f08de12 100644 --- a/src/domain/fee_plan_assignment.rs +++ b/src/domain/fee_plan_assignment.rs @@ -19,9 +19,9 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{FEE_PLAN_ASSIGNMENT_COUNT_FIELD, FEE_PLAN_ASSIGNMENT_TABLE}; use crate::database::Database; -use crate::domain::cap::{self, Claimed}; +use crate::db::cap::{self, Claimed}; use crate::domain::fee_plan::{FeePlan, FeePlanId}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::payment_ledger::PaymentLedger; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; diff --git a/src/domain/homework.rs b/src/domain/homework.rs index dc83337..6431149 100644 --- a/src/domain/homework.rs +++ b/src/domain/homework.rs @@ -17,9 +17,9 @@ use crate::constant::{ SUBJECT_HOMEWORK_COUNT_FIELD, }; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; use crate::domain::subject::SubjectId; use crate::domain::timestamp::Timestamp; diff --git a/src/domain/homework_file.rs b/src/domain/homework_file.rs index 7708634..822391c 100644 --- a/src/domain/homework_file.rs +++ b/src/domain/homework_file.rs @@ -16,7 +16,7 @@ use crate::constant::{ SUBMISSION_OPEN_GUARD, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; use crate::domain::homework::HomeworkId; use crate::domain::homework_submission::{HomeworkSubmission, HomeworkSubmissionId}; diff --git a/src/domain/homework_result.rs b/src/domain/homework_result.rs index 9354961..79c725e 100644 --- a/src/domain/homework_result.rs +++ b/src/domain/homework_result.rs @@ -188,7 +188,7 @@ impl HomeworkResult { // no counter column and is SCHEMAFULL, so `due_at` is the one `int` it // already has; do not invent a second spelling. // - // Not [`crate::domain::cap::touch_and_create`], which is the same shape + // Not [`crate::db::cap::touch_and_create`], which is the same shape // for a bare `CREATE`: a grade is an UPSERT (a regrade must overwrite), // and the freeze stamp and the grader's counter have to ride the same // transaction, which that helper has no room for. diff --git a/src/domain/meal_attendance.rs b/src/domain/meal_attendance.rs index 4cb7feb..4855e60 100644 --- a/src/domain/meal_attendance.rs +++ b/src/domain/meal_attendance.rs @@ -20,7 +20,7 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{MEAL_ATTENDANCE_STATUSES, MEAL_ATTENDANCE_TABLE}; use crate::database::Database; use crate::domain::menu::{MenuDate, MenuId, bump_menu_and_write}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/meal_booking.rs b/src/domain/meal_booking.rs index c9b4200..76b98be 100644 --- a/src/domain/meal_booking.rs +++ b/src/domain/meal_booking.rs @@ -35,10 +35,10 @@ use crate::constant::{ MENU_VERSION_FIELD, }; use crate::database::{Database, backoff, lost_the_race}; -use crate::domain::cap::{self, Claimed}; +use crate::db::cap::{self, Claimed}; use crate::domain::meal_ledger::{LedgerAmount, MealLedger}; use crate::domain::menu::{Menu, MenuDate, MenuId, MenuSlot}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::settings::{MealSlotDef, Settings}; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; diff --git a/src/domain/meal_ledger.rs b/src/domain/meal_ledger.rs index 61de8e7..ef531f1 100644 --- a/src/domain/meal_ledger.rs +++ b/src/domain/meal_ledger.rs @@ -63,7 +63,7 @@ use crate::database::{Database, lost_the_race}; use crate::domain::meal_booking::{MealBooking, MealBookingId}; use crate::domain::menu::MenuId; use crate::domain::menu_dish::MenuDish; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; // The client-chosen idempotence key both ledgers take — one grammar, one // validator, one type, rather than a second newtype that could drift from it. use crate::domain::payment_ledger::PaymentRequestKey; diff --git a/src/domain/menu.rs b/src/domain/menu.rs index d36489e..2412872 100644 --- a/src/domain/menu.rs +++ b/src/domain/menu.rs @@ -18,8 +18,8 @@ use crate::constant::{ MENU_VERSION_FIELD, REF_COUNT_FIELD, SLOT_REF_TABLE, }; use crate::database::{Database, transaction_with_retry, write_with_retry}; -use crate::domain::cap; -use crate::domain::page::PagedList; +use crate::db::cap; +use crate::db::page::PagedList; use crate::domain::settings::MealSlotDef; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; @@ -30,7 +30,7 @@ use crate::error::{AppError, ValidationError}; /// conflict-check). Publishing no longer needs it — the day+slot *is* the /// record id — and neither does a booking, a menu delete, or the settings /// slot-removal guard: those went to conditional single-record writes -/// ([`crate::domain::cap`]), which the store decides as this lock cannot. +/// ([`crate::db::cap`]), which the store decides as this lock cannot. // // corner-cut: the dish cap therefore rests on this lock alone — a dish write // added without taking it reopens the count-then-write hole silently. Closing @@ -49,7 +49,7 @@ pub(crate) static MENU_LOCK: Mutex<()> = Mutex::const_new(()); /// The reference counter for one meal slot — how many menus are published under /// that name, and whether the school has retired it (see -/// [`crate::domain::cap`]). The mirror of +/// [`crate::db::cap`]). The mirror of /// [`kind_ref`](crate::domain::exam_result::kind_ref) for exam kinds: the slot /// is snapshotted text on the menu, so this row is the only place the two /// tables' relationship is a single record concurrent writes can contend on. diff --git a/src/domain/menu_dish.rs b/src/domain/menu_dish.rs index e945ec5..853dfec 100644 --- a/src/domain/menu_dish.rs +++ b/src/domain/menu_dish.rs @@ -289,7 +289,7 @@ impl MenuDish { /// it takes the three-way shape: absent = keep, `Some(None)` = clear. /// /// The `SET` is built here rather than by - /// [`FieldUpdate`](crate::domain::field_update::FieldUpdate) because the + /// [`FieldUpdate`](crate::db::field_update::FieldUpdate) because the /// revision bump lands on *another* row and has to share this write's /// transaction; the field-by-field scoping — an omitted field is never /// written, so a concurrent PATCH of another one is not reverted — is the diff --git a/src/domain/message.rs b/src/domain/message.rs index a7af28e..0d245ae 100644 --- a/src/domain/message.rs +++ b/src/domain/message.rs @@ -14,7 +14,7 @@ use crate::constant::{ }; use crate::database::Database; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/mod.rs b/src/domain/mod.rs index 3b11edb..856592f 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -12,7 +12,6 @@ pub mod bank_question_image; pub mod board; pub mod board_stroke; pub mod builder; -pub mod cap; pub mod chatbot_message; pub mod chatbot_thread; pub mod class_blueprint; @@ -34,7 +33,6 @@ pub mod exam_question; pub mod exam_result; pub mod fee_plan; pub mod fee_plan_assignment; -pub mod field_update; pub mod homework; pub mod homework_file; pub mod homework_result; @@ -49,7 +47,6 @@ pub mod message; pub mod monotonic_id; pub mod note; pub mod note_file; -pub mod page; pub mod parent_link; pub mod payment_ledger; pub mod pomodoro; diff --git a/src/domain/note.rs b/src/domain/note.rs index f034219..a02ccbb 100644 --- a/src/domain/note.rs +++ b/src/domain/note.rs @@ -2,10 +2,10 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{MAX_NOTE_CONTENT_LEN, MAX_NOTE_TITLE_LEN, NOTE_TABLE}; use crate::database::Database; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; use crate::domain::note_file::NoteFile; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; use crate::validate::{validate_optional, validate_required}; diff --git a/src/domain/note_file.rs b/src/domain/note_file.rs index bf9fed3..2256f3e 100644 --- a/src/domain/note_file.rs +++ b/src/domain/note_file.rs @@ -12,10 +12,10 @@ use crate::constant::{ NOTE_FILE_TABLE, }; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::monotonic_id::next_ulid; use crate::domain::note::NoteId; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::error::{AppError, ValidationError}; #[derive(Debug, Clone, PartialEq, Eq, SurrealValue)] diff --git a/src/domain/payment_ledger.rs b/src/domain/payment_ledger.rs index 19dcddb..eb7521e 100644 --- a/src/domain/payment_ledger.rs +++ b/src/domain/payment_ledger.rs @@ -98,7 +98,7 @@ use crate::domain::fee_plan_assignment::{FeePlanAssignment, FeePlanAssignmentId} // error message for both ledgers. pub use crate::domain::meal_ledger::{LedgerAmount, LedgerMethod, LedgerNote}; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/domain/pomodoro.rs b/src/domain/pomodoro.rs index 3423e4b..3d9a983 100644 --- a/src/domain/pomodoro.rs +++ b/src/domain/pomodoro.rs @@ -497,7 +497,7 @@ mod tests { /// contention on one user row. /// /// Multi-threaded and off the embedded engine for the reason - /// [`crate::domain::cap`] spells out: the in-memory engine does not + /// [`crate::db::cap`] spells out: the in-memory engine does not /// conflict-check two concurrent writes to one record, so it would answer /// `Ok` to a write it dropped and *forge* the integrity failure this test /// exists to catch. diff --git a/src/domain/rag_output.rs b/src/domain/rag_output.rs index 338fbec..42fb038 100644 --- a/src/domain/rag_output.rs +++ b/src/domain/rag_output.rs @@ -20,7 +20,7 @@ use crate::domain::course::CourseId; use crate::domain::course_note::CourseNoteId; use crate::domain::course_note_file::CourseNoteFileId; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::error::AppError; diff --git a/src/domain/registration.rs b/src/domain/registration.rs index de3e642..7e976af 100644 --- a/src/domain/registration.rs +++ b/src/domain/registration.rs @@ -2,7 +2,7 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{REGISTRATION_COUNT_FIELD, REGISTRATION_TABLE}; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::event::{Event, EventId}; use crate::domain::role::Role; use crate::domain::user::{User, UserId}; diff --git a/src/domain/session_attendance.rs b/src/domain/session_attendance.rs index 3bead1b..132f147 100644 --- a/src/domain/session_attendance.rs +++ b/src/domain/session_attendance.rs @@ -8,7 +8,7 @@ use crate::database::{Database, transaction_with_retry}; use crate::domain::attendance::AttendanceStatus; use crate::domain::course::CourseId; use crate::domain::course_session::{CourseSession, CourseSessionId}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::AppError; diff --git a/src/domain/settings.rs b/src/domain/settings.rs index 21597a4..2aae23a 100644 --- a/src/domain/settings.rs +++ b/src/domain/settings.rs @@ -46,7 +46,7 @@ use crate::error::{AppError, ValidationError}; /// So the pair is serialized instead. Every writer of the singleton goes /// through `PATCH /settings`, and the deployment runs one process by contract /// (stop-the-world upgrades), so process-wide is deployment-wide here — the -/// same argument [`crate::domain::cap`]'s own lock makes for `retire_name`'s +/// same argument [`crate::db::cap`]'s own lock makes for `retire_name`'s /// two statements, one level up. The compare-and-set stays: it is what keeps a /// crashed or rolled-back attempt from writing a list nobody merged. /// diff --git a/src/domain/solution.rs b/src/domain/solution.rs index 8d5d7e8..452bab9 100644 --- a/src/domain/solution.rs +++ b/src/domain/solution.rs @@ -15,7 +15,7 @@ use crate::constant::{MAX_SOLUTION_BODY_LEN, SOLUTION_TABLE}; use crate::database::Database; use crate::domain::monotonic_id::next_ulid; use crate::domain::note_file::FileContentType; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::pool_question::{PoolQuestionId, bump_question_and_write}; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; diff --git a/src/domain/subject.rs b/src/domain/subject.rs index a80a10d..9df7c9b 100644 --- a/src/domain/subject.rs +++ b/src/domain/subject.rs @@ -4,11 +4,11 @@ use crate::constant::{ ENROLLMENT_COUNT_FIELD, MAX_SUBJECT_DESCRIPTION_LEN, MAX_SUBJECT_NAME_LEN, SUBJECT_TABLE, }; use crate::database::{Database, transaction_with_retry}; -use crate::domain::cap; +use crate::db::cap; use crate::domain::course::CourseId; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::error::{AppError, ValidationError}; use crate::validate::{validate_optional, validate_required}; diff --git a/src/domain/term.rs b/src/domain/term.rs index d1c1599..79c060b 100644 --- a/src/domain/term.rs +++ b/src/domain/term.rs @@ -10,9 +10,9 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::{COURSE_COUNT_FIELD, MAX_TERM_NAME_LEN, TERM_CLASS_COUNT_FIELD, TERM_TABLE}; use crate::database::{Database, write_with_retry}; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::{Timestamp, range_error}; use crate::error::{AppError, ValidationError}; use crate::validate::validate_required; diff --git a/src/domain/user.rs b/src/domain/user.rs index e26349c..a185090 100644 --- a/src/domain/user.rs +++ b/src/domain/user.rs @@ -13,10 +13,10 @@ use crate::constant::{ use crate::database::{Database, transaction_with_retry, write_with_retry}; use crate::domain::appointment::AppointmentStatus; use crate::domain::board::Board; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; use crate::domain::note_file::FileContentType; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::preferences::{Language, PaletteColor, Theme}; use crate::domain::profile::{Bio, BirthDate, DisplayName, Email, PersonName, Phone}; use crate::domain::role::Role; @@ -31,7 +31,7 @@ use crate::validate::{validate_password, validate_username}; /// guard is a count-then-write: read whether another admin exists, then lower /// this row. SurrealDB conflict-checks neither side of that pair — a /// `BEGIN…COMMIT` does not serialize a cross-record count against a concurrent -/// update (write-skew, see [`crate::domain::cap`]) and a statement that only +/// update (write-skew, see [`crate::db::cap`]) and a statement that only /// *reads* the rival's row never collides with it. So two admins demoting each /// other both counted the other and both committed, leaving **zero** admins and /// a school nobody can administer: `ensure_admin` refuses to promote an @@ -41,7 +41,7 @@ use crate::validate::{validate_password, validate_username}; /// Serializing the pair is what closes it, the same argument /// [`crate::domain::settings::SETTINGS_LOCK`] makes one level up: the deployment /// runs one process by contract (stop-the-world upgrades), so process-wide is -/// deployment-wide. A per-row counter (the [`crate::domain::cap`] shape) does +/// deployment-wide. A per-row counter (the [`crate::db::cap`] shape) does /// not fit — the count being capped is over *every* user row, with no parent /// record to hold it and no place to seed one without a backfill. /// diff --git a/src/domain/work_entry.rs b/src/domain/work_entry.rs index 1ac7874..494f473 100644 --- a/src/domain/work_entry.rs +++ b/src/domain/work_entry.rs @@ -2,9 +2,9 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::constant::WORK_ENTRY_TABLE; use crate::database::{Database, transaction_with_retry}; -use crate::domain::field_update::FieldUpdate; +use crate::db::field_update::FieldUpdate; use crate::domain::monotonic_id::next_ulid; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::domain::user::UserId; use crate::error::{AppError, ValidationError}; diff --git a/src/lib.rs b/src/lib.rs index 0395d94..a57cded 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ pub mod ai; pub mod config; pub mod constant; pub mod database; +pub mod db; pub mod domain; pub mod error; pub mod migration_sql; diff --git a/src/migration_sql.rs b/src/migration_sql.rs index c558022..e4f77fe 100644 --- a/src/migration_sql.rs +++ b/src/migration_sql.rs @@ -280,7 +280,7 @@ pub const MIGRATION: &str = " DEFINE FIELD IF NOT EXISTS audience.class ON event TYPE option>; DEFINE FIELD IF NOT EXISTS audience.capacity ON event TYPE option; -- Seats taken on the signup list, the stored capacity guard that closes - -- write-skew between concurrent request tasks (see `crate::domain::cap`). + -- write-skew between concurrent request tasks (see `crate::db::cap`). -- Absent reads as zero, so no Rust struct needs it. DEFINE FIELD IF NOT EXISTS registration_count ON event TYPE option; REMOVE FIELD IF EXISTS audience.users ON TABLE event; @@ -311,7 +311,7 @@ pub const MIGRATION: &str = " -- is exactly what an absent stamp already means. DEFINE FIELD IF NOT EXISTS archived_at ON term TYPE option; -- Courses still linking this term, the stored delete guard that closes - -- write-skew between concurrent request tasks (see `crate::domain::cap`). + -- write-skew between concurrent request tasks (see `crate::db::cap`). -- Absent reads as zero, so no Rust struct needs it. DEFINE FIELD IF NOT EXISTS course_count ON term TYPE option; -- Classes linking this term, the other half of the same guard. A column of @@ -782,7 +782,7 @@ pub const MIGRATION: &str = " DEFINE FIELD IF NOT EXISTS date ON menu TYPE string READONLY; DEFINE FIELD IF NOT EXISTS slot ON menu TYPE string READONLY; DEFINE FIELD IF NOT EXISTS capacity ON menu TYPE option; - -- `seats_booked` is the seat cap's counter (see `domain::cap`) and + -- `seats_booked` is the seat cap's counter (see `db::cap`) and -- `version` the menu's revision: a booking claims its seat only while the -- menu still stands at the revision it read the price at, so a dish -- re-priced mid-booking cannot be billed as the old price. Both absent diff --git a/src/tenant.rs b/src/tenant.rs index d263192..163ffba 100644 --- a/src/tenant.rs +++ b/src/tenant.rs @@ -30,7 +30,7 @@ use surrealdb::types::{RecordId, RecordIdKey, SurrealValue}; use crate::config::Config; use crate::constant::{MAX_SLUG_LEN, MIN_SLUG_LEN}; use crate::database::{Database, lost_the_race, migrate, migrate_control}; -use crate::domain::page::PagedList; +use crate::db::page::PagedList; use crate::domain::timestamp::Timestamp; use crate::error::{AppError, ValidationError}; use crate::module::ModuleSet; diff --git a/src/web/exams/mod.rs b/src/web/exams/mod.rs index 927d765..64c52df 100644 --- a/src/web/exams/mod.rs +++ b/src/web/exams/mod.rs @@ -72,7 +72,7 @@ impl Scheduled for Exam { } /// Serializes the exam subsystem's cross-record check-then-writes, which -/// `BEGIN…COMMIT` cannot (write skew) — the reasoning in [`crate::domain::cap`]. +/// `BEGIN…COMMIT` cannot (write skew) — the reasoning in [`crate::db::cap`]. /// It orders requests, but only around what it wraps — every invariant that /// could be moved into the database itself has been, so a gap between a read /// and its write is decided by the store. What is left here needs a diff --git a/src/web/homework.rs b/src/web/homework.rs index 64f0582..a012db2 100644 --- a/src/web/homework.rs +++ b/src/web/homework.rs @@ -78,7 +78,7 @@ use super::{ /// delete used to take is on this list any more. /// /// Lock order, where both are taken: `HOMEWORK_LOCK` before the counter lock in -/// [`crate::domain::cap`], never the reverse. +/// [`crate::db::cap`], never the reverse. // corner-cut: global RwLock, shard per-homework if write latency ever matters. pub(crate) static HOMEWORK_LOCK: tokio::sync::RwLock<()> = tokio::sync::RwLock::const_new(()); diff --git a/src/web/mod.rs b/src/web/mod.rs index 5a24254..2cc4f0a 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -147,7 +147,7 @@ pub(crate) async fn undo_if_demoted(target: &UserId, db: &Database) -> Result<() /// If both ends are present, `ends_at` must not precede `starts_at`. Shared by /// everything that carries a time range (events, course sessions). The PATCH /// paths re-check this at write time via -/// [`crate::domain::field_update::FieldUpdate::ordered`], which answers with the +/// [`crate::db::field_update::FieldUpdate::ordered`], which answers with the /// same error — this is the pre-flight, that is the race closer. pub(crate) fn check_time_range( starts_at: Option, @@ -405,7 +405,7 @@ mod tests { /// refuse; with the account still staff it must undo nothing at all. /// /// Asserted on stored state, never on a return value: the in-memory engine - /// forges those (see [`crate::domain::cap`]). + /// forges those (see [`crate::db::cap`]). #[tokio::test] async fn undo_if_demoted_repairs_both_assignments_or_neither() { use crate::domain::class_group::{ClassGroup, ClassName}; diff --git a/src/web/settings.rs b/src/web/settings.rs index f664175..f71f766 100644 --- a/src/web/settings.rs +++ b/src/web/settings.rs @@ -9,7 +9,7 @@ use surrealdb::types::RecordId; use crate::constant::CAS_UPDATE_RETRIES; use crate::database::Database; -use crate::domain::cap; +use crate::db::cap; use crate::domain::exam_result::kind_ref; use crate::domain::menu::slot_ref; use crate::domain::settings::{ExamKindDef, GradeBand, MealSlotDef, SETTINGS_LOCK, Settings};