forge
Explore
Log in

Don't you dare go Hollow

Commits

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

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

✨ feat: compose-stack deploy plus in-tree schema workAhmet Kaan Gümüş · 57fad2c
✨ feat: compose-stack deploy plus in-tree schema work

Production deploy is podman compose (postgres + backend + openobserve)
instead of a systemd binary. CI stays a throwaway postgres sidecar.
Operator credentials live in ~/hezarfen_backend/hezarfen_backend.env
(0600); the deploy never writes that file.

Also lands the working-tree schema/junction and .sqlx updates that were
already sitting next to this change.

2026-09-12

2026-09-11

🧹 chore: split meal_attendance, meal_ledger, menu, menu_dish, dietary_profile into domain/db/service layersAhmet Kaan Gümüş · d548120
🧹 chore: split meal_attendance, meal_ledger, menu, menu_dish, dietary_profile into domain/db/service layers

- db/: menu (publish/read/find/list/CAS cap update/cascading delete +
  bump_menu_and_write), menu_dish (create/read/listings/count/patch/delete),
  meal_attendance (mark/list_for_menu/list_for_student), meal_ledger
  (append/read/price_snapshot/list_for_student/balance_of + KindTotal),
  dietary_profile (read/tags_of/save). Bodies byte-identical; entity
  fields pub(crate) for cross-layer construction (exam precedent).
- service/: menu owns MENU_LOCK (multi-call count-then-write span) and
  every dish write (add_dish with the MAX_DISHES_PER_MENU gate,
  update_dish/delete_dish) plus menu/dish read pass-throughs;
  meal_ledger owns charge_booking/reverse_booking/credit orchestration;
  meal_attendance and dietary_profile are read-through pass-throughs.
- domain/: pure remnants only — ids, newtypes, getters, sign convention,
  charge_for/reversal_for row builders, conflicts; ULID IDS minters stay;
  persistence tests ride with their fns into db/.
- web/meals.rs: handlers call service::* only; MENU_LOCK leases and the
  dish-cap gate moved out; validation order preserved.
- re-pointed merged callers (service/meal_booking, db/meal_booking,
  db/exam_attempt doc link) and test imports (integration, regress_meals).

cargo check --all-targets clean; cargo test --lib 577 passed 0 failed;
cargo test --test regress_meals 18 passed 0 failed.

2026-08-04

fix: 🍽️ stop an attendance mark from outliving its menuAhmet Kaan Gümüş · 84c873c
fix: 🍽️ stop an attendance mark from outliving its menu

Marking attendance guarded itself by reading the menu, and a delete
sweeps its children in one transaction. A mark landing after that
delete removed the row but before it committed read a menu that was
still there, while the sweep ran on a snapshot taken before the mark
existed — so both committed and neither caller was told. The store
does not track an insert into a range another transaction already
swept.

That left a mark nothing could reach or remove, on an id minted from
the date and slot: republishing that day brought it back as a mark on
the new menu, the kitchen reading served for a student who never came.
Measured on the real engine, not theorised: 378 of 3600 raced rounds.

A dish never had this hole because it bumps the menu's revision, so
the two writes collide on one key and the store aborts a side. Marks
now go through the same helper, which moves to the menu itself since
both its children need it.

The dish test that found this was asserting a store-enforced invariant
on the in-memory engine, which cannot enforce one — a few percent of
loaded runs failed on correct code. It now pins the logic without a
race, and the concurrent claim moves to a real-server test that holds
the delete open with an event and races one child per round: racing
both hides the bug, because the first writer makes the delete re-send
and the re-sent sweep takes the other's row.

2026-08-02

fix: 🔩 close the bug hunt across meals, classes and capsAhmet Kaan Gümüş · 7198cea
fix: 🔩 close the bug hunt across meals, classes and caps

A three-domain hunt, its fixes, and a verifier panel that refuted two of
them. Kept as one commit because the pieces interlock — cap.rs, the
settings pair and the pump all move together, and no smaller cut compiles.

Money can no longer be lost or stranded. Both seat transitions carry
their ledger line inside their own transaction: the claim writes the
charge, the flip writes the reversal. Before, a crash between the two
left a seat held with no bill, or a bill with no seat, keyed to an
attempt no later request could ever reach. A lost cancel could refund a
live seat. The menu revision was bumped in a query of its own, so a
booking reading in the gap claimed against a capacity or a price the
menu had already left.

Deleting a menu now takes its marks and its dishes with it, in the
transaction that deletes the row. The id is deterministic on (date,
slot), so anything left behind came back on the next publish — the
kitchen reading "served" for a student who never came.

A seat is always releasable: manager+ cancels any booking and is not
bound by the cutoff, so a promoted student's seat no longer wedges its
menu forever, and a debt that outlived its owner's role can be settled.
Canteen money follows /payments and is manager+, not teacher+ — what a
family owes the school is not classroom information.

The class pump claims its pivot in-transaction. An attach racing a
course delete used to commit a link to a row that was gone, and nothing
could then detach it or delete the class. A hand enroll now disowns a
pumped row, so a sweep cannot take back a roster decision an operator
made by hand. The role sweep is one transaction. Rosters are ordered by
when a student was added, which is what they always claimed. Both class
axes have a ceiling, and each refuses on the other's, because a pump
writes one row per member per course in a single transaction.

Settings edits are serialized: retire is idempotent, so an undo log
cannot tell the attempt that flipped a name from one that found it
already flipped, and the loser un-retired what the winner had legally
retired — leaving a kind gone from the list, gradable, and unremovable
for good. Grading now checks the school's list, not only the counter.
Three caps that read a snapshot integer now read the live column.

A clear marker is charged to the board's lifetime counter and boot
repairs the boards that predate it. Blank canvases refuse the clear, and
the room reports that as its own code: the refusal text had drifted into
the substring the WebSocket read as "closed", which told a live room it
was permanently read-only.

Verified against the real volume: both boot backfills, the slot-name
rule and its grandfather clause, and the new money gate.

2026-07-31

fix: 🔁 retry every guarded transaction that loses a write raceAhmet Kaan Gümüş · 755f4ab
fix: 🔁 retry every guarded transaction that loses a write race

08b1b0f gave the four guarded deletes a retry. It left the rest of the
class alone, and the rest of the class is the same defect: a guarded
BEGIN..COMMIT that loses a round reports the abort's generic sibling slot
as AppError::Db, so an ordinary contended write answers 500 instead of
the 409 or 404 it owes.

Eight more sites now go through transaction_with_retry: ExamResult's mark
and its removal, AppointmentSlot::delete_free, MenuDish::create,
PomodoroSession::finish, WorkEntry::check_out, and the exam freeze gate
covering ExamQuestion insert/update/delete and QuestionImage
upsert/delete.

The freeze gate needed restructuring rather than wrapping. unfrozen()
built the SQL and frozen_check() inspected an already-sent response, so
the five callers owned the send and nothing in that split could re-send.
Both are replaced by write_unfrozen(), which owns the send and therefore
can retry; frozen_check is gone, so no path skips it.

ExamResult::remove additionally dropped its .check()? — that returns the
lowest-slot error, so an aborted transaction's "not executed" sibling
masked the real retryable conflict. The same masker was deleted from
Exam::delete in 08b1b0f.

transaction_with_retry's admissibility clause is now a rule instead of a
list of callers, which had already gone stale: a statement is admissible
iff it cannot legitimately answer "already exists" — UPDATE and DELETE
never can, a CREATE cannot when no rival can reach its id, and an UPSERT
cannot when its id is bijective with every unique tuple its table
indexes.

Re-send soundness is measured, not argued: injecting a THROW just before
each batch's trailing RETURN makes every statement run and then aborts
the whole transaction, and re-sending the real SQL afterwards left the
suite green across all twelve sites, with no batch double-applied.

2026-07-27

fix: 🧷 close the cross-table races the locks never closedAhmet Kaan Gümüş · 4f7bdaf
fix: 🧷 close the cross-table races the locks never closed

Every remaining check-then-write that spanned tables becomes a
single-record conditional write, so it holds across replicas:

- subject delete: refcounts (exam_question_count/homework_count) claimed
  and released by every question/homework write; the triple lock hold
  dies, BANK/TERM/ENROLL locks die outright
- exam kinds: kind_ref {count,retired} records; grading claims, removal
  retires only at zero — grading a removed kind and re-kinding a graded
  exam are now 409 (both previously silently mis-weighted marks)
- homework: the grade stamps the submission row in its own transaction;
  student writes are conditional on the stamp being absent
- appointments: slot occupancy is a cap-1 counter; the lock survives
  only for the within-replica approved-overlap check
- meals: seat counter + menu version CAS (price can no longer tear mid
  booking) + deterministic menu:date_slot id kills duplicate publish
- cap::claim_and_create: member gate, then seat, then child CREATE in
  one transaction — a duplicate loser no longer eats a stranger's seat
  or gets refused for a row it already owns
- boot: the two unguarded lease statements now retry on transaction
  conflict (the escape was ~1-in-15 under full-suite load)

Two races reviewed and accepted, documented in README ## Concurrency
model: the attempt-seq late save (one history row, grade of record
untouched) and cross-replica approved-overlap (visible, cancellable).

Deployment contract (README): counter-adding releases restart all
replicas together — an old binary's writes skip new counters and the
= NONE backfill guard rightly refuses to re-seed.

Every guard is mutation-proven; backfills are one-time, = NONE-guarded,
ordered after the destructive sweeps, and verified against the live
volume.

2026-07-26

feat: 🍽️ run the canteen: menus, seats, allergens and a ledgerAhmet Kaan Gümüş · fd5cfd1
feat: 🍽️ run the canteen: menus, seats, allergens and a ledger

Published menu calendar (manager+ authors, everyone reads), per-student
dietary profiles that mark conflicting dishes, meal booking with an
optional per-menu capacity, meal attendance, and booking-triggered
billing.

Booking is the charge trigger: reserving a seat stamps a charge at a
price snapshot, so later dish edits never rewrite what a student owes.
No-show still pays, because the kitchen already bought the food, which
is why attendance has no billing effect at all. Money enters only as
admin-recorded credit entries; there is no gateway and no card data.

The ledger is append-only. Cancelling appends a reversal rather than
deleting the charge, balance is always folded from the rows, and the
sign lives in exactly one function. A deletable ledger row would
rewrite a student's financial history leaving no trace.

Charges and reversals are keyed per (booking, attempt) and written
under MENU_LOCK alongside the seat, so a double-click, a retry, or a
cancel cut short mid-flight all settle to one charge and one refund.
That lock is in-process only: a second replica would break every
capacity and charge guarantee here.

A parent may book for a linked student, the first write parent_link
has ever authorised, and sees only seats whose link is still live.