forge
Explore
Log in

Don't you dare go Hollow

Drop ReportSchool.slug

Browse files at this commit

a79354bbf31e8a2b385e7e85245dd70919b51395Ahmet Kaan GümüşParent: 440bab7
  • fix
    • drop ReportSchool.slug
    • school identity is the uuid
Show full message
fix(report): drop ReportSchool.slug; school identity is the uuid

The backend no longer sends slug on the report-school payload. A stray slug key is ignored, and docs plus ZEKA_SCHOOLS examples name the hyphenated school uuid.
README.mdmodified+2 -2
@@ -103,13 +103,13 @@ bir modele o veriyi vermek, erişim kontrolünü modelin içinden dolanmak olurd
103 `hab/2` üzerinde taze bir istemci-başlatımlı akış açar ve çerçeveyi yazar:103 `hab/2` üzerinde taze bir istemci-başlatımlı akış açar ve çerçeveyi yazar:
104 104
105 ```105 ```
106-{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<slug>", "payload": {...} }106+{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<uuid>", "payload": {...} }
107 107
108 { "status": "ok", "id": ..., "school": ..., "payload": {...} }108 { "status": "ok", "id": ..., "school": ..., "payload": {...} }
109 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }109 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }
110 ```110 ```
111 111
112-Okul **çerçevededir**, payload'da değil: backend slug'ı çözer ve her ifadeyi o112+Okul **çerçevededir**, payload'da değil: `school` tireli okul uuid'sidir; backend onu çözer ve her ifadeyi o
113 okulun kendi veritabanında koşturur. Reddin kodu tiplidir (`unknown_school`,113 okulun kendi veritabanında koşturur. Reddin kodu tiplidir (`unknown_school`,
114 `not_permitted`, `invalid_payload`, `too_many_rows`, `unavailable`, …) ve114 `not_permitted`, `invalid_payload`, `too_many_rows`, `unavailable`, …) ve
115 `CapabilityRefused` olarak yükselir; `status: "err"` asla başarı sayılmaz.115 `CapabilityRefused` olarak yükselir; `status: "err"` asla başarı sayılmaz.
deploy/hezarfen_zeka.env.examplemodified+1 -1
@@ -100,7 +100,7 @@ AI_RECONNECT_MAX_SECS=120
100 # Okul KUTUGU backend'dedir: hangi okullarin var oldugu `insight.schools.list`100 # Okul KUTUGU backend'dedir: hangi okullarin var oldugu `insight.schools.list`
101 # yetenek cagrisiyla backend'den okunur. ZEKA_SCHOOLS yalnizca bir FILTREdir;101 # yetenek cagrisiyla backend'den okunur. ZEKA_SCHOOLS yalnizca bir FILTREdir;
102 # BOS BIRAKILIRSA butun aktif okullar islenir -- donem ortasi kayit olan102 # BOS BIRAKILIRSA butun aktif okullar islenir -- donem ortasi kayit olan
103-# ogrenci gorunmez, ayrilan silinmez. Ornek filtre: hezarfen-demo103+# ogrenci gorunmez, ayrilan silinmez. Ornek filtre (tireli okul uuid): 01a0b0a5-ffb5-7682-8726-7e4ef1a5c68d
104 ZEKA_SCHOOLS=104 ZEKA_SCHOOLS=
105 105
106 # Ogrenci listesi hala BURADAN verilir: backend'de kullanici LISTELEME yolu106 # Ogrenci listesi hala BURADAN verilir: backend'de kullanici LISTELEME yolu
service/.env.examplemodified+1 -1
@@ -64,7 +64,7 @@ AI_RECONNECT_MAX_SECS=120
64 #64 #
65 # Okul KUTUGU backend'dedir: hangi okullarin var oldugu `insight.schools.list`65 # Okul KUTUGU backend'dedir: hangi okullarin var oldugu `insight.schools.list`
66 # yetenek cagrisiyla backend'den okunur. ZEKA_SCHOOLS yalnizca bir FILTREdir;66 # yetenek cagrisiyla backend'den okunur. ZEKA_SCHOOLS yalnizca bir FILTREdir;
67-# BOS BIRAKILIRSA butun aktif okullar islenir. Ornek filtre: hezarfen-demo67+# BOS BIRAKILIRSA butun aktif okullar islenir. Ornek filtre (tireli okul uuid): 01a0b0a5-ffb5-7682-8726-7e4ef1a5c68d
68 ZEKA_SCHOOLS=68 ZEKA_SCHOOLS=
69 69
70 # Ogrenci listesi hala buradan verilir: backend'de kullanici LISTELEME yolu70 # Ogrenci listesi hala buradan verilir: backend'de kullanici LISTELEME yolu
service/README.mdmodified+2 -2
@@ -39,13 +39,13 @@ Aynı köprüye, **yetenek çağrısıyla**. Servis taze bir istemci-başlatıml
39 şu çerçeveyi yazar:39 şu çerçeveyi yazar:
40 40
41 ```41 ```
42-{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<slug>", "payload": {...} }42+{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<uuid>", "payload": {...} }
43 43
44 { "status": "ok", "id": ..., "school": ..., "payload": {...} }44 { "status": "ok", "id": ..., "school": ..., "payload": {...} }
45 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }45 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }
46 ```46 ```
47 47
48-Okul çerçevededir; backend slug'ı çözer ve her ifadeyi o okulun kendi48+Okul çerçevededir; `school` tireli okul uuid'sidir. Backend onu çözer ve her ifadeyi o okulun kendi
49 veritabanında koşturur. Dokuz `zeka_*` tablosu orada durur ve DDL'i backend49 veritabanında koşturur. Dokuz `zeka_*` tablosu orada durur ve DDL'i backend
50 deposundadır (`migrations/school/20260917000002_zeka.sql`) — servis ne şema50 deposundadır (`migrations/school/20260917000002_zeka.sql`) — servis ne şema
51 uygular ne de bir veritabanı kullanıcısı ister.51 uygular ne de bir veritabanı kullanıcısı ister.
service/docs/BACKEND-GEREKSINIMLERI.mdmodified+3 -3
@@ -53,7 +53,7 @@ Iki yon birden. Ikisi de ayni cerceve bicimini kullanir
53 cercevededir**, payload'da degil:53 cercevededir**, payload'da degil:
54 54
55 ```55 ```
56-{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<slug>", "payload": {...} }56+{ "id": "<ulid>", "capability": "insight.<ad>", "school": "<uuid>", "payload": {...} }
57 57
58 { "status": "ok", "id": ..., "school": ..., "payload": {...} }58 { "status": "ok", "id": ..., "school": ..., "payload": {...} }
59 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }59 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }
@@ -168,7 +168,7 @@ Backend, okulun `zeka_*` satirlarini **kendi okur** ve tek bir
168 cercevesinde **HTML metni olarak** dondurur. Blob yuklemesi yok, depo yok:168 cercevesinde **HTML metni olarak** dondurur. Blob yuklemesi yok, depo yok:
169 belge, servisin hicbir okuma yapmadigi tek `insight.*` isleyicisidir.169 belge, servisin hicbir okuma yapmadigi tek `insight.*` isleyicisidir.
170 170
171-**Istek payload'i.** Cercevedeki `school` = okul slug'i. Satirlar ZEKA'nin171+**Istek payload'i.** Cercevedeki `school` = tireli okul uuid'si. Satirlar ZEKA'nin
172 depo yoluyla yazdigi bicimdir -- backend'in kendi yapilari (`db/insight.rs`172 depo yoluyla yazdigi bicimdir -- backend'in kendi yapilari (`db/insight.rs`
173 `SummaryRow` / `RecommendationRow` / `ProfileRow` / `RunRow`), yani ikinci bir173 `SummaryRow` / `RecommendationRow` / `ProfileRow` / `RunRow`), yani ikinci bir
174 esleme yok:174 esleme yok:
@@ -178,7 +178,7 @@ esleme yok:
178 | `kind` | str | Zorunlu; sunulan tek deger `okul` |178 | `kind` | str | Zorunlu; sunulan tek deger `okul` |
179 | `run_day` | str | `YYYY-MM-DD` (TR gunu); yoksa en yeni kosu satirindan turetilir |179 | `run_day` | str | `YYYY-MM-DD` (TR gunu); yoksa en yeni kosu satirindan turetilir |
180 | `requested_by` | str | Belgeyi isteyen mudur; okuma yapilmadigi icin yalniz log'a yazilir |180 | `requested_by` | str | Belgeyi isteyen mudur; okuma yapilmadigi icin yalniz log'a yazilir |
181-| `school` | nesne | `{id, slug, name}`; `name` belge BASLIGIDIR, `slug` cerceveyle ayni olmali |181+| `school` | nesne | `{id, name}`; `name` belge BASLIGIDIR, `id` cercevedeki uuid ile aynidir. `slug` yok |
182 | `classes` | liste | `[{id, name}]`: okulun butun subeleri, ad sirasinda. Satirlardaki `marks.classes` KIMLIK tasir; tabloya yazilan GORUNEN ad bu haritadan gelir. Kabul edilen ikinci bicim `class_names: {<id>: "<ad>"}` (`classes` varsa o kazanir) |182 | `classes` | liste | `[{id, name}]`: okulun butun subeleri, ad sirasinda. Satirlardaki `marks.classes` KIMLIK tasir; tabloya yazilan GORUNEN ad bu haritadan gelir. Kabul edilen ikinci bicim `class_names: {<id>: "<ad>"}` (`classes` varsa o kazanir) |
183 | `summaries` | liste | `zeka_student_summary` satirlari (`attention` listesi dahil) |183 | `summaries` | liste | `zeka_student_summary` satirlari (`attention` listesi dahil) |
184 | `recommendations` | liste | `zeka_recommendation` satirlari |184 | `recommendations` | liste | `zeka_recommendation` satirlari |
service/docs/KOPRU-KANITI.mdmodified+1 -1
@@ -278,7 +278,7 @@ dogrulamaz.
278 278
279 ### 5.3 Backend'in kendi mantigi279 ### 5.3 Backend'in kendi mantigi
280 280
281-- **Okul slug dogrulama kurallari.** Backend `Slug::try_new` kullanir; sahte281+- **Okul uuid dogrulama kurallari.** Backend tireli uuid parse eder (`SchoolId::try_parse`); sahte
282 sunucu kaba bir denetim yapar. `malformed` kodu gercek kurallarla uretilmedi.282 sunucu kaba bir denetim yapar. `malformed` kodu gercek kurallarla uretilmedi.
283 - **Kullanici cozumleme.** `on_behalf_of`'un `user:` onekiyle ya da onsuz283 - **Kullanici cozumleme.** `on_behalf_of`'un `user:` onekiyle ya da onsuz
284 okunmasi, silinmis/rutbesi dusurulmus kullanici, `unknown_user` kodu.284 okunmasi, silinmis/rutbesi dusurulmus kullanici, `unknown_user` kodu.
service/src/capabilities.pymodified+2 -2
@@ -193,7 +193,7 @@ class ReportRequest(TypedDict, total=False):
193 yazdigi bicimin aynisi, yani ikinci bir esleme yok. Satirlarda `school`193 yazdigi bicimin aynisi, yani ikinci bir esleme yok. Satirlarda `school`
194 YOKTUR -- ZEKA onu hic yazmaz; cercevede gelir ve isleyici her satira194 YOKTUR -- ZEKA onu hic yazmaz; cercevede gelir ve isleyici her satira
195 damgalar (tek kimlik kaynagi). Payload'daki `school` yalniz GORUNUM icin195 damgalar (tek kimlik kaynagi). Payload'daki `school` yalniz GORUNUM icin
196- (`name` baslikta); `slug` cerceveyle celisirse istek reddedilir.196+ (`name` baslikta, `id` okul uuid'si). Backend `slug` gondermez.
197 """197 """
198 198
199 kind: str199 kind: str
@@ -203,7 +203,7 @@ class ReportRequest(TypedDict, total=False):
203 requested_by: str203 requested_by: str
204 """Belgeyi isteyen mudur. Okuma yapilmadigi icin yalniz log'a yazilir."""204 """Belgeyi isteyen mudur. Okuma yapilmadigi icin yalniz log'a yazilir."""
205 school: dict[str, Any]205 school: dict[str, Any]
206- """`{"id": ..., "slug": ..., "name": ...}` -- `name` belge basligidir."""206+ """`{"id": ..., "name": ...}` -- `id` okul uuid'si, `name` belge basligidir."""
207 classes: list[dict[str, Any]]207 classes: list[dict[str, Any]]
208 """`[{"id": ..., "name": ...}]` -- okulun butun subeleri (kimlik -> GORUNEN208 """`[{"id": ..., "name": ...}]` -- okulun butun subeleri (kimlik -> GORUNEN
209 ad). Satirlardaki `marks.classes` KIMLIK tasir; tabloya yazilan ad bu209 ad). Satirlardaki `marks.classes` KIMLIK tasir; tabloya yazilan ad bu
service/src/cli.pymodified+2 -2
@@ -342,7 +342,7 @@ def build_parser() -> argparse.ArgumentParser:
342 run.set_defaults(func=_cmd_run, is_async=True)342 run.set_defaults(func=_cmd_run, is_async=True)
343 343
344 sweep = sub.add_parser("sweep", help="saklama süresi süpürmesini koştur (köprüden)")344 sweep = sub.add_parser("sweep", help="saklama süresi süpürmesini koştur (köprüden)")
345- sweep.add_argument("--school", required=True, help="okul slug'ı")345+ sweep.add_argument("--school", required=True, help="okul uuid'si")
346 sweep.add_argument("--now", type=int, help="unix ms; yalnız çıktı içindir")346 sweep.add_argument("--now", type=int, help="unix ms; yalnız çıktı içindir")
347 sweep.set_defaults(func=_cmd_sweep, is_async=True)347 sweep.set_defaults(func=_cmd_sweep, is_async=True)
348 348
@@ -351,7 +351,7 @@ def build_parser() -> argparse.ArgumentParser:
351 )351 )
352 schedule.add_argument(352 schedule.add_argument(
353 "--schools",353 "--schools",
354- help="virgülle ayrılmış slug listesi — backend'in verdiği listenin "354+ help="virgülle ayrılmış uuid listesi — backend'in verdiği listenin "
355 "FİLTRESİ. Verilmezse bütün aktif okullar koşar.",355 "FİLTRESİ. Verilmezse bütün aktif okullar koşar.",
356 )356 )
357 schedule.add_argument("--fixtures", required=True)357 schedule.add_argument("--fixtures", required=True)
service/src/handlers.pymodified+4 -11
@@ -102,7 +102,7 @@ _UNAVAILABLE = {
102 "term": "no term directory; `term` must be an ISO-8601 date",102 "term": "no term directory; `term` must be an ISO-8601 date",
103 }103 }
104 104
105-#: School slug -> lock. One compute per school at a time: a dispatched refresh105+#: School uuid -> lock. One compute per school at a time: a dispatched refresh
106 #: and the night scheduler can overlap, and two `run_school` sweeps on one106 #: and the night scheduler can overlap, and two `run_school` sweeps on one
107 #: school would interleave the day's run-ledger row (the row is keyed by107 #: school would interleave the day's run-ledger row (the row is keyed by
108 #: `run_day`) and race the per-student upserts. In-process only, which is108 #: `run_day`) and race the per-student upserts. In-process only, which is
@@ -568,22 +568,15 @@ def _report_school(frame_school: str, payload: dict[str, Any]) -> str:
568 """The value every row is stamped with -- and the document's own school.568 """The value every row is stamped with -- and the document's own school.
569 569
570 The frame's `school` is the tenant identity; `payload.school.name` is the570 The frame's `school` is the tenant identity; `payload.school.name` is the
571- DISPLAY name the report title carries. A payload whose `school.slug`571+ DISPLAY name the report title carries. `payload.school` is `{id, name}`
572- disagrees with the frame is refused: two identity sources is how another572+ (school uuid + title). The backend does not send `slug`; a stray `slug`
573- school's rows reach a document.573+ key is ignored. Identity is the frame alone.
574 """574 """
575 info = payload.get("school")575 info = payload.get("school")
576 if info is None:576 if info is None:
577 return frame_school577 return frame_school
578 if not isinstance(info, dict):578 if not isinstance(info, dict):
579 raise CapabilityError("bad_request", "'school' bir nesne olmali")579 raise CapabilityError("bad_request", "'school' bir nesne olmali")
580- slug = info.get("slug")
581- if isinstance(slug, str) and slug.strip() and slug.strip() != frame_school:
582- raise CapabilityError(
583- "bad_request",
584- f"payload'daki school.slug ({slug!r}) cercevedeki okulla "
585- f"({frame_school!r}) ayni degil",
586- )
587 name = info.get("name")580 name = info.get("name")
588 if isinstance(name, str) and name.strip():581 if isinstance(name, str) and name.strip():
589 return name.strip()582 return name.strip()
service/src/protocol.pymodified+1 -1
@@ -26,7 +26,7 @@ Uc istemci baslatimli sekil, zorunlu alaniyla ayirt edilir: `ApiRequest`'te
26 okur; ucuncusu backend'in bir operasyonunu kosturur -- ZEKA'nin veritabani26 okur; ucuncusu backend'in bir operasyonunu kosturur -- ZEKA'nin veritabani
27 erisimi olmadigi icin yazma yolu YALNIZCA budur.27 erisimi olmadigi icin yazma yolu YALNIZCA budur.
28 28
29-Okul kapsami (`protocol.rs:36-47`): her istek cercevesi okulunu slug ile29+Okul kapsami (`protocol.rs:36-47`): her istek cercevesi okulunu tireli uuid ile
30 adlandirir, her cevap onu yankilar. `Hello` KASITLI olarak okul tasimaz --30 adlandirir, her cevap onu yankilar. `Hello` KASITLI olarak okul tasimaz --
31 filo tum okullar icin paylasilir. Varsayilan ya da geri dusme yoktur.31 filo tum okullar icin paylasilir. Varsayilan ya da geri dusme yoktur.
32 32
service/src/scheduler.pymodified+2 -2
@@ -31,7 +31,7 @@ Tasarım kararları (`MODULLER.md` §2.12)
31 * **Okul listesi her tikte dizinden okunur**: hangi okulların var olduğunu31 * **Okul listesi her tikte dizinden okunur**: hangi okulların var olduğunu
32 kontrol veritabanı bilir (`tenants.py`), yapılandırma değil. `ZEKA_SCHOOLS`32 kontrol veritabanı bilir (`tenants.py`), yapılandırma değil. `ZEKA_SCHOOLS`
33 artık yalnızca bir filtredir; boşsa bütün aktif okullar işlenir.33 artık yalnızca bir filtredir; boşsa bütün aktif okullar işlenir.
34-* **Her okul KENDİ veritabanına yazar**: depo, okulun slug'ından çözülür.34+* **Her okul KENDİ veritabanına yazar**: depo, çerçevedeki okul uuid'sinden çözülür.
35 Tek bir `store` nesnesi paylaşılmaz — paylaşılsaydı bütün okulların satırı35 Tek bir `store` nesnesi paylaşılmaz — paylaşılsaydı bütün okulların satırı
36 ilk okulun veritabanına düşerdi.36 ilk okulun veritabanına düşerdi.
37 * **Günde bir kez.** Bir okul için o TR gününde koşu yapıldıysa tekrar37 * **Günde bir kez.** Bir okul için o TR gününde koşu yapıldıysa tekrar
@@ -185,7 +185,7 @@ class Scheduler:
185 if self._last_run_day.get(school) == day:185 if self._last_run_day.get(school) == day:
186 continue186 continue
187 # Her okul KENDI deposundan yazar: okulun veritabani,187 # Her okul KENDI deposundan yazar: okulun veritabani,
188- # cercevedeki slug'dan cozulur (`tenants.py`). Deposu188+ # cercevedeki uuid'den cozulur (`tenants.py`). Deposu
189 # acilamayan okul dusen okuldur -- tur devam eder, `internal`189 # acilamayan okul dusen okuldur -- tur devam eder, `internal`
190 # diye bir seye donusmez.190 # diye bir seye donusmez.
191 try:191 try:
service/src/store.pymodified+2 -2
@@ -24,7 +24,7 @@ TEL (kablo) SÖZLEŞMESİ
24 istemci-başlatımlı akışta gider (tıpkı `ApiRequest` gibi):24 istemci-başlatımlı akışta gider (tıpkı `ApiRequest` gibi):
25 25
26 { "id": "<ulid>", "capability": "insight.<noun>[.<verb>]",26 { "id": "<ulid>", "capability": "insight.<noun>[.<verb>]",
27- "school": "<slug>", "payload": { ... } }27+ "school": "<uuid>", "payload": { ... } }
28 28
29 { "status": "ok", "id": ..., "school": ..., "payload": { ... } }29 { "status": "ok", "id": ..., "school": ..., "payload": { ... } }
30 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }30 { "status": "err", "id": ..., "school": ..., "code": ..., "message": ... }
@@ -34,7 +34,7 @@ istemci-başlatımlı akışta gider (tıpkı `ApiRequest` gibi):
34 `not_permitted`, `invalid_payload`, `unavailable`, `timed_out`, `internal`,34 `not_permitted`, `invalid_payload`, `unavailable`, `timed_out`, `internal`,
35 `too_many_rows`) ve `CapabilityRefused` olarak yükselir.35 `too_many_rows`) ve `CapabilityRefused` olarak yükselir.
36 36
37-Okul **çerçevededir**, payload'da değil: backend slug'ı çözer ve her ifadeyi37+Okul **çerçevededir**, payload'da değil: `school` tireli okul uuid'sidir; backend onu çözer ve her ifadeyi
38 o okulun kendi veritabanında koşturur. Tek istisna `insight.schools.list`38 o okulun kendi veritabanında koşturur. Tek istisna `insight.schools.list`
39 (deployment ölçekli): çerçevede `school: ""` gider.39 (deployment ölçekli): çerçevede `school: ""` gider.
40 40
service/tests/test_report_capability.pymodified+8 -7
@@ -251,7 +251,7 @@ def payload(**over: Any) -> dict[str, Any]:
251 "kind": "okul",251 "kind": "okul",
252 "run_day": RUN_DAY,252 "run_day": RUN_DAY,
253 "requested_by": "mudur-1",253 "requested_by": "mudur-1",
254- "school": {"id": "01990000-0000-7000-8000-000000000001", "slug": SCHOOL, "name": DISPLAY},254+ "school": {"id": "01990000-0000-7000-8000-000000000001", "name": DISPLAY},
255 # Sibling key, read whole from the school's own class table: the rows255 # Sibling key, read whole from the school's own class table: the rows
256 # carry class IDS, and the document must print NAMES.256 # carry class IDS, and the document must print NAMES.
257 "classes": [257 "classes": [
@@ -426,12 +426,13 @@ class RefusalTests(ReportCase):
426 self.assertEqual(caught.exception.code, "bad_request")426 self.assertEqual(caught.exception.code, "bad_request")
427 self.assertIn("baska-okul", str(caught.exception))427 self.assertIn("baska-okul", str(caught.exception))
428 428
429- async def test_a_school_slug_disagreeing_with_the_frame_is_refused(self) -> None:429+ async def test_a_stray_school_slug_is_ignored(self) -> None:
430- with self.assertRaises(CapabilityError) as caught:430+ # Backend dropped ReportSchool.slug. A leftover key must not refuse
431- await self.dispatch(431+ # and must not become a second identity.
432- payload(school={"id": "x", "slug": "baska-okul", "name": "Başka"})432+ answer = await self.dispatch(
433- )433+ payload(school={"id": "x", "slug": "baska-okul", "name": "Başka"})
434- self.assertEqual(caught.exception.code, "bad_request")434+ )
435+ self.assertIn("Başka", answer["html"])
435 436
436 async def test_a_malformed_row_list_is_refused(self) -> None:437 async def test_a_malformed_row_list_is_refused(self) -> None:
437 with self.assertRaises(CapabilityError) as caught:438 with self.assertRaises(CapabilityError) as caught: