forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on af331ecc8a4a0c661bcdbc905b95bb2cf77a72deFiltered to src/web/extractor.rsClear filter

2026-09-11

🧹 chore: split profile, badge, builder into domain/db/service layersAhmet Kaan Gümüş · 7f616c0
🧹 chore: split profile, badge, builder into domain/db/service layers

C3 identity lane. Moves, not rewrites:

- badge: BadgeStats::load / BadgeAward::list_for / sync (UPSERT with the
  earned_at = NONE idempotency stays whole) -> db::badge, with the
  award-key mint and the persistence tests; BadgeStat/BadgeStats/earned/
  BadgeAward (pure rules) stay in domain::badge; service::badge wraps
  list_for/sync for the web layer.
- profile: ProfileStats::load (+ PomodoroTotals, persistence tests) ->
  db::profile; newtypes + getters stay; service::profile::load wraps.
- builder: find_by_username/read/create(create_session)/find_by_token/
  delete_by_token -> db::builder; the idempotent seed ensure ->
  service::builder (ensure_admin precedent); both tests ride their fns.
- preferences, key: fully pure (validated newtypes, composite-id
  helpers) — stay domain-only, no db/service modules created.

Entity fields the split constructs from are now pub(crate) (Builder,
BuilderSession, ProfileStats), matching the user split.

Callers re-pointed crate-wide: web/{users,exams/mod,questions,homework,
sessions,auth,extractor,builder,tenant_state}, service/exam_attempt.rs
(badge::sync after start), database.rs (control seed), tests/
{builder_api,e2e,integration}; cross-lane compile fixups in
domain/pomodoro.rs and domain/session_attendance.rs (their lanes
re-point on merge). constant.rs doc link -> crate::db::badge::list_for.
🧹 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: per-school modules; a disabled module answers 403 on every route in its nestAhmet Kaan Gümüş · 5d7f87c
✨ feat: per-school modules; a disabled module answers 403 on every route in its nest

Twenty-one modules, one per router nest, with an explicit dependency graph
derived from the record links (exams need courses and subjects, marks need
exams, …) and four packages for the catalog. The enabled set lives on the
school's control row and rides the tenant resolution that already happens
once per request; every nest carries a route_layer gate, the four child
creates inside /courses are gated by their own module, and the AI blob
stream refuses `module_disabled` when course notes are off.
✨ 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-12

2026-07-19

🐛 fix: authz holes and stale-read races from the bug huntAhmet Kaan Gümüş · de938d8
🐛 fix: authz holes and stale-read races from the bug hunt

- messages: a PATCH rejected on the folder no longer half-applies the
  read flag; the whole body validates before any write
- messages: the delete-from-trash gate rides in the UPDATE's WHERE
  instead of a check-then-act window
- notes: all nine handlers now require the student role — the read-only
  parent role could create notes and upload files (new RequireStudent)
- reports: a parent link whose student side changed role is inert;
  ensure_can_observe re-reads the target's live role like enrollments
- exams: update_exam takes the EXAM_LOCK writer lease before reading
  the row its merge defaults and draft/mode gates judge

Re-link keeping one tie while linked_by moves to the latest linker is
deliberate (matches re-enroll); doc reworded to say so.

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

2026-07-11

✨ feat(web): axum handlers, DTOs, and auth extractorsAhmet Kaan Gümüş · 3c4822c
✨ feat(web): axum handlers, DTOs, and auth extractors

The HTTP layer over the domain. DTOs are plain strings on the wire;
handlers parse them into validated newtypes before touching the
database. Responses share one UserResponse shape (id, username, role).

Auth is a session cookie: login sets an HttpOnly, SameSite=Lax
`session` cookie (Secure when configured) backed by a server-side row;
logout is idempotent. Extractors encode access control by type —
CurrentUser for any logged-in caller, RequireTeacher / RequireAdmin
for role-gated routes — with the role re-read every request so a change
takes effect on the next call.

Routers: auth (register/login/logout/me), users (admin listing + role
changes), notes (per-user CRUD), events + attendance, and exams +
results. Ownership and role rules live in the handlers: event/exam
edits are creator-or-manager+, grading is teacher+ and never targets
oneself, and admins can't change their own role.