Commits
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-07
✨ feat: real /health, error and panic telemetryAhmet Kaan Gümüş · c00f83a
✨ feat: real /health, error and panic telemetry
`/health` (and its `/` mirror) now answers what the process can actually do —
`{status, db, ai:{enabled,workers}}`, 200 when the database is up and 503 with
`"db":"down"` when it is not. It is exempt from the db guard alongside
`/limits`: a probe refused by the outage it exists to report names nothing.
Every `AppError` arm now records a stable snake_case class on the request span
(`error.type`) and counts itself into `errors_total` with that class and the
status. One log line per refusal, by severity: 5xx at error! with the
underlying error (which the arm's own Display hides), 429 and the reconnect
503 at warn!, the caller's 4xx at debug! — no path, no user, no body anywhere.
`record_response` no longer overwrites `error.type` with the status code.
Panics are no longer a dropped connection: a process-wide hook logs
`exception.type/message/stacktrace` and counts `panics_total`, and a
`CatchPanicLayer` inside the trace layer answers the same `{"error":"internal
server error"}` 500 every other internal error answers, tagging its span
`panic`.
Claude-Session: https://claude.ai/code/session_018sqvyBCZ9kpQP6vnGomT2s2026-09-05
✨ feat: builder sells modules per school, one at a time or in batchesAhmet Kaan Gümüş · c78e41a
✨ feat: builder sells modules per school, one at a time or in batches
`GET|PATCH /schools/{slug}/modules`, `POST|DELETE /schools/{slug}/modules/{module}`;
a batch names modules or whole packages, resolves to one set, is validated
against the dependency graph once and written once, or not at all. Public
`GET /modules/catalog` lists modules, packages and requirements; a school
reads its own set at `GET /modules`. Schools can be created with a narrowed
set.✨ feat: per-school modules; a disabled module answers 403 on every route in its nestAhmet Kaan Gümüş · 5d7f87c
✨ feat: per-school modules; a disabled module answers 403 on every route in its nest Twenty-one modules, one per router nest, with an explicit dependency graph derived from the record links (exams need courses and subjects, marks need exams, …) and four packages for the catalog. The enabled set lives on the school's control row and rides the tenant resolution that already happens once per request; every nest carries a route_layer gate, the four child creates inside /courses are gated by their own module, and the AI blob stream refuses `module_disabled` when course notes are off.
2026-08-04
feat: 🏷️ answer a manual class refusal with the pump's own codeAhmet Kaan Gümüş · 574b977
feat: 🏷️ answer a manual class refusal with the pump's own code Attaching a course or adding a member by hand refused with an English sentence, while the very same conditions reached through a blueprint pump had just become machine codes. One cause, two shapes — and the client that has to word them is bilingual. The vocabulary now has one home on the pump's own refusal type, the blueprint's skip list reads it from there, and the two manual routes carry it as a code beside the sentence they already sent. Prose is unchanged and no other route gains the field. Coding these also exposed a claim this series had been making wrongly: a pump attaches a course it has just proved alive, so it can never report a stale link. Only a member add walks the section's existing courses, and only it can answer that one.
2026-07-22
2026-07-21
🐛 fix(db): retry boot connect, refuse while socket downAhmet Kaan Gümüş · bebca49
🐛 fix(db): retry boot connect, refuse while socket down Two failures survived 6627128, which only classified errors from queries in flight *at* the drop — queries arriving after it produce no error at all, so there was nothing to classify. Boot did one connect() and exited on refusal. The runtime then restarted the process, it failed again in ~100ms, and a few seconds of startup skew burned the whole restart budget: 6 deaths in 0.6s in the field log, then down for 12h. Now retries 1s doubling to 5s, forever — only the dial, since bad credentials never heal by waiting. A query issued while the socket is down does not fail. The SDK's router_reconnect loops on 1s retries and stops draining route_rx, so the query parks until the database returns and only then executes. Reproduced: POST /auth/login gave no response at 25s, and the keepalive went silent 4m17s before firing two pings in the same millisecond on heal. Those two pings rule out a plain timeout middleware — a parked query still runs, so a timeout-sourced 503 would let a client retry double-apply a mark or an exam answer. Instead the keepalive (now 5s) publishes DbHealth and db_guard refuses at the edge, before anything is queued, which is what keeps Retry-After: 1 honest. The 30s request timeout is only a backstop for requests racing detection; those answer DbTimeout — same 503, no Retry-After, "may or may not have applied". WS and SSE are unaffected: both return their response immediately and stream afterwards. Known gap: exam_ws socket-loop queries run after the upgrade response, so db_guard does not cover them; they still park and heal on reconnect. Verified in podman against the existing volume: boot with the database down backs off and stays alive, requests during an outage answer 503 in 0.3ms, recovery needs no restart.
🐛 fix(db): map ws session-replay races to 503 + keepaliveAhmet Kaan Gümüş · 6627128
🐛 fix(db): map ws session-replay races to 503 + keepalive
The SDK's reconnect replays signin/use_ns fire-and-forget, so queued
queries can race it and get refused pre-execution ("Specify a
namespace" / "Anonymous access"), and a query in flight at the drop
dies as a connection error — all surfaced as 500s. Classify those
(narrow strings + is_connection) as DbUnavailable → 503 with
Retry-After: 1; refused-pre-execution makes a client retry always
safe, unlike a body-replaying retry middleware. A 30s RETURN 1
keepalive task makes drops heal between requests, not under one.
Restart storm (2× DB restarts under 200ms hammer): 0×500.2026-07-15
✨ feat(notes): file attachments with school-set size capAhmet Kaan Gümüş · f1b532b
✨ feat(notes): file attachments with school-set size cap
Blobs live on disk under FILES_PATH (same volume as the DB), named by
the row's ULID so user input never shapes a path; the note_file row
keeps only metadata. DB-blob storage rejected: multi-MB PDFs bloat
surrealkv's LSM tree and buffer whole in RAM on every read.
- POST/GET /notes/{id}/files, GET/DELETE /notes/{id}/files/{file_id};
owner-only through the owning note, staff included
- max_file_bytes in settings (1 KiB-25 MiB hard cap, default 5 MiB),
enforced on streamed bytes (413), inside the settings CAS guard;
option<int> so pre-field volumes boot without a backfill
- 10 files per note; deleting a note removes rows first, blobs after,
so a crash strands at worst an unreachable blob2026-07-11
✨ 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.