forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on af331ecc8a4a0c661bcdbc905b95bb2cf77a72deFiltered to src/web/settings.rsClear filter

2026-09-11

🧹 chore: split note/session/settings into domain/db/service layersAhmet Kaan Gümüş · efea304
🧹 chore: split note/session/settings into domain/db/service layers

Pilot wave of the three-layer split. All query execution for the three
domains now lives in src/db/{note,session,settings}.rs as free fns taking
db first; web handlers call service::<x>::* only; domain keeps pure types.

- service/settings.rs gains the PATCH workflow (apply) and SETTINGS_LOCK —
  it spans a multi-call pair (retire names, CAS save, restore), so it is a
  service lock, not a db lock. The service takes its own input records
  (SettingsPatch/*Input) so wire DTOs stay in web and list validation keeps
  its original order, including the try_kept grandfathering that needs the
  stored list.
- Note/Session/Settings fields the db layer mints or CAS-binds become
  pub(crate); Settings::record_id becomes pub(crate).
- Unit tests rode with their fns: note delete cascade → db/note, session
  purge → db/session, settings load/save/CAS → db/settings, the whole
  settings edit workflow suite → service/settings.
- Doc links re-pointed (user, class_blueprint, bank_question, exam,
  note_file, tests/regress_roles); NoteId::generate's stale
  'Note::list_for_user' link now names db::note::list_for.
- Known residual for a later wave: web/notes.rs:411 file.delete() is
  note_file-domain persistence (note_file splits in C3).

2026-09-05

✨ feat: one database per school behind a control registry; login names the schoolAhmet Kaan Gümüş · b7dfc0c
✨ feat: one database per school behind a control registry; login names the school

Namespace `hezarfen` now holds one DATABASE per school (name = slug) plus a
`control` database with the school registry, builder accounts and builder
sessions. `Tenants` keeps one separately-connected handle per school; the
shadow `web::tenant_state::State` resolves the school from the
`<slug>.<token>` cookie so every handler's `st.db` is school-scoped by
construction. `POST /auth/login` / `register` carry `school`; a suspended
school answers 403 everywhere. `BUILDER_USERNAME`/`BUILDER_PASSWORD` seed the
vendor account; the boot admin seed is gone. No customers, no compat shims.

2026-08-05

🍽️ fix: close the canteen's existence oracle and its cutoff trapAhmet Kaan Gümüş · 4586d9a
🍽️ fix: close the canteen's existence oracle and its cutoff trap

cancel_booking read the booking before authorising, and booking ids are
derivable from the menu date, slot and user key. Any teacher could
enumerate exactly which student booked which meal by reading the status
code — 403 meant booked, 404 meant not — bypassing the deliberate
manager+ gate on the bookings list. It now authorises off the path id
first, so an unauthorised caller cannot tell the two apart. It was the
only read-then-authorise ordering in the file.

served_at fell back to midnight UTC when a slot carried no
serving_minute, and all three shipped slots carry none. Setting
meal_cancel_cutoff_minutes without serving hours therefore made every
same-day menu unbookable and uncancellable by students. A slot with no
serving hour now has no cutoff; the impossible-day refusal still runs
first, so the fail-closed rule survives.

claim_and_place and release_seat were the only conflict-retry loops in
the crate with no backoff and three tries, while every sibling uses eight
with exponential backoff — and these are precisely the "one HTTP burst
on a single parent" case that sizing exists for.

DietaryProfile::save did read-then-create, so two concurrent first
writes made the loser a 500.

book's held-seat path answered from a row read a round trip earlier, so
a cancel in the gap produced a 201 claiming a seat the store had already
cancelled and refunded.

Book/cancel cycles are now capped, and balance_of aggregates per kind
instead of folding the student's entire ledger in process.

2026-08-02

fix: 🔩 clear the deferred backlog and ship class phase 2Ahmet Kaan Gümüş · afff737
fix: 🔩 clear the deferred backlog and ship class phase 2

Ten defects and two features, worked as one series because the doc
surfaces and the const table are shared.

Defects closed:

- Cross-exam answer-key leak. The bank copies `correct` into every
  instantiation, so reviewing exam A handed out the key to a question
  the caller was still writing in exam B. Review now blanks those
  questions rather than closing: the join matches on `from_bank` AND
  `banked_as` (a question can carry both — instantiated, then re-saved
  to the bank — so a coalesce misses a copy), redacting `correct`, the
  correctness flag and that question's `auto_score` share. Keyed on the
  template, never the exam, so the rest of the review reads normally.
- `set_role` was not atomic with its sweeps. The role write and every
  grant it invalidates now commit as one transaction; the board rooms
  are told after COMMIT from the cascade's own result slot. Built
  best-of-N; the losing charter left the one sweep outside whose failure
  strands an event seat no route can free.
- Board rosters held below-student ids, which 400d the creator's next
  roster PATCH. Repaired at boot, and a PATCH may now send back the
  roster it was served: an id already present that stopped qualifying is
  dropped, a new one still refused.
- `note_file` blobs leaked. The delete transaction returns the rows it
  removed and the handler unlinks exactly those, not a pre-read snapshot.
- Rate limiting failed open on a saturated map. Never-seen clients now
  share one metered overflow budget instead of arriving unmetered.
- Whiteboards: `GET /boards` takes `?open=`, `/strokes` no longer leaks
  a clear marker the socket filters out, and a locked board refuses its
  creator's clear (409) — the lock now means one thing on every path.
- Blueprint skips named the wrong record: `Attached::Gone` was two facts
  under one name, split into `Gone` (class) and `PivotGone` (course).

Features:

- Event audience `kind=class` — live from `class_member`, membership
  checked in one select because the (class, user) pair is the row id.
- Grade blueprints: a grade's course template, retro-pumped best-effort
  with a skip list. Attachments carry a provenance tag, so removal
  spares what a human placed. A course deleted out from under a
  blueprint is pruned from the template by the pump that finds it.

Forcing functions, because a hand-kept copy drifts:

- `protected_routes_require_session` is derived from the emitted
  OpenAPI: 248 -> 254 operations swept, was 80 typed by hand.
- Every JSON-bodied operation declares 422 (74 sites), pinned both ways
  — and multipart routes, which answer 400, are pinned to NOT declare it.
- The SurrealQL registration-freeze guard is pinned against the Rust it
  copies; both mutations of it fail the test.
- `migration_mark` gates one-time backfills. The roster repair rescanned
  every board against every user on every boot (773ms at 300/2000 with
  nothing to write); it is now skipped once done.

Verified by a three-lens verifier panel — which caught the `banked_as`
half of the answer-key leak by executing a probe, after the first fix
had been reported complete — and by a podman boot against the existing
volume: both new fields defined, the marker written, boot 2 skipping the
scan, and the live API answering on the new routes.
fix: 🔩 close the bug hunt across meals, classes and capsAhmet Kaan Gümüş · 7198cea
fix: 🔩 close the bug hunt across meals, classes and caps

A three-domain hunt, its fixes, and a verifier panel that refuted two of
them. Kept as one commit because the pieces interlock — cap.rs, the
settings pair and the pump all move together, and no smaller cut compiles.

Money can no longer be lost or stranded. Both seat transitions carry
their ledger line inside their own transaction: the claim writes the
charge, the flip writes the reversal. Before, a crash between the two
left a seat held with no bill, or a bill with no seat, keyed to an
attempt no later request could ever reach. A lost cancel could refund a
live seat. The menu revision was bumped in a query of its own, so a
booking reading in the gap claimed against a capacity or a price the
menu had already left.

Deleting a menu now takes its marks and its dishes with it, in the
transaction that deletes the row. The id is deterministic on (date,
slot), so anything left behind came back on the next publish — the
kitchen reading "served" for a student who never came.

A seat is always releasable: manager+ cancels any booking and is not
bound by the cutoff, so a promoted student's seat no longer wedges its
menu forever, and a debt that outlived its owner's role can be settled.
Canteen money follows /payments and is manager+, not teacher+ — what a
family owes the school is not classroom information.

The class pump claims its pivot in-transaction. An attach racing a
course delete used to commit a link to a row that was gone, and nothing
could then detach it or delete the class. A hand enroll now disowns a
pumped row, so a sweep cannot take back a roster decision an operator
made by hand. The role sweep is one transaction. Rosters are ordered by
when a student was added, which is what they always claimed. Both class
axes have a ceiling, and each refuses on the other's, because a pump
writes one row per member per course in a single transaction.

Settings edits are serialized: retire is idempotent, so an undo log
cannot tell the attempt that flipped a name from one that found it
already flipped, and the loser un-retired what the winner had legally
retired — leaving a kind gone from the list, gradable, and unremovable
for good. Grading now checks the school's list, not only the counter.
Three caps that read a snapshot integer now read the live column.

A clear marker is charged to the board's lifetime counter and boot
repairs the boards that predate it. Blank canvases refuse the clear, and
the room reports that as its own code: the refusal text had drifted into
the substring the WebSocket read as "closed", which told a live room it
was permanently read-only.

Verified against the real volume: both boot backfills, the slot-name
rule and its grandfather clause, and the new money gate.

2026-07-30

chore: 🧹 drop the coordination for replicas we never runAhmet Kaan Gümüş · a9cfe7b
chore: 🧹 drop the coordination for replicas we never run

The backend runs as one process against one database, deployed
stop-the-world. The machinery that let several of them agree was built
ahead of a multi-replica rollout that stayed parked, so none of it was
ever load-bearing: the boot lease elected a leader out of a field of
one, the ai_worker table announced a worker to nobody, and the chat
claim queue only ever claimed its own writes.

Boot now migrates and seeds straight-line; a chat turn is dispatched by
the handler that accepted it; the 503 gate reads the in-process
registry. The retired columns and tables are unset and removed in
separate batches, repair before REMOVE.

What stays, with its reason corrected rather than removed: cap.rs,
field_update.rs, the refcounts, the CAS retry loops and the in-process
locks. Those close write skew between concurrent requests inside one
process, which two replicas made worse but never caused.

A turn orphaned by a restart or a panic is no longer reclaimed. It
settles as timed_out within CHATBOT_PENDING_STALE_SECS.

The design survives in the ledger if a second process is ever wanted.

2026-07-27

fix: 🧷 close the cross-table races the locks never closedAhmet Kaan Gümüş · 4f7bdaf
fix: 🧷 close the cross-table races the locks never closed

Every remaining check-then-write that spanned tables becomes a
single-record conditional write, so it holds across replicas:

- subject delete: refcounts (exam_question_count/homework_count) claimed
  and released by every question/homework write; the triple lock hold
  dies, BANK/TERM/ENROLL locks die outright
- exam kinds: kind_ref {count,retired} records; grading claims, removal
  retires only at zero — grading a removed kind and re-kinding a graded
  exam are now 409 (both previously silently mis-weighted marks)
- homework: the grade stamps the submission row in its own transaction;
  student writes are conditional on the stamp being absent
- appointments: slot occupancy is a cap-1 counter; the lock survives
  only for the within-replica approved-overlap check
- meals: seat counter + menu version CAS (price can no longer tear mid
  booking) + deterministic menu:date_slot id kills duplicate publish
- cap::claim_and_create: member gate, then seat, then child CREATE in
  one transaction — a duplicate loser no longer eats a stranger's seat
  or gets refused for a row it already owns
- boot: the two unguarded lease statements now retry on transaction
  conflict (the escape was ~1-in-15 under full-suite load)

Two races reviewed and accepted, documented in README ## Concurrency
model: the attempt-seq late save (one history row, grade of record
untouched) and cross-replica approved-overlap (visible, cancellable).

Deployment contract (README): counter-adding releases restart all
replicas together — an old binary's writes skip new counters and the
= NONE backfill guard rightly refuses to re-seed.

Every guard is mutation-proven; backfills are one-time, = NONE-guarded,
ordered after the destructive sweeps, and verified against the live
volume.
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-26

fix: 🕛 anchor the meal cutoff to when lunch is actually servedAhmet Kaan Gümüş · 21f4643
fix: 🕛 anchor the meal cutoff to when lunch is actually served

The booking and cancel deadline counted back from midnight UTC of the
menu date, so a two-hour cutoff on lunch barred bookings from 22:00 the
day before. Meal slots now carry an optional serving time and the
deadline counts back from that; a slot without one keeps the old
midnight behaviour, so nothing changes until a school sets hours.

Times are minutes past midnight UTC. There is deliberately no school
timezone setting, so a UTC+3 school enters 09:00 to mean noon; the
field says so wherever it is described.

Serving time is looked up live rather than snapshotted onto the menu,
because the cutoff minutes already are — freezing one half of a
deadline and not the other would split a single policy in two.

Storing an Option inside an object turned out to break the settings
CAS. SurrealDB drops an object key whose value is NONE, and a stored
{name} never again equals the {name, serving_minute: NONE} the derive
emits, so every PATCH /settings would have answered 409 forever for any
school whose slots predate this field. The guard now compares a rebuilt
projection. Verified against the live volume, whose singleton is
exactly that aged shape.

Also: losing a race to write a ledger line returned 500 rather than the
line the winner had already written. A duplicate record id is now read
back instead, matched on the typed error so real database failures
still surface.
feat: 🍽️ run the canteen: menus, seats, allergens and a ledgerAhmet Kaan Gümüş · fd5cfd1
feat: 🍽️ run the canteen: menus, seats, allergens and a ledger

Published menu calendar (manager+ authors, everyone reads), per-student
dietary profiles that mark conflicting dishes, meal booking with an
optional per-menu capacity, meal attendance, and booking-triggered
billing.

Booking is the charge trigger: reserving a seat stamps a charge at a
price snapshot, so later dish edits never rewrite what a student owes.
No-show still pays, because the kitchen already bought the food, which
is why attendance has no billing effect at all. Money enters only as
admin-recorded credit entries; there is no gateway and no card data.

The ledger is append-only. Cancelling appends a reversal rather than
deleting the charge, balance is always folded from the rows, and the
sign lives in exactly one function. A deletable ledger row would
rewrite a student's financial history leaving no trace.

Charges and reversals are keyed per (booking, attempt) and written
under MENU_LOCK alongside the seat, so a double-click, a retry, or a
cancel cut short mid-flight all settle to one charge and one refund.
That lock is in-process only: a second replica would break every
capacity and charge guarantee here.

A parent may book for a linked student, the first write parent_link
has ever authorised, and sees only seats whose link is still live.

2026-07-25

feat: 📐 publish every hard limit instead of making the frontend guessAhmet Kaan Gümüş · 7152aa9
feat: 📐 publish every hard limit instead of making the frontend guess

Every bound the API enforces lived in one of two places the frontend
could not read: a `pub const` in `constant.rs`, or English prose in a
doc comment ("1–20 entries", "`1`–`100`"). So the frontend kept its own
copy of each number, and the copies drifted the moment one moved.

Two surfaces now carry them, because clients consume them two ways.
`GET /limits` is one JSON document grouped by resource, built by naming
the constants directly — a runtime fetch, no codegen step, and it
carries what OpenAPI holds awkwardly (`reserved_usernames`, the raster
`image_content_types`, the closed role/kind/mode/status sets). The spec
gets the other half: 105 `max_length`/`minimum`/`min_items` bounds on the
request DTOs, which is what `openapi-typescript` and friends turn into
validators for free.

`/limits` is unauthenticated — the register form needs the username and
password bounds before a session exists, and none of it is secret, it is
the same rule a 400 already spells out. It is also exempt from the
database guard: it reads no row, and a frontend booting against a
reconnecting backend is exactly when it needs the contract, not a 503
that sends it back to the hard-coded copy.

Its `rate` group is the one part that is not compile-time. The
rate-limit tiers are env-tunable, so the endpoint reports this server's
live values off `AppState` rather than the shipped defaults — a client
should learn its budget here, not by collecting a 429.

`MAX_CHATBOT_THREAD_TITLE_LEN` moves to `constant.rs` on the way past.
It was private in `domain/chatbot_thread.rs`, reaching neither surface,
and its own comment asked to be moved the next time anyone was here.

Three tests keep both surfaces honest, because each is a hand-kept
mirror and a mirror nothing checks is one that goes stale. A constant
must reach `/limits` or an exclusion list that states why it does not; a
bound may not be declared outside `constant.rs` at all; and the emitted
spec is fetched and compared field by field against the constants —
never against literals, which would just be a third copy that passes
while both are wrong. That last one is unavoidable rather than
belt-and-braces: utoipa 5.5 takes a literal only, so
`max_length = MAX_NOTE_TITLE_LEN` does not compile.

Two duplicated `maximum = 500` literals are now pinned to
`MAX_PAGE_LIMIT`, which `constant.rs` previously only asked a human to
keep in step.
🎨 style: cargo fmt the tree before the audit fixesAhmet Kaan Gümüş · b4a5a00
🎨 style: cargo fmt the tree before the audit fixes

Pure reformatting, no behaviour change: rustfmt wrapping plus its
alphabetical `use`-list reordering across the files that had drifted.
Kept separate so the correctness commits that follow carry only logic.

2026-07-23

🎨 style(chatbot): rename thread/message off the mail collisionAhmet Kaan Gümüş · 92b232b
🎨 style(chatbot): rename thread/message off the mail collision

The AI chatbot's storage and web layer reused "conversation" and
"chat_message", the latter one underscore away from the human-to-human
mail `message` feature — every reader had to disambiguate two unrelated
tables by eye.

Rename the whole chatbot feature to a `chatbot_*` vocabulary:

  conversation  -> chatbot_thread    (ChatbotThread*, CHATBOT_THREAD_*)
  chat_message  -> chatbot_message   (ChatbotMessage*, CHATBOT_MESSAGE_*)
  /chat/conversations -> /chatbot/threads
  max_chat_conversations -> max_chatbot_threads
  max_chat_message_len   -> max_chatbot_message_len
  chat_history_turns     -> chatbot_history_turns
  RATE_LIMIT_CHAT_PER_MINUTE -> RATE_LIMIT_CHATBOT_PER_MINUTE
  DTO conversation_id -> thread_id

The out-of-process AI-service wire contract is deliberately untouched:
ai/chat.rs payload types, AI_CHAT_CAPABILITY ("chat.reply"), the serde
field names and the hab/1 ALPN stay as-is — other-language services
match on those literals. ai/chat.rs remains "the chat.reply payloads",
a separate concern from the chatbot feature it feeds.

Clean break, no row migration (pre-customer, FE not yet synced): old
conversation/chat_message rows in the volume are abandoned. Frontend
must adopt the new routes, the thread_id field, and the renamed
settings keys.
✨ feat(chat): relay chatbot over the AI bridgeAhmet Kaan Gümüş · b0aa0a1
✨ feat(chat): relay chatbot over the AI bridge

The backend relays between the frontend and an out-of-process AI service:
it owns auth, rate limiting, persistence and payload format, and may
inspect an answer before the frontend sees it. No rule or intent tables —
conversation is free-form.

Two-phase by design. POST persists the pending assistant row *before*
dispatching, then returns 202, so a reload never loses an answer; the
client either polls the message or opens an SSE stream. Both read the
same DTO, so they cannot disagree. Deltas are sliced from the finished
text because hab/1 is unary — the event shape exists so real streaming
drops in later without a client change.

A turn always settles. Every failure after the rows are written marks the
row failed with a machine-readable code, a boot sweep flips rows orphaned
by a restart, and a pending row older than five minutes reads as timed
out — projected at read, never written back, so a slow-but-alive answer
is not raced. An over-long answer is clipped and flagged rather than
dropped; an empty one fails.

Message ids come from a monotonic ULID generator: the two rows one POST
writes share a millisecond routinely, and a random tie-break rendered the
answer above its own question and handed the service [assistant, user],
breaking the documented oldest-first history contract.

The conversation cap counts and creates under a lock — SurrealDB
BEGIN/COMMIT does not serialize cross-record counts, and 16 concurrent
creators over-admitted a cap of 5 to 20 without it.

Every authenticated role may chat, parents included. Foreign threads are
404, never 403.

2026-07-22

✨ feat(deletes): guard course, exam-kind, and term removalAhmet Kaan Gümüş · 9191711
✨ feat(deletes): guard course, exam-kind, and term removal

Three referential-integrity guards, all 409 instead of silently taking
dependent data with them:

- DELETE /courses/{id} refuses while anyone is enrolled. The cascade
  used to delete the enrollments along with the course, so a roster
  could vanish on a misclick; the check and the delete are held under
  ENROLL_LOCK so a concurrent enroll cannot slip in behind it.
- PATCH /settings refuses to drop an exam kind whose exams already
  carry marks. Weights resolve live, so removing the kind would
  re-weight every one of those marks to 1 without touching a row. The
  check is re-run per CAS retry against the snapshot the save is
  conditioned on, under an EXAM_LOCK writer lease so grading cannot
  land the first mark mid-flight. An unmarked kind still leaves freely.
- DELETE /terms/{id} refuses while any course links it, rather than
  unlinking those courses. Guarded by a new TERM_LOCK, taken by the
  course writes that assign a term. Lock order: never held together
  with ENROLL_LOCK; if a path ever needs both, ENROLL_LOCK first.

No rows change; existing courses with a roster and terms with linked
courses simply need emptying before deletion. Frontend must surface
the new 409 on all three.

2026-07-15

✨ feat(notes): file attachments with school-set size capAhmet Kaan Gümüş · f1b532b
✨ feat(notes): file attachments with school-set size cap

Blobs live on disk under FILES_PATH (same volume as the DB), named by
the row's ULID so user input never shapes a path; the note_file row
keeps only metadata. DB-blob storage rejected: multi-MB PDFs bloat
surrealkv's LSM tree and buffer whole in RAM on every read.

- POST/GET /notes/{id}/files, GET/DELETE /notes/{id}/files/{file_id};
  owner-only through the owning note, staff included
- max_file_bytes in settings (1 KiB-25 MiB hard cap, default 5 MiB),
  enforced on streamed bytes (413), inside the settings CAS guard;
  option<int> so pre-field volumes boot without a backfill
- 10 files per note; deleting a note removes rows first, blobs after,
  so a crash strands at worst an unreachable blob

2026-07-14

✨ feat(exams)!: move weight off exams onto their kindAhmet Kaan Gümüş · 3681441
✨ feat(exams)!: move weight off exams onto their kind

Weighting is school policy, not per-exam data: each settings
exam_kinds entry is now {name, weight} (1-100, defaults all 1) and
mark reports resolve weights at read time, so editing a kind
reweights every exam of that kind at once; an exam keeping a
since-removed kind counts as 1.

BREAKING CHANGE: exams lose `weight` on the wire and in storage,
settings `exam_kinds` become objects. No data migration (pre-customer
clean break) — delete ./data/hezarfen.db and reboot.
🐛 fix: bind room writes to their sitting, wall unenrolled sittersAhmet Kaan Gümüş · 3375565
🐛 fix: bind room writes to their sitting, wall unenrolled sitters

Four bugs, each reproduced by a failing test first:

- A stale exam room's answer/finish acted on the *latest* attempt, so
  a lingering socket from a finished sitting could scribble on — or
  instantly submit — a retake it never hosted, burning a limited
  sitting. Messages now refuse any sitting but the room's own.
- The sitting's content endpoints (GET /attempt/questions, POST
  /attempt/answers) skipped the enrollment wall that guards the room
  door and the attempt start, so an unenrolled ex-student kept the
  question list and a writable answer sheet forever. Both are 403 now;
  finishing stays open, exactly like under a closed rejoin door.
- PATCH /settings merged over a snapshot and wrote the whole row back,
  so concurrent edits of different fields silently reverted each
  other. Saves are compare-and-set against the merged-from snapshot
  now, re-merging on refusal (409 only when still contended).
- Work-entry duration_ms overflowed i64 on absurd manager-corrected
  instants — a panic in debug, a wrapped negative in release, and a
  row that 500d every later read. The subtraction saturates now.

2026-07-13

✨ feat(school): editable policy settings + academic termsAhmet Kaan Gümüş · ea8bfeb
✨ feat(school): editable policy settings + academic terms

Every school differs; the varying parts become data instead of code:

- settings singleton (GET any user, PATCH manager+): exam kinds,
  attendance statuses, grade-display bands. Absent row = old
  hardcoded defaults, so existing databases behave unchanged.
- core four attendance statuses stay mandatory — the attendance
  rate is defined over them; school extras tally rate-neutral
  under a new `custom` bucket in reports.
- grade bands are display-only over the canonical 0-100 marks:
  reports gain grade/average_grade/overall_grade labels, stored
  marks never change with the display scale.
- terms are rows (semester/trimester/quarter all fit); courses
  link via nullable term_id, term delete unlinks, past dates
  allowed for mid-year calendar backfill.
- settings edits never rewrite stored rows: retired kinds and
  statuses live on in old records; only new writes validate
  against the current lists.