Commits
2026-09-11
🧹 chore: split chatbot_message, chatbot_thread, rag_output into domain/db/service layersAhmet Kaan Gümüş · 4ddbd6eBrowse files
🧹 chore: split note/session/settings into domain/db/service layersAhmet Kaan Gümüş · efea304
🧹 chore: split note/session/settings into domain/db/service layers
Pilot wave of the three-layer split. All query execution for the three
domains now lives in src/db/{note,session,settings}.rs as free fns taking
db first; web handlers call service::<x>::* only; domain keeps pure types.
- service/settings.rs gains the PATCH workflow (apply) and SETTINGS_LOCK —
it spans a multi-call pair (retire names, CAS save, restore), so it is a
service lock, not a db lock. The service takes its own input records
(SettingsPatch/*Input) so wire DTOs stay in web and list validation keeps
its original order, including the try_kept grandfathering that needs the
stored list.
- Note/Session/Settings fields the db layer mints or CAS-binds become
pub(crate); Settings::record_id becomes pub(crate).
- Unit tests rode with their fns: note delete cascade → db/note, session
purge → db/session, settings load/save/CAS → db/settings, the whole
settings edit workflow suite → service/settings.
- Doc links re-pointed (user, class_blueprint, bank_question, exam,
note_file, tests/regress_roles); NoteId::generate's stale
'Note::list_for_user' link now names db::note::list_for.
- Known residual for a later wave: web/notes.rs:411 file.delete() is
note_file-domain persistence (note_file splits in C3).2026-09-05
🔒 fix: the registry refuses an unsatisfiable module set; no AI egress without the ai packageAhmet Kaan Gümüş · 8f2c521
🔒 fix: the registry refuses an unsatisfiable module set; no AI egress without the ai package `Tenants::create`/`set_modules` validate the dependency graph themselves. A school without `chatbot` dispatches no rag indexing and the blob stream refuses `module_disabled`, so a customer who did not buy AI ships no data to the AI services.
✨ feat: AI bridge speaks hab/2; every frame names its schoolAhmet Kaan Gümüş · cedd07f
✨ feat: AI bridge speaks hab/2; every frame names its school The shared AI fleet now serves every school: `Request`, `ApiRequest` and `BlobRequest` carry `school`, responses echo it, api-reads and blob opens resolve that school's database and files, and rag answers land in the same school. New refusals `unknown_school` / `school_suspended`; hab/1 is rejected at ALPN and at `Hello`.
✨ 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.
🔀 chore: merge main (term archive) into rag/output; rag deletes respect an archived termAhmet Kaan Gümüş · b8069dc
🔀 chore: merge main (term archive) into rag/output; rag deletes respect an archived term
Conflict in course_notes.rs delete_one resolved as require_open → rag cascade → note delete. DELETE /course-notes/{id}/rag/{output_id} now answers 409 on an archived term like the other course-note writes.🗄️ feat: archive academic terms; an archived year is read-onlyAhmet Kaan Gümüş · c4232e6
🗄️ feat: archive academic terms; an archived year is read-only
`Term.archived_at` (nullable, no backfill) plus `POST /terms/{id}/archive`
and `POST /terms/{id}/unarchive` (manager+, idempotent: a repeat archive
keeps the original stamp). While a term is archived its own PATCH/DELETE,
linking a new course or class to it, and every write to a course or
class on it — enrollment, teacher assignment, class membership and
attach/detach/blueprint apply, sessions and roll call, subjects, exams
with their questions, images, attempts and answers, the exam-room
WebSocket door and `finish` frame, grading, homework and submissions,
course notes and files — answer `409` with `code: "term_archived"`.
Reads stay open. The guard is a pre-flight read of the term row: an
archive landing in the same instant as a write lets that one write
through (documented as the third accepted race).
Out of scope on purpose: personal notes, messages, pomodoro, meals,
payments, boards, appointments, chatbot, question pool/bank, events,
blueprint templates, the staff work log, and the role-demotion and
subject-delete integrity sweeps.
Coverage: 155 write routes classified (59 guarded, 93 out of scope);
e2e over real TCP covers archive → refused writes → open reads → the WS
handshake 409 → unarchive; the class refusal-code pin gains
`term_archived`; README prose, tag text and endpoint table regenerated.
Closes #22.🐛 fix: rag_output cascade order, newest-wins replace, sources indexAhmet Kaan Gümüş · ff36c8c
🐛 fix: rag_output cascade order, newest-wins replace, sources index Index the `sources` array (per element) and query it with CONTAINS so the file cascade is a lookup, not a scan; retire the unused `course` index. Run the rag cascade BEFORE the primary delete in both course-note delete handlers: derived rows are disposable, so a failure there leaves the note or file intact instead of 500ing after the row is gone and stranding blobs. Replace is now create-then-drop-older, so two concurrent rag.index tasks converge on exactly one row (the newest monotonic id) with no lock. Ref #27
✨ feat: course-note RAG outputs readable and deletable over HTTPAhmet Kaan Gümüş · b91417d
✨ feat: course-note RAG outputs readable and deletable over HTTP
Part 1 stored what the `rag.index` service produces for a course note but
nothing could read it. Add `GET /course-notes/{id}/rag` (paged, open to
anyone who can view the course) and `DELETE /course-notes/{id}/rag/{output_id}`
(teacher+ with management rights, 204), the delete scoped to the note in the
path so a sibling note's output is a 404 rather than a cross-note delete.
Outputs stay derived data: deleting one suppresses nothing, the next note or
file change may regenerate it.
Ref #27✨ feat: rag_output table + rag.index dispatch for course notesAhmet Kaan Gümüş · d42a1c3
✨ feat: rag_output table + rag.index dispatch for course notes The backend now owns the RAG side of a course note: a new `rag_output` table stores whatever an AI service produced for a note, and the backend asks for it — the AI service still writes no human data, and the api-read bridge stays GET-only. `rag.index` is dispatched fire-and-forget (tokio::spawn) after a note is created, edited, or gains/loses a file, so no HTTP handler waits on, or fails because of, an AI service; with no worker carrying the capability the trigger is a silent no-op. The request carries the note's text plus attachment METADATA only (file bytes deliberately off the wire — open with the service owner). Rows are derived data, so they cascade: the note delete drops its outputs, and a file delete drops every output built from it even when no service is connected. HTTP GET/DELETE routes over the rows are part 2. Ref #27
2026-08-19
✨ feat: course notes uploadable by responsible teacher+Ahmet Kaan Gümüş · 6b1748c
✨ feat: course notes uploadable by responsible teacher+
Mirror of the personal-note stack scoped to a course: course_note +
course_note_file tables, /course-notes routes (POST/GET list?course=,
GET/PATCH/DELETE /{id}, POST/GET /{id}/files, GET/DELETE /{id}/files/{fid}).
Write = can_manage_course (creator, assigned teacher, manager+; live
Teacher role floor). Read = can_view_course (manage or enrolled).
Blob-first upload, cap via cap::claim_and_create (MAX_COURSE_NOTE_FILES),
create-vs-deleted-course refused via cap::touch_and_create, course delete
cascades note/file rows and unlinks blobs.
Tests: 8 integration cases (authz matrix, demoted creator, cross-course
file IDOR, cap 409/413, blob cleanup, cascade 404), race-contract cases
in regress_course_child_orphans, domain unit tests. README Endpoints
table regenerated via doc_sync; Layout updated.