forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/web/messages.rsClear filter

2026-09-25

✨ feat(api): server-side filters on the list doorsAhmet Kaan Gümüş · d8dad92
✨ feat(api): server-side filters on the list doors

A caller no longer has to download a capped collection and narrow it
in the client:

- events, exams: the WindowParams pair is SQL (no whole-table load)
  and gains starts_before/ends_before, so a past/completed view is
  expressible
- sessions: starts_after/starts_before, half-open months
- homework: due_after/due_before (the open/past tabs), class_course
- meals menus: slot (was a post-page JS filter — page counts lied)
- users (admin): roles= comma set; courses: kind, q, taught
- appointments + slots: teacher (or me), starts_after/starts_before,
  status
- pomodoro log: from/to, with the focus total summed in SQL
- messages and boards: q (folded literal substring)
- pool questions: ?status= is a WHERE, not a post-filter
- bank/course-notes id filters: garbage is a 400 naming the field,
  not an empty page

Absent params return today's response byte-shape; page and count
share one WHERE.

2026-09-20

✨ feat(users): give students a school-issued student numberAhmet Kaan Gümüş · 777c7df
✨ feat(users): give students a school-issued student number

Every school numbers its students its own way ("1234", "9-B/17"), and the
account carried no field for it: the office kept the mapping outside the
product. The number is now a first-class optional field on the user row,
unique inside the school (per-school uniqueness is the per-school database)
and held by students only.

- migrations/school/20260920000001_student_number.sql: `app_user
  .student_number TEXT NULL`, the partial unique index over its non-NULL
  values, and a CHECK (student_number IS NULL OR role = 'student'). The boot
  sweep applies the file to already-provisioned schools like every other
  school migration.
- domain: `StudentNumber`, a validated newtype (trimmed, non-blank, at most
  MAX_STUDENT_NUMBER_LEN = 32) in the shape of `Username`, plus the one
  spelling of the non-student refusal both the web gate and the database map
  answer; `User` carries `Option<StudentNumber>`.
- db: `create_with_role` binds it into the mint; `set_profile` writes it and
  maps the index's 23505 to the coded 409 and the row's 23514 to the same 400
  the handler gate answers; `set_role_cascade` clears it in the same statement
  that leaves the `student` role. The CHECK is what closes the read-then-write
  race the handler-side gate cannot see: a profile save carrying a number from
  a `student` snapshot while a promotion commits first is refused by the row
  itself, and a test pins exactly that (it writes a teacher holding a number
  without the CHECK).
- web: `POST /users` and both profile doors (`PATCH /users/me`,
  `PATCH /users/{id}/profile`) accept it under the merge semantics the other
  patchable fields have (omitted = keep, blank = clear), with the role gate as
  a 400 and a duplicate as a 409 carrying `code: student_number_taken`.
  `UserResponse` (admin reads, create/patch echoes, `/auth/me`) and `PersonRef`
  (pickers, students lists) carry it; the school-wide public profile
  deliberately does not — an office identifier is not broadcast school-wide.
- /limits publishes `max_student_number_len`; spec_bounds pins both new
  `max_length` annotations and the README's bound count moves to 224.
- tests: the mint and both patch doors — trimmed storage, 33 chars a 400,
  whitespace read as absent, a duplicate a coded 409 on both paths, a
  non-student a 400, blank clearing, a promotion clearing with the role change
  (and a demotion back not restoring it), and the stale-snapshot race at the
  db layer.

Evidence: the partial index refuses a duplicate (23505 naming
app_user_student_number) and admits both rows once dropped inside a
rolled-back transaction; with the 409 mapping removed both write paths answer
500 and the tests fail; with the CHECK removed the race test writes the
forbidden row (role: Teacher, student_number: Some(...)) and fails.
Local-Gate: 2c10aae51c575b7f4207fa310d8938070c0fbb80 (1509 passed, 572s)

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-12

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.
✉️ feat: messages go upward only; students and parents can search staffAhmet Kaan Gümüş · 1d423c0
✉️ feat: messages go upward only; students and parents can search staff

A student or parent may only write to a teacher, manager or admin
(`Role::may_message`); staff still write to anyone. `POST /messages`
answers 403 below that bar, and only new sends are gated — stored
student↔student rows stay readable and filable.

`GET /users/search` opens to every signed-in role: a caller below
teacher sees only the staff they may message (the restriction sits in
the query, so `total` stays right), and asking for `role=student` or
`role=parent` from there is a 403. This is the recipient picker the
messaging rule needs.

Closes #23, closes #24.

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

feat: 📐 publish every hard limit instead of making the frontend guessAhmet Kaan Gümüş · 7152aa9
feat: 📐 publish every hard limit instead of making the frontend guess

Every bound the API enforces lived in one of two places the frontend
could not read: a `pub const` in `constant.rs`, or English prose in a
doc comment ("1–20 entries", "`1`–`100`"). So the frontend kept its own
copy of each number, and the copies drifted the moment one moved.

Two surfaces now carry them, because clients consume them two ways.
`GET /limits` is one JSON document grouped by resource, built by naming
the constants directly — a runtime fetch, no codegen step, and it
carries what OpenAPI holds awkwardly (`reserved_usernames`, the raster
`image_content_types`, the closed role/kind/mode/status sets). The spec
gets the other half: 105 `max_length`/`minimum`/`min_items` bounds on the
request DTOs, which is what `openapi-typescript` and friends turn into
validators for free.

`/limits` is unauthenticated — the register form needs the username and
password bounds before a session exists, and none of it is secret, it is
the same rule a 400 already spells out. It is also exempt from the
database guard: it reads no row, and a frontend booting against a
reconnecting backend is exactly when it needs the contract, not a 503
that sends it back to the hard-coded copy.

Its `rate` group is the one part that is not compile-time. The
rate-limit tiers are env-tunable, so the endpoint reports this server's
live values off `AppState` rather than the shipped defaults — a client
should learn its budget here, not by collecting a 429.

`MAX_CHATBOT_THREAD_TITLE_LEN` moves to `constant.rs` on the way past.
It was private in `domain/chatbot_thread.rs`, reaching neither surface,
and its own comment asked to be moved the next time anyone was here.

Three tests keep both surfaces honest, because each is a hand-kept
mirror and a mirror nothing checks is one that goes stale. A constant
must reach `/limits` or an exclusion list that states why it does not; a
bound may not be declared outside `constant.rs` at all; and the emitted
spec is fetched and compared field by field against the constants —
never against literals, which would just be a third copy that passes
while both are wrong. That last one is unavoidable rather than
belt-and-braces: utoipa 5.5 takes a literal only, so
`max_length = MAX_NOTE_TITLE_LEN` does not compile.

Two duplicated `maximum = 500` literals are now pinned to
`MAX_PAGE_LIMIT`, which `constant.rs` previously only asked a human to
keep in step.

2026-07-23

✨ feat(messages): let a sender archive their own copyAhmet Kaan Gümüş · 24dba16
✨ feat(messages): let a sender archive their own copy

Filing was asymmetric: a recipient could move their copy to
inbox/archive/trash, but a sender only to sent/trash — so a sent
message could never be archived, only trashed. Add `archive` to the
sender's allowed folders.

The archive folder view now unions both sides, matching how trash
already works, so a sender's archived copy actually shows up in the
archive list (previously the query was recipient-only for archive).
Origin-stamping and restore are folder-generic and already handle it:
a sender archiving from `sent` restores back to `sent`.

Doc surfaces (utoipa move-request + list docs, the messages and core
tag descriptions, README route table and messaging section) moved with
it; the folder-parse test now asserts both sides may archive while the
sender still cannot reach the inbox.
✨ feat(messages): remember where a filed copy came fromAhmet Kaan Gümüş · 79189b8
✨ feat(messages): remember where a filed copy came from

Archiving or trashing a copy stamps the folder it left onto that side's
origin field, exposed as `previous_folder`, so restoring puts it back
where it came from instead of always in the inbox.

The trash is never stamped — pulling a copy out of it must not leave the
copy pointing back at the discard pile — and a no-op move keeps the stamp
it had. `null` means "restore to the home folder", which is also how rows
filed before the field existed read (option columns, no backfill).

Folder names become a `Folder` enum: the DB columns, the list filter and
the stamp all pass through it, so the stale string arrays are gone and a
typo is a compile error rather than a silently empty folder.

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.
✨ feat(messages): one-to-one mail with per-side foldersAhmet Kaan Gümüş · f4b3828
✨ feat(messages): one-to-one mail with per-side folders

Any user writes to any user (the one place a parent acts); only
self-send is refused. A single row serves both parties, each owning
their copy: the recipient files through inbox/archive/trash with a
read flag the sender sees as a receipt, the sender through
sent/trash. Folder and read writes are field-scoped so the two
writers never clobber each other. Permanent delete works only from
the trash and drops the row once both sides are gone. Messages carry
an optional free-text label badge, and ?read=false with limit=1
turns the page total into the unread badge.