Commits
2026-09-17
📝 docs: rewrite the Turkish comments and doc comments in EnglishAhmet Kaan Gümüş · 7fec874
📝 docs: rewrite the Turkish comments and doc comments in English The Rust repo's own language is English; Turkish had leaked in from the sibling AI services. Translate every comment and doc comment to English using the code's own vocabulary (şube -> class section, dönem -> term, sınıf öğretmeni -> homeroom teacher, ortak sınav -> shared exam, karne -> report card, …). Quoted Turkish letters/words that are themselves the data under test (the text-fold examples in `text_fold`/`settings`, the non-ASCII filename sample) are kept. The README endpoint table is generated from those doc comments, so it is regenerated. AGENTS.md records the convention going forward: Turkish survives only where it is the data under test or user-visible content.
2026-09-16
✨ feat: the class×course instance is the academic anchor (K-12 remodel)Ahmet Kaan Gümüş · ae84034
✨ feat: the class×course instance is the academic anchor (K-12 remodel)
`course` was a school-wide singleton: enrollment, exams, sessions,
roll-call and homework all keyed on it, so two class sections teaching the same
course shared one roster, one exam set and one timetable. This moves the
academic anchor to `class_course` — the per-class instance — and rebuilds
the academic model around Turkish K-12.
Schema (migrations/school/20260916000001_k12_remodel.sql): `class_course`
becomes an instance (ders_saati, counts_toward_karne, enrollment_count,
class_course_teacher); enrollment re-keys to (class_course, app_user);
exam carries class_course + term (+ exam_audience for shared exams);
course_session / session_attendance / homework re-key; `class_member` is a
soft-leave history table (uuid PK, joined_at/left_at, partial unique index
on the live stint); `academic_year` sits above `term`; `class_group` links
a year, not a term; new `course_membership` (clubs/study), `karne_snapshot`;
settings gain branches/excuse_kinds/absence limits/timezone; profile gains
branch. Drops/recreates the identity-changing tables (pre-customer; the
migration resets every counter on a kept table that pointed at a dropped
one).
Layers: domain/db/service/web rewritten to the instance seam, with
`ensure_instance_teacher` gating instance writes (D10), the report card computed per
instance and weighted by ders_saati, an absence report, `/instances`
and `/academic-years` nests, and `/classes/{id}/instances`. Capacity and
the seat-claim 409 are gone; detach sweeps the whole instance subtree and
unlinks its blob keys.
Gates: cargo check --all-targets, SQLX_OFFLINE check (cache regenerated),
doc_sync, spec_bounds, limits_completeness, clippy -D warnings all green;
cargo nextest run 1370/1370.2026-09-14
✨ feat: compose-stack deploy plus in-tree schema workAhmet Kaan Gümüş · 57fad2c
✨ feat: compose-stack deploy plus in-tree schema work Production deploy is podman compose (postgres + backend + openobserve) instead of a systemd binary. CI stays a throwaway postgres sidecar. Operator credentials live in ~/hezarfen_backend/hezarfen_backend.env (0600); the deploy never writes that file. Also lands the working-tree schema/junction and .sqlx updates that were already sitting next to this change.
2026-09-12
🗃️ feat!: port courses, subjects, terms, enrollments, sessions, attendance to sqlx/PostgresAhmet Kaan Gümüş · f734c6aBrowse files
🗃️ feat: pub fn uuid(&self) accessor on all 34 Uuid id newtypesAhmet Kaan Gümüş · b3ab76fBrowse files
🗃️ fix: appointment.slot nullable ON DELETE SET NULL (dangling-ref booking contract)Ahmet Kaan Gümüş · d9b4e8eBrowse files
2026-09-11
2026-09-05
🗄️ feat: archive academic terms; an archived year is read-onlyAhmet Kaan Gümüş · c4232e6
🗄️ feat: archive academic terms; an archived year is read-only
`Term.archived_at` (nullable, no backfill) plus `POST /terms/{id}/archive`
and `POST /terms/{id}/unarchive` (manager+, idempotent: a repeat archive
keeps the original stamp). While a term is archived its own PATCH/DELETE,
linking a new course or class to it, and every write to a course or
class on it — enrollment, teacher assignment, class membership and
attach/detach/blueprint apply, sessions and roll call, subjects, exams
with their questions, images, attempts and answers, the exam-room
WebSocket door and `finish` frame, grading, homework and submissions,
course notes and files — answer `409` with `code: "term_archived"`.
Reads stay open. The guard is a pre-flight read of the term row: an
archive landing in the same instant as a write lets that one write
through (documented as the third accepted race).
Out of scope on purpose: personal notes, messages, pomodoro, meals,
payments, boards, appointments, chatbot, question pool/bank, events,
blueprint templates, the staff work log, and the role-demotion and
subject-delete integrity sweeps.
Coverage: 155 write routes classified (59 guarded, 93 out of scope);
e2e over real TCP covers archive → refused writes → open reads → the WS
handshake 409 → unarchive; the class refusal-code pin gains
`term_archived`; README prose, tag text and endpoint table regenerated.
Closes #22.2026-08-19
✨ feat: course notes uploadable by responsible teacher+Ahmet Kaan Gümüş · 6b1748c
✨ feat: course notes uploadable by responsible teacher+
Mirror of the personal-note stack scoped to a course: course_note +
course_note_file tables, /course-notes routes (POST/GET list?course=,
GET/PATCH/DELETE /{id}, POST/GET /{id}/files, GET/DELETE /{id}/files/{fid}).
Write = can_manage_course (creator, assigned teacher, manager+; live
Teacher role floor). Read = can_view_course (manage or enrolled).
Blob-first upload, cap via cap::claim_and_create (MAX_COURSE_NOTE_FILES),
create-vs-deleted-course refused via cap::touch_and_create, course delete
cascades note/file rows and unlinks blobs.
Tests: 8 integration cases (authz matrix, demoted creator, cross-course
file IDOR, cap 409/413, blob cleanup, cascade 404), race-contract cases
in regress_course_child_orphans, domain unit tests. README Endpoints
table regenerated via doc_sync; Layout updated.2026-08-13
chore: rename ponytail: comment marker to corner-cut:Ahmet Kaan Gümüş · ed88733
chore: rename ponytail: comment marker to corner-cut: Marker convention renamed after uninstalling the ponytail plugin; semantics unchanged (deliberate corner-cut, known ceiling + upgrade path). Token-only rename, 26 comment lines, no code change.
2026-08-05
🔗 fix: stop a course's children outliving the courseAhmet Kaan Gümüş · 0251364
🔗 fix: stop a course's children outliving the course
Exam, CourseSession and Subject creates were bare db.create calls that
wrote no key the delete cascade writes, so a create racing
DELETE /courses/{id} committed alongside it. The orphans were not merely
stray: every exam route funnels through course_of, which answered 500
forever, so the row was undeletable while still listed to manager+.
Sessions and subjects 404'd the same way.
All three now ride cap::touch_and_create against the course row.
Course::delete also skipped the two bank_question cleanups its per-entity
siblings perform, leaving source_exam and subject pointing at deleted
records — contradicting the documented "null once that subject was
deleted".
Real-server measurement: 4/4 rounds orphaned before, 0/4 after.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.
2026-08-04
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 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.
2026-08-01
2026-07-30
fix: 🔁 retry a guarded cascade that loses a write raceAhmet Kaan Gümüş · 616a66b
fix: 🔁 retry a guarded cascade that loses a write race A BEGIN/COMMIT delete that lost a write conflict answered 500 instead of the refusal or retry it owed. An aborted transaction errors *every* slot, and all but the failing one say a generic "not executed" — the consequence of the abort, never a reason of its own. Picking one of those out of the unordered HashMap from take_errors, or taking the first via check(), retired a retryable round as a database error. Measured on Course::delete at 1-3 of 20 raced rounds against a real server. transaction_with_retry is write_with_retry's story for the cascades that cannot be one statement: it matches the caller's THROW markers first, since a THROW is a decision and outranks a conflict, then re-sends while any slot reports a lost round. It hands back both the response and the drained errors because take_errors consumes and the caller needs the slots as well as the map. Course, Subject and Exam route through it; Exam also loses the check() that was masking the conflict behind a sibling slot. Term needed none of it — it is a single statement, so the existing write_with_retry was the whole fix. Four ignored race tests come with it. Only the course one discriminates, proven by cutting the retry loop to a single attempt and watching it go red; the other three guard their handlers' status codes and say so on themselves rather than implying a measurement they do not make. They share a lock so the documented invocation works.
chore: 🧹 drop the coordination for replicas we never runAhmet Kaan Gümüş · a9cfe7b
chore: 🧹 drop the coordination for replicas we never run The backend runs as one process against one database, deployed stop-the-world. The machinery that let several of them agree was built ahead of a multi-replica rollout that stayed parked, so none of it was ever load-bearing: the boot lease elected a leader out of a field of one, the ai_worker table announced a worker to nobody, and the chat claim queue only ever claimed its own writes. Boot now migrates and seeds straight-line; a chat turn is dispatched by the handler that accepted it; the 503 gate reads the in-process registry. The retired columns and tables are unset and removed in separate batches, repair before REMOVE. What stays, with its reason corrected rather than removed: cap.rs, field_update.rs, the refcounts, the CAS retry loops and the in-process locks. Those close write skew between concurrent requests inside one process, which two replicas made worse but never caused. A turn orphaned by a restart or a panic is no longer reclaimed. It settles as timed_out within CHATBOT_PENDING_STALE_SECS. The design survives in the ledger if a second process is ever wanted.
2026-07-27
fix: 🧷 close the cross-table races the locks never closedAhmet Kaan Gümüş · 4f7bdaf
fix: 🧷 close the cross-table races the locks never closed
Every remaining check-then-write that spanned tables becomes a
single-record conditional write, so it holds across replicas:
- subject delete: refcounts (exam_question_count/homework_count) claimed
and released by every question/homework write; the triple lock hold
dies, BANK/TERM/ENROLL locks die outright
- exam kinds: kind_ref {count,retired} records; grading claims, removal
retires only at zero — grading a removed kind and re-kinding a graded
exam are now 409 (both previously silently mis-weighted marks)
- homework: the grade stamps the submission row in its own transaction;
student writes are conditional on the stamp being absent
- appointments: slot occupancy is a cap-1 counter; the lock survives
only for the within-replica approved-overlap check
- meals: seat counter + menu version CAS (price can no longer tear mid
booking) + deterministic menu:date_slot id kills duplicate publish
- cap::claim_and_create: member gate, then seat, then child CREATE in
one transaction — a duplicate loser no longer eats a stranger's seat
or gets refused for a row it already owns
- boot: the two unguarded lease statements now retry on transaction
conflict (the escape was ~1-in-15 under full-suite load)
Two races reviewed and accepted, documented in README ## Concurrency
model: the attempt-seq late save (one history row, grade of record
untouched) and cross-replica approved-overlap (visible, cancellable).
Deployment contract (README): counter-adding releases restart all
replicas together — an old binary's writes skip new counters and the
= NONE backfill guard rightly refuses to re-seed.
Every guard is mutation-proven; backfills are one-time, = NONE-guarded,
ordered after the destructive sweeps, and verified against the live
volume.fix: 🪢 guard writes in the database, not the processAhmet Kaan Gümüş · 6c87eca
fix: 🪢 guard writes in the database, not the process
Two replicas are live; every process-local lock silently stopped
meaning anything. Move the invariants into the writes themselves:
- count caps (enroll/register/files/threads) become a counter column
claimed by UPDATE .. WHERE n < cap (domain/cap.rs), backfilled once,
decremented in the same transaction as every child delete
- exam freeze, re-draft and grade gates ride inside the write's own
transaction (IF .. THROW); SESSION/WORK_ENTRY/EVENT locks die, range
checks fold into the UPDATE's WHERE (FieldUpdate::ordered)
- appointment decisions CAS on status+proposed window+decided_by;
bank/exam updates CAS on their editable columns
- rate limiter syncs local windows to a shared minute row every 2s,
fail-open when the database is down
- paged GETs run LIMIT/START in the database (domain/page.rs); sites
that post-filter in Rust stay web-sliced and say so
- exams.rs (3629 lines) splits into web/exams/{mod,attempts,questions,
images,review}; image uploads single-source in web/image.rs; the
bare-seq key rule lives once in domain/key.rs; migration SQL moves
to migration_sql.rs
Every new guard is mutation-proven (removing it fails a named test).
Migration adds counter columns + rate_limit table; backfill is
one-time, guarded by = NONE, and verified against the live volume.
Traps recorded: SurrealQL 'x ?? 0 > 0' parses as 'x ?? (0 > 0)'; the
embedded mem engine drops one of two concurrent writes yet answers Ok.2026-07-26
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
🎨 style: cargo fmt the tree before the audit fixesAhmet Kaan Gümüş · b4a5a00
🎨 style: cargo fmt the tree before the audit fixes Pure reformatting, no behaviour change: rustfmt wrapping plus its alphabetical `use`-list reordering across the files that had drifted. Kept separate so the correctness commits that follow carry only logic.
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
fix: 🔒 drain the whole-row save backlogAhmet Kaan Gümüş · 19ba18a
fix: 🔒 drain the whole-row save backlog - a whole-row .content(self) reverts any write that landed between the struct's read and its save; the gate flagged 14 sites and this empties it - course.rs was the only genuinely raceable one, in both directions: teachers[] is written by assign, unassign and the demotion sweep while Course::update rewrites the text columns, so staffing a course reverted a concurrent rename and a rename dropped a concurrent assignment. Both reproduced as failing tests first - assign/unassign now use array::distinct(array::append(...)) and teachers -= $usr rather than rewriting the array from a stale read - session, event, note, term, homework and work-entry updates are each their row's only writer and rewrite every mutable field, so no failing interleaving exists today; converted defensively anyway, following Subject::update, and not test-proven - the five create/upsert sites are annotated instead: each builds its struct in place from the request and never reads it back
2026-07-22
2026-07-21
feat: 🎨 student answer-image endpoints mirroring question imagesAhmet Kaan Gümüş · 2c83c6f
feat: 🎨 student answer-image endpoints mirroring question images
- new AnswerImage domain keyed by (exam, user, question), stored as an
image/png blob with upsert-overwrite, mirroring QuestionImage
- routes: POST/DELETE/GET /exams/{id}/attempt/answers/{qid}/image (student
own, gated by the save_answer writable-attempt chain) and GET
/exams/{id}/attempts/{user}/answers/{qid}/image (teacher grading)
- answer_image (Option<ImageMetaResponse>) on the student sitting view and
the teacher grading sheet; live monitor and exam_ws untouched
- a drawing-only answer creates a blank text answer row so the drawing
surfaces in both views; removing the drawing grooms that blank row away
- cascade blobs+rows on exam delete, course delete, and retake wipe (rows
in the wipe transaction, blobs swept in start_attempt)
- integration tests: raster wall, own/teacher auth walls, upsert, retake +
exam-delete cascade, drawing-only surfacing and its cleanup✨ feat(courses): manager-assigned course teachersAhmet Kaan Gümüş · 5ff771b
✨ feat(courses): manager-assigned course teachers
A course used to have exactly one manager: its creator. A teacher taking
over someone else's class needed manager+, which is the wrong bar for
ordinary staffing.
Courses now carry a `teachers` list alongside the (still immutable)
`creator`. Manager+ assigns and unassigns via POST/DELETE
/courses/{id}/teachers; the assignee must already hold teacher+, since
every gate behind the assignment re-checks that bar anyway.
The rights split in two:
- can_manage_course: creator, assigned teacher, or manager+. Everything
inside the course — edit, enroll, exams, sessions, subjects, grading,
roll call. Every existing gate routes through this one helper, so
assignment reaches all of them at once.
- owns_course: creator or manager+ only. Deleting the course and changing
who teaches it. An assigned teacher runs a course; they don't own it,
and can't delete it out from under the person who made it.
Staffing is deliberately manager-only: a course's own creator cannot hand
management rights to their peers.
Stale data: rows written before the field decode as unassigned (a serde
default on the field) and the boot backfill fills them to []. DDL and
backfill stay in separate batches — sharing one silently strips keys on
SurrealDB 3. Verified against the real volume, not just the in-memory
tests: a legacy-shaped row backfilled, rendered, and took an assignment.
A demotion below teacher sweeps the user off every course they were
assigned to, mirroring how promotion drops enrollments.2026-07-19
✨ feat(exams): images on questions and choice optionsAhmet Kaan Gümüş · dbeb122
✨ feat(exams): images on questions and choice options Teachers pin one illustration to any question (the map above the prompt) and one picture per option on choice questions — the options themselves can be images. Multipart upload per slot, replace by re-upload, frozen with the question once attempts exist. - rows in question_image (deterministic id per slot, UPSERT = replace); blobs beside note files under FILES_PATH, capped by max_file_bytes - raster allowlist png/jpeg/webp/gif — SVG can script and these bytes render inline to students; served with nosniff + private, no-store - students fetch bytes behind the sitting wall (enrollment + started attempt, no early peek); course managers anytime - replacing a question's choices drops its option pictures (the illustration stays) — old pictures belong to the old options - blob cleanup wired into image replace/delete and question, exam, and course deletes (exam cascade result slot shifted 5 -> 6)
2026-07-17
✨ feat(subjects)!: course subjects, required on every exam questionAhmet Kaan Gümüş · 022aaaa
✨ feat(subjects)!: course subjects, required on every exam question
Each course now owns its curriculum as subjects (name + optional
description; course link fixed at creation). Every exam question must
be tagged with a subject of its exam's own course, so exam content is
attributable to a topic.
- POST/GET /courses/{id}/subjects (manage / course-visibility, paged)
- GET/PATCH/DELETE /subjects/{id}; delete is a 409 while any question
still references the subject — re-tag or delete those questions first
- course delete cascades its subjects
BREAKING: question create/update payloads require subject_id, and
questions written before subjects existed are destroyed on boot
(answers first) — nothing truthful to backfill, pre-customer clean
break.2026-07-16
✨ feat(courses): add kind course|study (supervised study)Ahmet Kaan Gümüş · f29537c
✨ feat(courses): add kind course|study (supervised study) Supervised study sessions are courses under a different label: `kind` is settable at creation, PATCH-editable, and returned on every course response. Behavior (enrollment, exams, sessions, marks) is identical for both kinds. Boot backfills pre-kind rows to `kind = 'course'`; new writes default the same way.
2026-07-14
✨ feat(exams)!: move weight off exams onto their kindAhmet Kaan Gümüş · 3681441
✨ feat(exams)!: move weight off exams onto their kind
Weighting is school policy, not per-exam data: each settings
exam_kinds entry is now {name, weight} (1-100, defaults all 1) and
mark reports resolve weights at read time, so editing a kind
reweights every exam of that kind at once; an exam keeping a
since-removed kind counts as 1.
BREAKING CHANGE: exams lose `weight` on the wire and in storage,
settings `exam_kinds` become objects. No data migration (pre-customer
clean break) — delete ./data/hezarfen.db and reboot.2026-07-13
✨ feat(school): editable policy settings + academic termsAhmet Kaan Gümüş · ea8bfeb
✨ feat(school): editable policy settings + academic terms Every school differs; the varying parts become data instead of code: - settings singleton (GET any user, PATCH manager+): exam kinds, attendance statuses, grade-display bands. Absent row = old hardcoded defaults, so existing databases behave unchanged. - core four attendance statuses stay mandatory — the attendance rate is defined over them; school extras tally rate-neutral under a new `custom` bucket in reports. - grade bands are display-only over the canonical 0-100 marks: reports gain grade/average_grade/overall_grade labels, stored marks never change with the display scale. - terms are rows (semester/trimester/quarter all fit); courses link via nullable term_id, term delete unlinks, past dates allowed for mid-year calendar backfill. - settings edits never rewrite stored rows: retired kinds and statuses live on in old records; only new writes validate against the current lists.
2026-07-12
✨ feat(authz): wall course reads behind enrollment and ownershipAhmet Kaan Gümüş · ed007d9
✨ feat(authz): wall course reads behind enrollment and ownership
Students could read any roster, roll call, and event attendance; any
teacher could read any exam's results, statistics, live monitor,
answer sheets, and answer key (correct included), plus full
marks/attendance reports of any user.
- can_view_course = enrolled | creator | manager+; the /courses and
/exams catalogs filter per caller (list_created, list_for_courses)
- course sub-reads (roster, results, statistics, live, questions,
answer sheets) require course-management rights
- roll-call and event rosters become teacher+ views; students keep
/attendance/me and /marks/me
- /marks/{user} and /attendance/{user} narrow to the courses the
caller manages; manager+ still sees the full report✨ 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✨ feat(exams): scheduled attempts, live monitor, questions, answers, exam roomAhmet Kaan Gümüş · ade4fed
✨ feat(exams): scheduled attempts, live monitor, questions, answers, exam room
- exam scheduling as one validated unit: mode sync|async + window
(+ per-student duration_ms for async); unscheduled stays offline-graded
- exam_attempt: one row per exam+user by composite id; start = attendance
signal, finish = submission; status/deadline recomputed from the current
schedule on every read (mode frozen once attempts exist, times extend live)
- teacher live monitor: GET /exams/{id}/live snapshot + SSE /live/stream
- exam_question: choice|text authored per exam, kind bundle (choices+correct)
validated as a unit, frozen once attempts start, ULID order
- exam_answer: upsert per question+user via composite id, kind-coherent,
server-clock stamped; pure auto_score over choice questions as a grading
suggestion — final mark stays human via /results
- student exam room WebSocket at /exams/{id}/attempt/ws: state ticks,
autosave acks, finish/expire lifecycle, gates rejected pre-upgrade with
proper HTTP statuses; shares the REST write path
- PersonRef embeds (id + username + display name) in people-bearing
responses, plus teacher+ GET /users/search
- cascades: exam/course deletes sweep attempts, questions, answers, results2026-07-11
✨ feat(courses): courses, enrollment, and course-scoped weighted examsAhmet Kaan Gümüş · cd56c5b
✨ feat(courses): courses, enrollment, and course-scoped weighted exams
Courses become the unit exams and enrollments hang off. Teachers create
them; editing, deleting, enrolling, and adding exams require course
management rights (creator, or manager/admin). Enrollment rows use a
deterministic composite (course, user) id, so enrolling is one atomic
idempotent UPSERT with no find-then-insert race. Deleting a course
cascades its exams, their results, and enrollments in one transaction.
Exams move inside a course (POST /courses/{id}/exams) and gain a weight
(1-100) that says how many times they count into the course average;
kinds grow to homework, quiz, midterm, final, project, and oral —
informational only, weight drives the math. Grading now demands course
management rights and an enrolled target; moving an exam between
courses is deliberately impossible so results can't be stranded.
Routes: courses CRUD, GET /courses/me for the caller's enrollments,
roster listing, enroll/unenroll, and per-course exam creation/listing.