Commits
2026-09-11
2026-09-05
✨ feat: one database per school behind a control registry; login names the schoolAhmet Kaan Gümüş · b7dfc0c
✨ feat: one database per school behind a control registry; login names the school Namespace `hezarfen` now holds one DATABASE per school (name = slug) plus a `control` database with the school registry, builder accounts and builder sessions. `Tenants` keeps one separately-connected handle per school; the shadow `web::tenant_state::State` resolves the school from the `<slug>.<token>` cookie so every handler's `st.db` is school-scoped by construction. `POST /auth/login` / `register` carry `school`; a suspended school answers 403 everywhere. `BUILDER_USERNAME`/`BUILDER_PASSWORD` seed the vendor account; the boot admin seed is gone. No customers, no compat shims.
2026-08-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.
2026-07-27
fix: 🪢 guard writes in the database, not the processAhmet Kaan Gümüş · 6c87eca
fix: 🪢 guard writes in the database, not the process
Two replicas are live; every process-local lock silently stopped
meaning anything. Move the invariants into the writes themselves:
- count caps (enroll/register/files/threads) become a counter column
claimed by UPDATE .. WHERE n < cap (domain/cap.rs), backfilled once,
decremented in the same transaction as every child delete
- exam freeze, re-draft and grade gates ride inside the write's own
transaction (IF .. THROW); SESSION/WORK_ENTRY/EVENT locks die, range
checks fold into the UPDATE's WHERE (FieldUpdate::ordered)
- appointment decisions CAS on status+proposed window+decided_by;
bank/exam updates CAS on their editable columns
- rate limiter syncs local windows to a shared minute row every 2s,
fail-open when the database is down
- paged GETs run LIMIT/START in the database (domain/page.rs); sites
that post-filter in Rust stay web-sliced and say so
- exams.rs (3629 lines) splits into web/exams/{mod,attempts,questions,
images,review}; image uploads single-source in web/image.rs; the
bare-seq key rule lives once in domain/key.rs; migration SQL moves
to migration_sql.rs
Every new guard is mutation-proven (removing it fails a named test).
Migration adds counter columns + rate_limit table; backfill is
one-time, guarded by = NONE, and verified against the live volume.
Traps recorded: SurrealQL 'x ?? 0 > 0' parses as 'x ?? (0 > 0)'; the
embedded mem engine drops one of two concurrent writes yet answers Ok.2026-07-25
fix: 🔐 a partial PATCH can no longer invert a rangeAhmet Kaan Gümüş · 352b0b0
fix: 🔐 a partial PATCH can no longer invert a range - regression from the previous commit: writing only the field a request carried meant an event's schedule and a work stint's clock were each checked against a stored other end that a concurrent request had already changed, so two individually valid PATCHes committed starts_at > ends_at (or check_in > check_out), both 200 - the old snapshot refill hid this by always writing a consistent pair; the parent commit passes the same attack, this one did not - add EVENT_LOCK and WORK_ENTRY_LOCK and hold them across read → range check → write, but only when a range field actually arrives, mirroring what terms already did correctly - both locks are leaves: their only holders take no other lock and no other lock holder takes them, so the documented EXAM → BANK and EXAM → HOMEWORK orders are unaffected - omitted fields are still never written; the lock guards the check, it does not license writing back what was only read - regression tests race one end against the other and assert the stored pair is ordered whatever each request returns
fix: 🧩 a PATCH writes only the fields it was givenAhmet Kaan Gümüş · 85b408e
fix: 🧩 a PATCH writes only the fields it was given - every PATCH handler loaded the row and refilled the fields the request omitted from that stale snapshot, so two concurrent partial PATCHes touching different fields lost each other: whoever wrote last silently reverted a field it was never asked to change - field-scoping the write did not fix this — the value bound to the SET still came from a stale read - add domain/field_update.rs: .set(column, Option<T>) skips an absent field entirely, so it is neither written nor bound, and an all-absent PATCH writes nothing at all - convert notes, events, terms, homework, work entries and courses, each with a 20-round concurrent-PATCH regression that fails against the old code on round 0 and passes after - nullable columns stay clearable: an event's schedule, a course's capacity and term, and homework's assigned subset keep the double-option so an explicit null still writes NONE, while an omitted field is left alone - homework's old fallback was worse than a no-op: it could re-narrow the assigned subset over a concurrent widening, behind the guard that exists to stop exactly that - cross-field validation still reads the stored row where it must (event and term ranges need both ends) — read for the check, never written back - HOMEWORK_LOCK was taken after the row read, so it never covered the read-modify-write it looked like it guarded
2026-07-15
✨ feat(web)!: paginate every list endpointAhmet Kaan Gümüş · f3d2b0a
✨ feat(web)!: paginate every list endpoint
Every array-returning GET now accepts `?limit=&offset=` and returns a
`{ items, total, limit, offset }` envelope instead of a bare array.
Paging is opt-in: omitting `limit` returns the full list (limit echoes
null), so callers that need the whole set — an exam's questions during a
sitting, roster/grade pickers — are never silently truncated. `total`
always carries the unpaged count, so a frontend can render "100 of 256"
and drive a pager without a second request.
Windowing is a slice over the already-ordered domain list (the domain
layer is untouched); endpoints that embed people run that join over the
page alone. `limit` must be 1..=500 and `offset` >= 0 (else 400); an
offset past the end yields an empty page, not an error.
Covers all 17 list GETs, including /courses/me, /work/me, /work/{user},
and /users/search — whose hard 10-row cap is dropped in favour of the
same paging. Not paged: /exams/{id}/attempt/{questions,answers}, the
marks & attendance report objects, /exams/{id}/live, and /settings.
Shared machinery lives in web::page (Page<T>, PageParams, paginate).
Docs updated across the OpenAPI spec (utoipa query params + Page_*
response schemas), the Swagger UI it feeds, and the README (a Paging
section plus a `· paged` tag on every list row).
BREAKING CHANGE: list endpoints return a pagination envelope, not a bare
JSON array — clients must read `.items`. /users/search no longer caps at
10 results.2026-07-14
🐛 fix: bind room writes to their sitting, wall unenrolled sittersAhmet Kaan Gümüş · 3375565
🐛 fix: bind room writes to their sitting, wall unenrolled sitters Four bugs, each reproduced by a failing test first: - A stale exam room's answer/finish acted on the *latest* attempt, so a lingering socket from a finished sitting could scribble on — or instantly submit — a retake it never hosted, burning a limited sitting. Messages now refuse any sitting but the room's own. - The sitting's content endpoints (GET /attempt/questions, POST /attempt/answers) skipped the enrollment wall that guards the room door and the attempt start, so an unenrolled ex-student kept the question list and a writable answer sheet forever. Both are 403 now; finishing stays open, exactly like under a closed rejoin door. - PATCH /settings merged over a snapshot and wrote the whole row back, so concurrent edits of different fields silently reverted each other. Saves are compare-and-set against the merged-from snapshot now, re-merging on refusal (409 only when still contended). - Work-entry duration_ms overflowed i64 on absurd manager-corrected instants — a panic in debug, a wrapped negative in release, and a row that 500d every later read. The subtraction saturates now.
2026-07-12
✨ feat(attendance): course sessions, roll call, work log, reportsAhmet Kaan Gümüş · 5b6aac1
✨ feat(attendance): course sessions, roll call, work log, reports
- course_session: a course's lesson (teacher, topic, required starts_at,
optional ends_at); managed under course rights like exams; explicit
teacher_id must hold teacher+; lists ordered by starts_at (timetable)
- session_attendance roll call: one row per session+user by composite id,
course denormalized so reports need no join; students never self-mark —
the session's teacher or a course manager marks enrolled students, and
the teacher's own presence row is manager+ only (no self-declared
presence); session/course deletes cascade roll-call rows
- work_entry staff timesheet (teacher+): check-in/out stamped by the
server clock only, so a client clock or crafted request can't forge
presence; one open stint per user held atomically — INSERT IGNORE on
the deterministic open_{user} id, check-out takes it via DELETE RETURN
BEFORE and re-files under a ULID; manager+ reads any log, corrects
closed stints (ordered instants), deletes entries
- attendance reports at /attendance/me and /attendance/{user} (teacher+),
mirroring the marks report: event tallies + session tallies +
per-course breakdown; rate = (present+late)/(present+absent+late) —
late attends, excused counts against no one; unenrolling hides marks
but never absences (attendance is a historical record)
- RequireManager extractor; check_time_range shared by events/sessions