forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/web/payments.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-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

Merge branch 'layer-split/fee_attendance'Ahmet Kaan Gümüş · 08aa13e
Merge branch 'layer-split/fee_attendance'

# Conflicts:
#	src/db/mod.rs
#	src/domain/attendance.rs
#	src/domain/event.rs
#	src/domain/session_attendance.rs
#	src/service/mod.rs
#	src/web/payments.rs
#	src/web/sessions.rs

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.

2026-08-13

📝 feat: generate README endpoint table from the served OpenAPI specAhmet Kaan Gümüş · bf8046e
📝 feat: generate README endpoint table from the served OpenAPI spec

tests/doc_sync.rs renders the 275-row table from /api-docs/openapi.json
(auth floor from declared 403s, else the handler's Require* extractor,
asserting exactly one floor per operation), drift-gated in the suite;
UPDATE_DOCS=1 regenerates. Static rows are router-verified and plain
.route() registrations must reach the table or the suite fails.
Curated prose folded into handler doc comments; CLAUDE.md convention
updated (table generated; full suite = cargo nextest run).

2026-08-05

💰 fix: bound the payments walk and settle the statement's arithmeticAhmet Kaan Gümüş · 39821ef
💰 fix: bound the payments walk and settle the statement's arithmetic

The statement folded its per-charge rollup from one read of the ledger
and balance_minor from a second, later one, so a credit landing in the
three-round-trip gap produced a self-inconsistent money document. It now
folds both from the lines already in hand.

applied_to walked a subtree one query per node under the process-global
PAYMENT_LOCK with nothing bounding it, so N one-minor-unit payments made
payment N+1 cost N+2 serialized queries while every other money write
queued. Capped at MAX_LEDGER_APPLIED_LINES subtree nodes — the node
count, not a credit count, because refunds under one credit are equally
unbounded.

assign_plan could issue 200 × 60 sequential writes in one request; now
bounded by MAX_FEE_PLAN_ASSIGN_WRITES, refused up front so nothing
partial is billed.

due_at declared minimum = 0 in its schema and enforced nothing, so
due_at: -1 was a 201 and overdue stayed true forever.

A PATCH racing a DELETE of an unassigned plan answered 409 "an assigned
plan cannot be edited" about a plan that was gone and never assigned;
FeePlan::update now disambiguates the way FeePlan::delete already did.

balance_of stops decoding the whole ledger to produce one integer.
fix: 💳 stop telling a bursar a reversed charge was paidAhmet Kaan Gümüş · 26a740d
fix: 💳 stop telling a bursar a reversed charge was paid

A reversal is a `+amount` child of the line it undoes, so it fills
exactly the room a payment would: `applied_to` folds it in and a reversed
charge reads as full to the last minor unit. `POST /payments/credits` against one
therefore answered "the charge is already paid in full" — about a charge
where not one minor unit ever arrived. It was reversed, and a bursar reading
that goes hunting for money that does not exist.

The stored outcome is right and does not move: a reversed charge is no
longer owed and takes no payment. Only the diagnostic changes. The
reversal's id is derived from its target's, so telling the two refusals
apart is one read, taken on the refusal path alone. `refund` passes
`None` and spends no read: a credit is never reversed, so a full fold
there can only mean the refunds.

Doc surfaces move with it: the route's 409, its handler doc, the
`payments` tag description, and the README route table and section.

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

fix: 🧊 freeze a fee plan the moment it is assignedAhmet Kaan Gümüş · ac70cc0
fix: 🧊 freeze a fee plan the moment it is assigned

The 409 that stops an assigned plan being edited or deleted was a scan
followed, some microseconds later, by the write it licensed. An assign
landing in that gap left a plan edited and assigned, or deleted with a
live assignment still naming it. The comment called it an accepted race
and blamed the other replica; there was never another replica, and two
concurrent requests in one process were always enough.

A plan now carries an assignment refcount. The assign claims it in the
same transaction that writes the row, and the edit and the delete are
conditional writes that refuse while it stands. The plan freezes at the
instant of the claim, so the assign re-reads it afterwards and bills the
copy that froze — the refcount alone still let an edit slip in front and
bill the snapshot the handler had read.

Existing plans are seeded from the assignments they already carry. An
absent counter reads as zero, which is the value that licenses an edit,
so a plan assigned before this would otherwise have come unfrozen.

Two things this uncovered. A cap claim that lost a write conflict was
answered as a 500 five times in six: the retryable conflict shared the
error batch with the sibling statements it aborted, and an arbitrary one
of those was returned. And a guarded write had no retry at all, so a
raced PATCH or DELETE failed outright rather than trying again.

The race tests run against a real server. On the embedded engine they
watched a 45-in-50 failure rate and passed.

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.
feat: 💰 track school fees in an append-only ledger of fee plansAhmet Kaan Gümüş · 740e96a
feat: 💰 track school fees in an append-only ledger of fee plans

Fee plans (name + 1..60 installments of {amount_minor, due_at}) are
assigned directly to students; assignment appends every installment as
a charge at once, keyed <plan>_<student>_c<n> so a replay bills nobody.
Payments target one charge, refunds target one credit, and a reversal
undoes only the negative-fold kinds — a mistaken credit is corrected by
a refund, never edited. Balance is never stored; the over-payment cap
folds the target's source subtree under PAYMENT_LOCK and stays advisory
across replicas, which the module doc states outright.

Meal money is untouched: two ledgers, two balances, one shared amount
vocabulary.