hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Regressions for the two holes the 2026-08-05 hunt left standing on the |
| 2 | //! role/parent-link surface: two admins demoting each other could empty the |
| 3 | //! admin set for good, and a parent's student list named accounts that had |
| 4 | //! since been promoted out of `student`. |
| 5 | //! |
| 6 | //! Every assertion re-reads the *store*. The in-memory engine forges wins under |
| 7 | //! concurrency (src/domain/cap.rs), so the race below is judged on how many |
| 8 | //! admins survive, never on which request answered what. |
| 9 | |
| 10 | |
| 11 | |
| 12 | use StatusCode; |
| 13 | use ; |
| 14 | use Database; |
| 15 | use Role; |
| 16 | use UserId; |
| 17 | use json; |
| 18 | |
| 19 | /// How many accounts hold `admin` right now, out of the store. |
| 20 | async |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | /// Two admins demote each other at the same instant. Both `RequireAdmin` |
| 28 | /// extractors resolve against the live rows before either write lands, so |
| 29 | /// before the floor guard both writes committed and the school was left with |
| 30 | /// **zero** admins — unrecoverable, since the boot seed refuses to promote an |
| 31 | /// existing non-admin row. |
| 32 | |
| 33 | async |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | /// The floor itself, driven where it is deterministic. Over HTTP the `409` is |
| 69 | /// reachable only through the race above (demoting an admin needs a *second* |
| 70 | /// admin logged in, so sequentially the target is never the last one), which is |
| 71 | /// exactly why the guard has to live in the writer rather than the handler. |
| 72 | |
| 73 | async |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | /// The self-demotion door, which the floor does not replace: an admin never |
| 106 | /// changes their own role, whether or not others exist. |
| 107 | |
| 108 | async |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | /// A `parent_link` whose student was promoted out — the row a lost sweep race |
| 127 | /// leaves behind, and the row an older build may already have on disk. Written |
| 128 | /// straight into the store (the role change is applied without `set_role`'s |
| 129 | /// sweep, which is precisely the state the race produces) and then read back |
| 130 | /// through both list handlers. |
| 131 | |
| 132 | async |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | /// Ids `sql` selects. |
| 183 | async |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 |