Commits
2026-09-12
2026-09-11
Merge branch 'layer-split/exam_artifacts'Ahmet Kaan Gümüş · 312f795
Merge branch 'layer-split/exam_artifacts' # Conflicts: # src/db/exam_attempt.rs # src/db/mod.rs # src/domain/attendance.rs # src/domain/chatbot_thread.rs # src/domain/homework_submission.rs # src/domain/session_attendance.rs # src/service/course.rs # src/service/mod.rs # src/web/exams/mod.rs
🧹 chore: split exam_answer/exam_result/answer_image/question_image into domain/db/service layersAhmet Kaan Gümüş · 61990deBrowse files
🧹 chore: split message/parent_link/registration into domain/db/service layersAhmet Kaan Gümüş · f820c36Browse files
Merge branch 'layer-split/user'Ahmet Kaan Gümüş · f30faee
Merge branch 'layer-split/user' # Conflicts: # src/domain/appointment_slot.rs # src/domain/exam_question.rs # src/domain/user.rs # src/service/course.rs # src/web/courses.rs # src/web/sessions.rs
🧹 chore: split note/session/settings into domain/db/service layersAhmet Kaan Gümüş · efea304
🧹 chore: split note/session/settings into domain/db/service layers
Pilot wave of the three-layer split. All query execution for the three
domains now lives in src/db/{note,session,settings}.rs as free fns taking
db first; web handlers call service::<x>::* only; domain keeps pure types.
- service/settings.rs gains the PATCH workflow (apply) and SETTINGS_LOCK —
it spans a multi-call pair (retire names, CAS save, restore), so it is a
service lock, not a db lock. The service takes its own input records
(SettingsPatch/*Input) so wire DTOs stay in web and list validation keeps
its original order, including the try_kept grandfathering that needs the
stored list.
- Note/Session/Settings fields the db layer mints or CAS-binds become
pub(crate); Settings::record_id becomes pub(crate).
- Unit tests rode with their fns: note delete cascade → db/note, session
purge → db/session, settings load/save/CAS → db/settings, the whole
settings edit workflow suite → service/settings.
- Doc links re-pointed (user, class_blueprint, bank_question, exam,
note_file, tests/regress_roles); NoteId::generate's stale
'Note::list_for_user' link now names db::note::list_for.
- Known residual for a later wave: web/notes.rs:411 file.delete() is
note_file-domain persistence (note_file splits in C3).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-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-21
✨ 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(users): read-only parent role with student tiesAhmet Kaan Gümüş · ec44315
✨ feat(users): read-only parent role with student ties
Parent sits below student in the hierarchy: clears no staff bar and
fails every exact student gate, so it can only observe. Admins tie
students to a parent under /users/{id}/students; the tie alone opens
the student's marks/attendance/pomodoro reports (full, unnarrowed)
plus the parent's own /users/me/students list. A role change off
either end of a tie sweeps it, mirroring the enrollment sweep.✨ feat(courses)!: embed the creator as a person refAhmet Kaan Gümüş · c996ce4
✨ feat(courses)!: embed the creator as a person ref
CourseResponse.creator was a bare user id, so the frontend catalog
resolved names by downloading users separately — a call that broke
with the blank-q rule and left students seeing raw ULIDs. Courses now
join the creator on like sessions and enrollments already do: one
person_map over the page's creators, PersonRef::resolve degrading to
the bare id if the row is gone.
BREAKING: course payloads return creator as {id, username,
display_name} instead of a string.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 report2026-07-11
✨ feat(marks): weighted mark reports per course and overallAhmet Kaan Gümüş · ebc1bd2
✨ feat(marks): weighted mark reports per course and overall
GET /marks/me gives any authenticated user their own report; GET
/marks/{user} (teacher+) reads anyone's, 404 for unknown users. For
each enrolled course the report joins the course's exams with the
user's graded results: per-exam entries (title, kind, weight, mark,
grader), a Σ(mark×weight)/Σ(weight) course average, and a plain mean
of course averages overall. Ungraded exams don't appear, averages stay
null until something is graded, and unenrolling hides a course's block
without deleting result rows.
ExamResult::list_for_user_in_course supplies the raw rows behind each
course block.