Commits
Commits on
69d4295dd558b3b2b267ec4b040ae0effce52e37Filtered to tests/partial_patch_sessions.rsClear filter2026-09-16
✨ feat: the class×course instance is the academic anchor (K-12 remodel)Ahmet Kaan Gümüş · ae84034
✨ feat: the class×course instance is the academic anchor (K-12 remodel)
`course` was a school-wide singleton: enrollment, exams, sessions,
roll-call and homework all keyed on it, so two class sections teaching the same
course shared one roster, one exam set and one timetable. This moves the
academic anchor to `class_course` — the per-class instance — and rebuilds
the academic model around Turkish K-12.
Schema (migrations/school/20260916000001_k12_remodel.sql): `class_course`
becomes an instance (ders_saati, counts_toward_karne, enrollment_count,
class_course_teacher); enrollment re-keys to (class_course, app_user);
exam carries class_course + term (+ exam_audience for shared exams);
course_session / session_attendance / homework re-key; `class_member` is a
soft-leave history table (uuid PK, joined_at/left_at, partial unique index
on the live stint); `academic_year` sits above `term`; `class_group` links
a year, not a term; new `course_membership` (clubs/study), `karne_snapshot`;
settings gain branches/excuse_kinds/absence limits/timezone; profile gains
branch. Drops/recreates the identity-changing tables (pre-customer; the
migration resets every counter on a kept table that pointed at a dropped
one).
Layers: domain/db/service/web rewritten to the instance seam, with
`ensure_instance_teacher` gating instance writes (D10), the report card computed per
instance and weighted by ders_saati, an absence report, `/instances`
and `/academic-years` nests, and `/classes/{id}/instances`. Capacity and
the seat-claim 409 are gone; detach sweeps the whole instance subtree and
unlinks its blob keys.
Gates: cargo check --all-targets, SQLX_OFFLINE check (cache regenerated),
doc_sync, spec_bounds, limits_completeness, clippy -D warnings all green;
cargo nextest run 1370/1370.2026-07-27
fix: 🪢 guard writes in the database, not the processAhmet Kaan Gümüş · 6c87eca
fix: 🪢 guard writes in the database, not the process
Two replicas are live; every process-local lock silently stopped
meaning anything. Move the invariants into the writes themselves:
- count caps (enroll/register/files/threads) become a counter column
claimed by UPDATE .. WHERE n < cap (domain/cap.rs), backfilled once,
decremented in the same transaction as every child delete
- exam freeze, re-draft and grade gates ride inside the write's own
transaction (IF .. THROW); SESSION/WORK_ENTRY/EVENT locks die, range
checks fold into the UPDATE's WHERE (FieldUpdate::ordered)
- appointment decisions CAS on status+proposed window+decided_by;
bank/exam updates CAS on their editable columns
- rate limiter syncs local windows to a shared minute row every 2s,
fail-open when the database is down
- paged GETs run LIMIT/START in the database (domain/page.rs); sites
that post-filter in Rust stay web-sliced and say so
- exams.rs (3629 lines) splits into web/exams/{mod,attempts,questions,
images,review}; image uploads single-source in web/image.rs; the
bare-seq key rule lives once in domain/key.rs; migration SQL moves
to migration_sql.rs
Every new guard is mutation-proven (removing it fails a named test).
Migration adds counter columns + rate_limit table; backfill is
one-time, guarded by = NONE, and verified against the live volume.
Traps recorded: SurrealQL 'x ?? 0 > 0' parses as 'x ?? (0 > 0)'; the
embedded mem engine drops one of two concurrent writes yet answers Ok.2026-07-25
fix: 🧩 finish the partial-PATCH sweep — 4 more handlers lost writesAhmet Kaan Gümüş · d773e7e
fix: 🧩 finish the partial-PATCH sweep — 4 more handlers lost writes 32bca26 routed six resources through `FieldUpdate` so a PATCH writes only the fields it was given. It stopped at six of ten. The remaining four still read the row unguarded and then wrote a field-scoped `SET` bound to that stale snapshot, so two concurrent PATCHes of different fields reverted each other, 200 OK, silently: - subjects and the two user routes (`apply_profile`/`apply_preferences`, four endpoints) move to `FieldUpdate`. No lock needed — neither has a cross-field check, so request-scoped values alone close it - course sessions get `SESSION_LOCK`, taken *before* the row read whenever `starts_at`/`ends_at` arrives, with the range merged and revalidated against the stored other end. The lock is not optional: converting to `FieldUpdate` without it re-introduces 9e25e0c, verified by disabling it and watching a one-ended PATCH store `starts_at > ends_at` with both requests answering 200 - bank questions instead take `BANK_LOCK.write()` before `owned_question`. This one is a genuine read-modify-write — the kind/choices/correct trio must merge from the stored row because choice ids carry the option pictures — so an exclusive lease over read+merge+write is the fix, the same shape as the exam PATCH. Per-field writes cannot express it - `subject.rs` also mints ids via `monotonic_id::next_ulid()` now, since subjects list `ORDER BY id ASC`; `bank_questions.rs` rustdoc stops calling a choice id a position Also verified safe and left alone: the exam and exam-question PATCHes already hold `EXAM_LOCK.write()` across read and write, settings uses a CAS retry, and messages/chatbot/questions/appointments write single fields. Each new suite races 20 rounds and reads the row back; every one fails if the stale refill is restored.