forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/web/boards.rsClear filter

2026-09-25

✨ feat(api): server-side filters on the list doorsAhmet Kaan Gümüş · d8dad92
✨ feat(api): server-side filters on the list doors

A caller no longer has to download a capped collection and narrow it
in the client:

- events, exams: the WindowParams pair is SQL (no whole-table load)
  and gains starts_before/ends_before, so a past/completed view is
  expressible
- sessions: starts_after/starts_before, half-open months
- homework: due_after/due_before (the open/past tabs), class_course
- meals menus: slot (was a post-page JS filter — page counts lied)
- users (admin): roles= comma set; courses: kind, q, taught
- appointments + slots: teacher (or me), starts_after/starts_before,
  status
- pomodoro log: from/to, with the focus total summed in SQL
- messages and boards: q (folded literal substring)
- pool questions: ?status= is a WHERE, not a post-filter
- bank/course-notes id filters: garbage is a 400 naming the field,
  not an empty page

Absent params return today's response byte-shape; page and count
share one WHERE.

2026-09-23

✨ feat: school identity is the uuid; drop the slugAhmet Kaan Gümüş · 2918040
✨ feat: school identity is the uuid; drop the slug

The school slug is gone from every surface: the session cookie prefix,
the /schools/{id} builder routes, FILES_PATH blob dirs, the hab/2 frame
school value, DTOs, and the /limits contract. SchoolId::try_parse is the
one wire parse (hyphenated uuid only); a non-uuid frame school answers
unknown_school. Register gets a public picker via the new unauthenticated
GET /auth/schools returning active [{id, name}]. The control migration
drops school_slug and the slug column, which invalidates every existing
session — old cookie prefixes cannot resolve.
Local-Gate: 3fafffd98aec59c68e2606833b87785d0abf2fee (1510 passed, 425s)

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.
✨ 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-12

🗃️ feat!: port boards, notes and rag to sqlx/PostgresAhmet Kaan Gümüş · c928ecf
🗃️ feat!: port boards, notes and rag to sqlx/Postgres

- board/note/course_note/rag_output db layers: static query!/query_as! against
  the union-schema prepare DB; PagedList/FieldUpdate for the runtime builders
- file caps via the cap claim CTE at each call site; board create claims
  app_user.board_count, delete releases it in the same tx
- BOARD_ROSTER_LOCK deleted: invite is one guarded atomic-array union
  (coalesce(array_agg(DISTINCT unnest(participants || $n))) with a
  cardinality cap on the row version the UPDATE acts on)
- stroke dual-counter claim: one UPDATE bumps both counters, lifetime cap +
  open guard + epoch in the WHERE; zero rows re-read via cap::full_kind
- board clear: pre-image read under SELECT ... FOR UPDATE, refusal precedence
  preserved (closed > not-creator > locked > blank), guarded epoch bump,
  marker insert, one tx (CLEAR_REFUSED THROW now Rust-level refusals)
- rag_output.payload JSONB (sqlx::types::Json), sources uuid[] cascade via
  $n = ANY(sources); note/course_note delete cascades sweep rag_output
  in-tx (real FKs refuse dangling derived rows)
- board rosters: uuid[] + GIN, membership reads $n = ANY(participants)
- dead SurrealQL-shaped constants removed (BOARD_OPEN_GUARD, BOARD_STROKE_TABLE,
  counter/file-count field constants); uuid::Uuid imports for my domain files

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

2026-09-05

🔒 fix: exam presence, board hub and chatbot limiter keys are school-scopedAhmet Kaan Gümüş · 4f92fea
🔒 fix: exam presence, board hub and chatbot limiter keys are school-scoped

In-process maps were keyed by bare record keys, which two schools' databases
can now hand out identically. `state::scoped_key` is the only key
constructor; the maps take the slug themselves so no caller can pass an
unscoped key.
✨ 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-05

🖍️ fix: tell a closed board's room it is closed, not pausedAhmet Kaan Gümüş · fcaf9ca
🖍️ fix: tell a closed board's room it is closed, not paused

A board can hold `locked` and `closed_at` at once — `set_locked` carries no
`WHERE closed_at = NONE` and `close` carries no lock test, so lock→close and
close→lock both land — and the module's two refusal classifiers disagreed
about that state. A stroke re-read the board and tested the lock first, so
`why_refused` answered BOARD_LOCKED ("the creator has paused drawing") for a
permanently read-only board; a clear tested `closed_at` first and answered
BOARD_CLOSED for the same board. Over the socket that is `locked` vs
`board_closed`, and the room is told to wait for a pause that can never lift:
there is no reopen route, and `close` is a one-way CAS.

Closed outranks locked, and the precedence now lives in one place —
`state_refusal` — that both classifiers read, rather than in two hand-kept
chains of the kind that drifted here. The clear path keeps its identity
check between the terminal answer and the pause, so a non-creator still gets
the `403` and a closed board still answers everyone the same.

`set_locked` is deliberately left ungated: locking a closed board is a no-op
on something already read-only, and refusing it would break the second half
of a close-then-lock a client may legitimately send in either order.
fix: 🎨 stop a bulk board invite from dropping the other invite's groupAhmet Kaan Gümüş · 0346717
fix: 🎨 stop a bulk board invite from dropping the other invite's group

`POST /boards/{id}/invite` reads the roster, unions its resolved group
into it, and stores the whole array back. Two invites from the creator
landing together both read roster R: one writes R∪A, the other R∪B, and
the second commit silently drops the first one's people — with both
callers told 200 and a list of participants who are not on the board,
against the route's own "strictly additive, nothing is ever removed by
it" contract. Neither write is wrong on its own, so the database cannot
refuse it; it is a lost update, not an over-cap.

Closed with an in-process lock over the whole read-modify-write, which
genuinely serializes here (one process, stop-the-world deploys) and,
unlike a compare-and-set, does not answer 409 to two calls that do not
conflict in intent. The cap is then checked against the roster actually
read under the lock, so the stored value is the checked value. The
roster branch of `PATCH /boards/{id}` takes the same lock — it reads the
current list before replacing it, so it is the other read-modify-write
of that field, and a lock only half the writers take serializes nothing.

The regression test races two class invites and reads the roster back
off the server: without the lock it drops one group, 2 of 4 members.

2026-08-04

feat: 🧑‍🏫 invite a whole class or club to a boardAhmet Kaan Gümüş · 0e3eae0
feat: 🧑‍🏫 invite a whole class or club to a board

A board roster was one id at a time, so opening a canvas for a class
meant typing thirty of them and the cap refused an ordinary club.

POST /boards/{id}/invite names a group instead — a class section, a
course (a club is a course), or an event's roster, resolved through the
audience machinery events already had. The ids expand once, into the
same flat participants array: a snapshot, not a subscription. Live
resolution would have made is_participant, the room's door and
list_for_user cross-table queries, and would have taken per-person
removal away from the creator, which is most of what a board roster is
for. The board stores no source, so re-inviting is both how a roster is
topped up and the one thing that undoes a removal.

Additive only; removal stays PATCH. The participant cap moves 50 -> 200
and is all-or-nothing — a partial invite would silently pick which half
of a class gets to draw. Ineligible members (gone, or below student, or
already there) drop silently, because one of them must not fail the
invite for the other twenty-nine.

The gate is not a new permission: a roster is visible to everyone on the
board, so inviting a group discloses it, and each source carries the
gate its own listing route carries. Bulk invite is therefore teacher+;
a student can still build a board by hand but cannot pour a class into
one.

resolve_participants now batches its lookup. It read one row per id,
which at the new cap made a read-modify-write PATCH of a class-filled
board — the ordinary client shape now — two hundred sequential reads.

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.
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-08-01

docs: 📐 tell the truth about a board bodyAhmet Kaan Gümüş · c47fb00
docs: 📐 tell the truth about a board body

Rejecting unknown keys made POST and PATCH /boards answer 422, a status
neither utoipa block declared, so a generated client had no case for the
first status a read-modify-write caller hits. Both now list it.

The README went further and promised the opposite of what ships: it said
the shared `participants` spelling meant a client "may post back a board
it just read", but a board response carries id, creator, locked_by and
epoch — all unknown to the request — so a verbatim round-trip is exactly
the 422. It now says to send the writable fields only.

The race test that comes with this is a smoke test and says so: cutting
the retry to a single attempt leaves it green in five runs of five, while
the same cut reddens its course.rs twin in two of three. Nothing exercises
this delete's retry; it stays because the batch is admissible for it, not
because a test has caught it losing a round.

2026-07-31

fix: 🖍️ name the board roster the same on the way in as on the way outAhmet Kaan Gümüş · 43bbae8
fix: 🖍️ name the board roster the same on the way in as on the way out

POST /boards read the invite list from `participant_ids` while the board
response and PATCH /boards/{id} both call it `participants`. Serde ignored
the unknown key, so a client that posted back a board it had just read got
a 201 for a board it was silently alone on — no error, no roster, a seat
spent. The create field is now `participants` like the other two; the repo
is pre-customer and the real volume holds zero board rows, so it is a clean
break with no alias and nothing stored to migrate.

Both board request bodies also deny unknown fields now, which makes the
next misspelling a 422 instead of a silent drop. That is deliberate local
deviation: no other REST DTO in this crate does it, and only these two have
already proven what ignoring a key costs.

Board::delete goes through transaction_with_retry. It was a bare query +
check() around a five-statement cascade that writes the stroke rows, the
board row and the creator's board_count; a stroke claim touching the same
board row aborts it, and check() retired that retryable round as a 500. No
statement can legitimately answer "already exists" — the DELETEs are
idempotent and the UPDATE is field-scoped — so re-sending is sound, and a
forced-abort probe confirmed the aborted round leaves the board, its
strokes and the seat untouched. No statement moved: RETURN stays slot 4.
fix: 🚫 keep parents off the whiteboard entirelyAhmet Kaan Gümüş · 860b4ce
fix: 🚫 keep parents off the whiteboard entirely

A parent is the school's read-only observer, but every board route was
`CurrentUser` only — so a parent could open a board and draw on it.

The cut that does the work is in `resolve_participants`: a parent id is
refused as a participant, so a parent is never on a roster. That alone
makes `board_for` and the room's door answer the outsider's 404 on every
id-scoped route. `POST /boards` and `GET /boards` take `RequireStudent`
(a 403 there leaks nothing — no board exists to hide), while the read
path and the socket door re-check the role and answer 404, never 403,
which would confirm the board is there. Refusing the door is also what
stops a parent drawing: no socket, no `stroke` frame, and no per-stroke
role read on the hot path.

A board row written earlier that still lists a parent is inert — that
parent now sees a 404 for it like any stranger.
feat: 🖌️ open the live board room over a WebSocketAhmet Kaan Gümüş · b9f3988
feat: 🖌️ open the live board room over a WebSocket

`GET /boards/{id}/ws` is the drawing half of the whiteboard: one socket per
participant, persist-then-publish so the fan-out can never carry a mark the
database refused, and a join that replays the current epoch only — a clear
bumps the epoch, it never deletes.

A `Lagged` receiver is the one failure that would corrupt a canvas silently,
so it says so and re-serves the whole current epoch rather than diffing from
a cursor whose gap is exactly what is unknown.

Every gate runs before the upgrade, so a stranger gets a 404 status and not
an instant close, and the roster is re-read on every stroke, clear and lock:
a frame is the prompt, the row is the authority.
feat: 🖍️ collaborative whiteboard domain, REST and limitsAhmet Kaan Gümüş · 5dfce55
feat: 🖍️ collaborative whiteboard domain, REST and limits

Boards are an ad-hoc invite list: the creator names participants, and
every participant draws. Clearing, locking, closing and deleting are the
creator's alone.

Strokes are an append-only log and a clear NEVER deletes — it bumps the
board's epoch, so the live canvas empties while the whole history stays
replayable. The clear marker row doubles as the epoch index, carrying the
epoch it closed and that epoch's final stroke count, which is why there
is no epochs table.

Growth is bounded by two counters claimed together in one conditional
write: epoch_stroke_count resets on a clear and caps the live canvas
(recoverable — clear and keep drawing), while total_stroke_count never
resets and stamps closed_at when the lifetime cap is hit, leaving the
board permanently read-only but fully readable. board_count on user
bounds the open-a-new-board escape hatch.

Outsiders get 404 everywhere so a board's existence never leaks;
a participant lacking creator rights gets 403, since existence has
already been disclosed to them.

The WebSocket room lands separately.