forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/domain/role.rsClear filter

2026-09-17

🔧 chore: give ResolvedTenant its core home and make constant.rs a leafAhmet Kaan Gümüş · d0dce85
🔧 chore: give ResolvedTenant its core home and make constant.rs a leaf

Two structural defects a knowledge-graph pass over src/+tests/+migrations
surfaced. Both were verified against the real `use` lines before being called
defects — a module cycle is legal Rust, so only the layering facts count.
No behavior change: every moved item is byte-identical in name, type, value,
element order and doc text.

- `ResolvedTenant` was *declared* in `src/web/tenant_state.rs` but *built and
  returned* by `Tenants::resolve` (`src/tenant.rs`), so the core tenant
  registry imported the web layer. The struct moves to `src/tenant.rs`; its
  `impl FromRequestParts` stays in the web module (same crate, local type).
  That deletes the crate's only core→web import edge, and with it the three
  module cycles running through `state.rs` and `ai::server`.
- `constant.rs` is documented "Validation limits, in one place" but imported
  four domain enums to hold non-limit vocabularies: `ROLES` → `domain/role.rs`,
  `THEMES`/`LANGUAGES` → `domain/preferences.rs`, `SENDER_FOLDERS`/
  `RECIPIENT_FOLDERS` → `domain/message.rs`, and the 34-row `BADGES` catalogue
  → `domain/badge.rs`. Each now lives in the module that owns its type, so
  `constant.rs` imports nothing from `crate::domain` and ten
  `constant ↔ domain` cycles disappear. `AI_PRINCIPAL_KEY` and
  `PALETTE_COLOR_*` stayed put.

Measured on the same corpus: 20 → 7 reported import cycles — all ten
constant↔domain and all three tenant↔web cycles gone. The surviving seven are
intra-layer domain cycles plus the ai↔web pair; the AI bridge is a peer
front-end reusing web authorization helpers, which is deliberate, not an
inversion.

Tests: the published-or-excluded guard in `limits_completeness` read only
`src/constant.rs`, so the five moved tables silently left its scan — the one
place this move weakened coverage. It now covers them by name, and its
`references()` check no longer counts a bare `use` line as "published", which
the first witness attempt proved had made the guard vacuous. Witnessed by
mutating BADGES and then ROLES out of `/limits`: each FAILs naming the moved
table, and each restore is sha256-identical.

Gates: no SQL touched (.sqlx and migrations clean), prepare DB unchanged;
SQLX_OFFLINE=true cargo check --all-targets, clippy -D warnings,
limits_completeness, spec_bounds all green; cargo nextest run 1386/1386 across
47 binaries (doc_sync included).

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

✉️ feat: messages go upward only; students and parents can search staffAhmet Kaan Gümüş · 1d423c0
✉️ feat: messages go upward only; students and parents can search staff

A student or parent may only write to a teacher, manager or admin
(`Role::may_message`); staff still write to anyone. `POST /messages`
answers 403 below that bar, and only new sends are gated — stored
student↔student rows stay readable and filable.

`GET /users/search` opens to every signed-in role: a caller below
teacher sees only the staff they may message (the restriction sits in
the query, so `total` stays right), and asking for `role=student` or
`role=parent` from there is a 403. This is the recipient picker the
messaging rule needs.

Closes #23, closes #24.

2026-08-12

🤖 feat: add service-only Role::AiAhmet Kaan Gümüş · 3a01d26
🤖 feat: add service-only Role::Ai

The principal an out-of-process AI service carries over the QUIC bridge.
Declared first in the enum so the derived Ord puts it under every role: it
clears no `at_least` bar and fails every exact `== Role::Student` /
`== Role::Parent` gate. Absent from ROLES, which is what makes it
unassignable — `try_from_str` searches that table, so "ai" is rejected like
any unknown word, and /limits keeps listing the five human roles. Role still
carries no serde derive, so nothing deserializes it off the wire.

`User::ai_principal` builds it in memory only, on the literal record key
`ai_service` that no minted ULID can collide with, with an empty password
hash that verifies against nothing. Never written to the database.

The web DTO gains the variant because the mapping is exhaustive, so "ai"
appears in the OpenAPI Role schema — documented there as never assignable.

2026-07-26

chore: 📦 give every constant one homeAhmet Kaan Gümüş · 78b25b5
chore: 📦 give every constant one home

Constants were scattered across 18 modules: table names and migration SQL in
database.rs, limits in config.rs and rate_limit.rs, magic strings sitting next
to the only code that read them. Nobody could answer "what are all the hard
values in this service?" without a grep.

They all live in constant.rs now — validation bounds, the 37 SurrealDB table
names, the PRE_REPAIR/MIGRATION/BACKFILL schema SQL, and the enum value tables
that used to hide as associated consts (Role::ALL -> ROLES, Folder::SENDER ->
SENDER_FOLDERS, and friends). Values are byte-identical; this changes no
behavior. constant.rs now imports crate::domain for the enum types, an
intra-crate cycle that compiles fine.

Statics stayed where they were. A Mutex or a ULID generator is runtime state,
not a constant, and moving them would only blur that line.

Two guards keep the consolidation honest. limits_completeness.rs already
failed on any pub const in constant.rs that is neither published through
/limits nor excluded with a reason; the *_TABLE names are excused by shape
rather than by 37 lines of boilerplate, but the excuse now requires the
absence of a MAX_/MIN_/DEFAULT_ prefix so a real bound cannot hide behind the
naming convention. And the move quietly dropped three rules off the end of the
text-fold table, which every existing test still passed — so the circumflexed
vowels are pinned, and search_fold_sql must emit one string::replace per rule
or the needle and the column drift apart.

2026-07-19

✨ feat(users): read-only parent role with student tiesAhmet Kaan Gümüş · ec44315
✨ feat(users): read-only parent role with student ties

Parent sits below student in the hierarchy: clears no staff bar and
fails every exact student gate, so it can only observe. Admins tie
students to a parent under /users/{id}/students; the tie alone opens
the student's marks/attendance/pomodoro reports (full, unnarrowed)
plus the parent's own /users/me/students list. A role change off
either end of a tie sweeps it, mirroring the enrollment sweep.

2026-07-11

✨ feat(domain): validated newtypes and entity persistenceAhmet Kaan Gümüş · ba2b9b1
✨ feat(domain): validated newtypes and entity persistence

Every value is a newtype constructed only after its validator passes
(Username, Password, NoteTitle, Mark, ...), so an invalid value can't
be represented. Each type derives SurrealValue, so one typed value
flows unchanged from HTTP input into the SCHEMAFULL store, and each
entity module owns its own persistence.

- user/role: argon2-hashed passwords; four hierarchical roles
  (student < teacher < manager < admin) with at_least() checks.
- session: an opaque random token, 7-day expiry, server-side lookup.
- note: per-user notes.
- event/attendance: events own attendance rows keyed by event+user;
  optional unix-millisecond starts_at/ends_at with ends >= starts.
- exam/exam_result: homework|quiz exams; one 0-100 mark per exam+user
  in its own row, never on a note.
- timestamp: the unix-millisecond instant shared across entities.

Record ids are ULIDs — time-sortable and safe to expose.