Commits
2026-09-24
✨ feat(schedule): holiday calendar, slot topics, and the weekly-plan materializer coreAhmet Kaan Gümüş · 7c481f7
✨ feat(schedule): holiday calendar, slot topics, and the weekly-plan materializer core Schema (migrations/school/20260924000001_holidays_and_materialize.sql): a school-wide `holiday` table over instant ranges, an optional `topic` on both weekly-plan slot tables, and UNIQUE (class_course, starts_at) on course_session so two lessons of one section cannot start together. Domain: `holiday` (name/kind/range newtypes, inclusive `overlaps`) and `calendar` (the school-zone day math hoisted out of web/attendance, which now imports it). `WeeklySlot` carries an optional topic; `overlaps` is unchanged. Db: `holiday` CRUD + overlap-paged list + the materializer's unpaged read; `course_session::insert_many` (one unnest INSERT .. ON CONFLICT DO NOTHING RETURNING, so the reported rows are the rows actually inserted) plus `existing_starts`; a duplicate start on the single-session route now answers 409 session_time_taken instead of a 500. Service: `holiday` pass-throughs and `course_session::materialize` — one transaction, archived-year wall, row lock on the instance, refusals coded instance_has_no_weekly_plan / instance_has_no_teacher, a range cap of 366 days and a candidate cap of 500, holidays and already-scheduled starts skipped and counted, nothing ever deleted. Dry run is side-effect free. The HTTP surface, per-section course lists, and the integration suite follow in later commits.
✨ feat(courses): grade-ladder course templates with per-class overridesAhmet Kaan Gümüş · 450bc8c
✨ feat(courses): grade-ladder course templates with per-class overrides course_offering per (course x grade_level 0..=12), per-class overrides on class_course (nullable scalars + *_inherited flags), subjects/weights/ weekly-plan axis tables, instance_resolve with batched twin, resolved title/description on instance-scoped reads, six new route groups, integration scenario test, README regenerated. Evolution migrations squashed into the base schema (20260912000002_courses + 20260916000001_k12_remodel). Local-Gate: 246daa3fb3ee7b0ff507a95d6ab346bab1333a37 (1556 passed, 455s)
2026-09-17
✨ feat: the podcast job's row and audio now live in the backend - backend-owned row, mp3 ingest, read gates without the serviceAhmet Kaan Gümüş · c44f362
✨ feat: the podcast job's row and audio now live in the backend - backend-owned row, mp3 ingest, read gates without the service
The job record lived only in the podcast service's own volume, so a restart
or a wiped volume lost every in-flight job a caller was polling and the mp3 it
was about to download. The backend now owns both ends of that state:
* `migrations/school/20260917000003_podcast.sql` — `podcast_job`, the job's
own row (user/source/format/state/stage/progress/error_code/audio_*/
duration/eta/created/updated). No `school` column: the school IS the
database, and the row's tenancy is (this database, user_id).
* `POST /podcast/jobs` mints the id, writes the row, THEN dispatches
`podcast.submit` with `{job_id, source_id, format, user_id}`; the service
echoes that id in its receipt (mismatch = 502 + a failed/bad_reply row).
No worker = 503 and no row; a refusal or transport failure tombstones the
row with the reason code — nothing is left claiming `queued`.
* The service reports every transition back through `podcast.report` (the new
client-initiated capability call, School-scoped, wired through
`src/ai/capability.rs`), which validates the echo, the jobs.py transition
table, the retention window and the done-means-audio rule before one
conditional UPDATE keyed on the state it read.
* The finished mp3 arrives as a `BlobUploadRequest` stream (exactly `size`
raw bytes), lands under the school's own blob root at
`podcast/<job-id>.<ext>` (temp+rename, row stamped in the same act, file
removed again if the row write finds the job gone), and `POST`ing a done
report before it is refused `audio_missing`.
* The read doors — `GET /podcast/jobs/{id}`, `.../result`,
`.../audio` — answer from the row with no service round trip: 404 for an
unknown or foreign job (foreign ids read as absent), 409 `not_ready` /
`audio_missing`, 410 past PODCAST_JOB_RETENTION_SECS, and a read-side-only
projection that presents a queued/running row nobody has updated inside its
ETA-scaled window as failed/interrupted — the GET writes nothing and a real
report overwrites it. `podcast.status`/`podcast.result` capabilities are
deleted with their payloads; the old `GET /podcast/audio?path=…` door is
gone (it named a cross-volume path and could not be owner-scoped).
Also: `AppError::Expired` (410) + the two room matches that needed it,
MIN_PROTECTED 323 -> 337 (real swept count), the three clippy fixes on the
committed tree, README regenerated, and the .sqlx entries for both lanes'
queries. This commit completes the tree that 7c96e47 half-staged: that commit
took the shared files (server/protocol/constant/db-mod/ai-capability) while
leaving `src/ai/podcast.rs`, `src/web/podcast.rs` and `tests/podcast.rs` at
their old versions, so main did not compile until this one.✨ feat: add the /rag nest over the course-note RAG bridgeAhmet Kaan Gümüş · a61e0a6
✨ feat: add the /rag nest over the course-note RAG bridge A separate rag_thread/rag_message pair of tables and a Module::Chatbot gated /rag nest, mirroring the chatbot's asynchronous send: POST answers 202 with a pending assistant row, an in-process task settles it, and both the poll read and the SSE stream project a stale pending row as failed. Every question is scoped server-side to the asker's own (sinif, ders) pairs — class-section instances, a linked parent's children, school-wide club/study memberships — never from the body. Each citation's corpus doc_id is resolved per candidate to a course-note file the asker may view, and the two storage caps refuse an over-bound reply whole rather than clipping it. rag.index replies now stamp each file's rag_doc_id, the missing link between a citation and its file. The chatbot's SSE helpers move to web/mod.rs so both nests stream through one implementation, and the instance/course visibility gates move from web to service so the scope deriver and the routes share one rule. Gates: cargo check --all-targets, clippy -D warnings, limits_completeness, spec_bounds, doc_sync (README regenerated), protected_routes_require_session (MIN_PROTECTED 269 -> 318, the real swept count), ai_bridge (75 tests).
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-14
🗃️ feat: pre-prod schema: person join key, drop school password copyAhmet Kaan Gümüş · 804bd3c
🗃️ feat: pre-prod schema: person join key, drop school password copy app_user no longer stores password_hash (login already verifies control person). School rows carry person uuid + created_at. class_blueprint is uuid-keyed; exam child rows composite-FK to (exam, question); pool/solution images are child tables; graded_at/marked_at/enrollment timestamps added. Left alone: occupancy/refcount counters (cap locks, not lies), ledger source, menu derived id, school.slug PK, fee_plan JSONB.
2026-09-13
✨ feat: person-scoped login; select school afterAhmet Kaan Gümüş · fae1f79
✨ feat: person-scoped login; select school after Login is username+password only. A person is global, memberships are per-school (role stays on app_user), and POST /auth/school binds when the account belongs to more than one school.
2026-09-11
Merge branch 'layer-split/notes_board'Ahmet Kaan Gümüş · e1b6791
Merge branch 'layer-split/notes_board' # Conflicts: # src/db/mod.rs # src/domain/rag_output.rs # src/service/course.rs # src/service/mod.rs # src/web/course_notes.rs
Merge branch 'layer-split/bank'Ahmet Kaan Gümüş · 164e756
Merge branch 'layer-split/bank' # Conflicts: # src/db/mod.rs # src/domain/bank_question.rs # src/domain/pomodoro.rs # src/domain/pool_question.rs # src/service/mod.rs # src/web/bank_questions.rs # src/web/exams/mod.rs
Merge branch 'layer-split/class'Ahmet Kaan Gümüş · dc8a635
Merge branch 'layer-split/class' # Conflicts: # src/db/cap.rs # src/domain/class_group.rs # src/domain/event.rs # src/web/classes.rs # src/web/users.rs # tests/regress_role_sweep.rs
Merge branch 'layer-split/exam_artifacts'Ahmet Kaan Gümüş · 312f795
Merge branch 'layer-split/exam_artifacts' # Conflicts: # src/db/exam_attempt.rs # src/db/mod.rs # src/domain/attendance.rs # src/domain/chatbot_thread.rs # src/domain/homework_submission.rs # src/domain/session_attendance.rs # src/service/course.rs # src/service/mod.rs # src/web/exams/mod.rs
Merge branch 'layer-split/homework'Ahmet Kaan Gümüş · 746045c
Merge branch 'layer-split/homework' # Conflicts: # src/db/mod.rs # src/domain/homework.rs # src/domain/homework_file.rs # src/domain/homework_result.rs # src/domain/homework_submission.rs # src/service/mod.rs # src/web/homework.rs
🧹 chore: split note_file/course_note/course_note_file/board/board_stroke into domain/db/service layersAhmet Kaan Gümüş · a15d2d2Browse files
🧹 chore: split class_course/class_group/class_member/class_pump into domain/db/service layersAhmet Kaan Gümüş · b1261c7Browse files
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
🧹 chore: split bank_question, bank_question_image, pool_question, solution into domain/db/service layersAhmet Kaan Gümüş · d0c4bb1Browse files
🧹 chore: split homework domains into domain/db/service layersAhmet Kaan Gümüş · e37f2b6
🧹 chore: split homework domains into domain/db/service layers homework, homework_file, homework_result, homework_submission: - db/<x>.rs: free fns (db first), byte-identical bodies; persistence tests ride along; DeleteOutcome + subject_gone file-local in their db modules - service/homework.rs: HOMEWORK_LOCK moves here from web/homework.rs; update (writer lease + orphan guard), delete (writer lease + blob-key collection), gate_own_submission, require_open_term, award_badges - service/homework_submission.rs: submit / delete workflows (reader lease) - service/homework_file.rs: ensure_can_attach, insert/delete pass-throughs - service/homework_result.rs: grade (writer lease + re-read + self/existence/ role/enrollment/audience gates) and ungrade - web/homework.rs: authz + DTO + blob I/O only; upload/delete-file lease the service-owned lock directly (web/exams/images.rs precedent) since the blob write sits inside the lease span - service/course.rs: re-pointed to service::homework::HOMEWORK_LOCK and db::homework_file::file_keys_for_course (lock order EXAM_LOCK then HOMEWORK_LOCK unchanged) - web/courses.rs create/list handlers call service::homework - regression: regress_homework_orphans re-pointed to db:: paths cargo check --all-targets clean; cargo test --lib 577 passed 0 failed; regress_homework_orphans 8/8, partial_patch_homework 3/3
🧹 chore: split exam_answer/exam_result/answer_image/question_image into domain/db/service layersAhmet Kaan Gümüş · 61990deBrowse files
🧹 chore: split fee_plan/fee_plan_assignment/attendance/session_attendance into domain/db/service layersAhmet Kaan Gümüş · 46cb63dBrowse files
Merge branch 'layer-split/meal'Ahmet Kaan Gümüş · b0e9ab8
Merge branch 'layer-split/meal' # Conflicts: # src/db/mod.rs # src/service/mod.rs
Merge branch 'layer-split/chatbot'Ahmet Kaan Gümüş · f360d85
Merge branch 'layer-split/chatbot' # Conflicts: # src/db/mod.rs # src/service/mod.rs
🧹 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.
Merge branch 'layer-split/catalog'Ahmet Kaan Gümüş · 8c2ca53
Merge branch 'layer-split/catalog' # Conflicts: # src/web/classes.rs
🧹 chore: split chatbot_message, chatbot_thread, rag_output into domain/db/service layersAhmet Kaan Gümüş · 4ddbd6eBrowse files
🧹 chore: split subject and term into domain/db/service layersAhmet Kaan Gümüş · 6533a0a
🧹 chore: split subject and term into domain/db/service layers
domain/subject.rs keeps SubjectId/SubjectName/SubjectDescription/Subject + getters
and the pure validation tests; domain/term.rs keeps TermId/TermName/gone_error/
archived_error/ref_move/Term + getters.
db/subject.rs: create (cap::touch_and_create), read, list_by_ids, list_for_course,
update (FieldUpdate), delete (guarded transaction). db/term.rs: create, read,
list_all, update (ordered range guard), delete (refcount-guarded), archive,
unarchive, stamp. Persistence race tests ride along byte-identical.
service/subject.rs: pass-throughs + the moved id resolvers in_course/must_exist
(was web::subjects helpers). service/term.rs: pass-throughs + require_open
(was Term::require_open), resolve (was web::terms::resolve_term), require_writable
(the archived-refusal gate update/delete handlers inlined), delete's linked-409
mapping (was web::terms).
Web: subjects.rs/terms.rs handlers call service only; the archived gate stays
ordered before the range pre-flight by calling service::term::require_writable
between read and write. Callers re-pointed crate-wide: web/courses.rs,
web/classes.rs, web/homework.rs, web/exams/{mod,questions}.rs, web/bank_questions.rs,
db/{course,exam,exam_attempt,exam_question}.rs (tests + doc links),
service/{course,exam_attempt}.rs, domain/{class_group,bank_question,homework,
homework_file,homework_result,homework_submission}.rs (tests + doc links),
tests/regress_course_{child_orphans,delete}.rs.
Purity verdicts: domain/{timestamp,monotonic_id,text_fold,role}.rs have zero
production query execution (text_fold's only .query( is inside a #[cfg(test)]
folding test) — they stay domain-only, no db/service modules.
cargo check --all-targets 0 warnings; cargo test --lib 577 passed 0 failed;
integration: 13 subject/term/question/homework route tests green.Merge branch 'layer-split/identity'Ahmet Kaan Gümüş · 919680f
Merge branch 'layer-split/identity' # Conflicts: # src/db/mod.rs # src/domain/pomodoro.rs # src/domain/profile.rs # src/service/mod.rs # src/web/users.rs
Merge branch 'layer-split/comms'Ahmet Kaan Gümüş · 4ab90d9
Merge branch 'layer-split/comms' # Conflicts: # src/db/mod.rs # src/domain/event.rs # src/domain/registration.rs # src/service/mod.rs # src/web/pomodoro.rs
🧹 chore: split profile, badge, builder into domain/db/service layersAhmet Kaan Gümüş · 7f616c0
🧹 chore: split profile, badge, builder into domain/db/service layers
C3 identity lane. Moves, not rewrites:
- badge: BadgeStats::load / BadgeAward::list_for / sync (UPSERT with the
earned_at = NONE idempotency stays whole) -> db::badge, with the
award-key mint and the persistence tests; BadgeStat/BadgeStats/earned/
BadgeAward (pure rules) stay in domain::badge; service::badge wraps
list_for/sync for the web layer.
- profile: ProfileStats::load (+ PomodoroTotals, persistence tests) ->
db::profile; newtypes + getters stay; service::profile::load wraps.
- builder: find_by_username/read/create(create_session)/find_by_token/
delete_by_token -> db::builder; the idempotent seed ensure ->
service::builder (ensure_admin precedent); both tests ride their fns.
- preferences, key: fully pure (validated newtypes, composite-id
helpers) — stay domain-only, no db/service modules created.
Entity fields the split constructs from are now pub(crate) (Builder,
BuilderSession, ProfileStats), matching the user split.
Callers re-pointed crate-wide: web/{users,exams/mod,questions,homework,
sessions,auth,extractor,builder,tenant_state}, service/exam_attempt.rs
(badge::sync after start), database.rs (control seed), tests/
{builder_api,e2e,integration}; cross-lane compile fixups in
domain/pomodoro.rs and domain/session_attendance.rs (their lanes
re-point on merge). constant.rs doc link -> crate::db::badge::list_for.🧹 chore: split message/parent_link/registration into domain/db/service layersAhmet Kaan Gümüş · f820c36Browse files
🧹 chore: split pomodoro/work_entry/event into domain/db/service layersAhmet Kaan Gümüş · 47eb006Browse files
Merge branch 'layer-split/user'Ahmet Kaan Gümüş · f30faee
Merge branch 'layer-split/user' # Conflicts: # src/domain/appointment_slot.rs # src/domain/exam_question.rs # src/domain/user.rs # src/service/course.rs # src/web/courses.rs # src/web/sessions.rs
Merge branch 'layer-split/exam'Ahmet Kaan Gümüş · e0fb40e
Merge branch 'layer-split/exam' # Conflicts: # src/db/mod.rs # src/domain/course_session.rs # src/domain/exam.rs # src/domain/exam_question.rs # src/service/mod.rs # tests/regress_course_child_orphans.rs
Merge branch 'layer-split/enrollment'Ahmet Kaan Gümüş · c4e9b2c
Merge branch 'layer-split/enrollment' # Conflicts: # src/db/mod.rs # src/domain/event.rs # src/service/mod.rs
Merge branch 'layer-split/meal_booking'Ahmet Kaan Gümüş · 78600f5
Merge branch 'layer-split/meal_booking' # Conflicts: # src/service/mod.rs
Merge branch 'layer-split/class_blueprint'Ahmet Kaan Gümüş · 38a619c
Merge branch 'layer-split/class_blueprint' # Conflicts: # src/service/mod.rs
🧹 chore: split course_session into domain/db/service layersAhmet Kaan Gümüş · 0ddaa5d
🧹 chore: split course_session into domain/db/service layers domain/course_session.rs keeps the pure surface: CourseSessionId (its ULID mint stays per the monotonic_id precedent), SessionTopic, the entity with pub(crate) fields, getters, and the topic-bound validation test. db/course_session.rs takes the query executors whole: create (the cap::touch_and_create claim that bumps the course row in the same transaction), read, list_for_course, the field-scoped update, and the cascading delete transaction; the orphan-race persistence test rides along. service/course_session.rs takes resolve_session_teacher out of the web layer — the scheduling role floor (a student cannot teach a lesson) — plus the thin doors the web layer now calls instead of the removed inherent methods. No locks: course_session never held one; the range guard rides inside the UPDATE's WHERE. web/sessions.rs and web/courses.rs re-point every CourseSession call and the shared resolve_session_teacher import to service::course_session; call sites in domain/session_attendance.rs (incl. tests) and doc links in domain/event.rs go to db::course_session. tests/ import fixes only.
Merge branch 'layer-split/exam_attempt'Ahmet Kaan Gümüş · 7267caa
Merge branch 'layer-split/exam_attempt' # Conflicts: # src/db/mod.rs # src/domain/exam_attempt.rs # src/service/mod.rs # src/web/courses.rs # src/web/exam_ws.rs # src/web/exams/attempts.rs # src/web/exams/mod.rs # tests/regress_course_delete.rs
Merge branch 'layer-split/course'Ahmet Kaan Gümüş · ecd88d4
Merge branch 'layer-split/course' # Conflicts: # src/service/mod.rs
🧹 chore: split exam_attempt into domain/db/service layersAhmet Kaan Gümüş · c13b51d
🧹 chore: split exam_attempt into domain/db/service layers
src/domain/exam_attempt.rs keeps the pure core (ExamAttemptId, AttemptStatus,
the entity + getters, deadline/status arithmetic); fields went pub(crate) so
the layers can mint and target rows.
src/db/exam_attempt.rs takes every query: finish/set_left (the two
field-scoped writes), the reads (read, read_latest_for_user, list_*,
any_for_exam), and the write_unfrozen[_with] freeze-gate transaction gateway
with FROZEN_SLOT and the THROW markers.
src/service/exam_attempt.rs owns the workflows and the cross-call state:
EXAM_LOCK moves here from web/exams/mod.rs (it spans multi-call workflows —
start's writer lease, saves' reader leases), the sitting gates
(ensure_sittable/ensure_student/ensure_student_now/ensure_enrolled/
check_rejoin/writable_attempt) move out of the handlers, as do course_of
(web may not be imported from service) and question_of_exam (the answer
funnel's lookup). start keeps its name from the domain; start_attempt /
finish_attempt / save_answer_checked are the handler workflows extracted
whole, windows and term gates and all, in the original gate order.
web/exams/attempts.rs keeps authz extractors, DTOs, and response assembly
only; exam_ws.rs, exams/{mod,questions,images,review}.rs and courses.rs
re-point to the service paths; domain/exam_question.rs and
question_image.rs call the db-layer write_unfrozen* directly. Doc links to
moved items re-pointed. Tests ride with their layer: persistence
(field-scoped write) tests in db, workflow (start/retake/race) tests in
service; assertions unchanged, only paths and call shapes.