forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/domain/answer_image.rsClear filter

2026-09-15

🆔 fix: one id convention — every id is a v7 uuid, none is a v4Ahmet Kaan Gümüş · d40e4c9
🆔 fix: one id convention — every id is a v7 uuid, none is a v4

The crate mints UUIDv7 from the process-wide monotonic generator, but four
sites still minted a v4:

- ChoiceId (an exam choice's stable id) and the blob names of answer
  images, bank-question images and homework files: now next_uuid(), like
  their siblings (question_image already was)
- test_suffix()'s 5-hex tail is not an id — it is the random half of a test
  database's name — so it draws from the OS rng: a v7's leading hex digits
  *are* the mint time, which is exactly what two processes minting in the
  same millisecond share
- the request-id layer installed tower-http's MakeRequestUuid (a v4); it
  now mints through the crate's own generator, same wire shape

The manifest drops uuid's v4 feature, and a guard test scans src/ so a
stray v4 fails the suite. (tower-http's request-id feature still enables
uuid/v4 in the dependency graph; nothing here calls it.)

2026-09-12

🐛 fix: rename app_user in the six FromRow entities the port missedAhmet Kaan Gümüş · 0466c1a
🐛 fix: rename app_user in the six FromRow entities the port missed

PagedList reads with SELECT * + FromRow need field names to match
columns; Attendance, Enrollment, ExamAttempt, ExamResult, ExamAnswer
and AnswerImage carried a bare `user` field, so any paged read 500'd
with a database error (found live by e2e's full_user_journey via
GET /events/{id}/attendance). Attribute-only: query_as! sites are
unaffected, no .sqlx refresh needed.

2026-09-11

2026-08-05

🖼️ fix: stop image slots orphaning rows and blobsAhmet Kaan Gümüş · 2eab9e2
🖼️ fix: stop image slots orphaning rows and blobs

bank_question_image was the only child in its domain whose write moved
nothing on its parent, and BankQuestion::delete was two round trips
rather than one transaction. An upload whose body was still streaming
when the template was deleted left a metadata row and a blob that no
route could read or remove.

Three more of one shape: store_image read the slot's current row to
learn which blob to retire and then upserted, so two concurrent uploads
both retired the same old blob and stranded the loser's new one. Fixed
on the bank, exam-question and answer-image paths alike by reading the
replaced name inside the write's own transaction — the shape
PoolQuestion::set_image already used.

delete_question no longer unlinks blobs from a pre-read snapshot; the
delete returns the rows it actually swept, as Note::delete does.

BankQuestion::update_if_unchanged moves to write_with_retry: the image
upsert now writes the template row, so a raced PATCH would otherwise
have started answering 500.
fix: 🎨 stop a drawing from outliving its examAhmet Kaan Gümüş · f8b854c
fix: 🎨 stop a drawing from outliving its exam

A drawn answer was still a bare upsert — the exact shape the text answer
had before yesterday's fix — so it kept the hole: a drawing landing
after an exam delete removed the row but before it committed was swept
by nothing, and both sides reported success. 4 of 4 raced rounds against
a real server.

The blob went with it. The handler collects the names to unlink before
it calls the delete, so bytes written after that snapshot sit on disk
with no row and no reader forever.

It now moves the exam's mark counter and puts it straight back inside
its own transaction, like the answer beside it, so the two writes
collide on one key and the store refuses a side. Restored by captured
value, so the row is byte-identical and no teacher's edit is refused
because a student drew.

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

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

✨ feat(exams): keep every attempt's answers, drawings, and markAhmet Kaan Gümüş · 3668684
✨ feat(exams): keep every attempt's answers, drawings, and mark

Retakes wiped the prior sitting's answer sheet and overwrote the single
mark row, so a re-sit erased any record of how the student did before.
Teachers need that history to understand a student.

Each sitting now keeps its own rows, keyed by the attempt `seq` (in the
record id + a denormalized field). `seq==1` maps to the old bare key, so
existing rows need no migration beyond a `seq=1` backfill; the unique
indexes move to include `seq`. The retake answer/image wipe and the
per-retake blob GC are gone.

Grade-of-record stays the latest sitting: roster, report, and by-user
reads return the newest `seq`. Prior sittings are read-only, exposed to
course managers via new history endpoints:
  GET /exams/{id}/students/{user}/attempts
  GET /exams/{id}/students/{user}/attempts/{seq}/answers
  GET /exams/{id}/students/{user}/attempts/{seq}/answers/{qid}/image
  GET /exams/{id}/students/{user}/marks
Live reads (autosave, exam-room WS, monitor) scope to the current seq.

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