Commits
Commits on
03467171d2a77c2afca2575cd47f2d2e67e7818f2026-08-05
fix: 🎨 stop a bulk board invite from dropping the other invite's groupAhmet Kaan Gümüş · 0346717
fix: 🎨 stop a bulk board invite from dropping the other invite's group
`POST /boards/{id}/invite` reads the roster, unions its resolved group
into it, and stores the whole array back. Two invites from the creator
landing together both read roster R: one writes R∪A, the other R∪B, and
the second commit silently drops the first one's people — with both
callers told 200 and a list of participants who are not on the board,
against the route's own "strictly additive, nothing is ever removed by
it" contract. Neither write is wrong on its own, so the database cannot
refuse it; it is a lost update, not an over-cap.
Closed with an in-process lock over the whole read-modify-write, which
genuinely serializes here (one process, stop-the-world deploys) and,
unlike a compare-and-set, does not answer 409 to two calls that do not
conflict in intent. The cap is then checked against the roster actually
read under the lock, so the stored value is the checked value. The
roster branch of `PATCH /boards/{id}` takes the same lock — it reads the
current list before replacing it, so it is the other read-modify-write
of that field, and a lock only half the writers take serializes nothing.
The regression test races two class invites and reads the roster back
off the server: without the lock it drops one group, 2 of 4 members.fix: 🤖 answer a contended thread delete 204, not 500Ahmet Kaan Gümüş · c998c0d
fix: 🤖 answer a contended thread delete 204, not 500 `ChatbotThread::delete` was the one delete in this domain sent as a bare guarded transaction with no retry loop, the shape `Board::delete` documents. It writes the thread row, and so does every turn, every rename and every other thread's cap claim on the same user — a lost round therefore surfaced as `AppError::Db`, a 500 for a delete that merely raced and would have succeeded on a re-send. Now that a turn deliberately collides with this batch, that round is no longer rare. Admissible by the stated rule: the batch is DELETE / DELETE / UPDATE only, none of which can legitimately answer "already exists". On a re-sent round the thread is already gone, the `RETURN` is empty, and the caller gets the 404 that is the truth rather than a 500.
fix: 🤖 stop a chatbot turn from outliving its threadAhmet Kaan Gümüş · 2351107
fix: 🤖 stop a chatbot turn from outliving its thread
Sending gated itself by reading the thread and then created two rows
that wrote only `chatbot_message`. A delete sweeps its turns and drops
the thread in one transaction, so a create landing after that sweep but
before the commit read a thread that was still there (uncommitted) while
the sweep had run on a snapshot predating the new row — both committed,
and the prompt and its answer survived under a thread that was gone.
Reads do not conflict, and `SET x = x` is elided before it reaches the
write set, so only a write that MOVES a value on a key the delete also
writes serializes the two. Turns now ride `touch_and_write`, which bumps
the thread's `updated_at` in the same transaction as the create — the
shape a dish and an exam answer already use. That bump is also the
activity stamp the send path used to issue afterwards as a separate,
best-effort query whose failure was a `warn!`, so the stamp can no
longer be lost either. It is written strictly upwards rather than to
`$now`: a turn's two rows routinely share a millisecond with the
thread's own creation, and an UPDATE that changes nothing is elided —
which would collide with nothing.
Nothing swept the orphans: no migration sweep, and boot repair only
fails `pending` rows. They also stayed readable — `own_message` checked
the owner and the thread key but never that the thread existed — so
`GET /chatbot/threads/{deleted}/messages/{mid}` and its `/stream`
answered 200 with text the user had deleted. That read now re-reads the
thread, which is defence in depth for rows an older binary already left
on a live volume; the SSE poll loop is untouched, so it costs one extra
record read per polling client and not one per tick.fix: 💳 stop telling a bursar a reversed charge was paidAhmet Kaan Gümüş · 26a740d
fix: 💳 stop telling a bursar a reversed charge was paid A reversal is a `+amount` child of the line it undoes, so it fills exactly the room a payment would: `applied_to` folds it in and a reversed charge reads as full to the last minor unit. `POST /payments/credits` against one therefore answered "the charge is already paid in full" — about a charge where not one minor unit ever arrived. It was reversed, and a bursar reading that goes hunting for money that does not exist. The stored outcome is right and does not move: a reversed charge is no longer owed and takes no payment. Only the diagnostic changes. The reversal's id is derived from its target's, so telling the two refusals apart is one read, taken on the refusal path alone. `refund` passes `None` and spends no read: a credit is never reversed, so a full fold there can only mean the refunds. Doc surfaces move with it: the route's 409, its handler doc, the `payments` tag description, and the README route table and section.
test: 📅 prove a settled booking goes with its slotAhmet Kaan Gümüş · 04b3469
test: 📅 prove a settled booking goes with its slot `delete_free` cascades `DELETE appointment WHERE slot IN $slots` inside the slot delete's own transaction, but both existing tests stopped at the 204 — the cascade itself was never asserted. A booking left pointing at a deleted slot is a dangling link every read of it has to survive. The count is read from the database rather than off the response: a 204 was never proof the second statement ran. It passes, so the cascade holds today; this is the forcing function that keeps it holding.
fix: 📅 stop offering a slot booking will refuseAhmet Kaan Gümüş · 2202807
fix: 📅 stop offering a slot booking will refuse `GET /appointments/slots` listed every slot whose `ends_at` was still ahead, but `Appointment::book` refuses any slot whose `starts_at` has passed. The two windows disagreed, so a slot already underway sat on the student's bookable calendar as an entry that could only answer 409 — either published inside `check_not_past`'s 60-second grace, or simply started while the page was open. The listing moves to `book`'s bound: `starts_at > $from`. `book`'s rule is the real constraint, so the calendar stops advertising what booking refuses rather than booking loosening to match. The 60-second publish skew grace deliberately does not reach the listing either — `book` does not grant it, and a slot published a moment after its own start is unbookable from birth. Two source claims were false and are corrected with it: `book`'s comment said `list_upcoming` hid these slots, and the route doc called them "every slot still open in the future".
docs: 🎖️ say when a grade credit is given back and when a lesson is heldAhmet Kaan Gümüş · a7c8c8d
docs: 🎖️ say when a grade credit is given back and when a lesson is held The two counter rules changed under it: un-grading now refunds marks_given and high_mark (a cascade still does not), and a lesson is held by the first roll call taken at or after its own starts_at, not by the first roll call at all. Both the badge section and the roll-call paragraph said otherwise.
fix: 🎖️ hold a lesson only once its own time has comeAhmet Kaan Gümüş · 901238e
fix: 🎖️ hold a lesson only once its own time has come Roll call is not time-gated — a teacher may open the sheet early — and the first mark on any session credited lessons_held_total, future-dated ones included. Two hundred sessions scheduled for next week, one student marked in each, held two hundred lessons this afternoon; moving the credit off session creation had only doubled the request count. The counter is gated, not the route: the credit (and the stamp that makes it once-per-session) waits for the lesson's own starts_at. Because the stamp is written only on the branch that credits, a sheet opened early and touched again after the bell still credits exactly once, then — no backfill, and no migration mark. A sheet never touched again credits never, which is the cost. lessons_attended_total is deliberately left ungated: it is a delta off the row's stored status, which does not record whether the credit was taken, so a gate would refund at the correction what the early mark never credited. The ponytail names the column that would close it. The two integration tests that asserted the farm now ring the bell first, a stored-state trick the suite already uses for the streak — no route can backdate a lesson, which is what makes the gate hold.
fix: 🎖️ give the grade credit back when a grade is deletedAhmet Kaan Gümüş · 6197fc3
fix: 🎖️ give the grade credit back when a grade is deleted Both grade sites credit on the branch that finds no row, and a deleted row reads as no row — so ungrade-then-regrade credited a second time off one stored mark. Looped, one teacher and one student minted marks_given_250 and high_mark_25 from a single exam, or from a homework with no submission behind it at all, and an award once earned is never revoked. Each delete now refunds inside its own transaction and only for rows it really removed: marks_given_total to each removed row's own grader (a manager may un-grade what a teacher graded), and high_mark_total off the removed mark's BEFORE image. Floored at zero, so a row predating the columns cannot push one negative. HomeworkResult::remove takes the transaction_with_retry upgrade its sibling already wanted — the new counter is what makes it necessary, since the grader's row is written by exam grading too — and with it the hand-kept slot 1 becomes the usual trailing-RETURN count. The rule in constant.rs said the opposite; it now states which routes refund and why, and names the cascades as the one leak left open.
fix: 🏫 stop a deleted course from sticking in a blueprintAhmet Kaan Gümüş · b0f72a5
fix: 🏫 stop a deleted course from sticking in a blueprint A grade template holds its courses as a list on its own row, so nothing in `Course::delete`'s cascade could reach it: the id stayed, and the repair every doc surface named — `PATCH` the template back as it stands — is a 400 for naming a course that does not exist. The pump's own prune only fires while walking a section, so at a grade with no sections the id was permanent. The cascade now sweeps `class_blueprint` in the same transaction that detaches the course from the sections. Table scan, deliberately unindexed: one row per grade label, and a course delete is rare — and the per-element index the WHERE would want (`FIELDS courses[*]`) is the one this store answers with no rows at all. `prune` stays for the window the sweep cannot cover (a course deleted after a pump read the list it walks) and for ids written before this existed; its comment no longer argues the sweep should not exist.
fix: 📚 hold the exam lease while a course cascade sweeps sittingsAhmet Kaan Gümüş · 340ff4f
fix: 📚 hold the exam lease while a course cascade sweeps sittings delete_course takes the same cascade delete_exam does — its courses' exams and their attempts — and had the same hole: an attempt is the one exam child whose write cannot collide with the sweep, because its claim lands on the student's row rather than the exam's. Narrower than the exam twin, since the delete is refused while anyone is enrolled: a start would have to pass its enrollment gate and then have that enrollment removed under it. Same hole, same lease. Nothing on this path takes another lock, so it adds no ordering pair. No test of its own — the window needs an unenroll landing inside a start's own lease, which no sequence of HTTP calls can arrange. The mechanism is the one regress_exam_delete already pins.
fix: 📝 stop a sitting from starting inside an exam deleteAhmet Kaan Gümüş · 00207fe
fix: 📝 stop a sitting from starting inside an exam delete delete_exam took no lock at all, while its twin delete_homework has always held HOMEWORK_LOCK.write() across its whole cascade. Every other child of an exam now writes the exam row in its own transaction, so the store refuses the pair; an attempt cannot, because its claim lands on the student's row (exam_sat_total) and touches nothing the delete writes. So a start firing inside the delete window read an exam that was still there — deleted, uncommitted — and committed its sitting past a sweep that had already run without it. The row was unreachable afterwards, since every route to an attempt goes through its exam, while the student's lifetime sitting counter stayed up for good and a badge minted off it is never revoked. 3 of 3 raced rounds. start_attempt already holds the writer lease from its exam read through the insert, so giving the delete the same lease is the whole ordering: a start either lands before the sweep, which then takes its row, or reads no exam and is a 404. The lease spans the blob names too — they are collected before the rows go. Process-local, so it holds on a single replica with stop-the-world deploys; the ponytail names the store-level upgrade. The test drives the real handlers, because a lock in the web layer is invisible to a domain call, and the in-memory engine is enough for once: it asserts a mutex, not the store's conflict detection.
fix: ❓ stop a solution from outliving its pool questionAhmet Kaan Gümüş · 226334a
fix: ❓ stop a solution from outliving its pool question Offering a solution was a bare create guarded by a read of its question, and a question delete sweeps its solutions in its own transaction. An offer landing after that delete removed the row but before it committed read a question that was still there, while the sweep ran on a snapshot predating the offer — so both committed and neither caller was told: 4 of 4 raced rounds against a real server. The row it left is unreachable in every direction. Every route to a solution goes through its question, so no reader lists it, no author edits it, no delete clears it, and its photo blob stays on disk for good. The offer now moves the question's own asked_at and puts it straight back inside one transaction, so the two writes collide on one key and the store refuses a side. It goes through a helper on the question, the menu's shape, so the next child hung off a question inherits it. This row carries no counter or revision to bump and must not grow one for this alone; the value is restored by capture, so nothing outside the transaction ever observes the move. The delete rides the retry now — it contends with an offer by design, and a lost round through a bare check() was a 500 for a delete that only had to be re-sent.
fix: 🎨 stop a drawing from outliving its examAhmet Kaan Gümüş · f8b854c
fix: 🎨 stop a drawing from outliving its exam A drawn answer was still a bare upsert — the exact shape the text answer had before yesterday's fix — so it kept the hole: a drawing landing after an exam delete removed the row but before it committed was swept by nothing, and both sides reported success. 4 of 4 raced rounds against a real server. The blob went with it. The handler collects the names to unlink before it calls the delete, so bytes written after that snapshot sit on disk with no row and no reader forever. It now moves the exam's mark counter and puts it straight back inside its own transaction, like the answer beside it, so the two writes collide on one key and the store refuses a side. Restored by captured value, so the row is byte-identical and no teacher's edit is refused because a student drew.
fix: 📝 stop a question or picture from outliving its examAhmet Kaan Gümüş · 317df96
fix: 📝 stop a question or picture from outliving its exam Adding a question, or a picture on one, only *read* the exam it hung off — the freeze gate reads exam_attempt and nothing else — and an exam delete sweeps its questions in its own transaction. A write landing after that delete removed the exam row but before it committed read a row that was still there, while the cascade ran on a snapshot predating the insert, so both committed and neither caller was told: 4 of 4 raced rounds against a real server. An orphan question is worse than untidy. It keeps the reference it claimed on its subject, because the cascade's per-subject decrement counted only the rows it could see, and a subject delete is gated on that count reading zero — a subject nobody can ever delete again, hanging off an exam nobody can ever see. An orphan picture strands its blob too: the handler collects the names to unlink before it calls the delete. The gate now writes the exam row itself — bumping the mark counter and putting it straight back, by captured value so the row is byte-identical and NONE stays NONE — which is the shape an answer save and a menu child already use. It moves a value on purpose: an update that leaves the document unchanged is elided and never reaches the write set, so it would collide with nothing. One site covers both children, and every future writer through the gate. Tests that wrote a question or a picture against an exam id nothing ever created now create one: that is a 404 today, not a silent orphan.
2026-08-04
docs: 🍽️ say which bound drops an orphaned markAhmet Kaan Gümüş · 6b7beb1
docs: 🍽️ say which bound drops an orphaned mark Said a bounded read drops one. Only ?from= does — a link to a deleted menu has no date, so it fails a lower bound and passes an upper one, and ?to= on its own still returns the mark.
fix: 🪝 make the course claim a write the store can seeAhmet Kaan Gümüş · 6200ad0
fix: 🪝 make the course claim a write the store can see Attaching a course to a class claimed the course row by re-stating its counter — SET count = count — on the reasoning that the row must be touched, not changed. SurrealDB drops an update that leaves the document unchanged, so that statement never entered the write set and never collided with anything. A concurrent course delete and the attach both committed, leaving a class linked to a course that was gone. The claim now bumps the counter, checks the row is still there, and puts the value back as it found it — absent stays absent, so the boot backfill still matches. Both statements are in the one transaction, so nothing can observe the bump or strand it. A sweep for the same shape found no other site: every other claim in the crate moves a real value.
docs: 🍽️ correct what an orphaned mark could be read throughAhmet Kaan Gümüş · 36c718a
docs: 🍽️ correct what an orphaned mark could be read through Said reading one was impossible because every path went through the menu. Only the writes do: the student's own attendance list filters on the student and a date window, never on the menu still existing, so such a mark would have come back there. Nothing can create one now, and the sweep is what clears them.
fix: 📝 stop an answer from outliving its examAhmet Kaan Gümüş · 02b1ff8
fix: 📝 stop an answer from outliving its exam Saving an answer only read the exam it belonged to, and a delete sweeps answers in its own transaction — so a save landing inside that window wrote a row the sweep had already passed, and both sides reported success. The same shape as the attendance mark, one domain over; measured 4 of 4 raced rounds against a real server. The save now writes the exam row itself, so the two collide and the store refuses one. It has to move a value to do that: SurrealDB drops an update that leaves the document unchanged, so setting the counter to itself never enters the write set and never conflicts — it is bumped and put back inside the one transaction instead. No new column, since a whole-row save would strip one at the next edit. Editing an exam now rides the retry too. The answer touch makes that row hot, and a lost round through the old bare query was a 500.
fix: 🍽️ stop an attendance mark from outliving its menuAhmet Kaan Gümüş · 84c873c
fix: 🍽️ stop an attendance mark from outliving its menu Marking attendance guarded itself by reading the menu, and a delete sweeps its children in one transaction. A mark landing after that delete removed the row but before it committed read a menu that was still there, while the sweep ran on a snapshot taken before the mark existed — so both committed and neither caller was told. The store does not track an insert into a range another transaction already swept. That left a mark nothing could reach or remove, on an id minted from the date and slot: republishing that day brought it back as a mark on the new menu, the kitchen reading served for a student who never came. Measured on the real engine, not theorised: 378 of 3600 raced rounds. A dish never had this hole because it bumps the menu's revision, so the two writes collide on one key and the store aborts a side. Marks now go through the same helper, which moves to the menu itself since both its children need it. The dish test that found this was asserting a store-enforced invariant on the in-memory engine, which cannot enforce one — a few percent of loaded runs failed on correct code. It now pins the logic without a race, and the concurrent claim moves to a real-server test that holds the delete open with an event and races one child per round: racing both hides the bug, because the first writer makes the delete re-send and the re-sent sweep takes the other's row.
docs: 📏 say what the refusal-code guard cannot catchAhmet Kaan Gümüş · f27ac0a
docs: 📏 say what the refusal-code guard cannot catch The comment claimed a code documented on no surface at all would fail the test. It would not: the three lists it compares against are hand-kept, so a code this file has never heard of passes every assertion. What actually holds that end is the exhaustive match plus the per-axis unit test, and adding a code means editing both.
fix: 🧭 name the ceiling a class refusal actually hitAhmet Kaan Gümüş · 82c0ee2
fix: 🧭 name the ceiling a class refusal actually hit The refusal codes shipped one commit ago read the same on both axes, but two of them mean opposite things depending on which side is being attached: a class at its ceiling is out of course places when a course arrives and out of seats when a student does. So adding a student to a full section answered class_at_course_ceiling next to a sentence about students, and a section carrying too many courses answered class_roster_too_large. The two tests covering it pinned the wrong answer, one of them while asserting the prose was right. The ceiling codes now live on the axis, so each names what it hit, and the member route gains the two it needed. Its documentation was wrong in the other direction too: it derived the manual code set from the pump's, which quietly promised codes only a pump can answer — a deleted class or course is a 404 there, never a 409. Each route now states its own set, and the spec guard compares those sets rather than searching the whole document for the strings, which is why it never caught any of this.
feat: 🏷️ answer a manual class refusal with the pump's own codeAhmet Kaan Gümüş · 574b977
feat: 🏷️ answer a manual class refusal with the pump's own code Attaching a course or adding a member by hand refused with an English sentence, while the very same conditions reached through a blueprint pump had just become machine codes. One cause, two shapes — and the client that has to word them is bilingual. The vocabulary now has one home on the pump's own refusal type, the blueprint's skip list reads it from there, and the two manual routes carry it as a code beside the sentence they already sent. Prose is unchanged and no other route gains the field. Coding these also exposed a claim this series had been making wrongly: a pump attaches a course it has just proved alive, so it can never report a stale link. Only a member add walks the section's existing courses, and only it can answer that one.
fix: 🧮 read a page total the planner answered from an indexAhmet Kaan Gümüş · 4889fd9
fix: 🧮 read a page total the planner answered from an index
Asking for the sections with no grade answered 500. SurrealDB rewrites
count() into a count straight off an index or the table when the
predicate is known at plan time, and that plan returns {count: N}
rather than the projected int the page decoder expected — so a filter
on an indexed field broke the count that pages it, while the same
filter with a bound parameter did not.
The total now reads either shape. That is also what the WHERE true
appended to every unfiltered read was working around, one altitude too
low and at the price of a scan where the bare read counts in O(1), so
it goes.
Only the class index was reaching the rewrite; every other paged read
binds its parameter or filters an unindexed field. In-memory tests
cannot see any of this — the mem engine never rewrites the plan, which
is why the container caught it and the suite did not.feat: 🩺 say which sections are out of step with their blueprintAhmet Kaan Gümüş · 0684656
feat: 🩺 say which sections are out of step with their blueprint A pump is best-effort, so it can leave a grade half stocked — and the skip list saying which half lived in one response body and nowhere else. A manager who closed the tab had no way back to it. The status read answers it from the store: the template, how many sections carry the label, and what each section is missing. A course attached by hand counts as present, because that is exactly what the pump does with it. It also writes down the recovery nobody had been told: re-sending the same list re-runs the pump, and a section can be re-stocked on its own. A class moved to another grade keeps what the old template gave it — which this read now shows rather than leaving to be discovered.
feat: 🔍 filter the class index by gradeAhmet Kaan Gümüş · cf0a010
feat: 🔍 filter the class index by grade A blueprint keys on a grade label and its pump is best-effort, so a manager can be handed a skip list naming three sections at grade 9 — and had no way to list the sections at grade 9. The label the office typed is the only thing tying them together, and nothing read it. Matched verbatim, like the pump it exists to debug: a filter that trimmed or folded would disagree with the thing it is meant to explain. An empty value asks for the sections carrying no grade at all, which is what an empty grade already means everywhere a class is written.
feat: 🏗️ stock a new section from its grade's blueprintAhmet Kaan Gümüş · 67ced09
feat: 🏗️ stock a new section from its grade's blueprint Editing a template reached every section already at the grade, but making a section reached no template — so a blueprint described every section except the ones created after it, and the office had to remember a second call each time. A create now applies its grade's blueprint, after the homeroom demotion rollback and never before it: the rollback deletes the class, and that delete refuses while the class holds courses. The 201 body carries the class, what could not be stocked, and which grade's template stocked it — null when none covers the grade, which is also what a stocking that faulted reports, because a 500 here would strand a section whose id nothing else returns.
feat: 📊 say how many sections a blueprint pump reachedAhmet Kaan Gümüş · 81c5490
feat: 📊 say how many sections a blueprint pump reached A grade label is free text and matched exactly, so a section typed "9 " carries a grade no blueprint for "9" will ever find. The pump answered that with an empty skip list, which reads exactly like every section having taken the whole template. It now says how many sections it walked, so nothing reached is a zero a manager can see rather than a silence. Normalising the label was the other way out and is not taken: the label is the blueprint's own record id, schools spell their ladders differently on purpose, and nothing would repair the labels already stored.
fix: 🧹 report a dead course once per pump, not once per sectionAhmet Kaan Gümüş · 7bfebea
fix: 🧹 report a dead course once per pump, not once per section A course deleted out from under a blueprint is pruned by the pump that finds it, but the pump looped its sections over the list it read at the start, so twelve sections meant twelve identical skips and twelve prune writes for one dead course — and the rustdoc claimed otherwise. The run now carries what it has found dead, and a blueprint that is itself deleted mid-run ends the loop rather than answering for every section left: the remaining sections would all answer the same. The skips already collected are still returned, because the sections before it did attach.
fix: 🔒 stop a deleted blueprint from stranding the rows it taggedAhmet Kaan Gümüş · b1c8e7a
fix: 🔒 stop a deleted blueprint from stranding the rows it tagged Delete swept the course list the handler had read and then removed the row, so a pump adding a course in between left class_course rows tagged with a blueprint that no longer existed — reachable by nothing, since the sweep is the only thing that reads the tag. Delete now takes a compare-and-set on that list, removes the row first and only then sweeps by the tag itself, so a racing addition is swept too; the pump answers blueprint_deleted rather than landing an orphan, claiming the blueprint inside its own transaction; and BLUEPRINT_LOCK closes what neither could, since SurrealDB does not serialise the pump's cross-record read against this delete. The residue is a process crash between the delete and the sweep, which no lock survives: inert rows, a detach each, counters exact. The pump's created-row slot was hand-counted (7, or 9 on an axis with a pivot claim). The guard would have shifted it silently on the only path that uses the guard, so the statement list is built as a list and the slot is read off its length.
fix: 🏷️ name blueprint skips with codes a client can branch onAhmet Kaan Gümüş · b7a351c
fix: 🏷️ name blueprint skips with codes a client can branch on The pump reported a refused (class, course) pair with an English sentence, which a bilingual client can neither branch on nor translate. Every other enum here is an id plus a client-side label; skips now are too, over a closed set documented on the response schema. No information is lost: Skip already carried the class and the course as their own fields, and neither sentence that named a record ever interpolated it.
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.
feat: 🧑🏫 invite a whole class or club to a boardAhmet Kaan Gümüş · 0e3eae0
feat: 🧑🏫 invite a whole class or club to a board
A board roster was one id at a time, so opening a canvas for a class
meant typing thirty of them and the cap refused an ordinary club.
POST /boards/{id}/invite names a group instead — a class section, a
course (a club is a course), or an event's roster, resolved through the
audience machinery events already had. The ids expand once, into the
same flat participants array: a snapshot, not a subscription. Live
resolution would have made is_participant, the room's door and
list_for_user cross-table queries, and would have taken per-person
removal away from the creator, which is most of what a board roster is
for. The board stores no source, so re-inviting is both how a roster is
topped up and the one thing that undoes a removal.
Additive only; removal stays PATCH. The participant cap moves 50 -> 200
and is all-or-nothing — a partial invite would silently pick which half
of a class gets to draw. Ineligible members (gone, or below student, or
already there) drop silently, because one of them must not fail the
invite for the other twenty-nine.
The gate is not a new permission: a roster is visible to everyone on the
board, so inviting a group discloses it, and each source carries the
gate its own listing route carries. Bulk invite is therefore teacher+;
a student can still build a board by hand but cannot pour a class into
one.
resolve_participants now batches its lookup. It read one row per id,
which at the new cap made a read-modify-write PATCH of a class-filled
board — the ordinary client shape now — two hundred sequential reads.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: 🔩 make ownership a live grant, not a permanent oneAhmet Kaan Gümüş · 8c0ba1e
fix: 🔩 make ownership a live grant, not a permanent one Creating a course, teaching a session, publishing an event, owning a bank template — each of these granted rights forever, whatever role the account held afterwards. `set_role` swept the course *assignment* list on demotion but never the creator link, and none of the ownership helpers re-read the caller's role, so an account demoted to `student` or `parent` kept management of everything it had ever made. That was reachable over plain HTTP, not theoretical. Several routes take `CurrentUser` rather than `RequireTeacher`, so a demoted creator still read draft exams — defeating the 404-not-403 rule that exists to hide a draft's very existence — still listed and read that course's homework, and still saw the course in every catalogue. A demoted session teacher still read their session with no course rights at all. Every ownership arm now carries a live `teacher` floor, enforced inside the helper rather than trusted from the caller: - `can_manage_course` and `owns_course`, plus `visible_courses`, which fed the id sets behind `/courses`, `/exams` and `/homework`; - `is_live_session_teacher`, replacing a bare `session.is_teacher`; - `can_manage` for events and for appointment slots; - `can_see` and `ensure_owner` for the question bank — floored whole, not only on the owner arm, since gating one arm would have left a demoted owner locked out of their own private template while still reading every school-wide one, the strictly larger set. The `creator`, `owner` and `teacher` columns are deliberately not swept. They answer "who made this", which stays true after a demotion; it is the grant that is conditional, not the history. The helpers carried a comment claiming callers had already cleared the teacher bar via `RequireTeacher`. It was false at five call sites and had been since the first `CurrentUser` route was added — nobody rechecks a comment. The appointments copy was false twice over: it justified an exception for `cancel` reaching the helper, and `cancel` is requester-only and never calls it. That phrasing is now extinct in this codebase, which matters more than the individual fixes: a helper that trusts its callers is one extractor change away from this bug. Each floor is pinned by a test that fails when the floor is removed, and the no-orphan side by tests that fail when a floor is made too strict — manager and admin clear the `teacher` bar by definition, so nothing is left unadministerable. The bank's admin arm had a test that passed vacuously, asserting against a school-visible row where the school arm alone would grant; it now asserts on a private template owned by someone else. Verified against the real volume: on unswept rows, a demoted creator loses the catalogue, the draft, the homework and the session, while manager, admin and still-teacher accounts keep everything, and no pre-existing row became unreachable. Left standing: `set_role` still writes the role before its sweeps and they are not one transaction. Every sweep is idempotent and, now that rights are re-read live, grants nothing in the meantime.
chore: 🧹 untrack the surreal CLI history fileAhmet Kaan Gümüş · 2cb4f5f
chore: 🧹 untrack the surreal CLI history file `history.txt` is the SurrealDB CLI's rustyline history, tracked by accident since 44cdf55. It is 2.9 MB of machine-generated SQL, and any knowledge-base query run from the repo root rewrites it — so it rode along in commit after commit as churn no message ever described, and a `git add -A` could fold it into an unrelated change without anyone noticing. Untracked, not deleted: the file stays on disk so the CLI keeps its history, and `.gitignore` now keeps it out of the index for good.
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 leaks a five-domain hunt turned upAhmet Kaan Gümüş · a3fe8cf
fix: 🔩 close the leaks a five-domain hunt turned up Five hunters swept exams, homework/attendance, identity, money/scheduling and messaging/courses; a three-lens verifier panel then refuted three of the first fixes, and those corrections are folded in here. Leaks and races closed: - exam self-review gated on *any* mark, so a seq-1 grade opened the answer key forever — a student mid-retake read `correct` and `is_correct` off the sheet they were still writing. All four review reads now 409 while the caller's latest sitting is in progress. - roll call could land after its session was deleted, and the orphan was unremovable (its delete route 404s on the vanished session) while the attendance report went on counting it. The write now proves its parent exists in the same transaction, the way ExamResult::grade does. - a teacher could counter-propose and then approve their own proposal, committing the requester to a time only the teacher ever named; and even after that, re-proposing between the requester's read and their accept moved the meeting under them. Approve refuses while a proposal stands, and accept now pins the window it is answering. - two concurrent chatbot posts on one thread cross-attributed their answers — both replied to the second prompt, the first was never answered. The prompt id rides the request instead of being re-derived from write order. - a whiteboard participant demoted to `parent` kept drawing, and kept *reading* the live canvas for up to 15s. Every frame is authorized before delivery now, and a demotion sweeps the account off rosters. - a demotion to `parent` stranded event signups no one could free. Promotions are left alone (staff free their own seats) and closed lists are never rewritten. - the rate-limit bucket map was unbounded past 10k live keys and then scanned O(n) under the global mutex on every request. Eviction is bounded and never frees an exhausted bucket — the first attempt did, which traded a memory bug for an auth-bypass, so it is pinned by a test that floods at the victim's own spend. - session and event cascades ran as loose queries; a concurrent write slipped between them and orphaned rows, and for notes a blob nothing could ever reclaim. All three are one transaction now. - sixteen id generators still used Ulid::new(), whose random low bits scramble same-millisecond rows under the "newest first" the docs promise; five listings had no tie-break at all, so offset paging could skip or duplicate a row. Also: $session is a protected SurrealDB 3 variable — binding it fails the whole query as a bare 500, which is what hid the attendance fix. Accepted, documented, not fixed: one bank template instantiated into two exams copies `correct` into both, and the review gate is per-exam.
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.