forge
Explore
Log in

Don't you dare go Hollow

Modules subsection — what a school buys, dependencies, batch semantics

Browse files at this commit

11422c36f355110a07f5aa95c9db75b82bcd66c9Ahmet Kaan GümüşParent: c78e41a
  • docs
    • modules subsection — what a school buys, dependencies, batch semantics
Show full message
📝 docs: modules subsection — what a school buys, dependencies, batch semantics
README.mdmodified+121 -1
@@ -321,6 +321,124 @@ its uploaded files. Irreversible on purpose: suspension is the reversible door.
321 **AI frames name the school.** One AI service serves the whole deployment, so321 **AI frames name the school.** One AI service serves the whole deployment, so
322 every `hab/2` frame carries a `school` field — see "AI bridge (QUIC)".322 every `hab/2` frame carries a `school` field — see "AI bridge (QUIC)".
323 323
324+### Modules
325+
326+A **module** is one router nest (`/meals`, `/exams`, `/boards`, …) sold as a
327+unit: the thing a school buys and the thing the router refuses are the same
328+thing, so there is no per-route entitlement list to keep in step with the
329+routes. A school's set is stored on its registry row, defaults to everything on
330+`POST /schools` (pass `modules` there to sell less), and is the vendor's to
331+change afterwards.
332+
333+There are 21 modules, bundled into four packages. A package is only a name for
334+a set of modules — entitlement is always stored per module, so re-packaging
335+never migrates a school's row. `requires` is structural, never commercial:
336+every edge below is a stored `record<…>` reference into the other module's data
337+(or a report that reads it), which is why a set that breaks one is refused.
338+
339+| Module | Package | Requires |
340+| --- | --- | --- |
341+| `attendance` | `academics` | `events`, `sessions` |
342+| `bank_questions` | `academics` | — |
343+| `classes` | `academics` | `courses` |
344+| `course_notes` | `academics` | `courses` |
345+| `courses` | `academics` | — |
346+| `exams` | `academics` | `courses`, `subjects` |
347+| `homework` | `academics` | `courses`, `subjects` |
348+| `marks` | `academics` | `exams` |
349+| `sessions` | `academics` | `courses` |
350+| `subjects` | `academics` | `courses` |
351+| `appointments` | `communication` | — |
352+| `boards` | `communication` | — |
353+| `events` | `communication` | — |
354+| `messages` | `communication` | — |
355+| `notes` | `communication` | — |
356+| `questions` | `communication` | — |
357+| `meals` | `operations` | — |
358+| `payments` | `operations` | — |
359+| `pomodoro` | `operations` | — |
360+| `work` | `operations` | — |
361+| `chatbot` | `ai` | — |
362+
363+`GET /modules/catalog` publishes exactly this table (unauthenticated and
364+deploy-constant, like `GET /limits`), and `GET /modules` answers any signed-in
365+user with their own school's enabled set — so a client hides a nest the school
366+never bought instead of discovering it as a `403`. Both are ungated on purpose:
367+an entitlement lookup a disabled module could switch off would be unusable
368+exactly when it is needed.
369+
370+**The dependency rule.** A module may not be on without what it requires, and
371+may not be taken back while something the school still has requires it. Both
372+refusals are `409` and both name *every* violation at once, so a caller fixing
373+a set does not discover the problems one round trip at a time:
374+
375+```json
376+{"error": "conflict: exams requires courses, which is not enabled; exams requires subjects, which is not enabled"}
377+{"error": "conflict: courses is required by exams, subjects"}
378+```
379+
380+**Selling.** `GET /schools/{slug}/modules` returns both halves (`enabled` +
381+`disabled`, each sorted — together they are the whole catalog).
382+`POST|DELETE /schools/{slug}/modules/{module}` moves one module and is
383+idempotent: a module the school already has (or already lacks) is a `200` with
384+the unchanged set. An unknown module name in the path is a `404`, the same
385+verdict an unknown school gets.
386+
387+`PATCH /schools/{slug}/modules` re-sells the whole shelf in one call, with any
388+mix of the four optional lists `enable`, `disable`, `enable_packages`,
389+`disable_packages` (a package expands to its modules). The lists are folded
390+into **one** resulting set, which is validated **once** and written **once or
391+not at all** — so a `PATCH` enabling `exams` and `subjects` together succeeds
392+where two single calls would refuse the first, and a rejected request leaves the
393+row untouched. An empty body, or a set equal to the current one, is a no-op
394+`200`. An unknown module or package name is a `400`, and so is a name pulled
395+both ways at once — picking a side silently would sell (or unsell) a module the
396+caller also asked for the opposite of:
397+
398+```json
399+{"error": "module: `kantin` is not a known module"}
400+{"error": "module: `meals` is asked for in both directions at once"}
401+```
402+
403+**What a disabled module looks like from inside the school.** Every route in
404+its nest answers:
405+
406+```json
407+{"error": "module disabled", "module": "meals"}
408+```
409+
410+with `403`. The gate is a `route_layer`, so a path that does not exist inside a
411+disabled nest is still a `404` — a disabled module is a refusal on the routes
412+that exist, not a wall around a URL space. The four child routes under
413+`/courses/{id}` that belong elsewhere (`/exams`, `/sessions`, `/subjects`,
414+`/homework`) carry the child module's gate as well as the `courses` one, so
415+either being off refuses. Nothing is deleted: a disabled module's rows stay put
416+and come back untouched when it is re-enabled.
417+
418+**Core is never gated.** Auth, users, settings, terms, `GET /limits`, the
419+module lookups themselves, AI discovery and the whole builder surface answer
420+whatever a school has bought — they are how a school logs in, is configured and
421+is fixed.
422+
423+**A change takes effect on the school user's next request**, with the same
424+cookie and no re-login: the registry row is read on every request, exactly like
425+suspension.
426+
427+**The AI bridge obeys the same entitlements.** An api-read frame is dispatched
428+into the router carrying the school's module set, so a read into a disabled
429+nest comes back as that same `403` body. The blob stream is the one surface
430+that bypasses the router, so it checks `course_notes` by hand and refuses with
431+code `module_disabled` when the school does not have it.
432+
433+A walk-through — the vendor takes `meals` away and gives it back:
434+
435+```bash
436+curl -c v.txt -X POST localhost:6060/builder/login -H 'content-type: application/json' -d '{"username":"builder","password":"correct horse battery"}'
437+curl -b v.txt -X DELETE localhost:6060/schools/demo/modules/meals # 200, meals now in "disabled"
438+curl -b s.txt localhost:6060/meals/menus # 403 {"error":"module disabled","module":"meals"}
439+curl -b v.txt -X POST localhost:6060/schools/demo/modules/meals # 200, and the student's next call works again
440+```
441+
324 ## Auth model442 ## Auth model
325 443
326 Login sets an `HttpOnly`, `SameSite=Lax` `session` cookie (7-day expiry, stored444 Login sets an `HttpOnly`, `SameSite=Lax` `session` cookie (7-day expiry, stored
@@ -800,7 +918,9 @@ slug), not the control one — e.g.
800 `Auth` is the minimum role; `no` means no session required, `student` means any918 `Auth` is the minimum role; `no` means no session required, `student` means any
801 logged-in user. `builder` is not a school role: it means the deployment's919 logged-in user. `builder` is not a school role: it means the deployment's
802 vendor account (see the `builder` tag), whose cookie is refused on every other920 vendor account (see the `builder` tag), whose cookie is refused on every other
803-endpoint here exactly as a school's cookie is refused on its.921+endpoint here exactly as a school's cookie is refused on its. The table lists
922+every route this deployment serves; a route in a module the school has not
923+bought answers `403 {"error": "module disabled", …}` instead — see "Modules".
804 924
805 A course is a regular taught course (kind `course`, the default), an *etüt* (kind925 A course is a regular taught course (kind `course`, the default), an *etüt* (kind
806 `study` — a supervised study session), or a *kulüp* (kind `club` — a student926 `study` — a supervised study session), or a *kulüp* (kind `club` — a student