🧪 the three gates the merged /rag tree left red
Browse files at this commitebffd41acbeb31d10b21d6eeb70a9dbaaaa29b10Parent: 39f97e4- fix
- 🧪 the three gates the merged /rag tree left red
4 changed files +13 -13
- .gitignore +1 -0
- README.md +1 -1
- tests/ai_protocol.rs +3 -2
- tests/integration.rs +8 -10
.gitignoremodified+1 -0
| @@ -3,3 +3,4 @@ | |||
| 3 | .env | 3 | .env |
| 4 | /history.txt | 4 | /history.txt |
| 5 | /graphify-out | 5 | /graphify-out |
| 6 | +/src/graphify-out | ||
README.mdmodified+1 -1
| @@ -1153,7 +1153,7 @@ window filtering, before paging; negative values are a `400` naming the field. | |||
| 1153 | | DELETE | `/academic-years/{id}` | manager | Delete an academic year. Requires manager+. Refused with a 409 while any şube or dönem still links it — move or delete them first. An archived year must be re-opened (`PATCH` is not enough: there is no unarchive here, so the row is only deletable while open) like every other past-structure write. | | 1153 | | DELETE | `/academic-years/{id}` | manager | Delete an academic year. Requires manager+. Refused with a 409 while any şube or dönem still links it — move or delete them first. An archived year must be re-opened (`PATCH` is not enough: there is no unarchive here, so the row is only deletable while open) like every other past-structure write. | |
| 1154 | | POST | `/academic-years/{id}/archive` | manager | Archive an academic year. Requires manager+. Stamps `archived_at`, and from then on the whole year is past structure: no new şube, no new dönem, no exam inside it, and no edit or delete of the year itself. Idempotent — a second archive answers `200` with the stamp that already stood. There is no unarchive route: the row is deletable only while open. | | 1154 | | POST | `/academic-years/{id}/archive` | manager | Archive an academic year. Requires manager+. Stamps `archived_at`, and from then on the whole year is past structure: no new şube, no new dönem, no exam inside it, and no edit or delete of the year itself. Idempotent — a second archive answers `200` with the stamp that already stood. There is no unarchive route: the row is deletable only while open. | |
| 1155 | | POST | `/academic-years/{id}/rollover` | manager | Carry another year's şubeler into this one. Requires manager+. Each şube of `from_year` whose grade the target year promotes is planted afresh here — same name, mapped grade, and copies of its instances (`ders_saati`, karne policy, teachers) and of every live member, who are also enrolled into the new instances. A grade with no promotion entry stays behind: that is graduation, and `graduated` names it. The target must be empty (a second rollover into it is a 409, which is what makes the command idempotent), open, and different from the source. | | 1155 | | POST | `/academic-years/{id}/rollover` | manager | Carry another year's şubeler into this one. Requires manager+. Each şube of `from_year` whose grade the target year promotes is planted afresh here — same name, mapped grade, and copies of its instances (`ders_saati`, karne policy, teachers) and of every live member, who are also enrolled into the new instances. A grade with no promotion entry stays behind: that is graduation, and `graduated` names it. The target must be empty (a second rollover into it is a 409, which is what makes the command idempotent), open, and different from the source. | |
| 1156 | -| GET | `/ai/capabilities` | no | The capabilities connected AI services are serving right now, per capability, with the work in flight — a discovery read for an operator or a service deciding what it may ask this bridge to do. | | 1156 | +| GET | `/ai/capabilities` | student | The capabilities connected AI services are serving right now, per capability, with the work in flight — a discovery read for an operator or a service deciding what it may ask this bridge to do. | |
| 1157 | | GET | `/ai/certificate` | no | The AI bridge's certificate (PEM + SHA-256 fingerprint) for a service to pin; `404` when the bridge is off. | | 1157 | | GET | `/ai/certificate` | no | The AI bridge's certificate (PEM + SHA-256 fingerprint) for a service to pin; `404` when the bridge is off. | |
| 1158 | | GET | `/api-docs/openapi.json` | no | Raw OpenAPI 3 spec | | 1158 | | GET | `/api-docs/openapi.json` | no | Raw OpenAPI 3 spec | |
| 1159 | | GET | `/appointments` | student | List bookings, newest first. Students and parents see the ones they requested; teacher+ see the ones aimed at their own slots — their request inbox. Managers and admins read their own inbox too (they may still decide any booking by id). Paged via `?limit=&offset=` (omit `limit` for every booking); returns a `{items, total, limit, offset}` envelope. | | 1159 | | GET | `/appointments` | student | List bookings, newest first. Students and parents see the ones they requested; teacher+ see the ones aimed at their own slots — their request inbox. Managers and admins read their own inbox too (they may still decide any booking by id). Paged via `?limit=&offset=` (omit `limit` for every booking); returns a `{items, total, limit, offset}` envelope. | |
tests/ai_protocol.rsmodified+3 -2
| @@ -1063,7 +1063,7 @@ async fn rag_chat_payloads_carry_the_documented_wire_keys() { | |||
| 1063 | // Byte-level: the `(sinif, ders)` pair set, not a re-wrapped shape. | 1063 | // Byte-level: the `(sinif, ders)` pair set, not a re-wrapped shape. |
| 1064 | let text = String::from_utf8(bytes).expect("the frame body is UTF-8 JSON"); | 1064 | let text = String::from_utf8(bytes).expect("the frame body is UTF-8 JSON"); |
| 1065 | assert!( | 1065 | assert!( |
| 1066 | - text.contains(r#""scope":[{"sinif":"11","ders":"Fizik"}]"#), | 1066 | + text.contains(r#""scope":[{"ders":"Fizik","sinif":"11"}]"#), |
| 1067 | "{text}" | 1067 | "{text}" |
| 1068 | ); | 1068 | ); |
| 1069 | 1069 | ||
| @@ -1083,7 +1083,8 @@ async fn rag_chat_payloads_carry_the_documented_wire_keys() { | |||
| 1083 | let id = frame["id"].as_str().expect("trace id").to_string(); | 1083 | let id = frame["id"].as_str().expect("trace id").to_string(); |
| 1084 | raw::answer( | 1084 | raw::answer( |
| 1085 | send, | 1085 | send, |
| 1086 | - format!(r#"{{"status":"ok","id":"{id}","school":"{SCHOOL}","payload":{reply}}}"#).as_bytes(), | 1086 | + format!(r#"{{"status":"ok","id":"{id}","school":"{SCHOOL}","payload":{reply}}}"#) |
| 1087 | + .as_bytes(), | ||
| 1087 | ) | 1088 | ) |
| 1088 | .await; | 1089 | .await; |
| 1089 | 1090 | ||
tests/integration.rsmodified+8 -10
| @@ -27164,15 +27164,8 @@ async fn course_note_creator_writes_assigned_teacher_refused_and_enrolled_studen | |||
| 27164 | // (a) the creator writes note + file. | 27164 | // (a) the creator writes note + file. |
| 27165 | let note = create_course_note(&app, &creator, &course, "recap").await; | 27165 | let note = create_course_note(&app, &creator, &course, "recap").await; |
| 27166 | let bytes = b"%PDF-1.4 fake"; | 27166 | let bytes = b"%PDF-1.4 fake"; |
| 27167 | - let up = upload_course_note_file( | 27167 | + let up = |
| 27168 | - &app, | 27168 | + upload_course_note_file(&app, &creator, ¬e, "recap.pdf", "application/pdf", bytes).await; |
| 27169 | - &creator, | ||
| 27170 | - ¬e, | ||
| 27171 | - "recap.pdf", | ||
| 27172 | - "application/pdf", | ||
| 27173 | - bytes, | ||
| 27174 | - ) | ||
| 27175 | - .await; | ||
| 27176 | assert_eq!(up.status, StatusCode::CREATED, "{}", up.body); | 27169 | assert_eq!(up.status, StatusCode::CREATED, "{}", up.body); |
| 27177 | let file_id = id_of(&up.body); | 27170 | let file_id = id_of(&up.body); |
| 27178 | 27171 | ||
| @@ -29685,8 +29678,13 @@ const CORE_PREFIXES: [(&str, &str); 13] = [ | |||
| 29685 | /// Every module's nest prefix. Written down rather than derived: the point is | 29678 | /// Every module's nest prefix. Written down rather than derived: the point is |
| 29686 | /// to catch a nest that was mounted without a gate, and a derived list would | 29679 | /// to catch a nest that was mounted without a gate, and a derived list would |
| 29687 | /// be derived from the same code it is checking. | 29680 | /// be derived from the same code it is checking. |
| 29688 | -const MODULE_PREFIXES: [(Module, &str); 22] = [ | 29681 | +/// |
| 29682 | +/// A module may own more than one prefix: `courses` also answers under | ||
| 29683 | +/// `/instances` (the instance anchor), and `chatbot` — the whole `ai` package — | ||
| 29684 | +/// also answers under `/rag`. | ||
| 29685 | +const MODULE_PREFIXES: [(Module, &str); 23] = [ | ||
| 29689 | (Module::Chatbot, "/chatbot"), | 29686 | (Module::Chatbot, "/chatbot"), |
| 29687 | + (Module::Chatbot, "/rag"), | ||
| 29690 | (Module::Notes, "/notes"), | 29688 | (Module::Notes, "/notes"), |
| 29691 | (Module::Messages, "/messages"), | 29689 | (Module::Messages, "/messages"), |
| 29692 | (Module::Events, "/events"), | 29690 | (Module::Events, "/events"), |