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: 🔩 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.
feat: 🧑🏫 give a class section a homeroom teacher and open it to studentsAhmet Kaan Gümüş · e590b84
feat: 🧑🏫 give a class section a homeroom teacher and open it to students
Two gaps in the class-section layer, closed together because the
second is what makes the first worth storing: a section could name no
homeroom teacher, and a student could never learn which section they were
in — every /classes route was teacher+, so the layer was invisible to the
people inside it.
A section carries an optional `teacher`. The named account must be
teacher+, `null` and `""` both clear it, and an omitted field is left
alone rather than re-stated from the caller's snapshot. The column is
additive: rows written before it carry no key at all, which reads back
as null, so nothing is backfilled and no whole-row write coerces a
counter. A demotion clears the column everywhere — only teacher+ may
hold a section, and the sweep set_role already ran for course staffing
now runs for sections too.
Two reads sit outside the teacher+ bar. GET /classes/me serves any
authenticated caller their own section; GET /classes/user/{user} serves
teacher+ or a linked parent, through the same observer gate marks,
attendance and pomodoro use — which 403s before it 404s, so a parent
never gets an existence oracle.
Opening those reads meant the response could no longer carry `creator`.
A section's creator is always manager+, and below teacher+ that identity
was unreachable: GET /users is admin-only and /users/search is teacher+.
So `creator` is null for those callers and the join never even fetches
it, which keeps the response and the person map from drifting apart.
The role bar was a read-then-write with nothing between them. A demotion
landing in that window left the account homeroom teacher forever, since
its sweep had already run and matched nothing — and course assignment
had carried the same hole since it was written. Both now re-read the
live role after the write and undo the assignment with a 409. A create
that loses this way rolls the whole section back rather than leaving a
teacherless one standing, and the rollback releases the term reference
inside its own transaction, so no term is left undeletable. A rollback
the delete guard refuses is a 500, not a 409 whose text promises nothing
was created.
Every guard here is pinned by a test that fails when the guard is
removed, including the three race sites: a DEFINE EVENT on the table
being written fires inside the handler's own write, which is exactly the
window between the role check and the re-read. No production code knows
the seam exists.
Verified against the real volume: the migration applies to a database
whose section rows predate the column, those rows come back byte-identical
with every refcount intact, a second boot changes nothing, and both new
reads answer correctly on stored data.
The English prose calls this a class section throughout, keeping şube as
a parenthetical gloss — the word has a plain equivalent and the docs were
carrying the Turkish as though it did not.
Known and left: can_manage_course still trusts Course.creator without
re-reading the live role, so a demoted creator keeps course-management
reads — its own series. set_role writes the role before its sweeps and
they are not one transaction; every sweep is idempotent and grants
nothing, so a re-sent PATCH repairs the residue.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
docs: 🧹 stop the migration comments claiming a fleetAhmet Kaan Gümüş · 079af73
docs: 🧹 stop the migration comments claiming a fleet Multi-replica support was deleted; the rate_limit row is restart continuity for one process, the capacity/delete guards close write skew between concurrent request tasks, and the = NONE seeds are about migrate() rerunning on an existing volume — not about a peer serving. Comment prose only; no SQL byte changed.
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
fix: 🧊 freeze a fee plan the moment it is assignedAhmet Kaan Gümüş · ac70cc0
fix: 🧊 freeze a fee plan the moment it is assigned The 409 that stops an assigned plan being edited or deleted was a scan followed, some microseconds later, by the write it licensed. An assign landing in that gap left a plan edited and assigned, or deleted with a live assignment still naming it. The comment called it an accepted race and blamed the other replica; there was never another replica, and two concurrent requests in one process were always enough. A plan now carries an assignment refcount. The assign claims it in the same transaction that writes the row, and the edit and the delete are conditional writes that refuse while it stands. The plan freezes at the instant of the claim, so the assign re-reads it afterwards and bills the copy that froze — the refcount alone still let an edit slip in front and bill the snapshot the handler had read. Existing plans are seeded from the assignments they already carry. An absent counter reads as zero, which is the value that licenses an edit, so a plan assigned before this would otherwise have come unfrozen. Two things this uncovered. A cap claim that lost a write conflict was answered as a 500 five times in six: the retryable conflict shared the error batch with the sibling statements it aborted, and an arbitrary one of those was returned. And a guarded write had no retry at all, so a raced PATCH or DELETE failed outright rather than trying again. The race tests run against a real server. On the embedded engine they watched a 45-in-50 failure rate and passed.
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.
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
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-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.