forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/validate.rsClear filter

2026-07-29

fix: 🔁 make a retried payment one payment, and page the statementAhmet Kaan Gümüş · 4fe02bc
fix: 🔁 make a retried payment one payment, and page the statement

A client that resends POST /payments/credits or /refunds after a
timeout may now carry a request_key; the line's id derives from
(target, kind, key), so the replay reads back the recorded line
instead of minting a second one, even when it filled the charge to
the brim. Same key with a different amount or target is answered 409
— the stored line never bends to a retry. Keys are letters, digits
and '-' only: '_' joins id parts, so a key like 'abc_r' could spell
another line's reversal id; append() now also refuses to hand back a
line of another kind, turning any future grammar slip into a 500
instead of money on the wrong line.

Statements page their per-charge rows through the usual
?limit&offset envelope; the balance and every rollup still fold the
whole ledger before the window is cut.

2026-07-22

2026-07-19

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(exams): open mode, attempt limits, retakes, rejoin doorAhmet Kaan Gümüş · 9835fe7
✨ feat(exams): open mode, attempt limits, retakes, rejoin door

Unscheduled exams were dead ends: attempts answered 409 "nothing to
sit", and every exam was hard-wired to a single sitting.

- mode "open": sittable anytime, no window; duration_ms optional per
  attempt (absent = unlimited time). Modeless exams stay offline
  drafts — still 409, so a student can't freeze a draft's questions.
- max_attempts (0 = unlimited, default 1): terminal attempts can be
  followed by numbered retakes that start from a blank answer sheet;
  the previous sitting's answers are wiped on the next start.
- allow_rejoin: live teacher toggle. Leaving the exam room (WS close
  mid-attempt) stamps left_at; with the door closed, re-entry and all
  saves 409 until reopened. Finish stays allowed either way.
- Attempt deadline generalized to min(ends_at, started_at + duration),
  either side optional; none = ends only by submission.

Boot migration backfills max_attempts/allow_rejoin/seq on existing
rows and replaces the single-attempt unique index (exam, user) with
(exam, user, seq) via REMOVE INDEX IF EXISTS. Sitting #1 keeps the
legacy {exam}_{user} record id, so pre-upgrade attempts stay valid.
✨ 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.
✨ feat(auth): strict username charset + reserved namesAhmet Kaan Gümüş · 4384914
✨ feat(auth): strict username charset + reserved names

Usernames accepted any ASCII between the length checks — control
characters, spaces, quotes, and HTML metacharacters all passed, which
enables log injection (\n, ESC), lookalike impersonation ('admin
support'), and stored XSS wherever a frontend renders names unescaped.

- allowlist: lowercase letters, digits, single interior . _ -
- must start and end with a letter or digit; no consecutive separators
- staff-looking names (admin, administrator, root, support, system,
  moderator, staff) rejected at /auth/register only — the
  ADMIN_USERNAME bootstrap still seeds them through the same newtype
- duplicate-register 409 kept: usernames are public handles, the
  existence leak is deliberate

Existing rows are not revalidated or migrated.

2026-07-12

✨ 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, results

2026-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.
✨ feat(profile): optional personal info on user accountsAhmet Kaan Gümüş · baceaf5
✨ feat(profile): optional personal info on user accounts

Every account (any role) gains name, surname, email, phone, and birth
date as optional fields backed by validated newtypes: PersonName keeps
unicode and trims, Email and Phone get pragmatic shape validators, and
BirthDate parses real calendar dates in YYYY-MM-DD form and refuses the
future. Existing rows read back as None via option<string> columns.

Endpoints: PATCH /users/me lets any authenticated user edit their own
info; GET /users/{id} and PATCH /users/{id}/profile give admins the
school-office path for maintaining records. Patch semantics per field:
omitted keeps the current value, an empty string clears it, anything
else is validated and set. UserResponse now carries the new fields.
✨ feat(core): error taxonomy, field validators, and limitsAhmet Kaan Gümüş · 90effd1
✨ feat(core): error taxonomy, field validators, and limits

Foundations shared by every layer.

constant.rs centralizes the validation bounds — username/password
lengths, free-text caps, the closed sets of attendance statuses and
exam kinds, the mark range, and the session lifetime — so no limit is
hardcoded twice.

error.rs defines ValidationError and the single AppError enum, plus
its IntoResponse: each variant maps to one status code and the uniform
`{ "error": ... }` body. TooManyRequests carries its Retry-After;
Db/Internal are logged and answered generically so no internals leak.
argon2 hashing failures fold into Internal.

validate.rs holds the field validators every newtype's try_new runs
before wrapping a value — parse, don't validate. Lengths are counted
in characters, not bytes, and usernames are trimmed first so padding
can't defeat the minimum.