Commits
2026-08-04
feat: 🎖️ earn badges on both sides of the classroomAhmet Kaan Gümüş · 46c76f5
feat: 🎖️ earn badges on both sides of the classroom Pass 2 gave badges only to students doing their own homework. Seven new families cover the rest of the school and the two shapes a plain tally could not express. Teachers earn `marks_given` (a grade recorded, once per pair — a regrade moves nothing), `lessons_held` (credited at the first roll call taken for a session, so a lesson scheduled and cancelled counts for nothing), and `pool_approved`. Students earn `pool_published`, `high_mark` (an exam mark at or above 90, once per sitting), `lessons_attended` (marked present or late at roll call, moved back down by a correction), and `study_streak` — the longest run of consecutive days finishing a pomodoro, read as a high-water mark so breaking it never takes the badge back. Days end at midnight UTC, like every other day calculation here. Both counters of the question pool skip a self-approval: a counter moves only when one person's work was judged by somebody else, which closes the ask-approve-delete farm on the staff side the way crediting at approval closes it on the student side. Every counter moves inside the transaction of the write that causes it. The streak needs two statements rather than one because sibling SET clauses read the row's before-state, so `longest` would lag `current` forever; the pair sits in one transaction, and `max` keeps it monotone under every interleaving, verified on a real 3.2.3 server. No backfill and no migration mark: every counter starts at zero at this deploy.
feat: 🏅 earn badges for the work already doneAhmet Kaan Gümüş · a00880e
feat: 🏅 earn badges for the work already done Thirteen badges a student earns by doing the work, so the profile has something to be proud of rather than just a photo and a bio. Nothing awards a badge by hand and nothing takes one away. A badge is earned when a counter crosses a threshold, and it is permanent: withdraw the submission that earned it and the count falls while the badge stays, because a stamped `earned_at` is the motivational payload and a badge that evaporates is worse than no badge. The catalog is hardcoded, so changing a threshold is a deploy and the evaluator stays a pure function of the counters. It rides GET /limits as a group like every other bound; labels and icons are the frontend's, keyed by badge id. The counters are the real work. Homework, exam and attempt tables are indexed for the questions the rest of the API asks, so counting a single student's history meant a full table scan — the numbers are therefore tallied at write time, in the same transaction as the write that causes them. Existing accounts are seeded once from their real history, gated by a mark whose skip is proven rather than assumed, so nobody starts at zero for work they already did. Withdrawing your own submission decrements, and that is the only decrement in the codebase: withdrawal is student-callable, so without it submit/delete/submit would farm the counter. Cascades never decrement — history a teacher erased is still history the student lived. The cost is that a re-run seed, which can only count rows that still exist, comes out lower than the live tally; documented where someone would otherwise "repair" it. Deadlines move, so the on-time verdict is now stored on the submission beside the count it fed. Judging it again at withdrawal read whatever the deadline had become since, which drifted the tally in both directions — far enough that on-time could exceed submitted. Attendance counters were dropped: those tables already carry per-user indexes, so there is no scan to fix, the status list is school-editable, and roll-call corrections would need a decrement that fights permanence.
feat: 🪪 give every person a public profileAhmet Kaan Gümüş · b326165
feat: 🪪 give every person a public profile Avatar, bio, display name, live class/course blocks and read-time stat counters, so the school has something to motivate students with. The fields ride the user row rather than a profile table: the row already carries the self-service columns and their field-scoped writers, so a separate table would only add a "profile row missing" state every read must degrade, plus a second write to the admin-seed path. DDL only, no backfill — every pre-existing row reads null, or 0 for derived stats. Contact fields stay off the public projection and keep their old gate. Reads are school-wide except for parents, who reach only their own profile and their currently-linked students'; the link and the target's live role are re-read per call, so a promoted-out student stops being readable at once. The courses block is intersected with what the viewer can already see, since a course title a caller is 403'd from reading directly must not leak through someone else's profile. stats.courses stays the owner's true total — an aggregate reveals magnitude, not identity — so a stranger sees an empty block beside a non-zero count. Classes stay a narrowed id/name/grade projection: a homeroom section is the social signal, a private club name is not. Stats are computed at read and floored at 0. Exam average, homework rate and attendance rate are deliberately absent: those tables are indexed such that a per-user aggregate is a full table scan. Avatars reuse the one-image-on-the-owning-row pattern and the school's existing max_file_bytes, raster only. Deleting one is admin-reachable because an offensive avatar is a real school problem and no user-delete route exists to fall back on. Also floors pomodoro focus time at both ends: a backwards clock could record a negative stint, which the profile would have served as a negative total. No badges yet — those are auto-earned only and land next.
2026-08-02
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-08-01
2026-07-31
feat: 🖍️ collaborative whiteboard domain, REST and limitsAhmet Kaan Gümüş · 5dfce55
feat: 🖍️ collaborative whiteboard domain, REST and limits Boards are an ad-hoc invite list: the creator names participants, and every participant draws. Clearing, locking, closing and deleting are the creator's alone. Strokes are an append-only log and a clear NEVER deletes — it bumps the board's epoch, so the live canvas empties while the whole history stays replayable. The clear marker row doubles as the epoch index, carrying the epoch it closed and that epoch's final stroke count, which is why there is no epochs table. Growth is bounded by two counters claimed together in one conditional write: epoch_stroke_count resets on a clear and caps the live canvas (recoverable — clear and keep drawing), while total_stroke_count never resets and stamps closed_at when the lifetime cap is hit, leaving the board permanently read-only but fully readable. board_count on user bounds the open-a-new-board escape hatch. Outsiders get 404 everywhere so a board's existence never leaks; a participant lacking creator rights gets 403, since existence has already been disclosed to them. The WebSocket room lands separately.
2026-07-30
feat: 🎨 sync the accent color like theme and languageAhmet Kaan Gümüş · 9490623
feat: 🎨 sync the accent color like theme and language
The frontend's palette picker kept the chosen accent in localStorage, so
it never followed the user to another device. `palette_color` joins
`theme` and `language` as a third per-user preference: a nullable hex
color on the user row, self-managed and admin-editable through the same
two PATCH routes, `null` until chosen.
The value set is deliberately open — any `#rrggbb` — rather than an enum
of the frontend's palette entries, so adding a palette is a frontend-only
change. Mixed case is accepted and stored lowercase, which is why
`/limits` publishes the accept-set pattern (`^#[0-9a-fA-F]{6}$`) and not
the storage form: a client validating its own input against the published
regex has to agree with the server, and a test now compiles that regex
and runs it over the validator's own accept/reject examples.2026-07-29
fix: 🔁 make a retried payment one payment, and page the statementAhmet Kaan Gümüş · 4fe02bc
fix: 🔁 make a retried payment one payment, and page the statement A client that resends POST /payments/credits or /refunds after a timeout may now carry a request_key; the line's id derives from (target, kind, key), so the replay reads back the recorded line instead of minting a second one, even when it filled the charge to the brim. Same key with a different amount or target is answered 409 — the stored line never bends to a retry. Keys are letters, digits and '-' only: '_' joins id parts, so a key like 'abc_r' could spell another line's reversal id; append() now also refuses to hand back a line of another kind, turning any future grammar slip into a 500 instead of money on the wrong line. Statements page their per-charge rows through the usual ?limit&offset envelope; the balance and every rollup still fold the whole ledger before the window is cut.
feat: 💰 track school fees in an append-only ledger of fee plansAhmet Kaan Gümüş · 740e96a
feat: 💰 track school fees in an append-only ledger of fee plans
Fee plans (name + 1..60 installments of {amount_minor, due_at}) are
assigned directly to students; assignment appends every installment as
a charge at once, keyed <plan>_<student>_c<n> so a replay bills nobody.
Payments target one charge, refunds target one credit, and a reversal
undoes only the negative-fold kinds — a mistaken credit is corrected by
a refund, never edited. Balance is never stored; the over-payment cap
folds the target's source subtree under PAYMENT_LOCK and stays advisory
across replicas, which the module doc states outright.
Meal money is untouched: two ledgers, two balances, one shared amount
vocabulary.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.
chore: 📦 give every constant one homeAhmet Kaan Gümüş · 78b25b5
chore: 📦 give every constant one home Constants were scattered across 18 modules: table names and migration SQL in database.rs, limits in config.rs and rate_limit.rs, magic strings sitting next to the only code that read them. Nobody could answer "what are all the hard values in this service?" without a grep. They all live in constant.rs now — validation bounds, the 37 SurrealDB table names, the PRE_REPAIR/MIGRATION/BACKFILL schema SQL, and the enum value tables that used to hide as associated consts (Role::ALL -> ROLES, Folder::SENDER -> SENDER_FOLDERS, and friends). Values are byte-identical; this changes no behavior. constant.rs now imports crate::domain for the enum types, an intra-crate cycle that compiles fine. Statics stayed where they were. A Mutex or a ULID generator is runtime state, not a constant, and moving them would only blur that line. Two guards keep the consolidation honest. limits_completeness.rs already failed on any pub const in constant.rs that is neither published through /limits nor excluded with a reason; the *_TABLE names are excused by shape rather than by 37 lines of boilerplate, but the excuse now requires the absence of a MAX_/MIN_/DEFAULT_ prefix so a real bound cannot hide behind the naming convention. And the move quietly dropped three rules off the end of the text-fold table, which every existing test still passed — so the circumflexed vowels are pinned, and search_fold_sql must emit one string::replace per rule or the needle and the column drift apart.
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.