Mods: close three storage gaps Codex's review found

- Reject a second running mod with an id already in use: two mods
  sharing an id would also share capability storage's data_dir,
  letting one read, overwrite or delete the other's state.
- Cap storage to 64 keys per mod, not just 4 MiB: zero- or near-zero-
  byte values could otherwise flood the directory with files the
  byte quota never sees.
- Add a 1 MiB per-call write budget, separate from the 4 MiB on-disk
  quota: a loop replacing one key stays under the quota on every
  check (the total on disk never grows) while still doing unbounded
  synchronous disk I/O per call, which fuel never meters.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
yvonne
2026-10-19 19:56:12 +02:00
parent 8d55af7cae
commit c3f23d9452
4 changed files with 132 additions and 9 deletions
+5 -1
View File
@@ -82,7 +82,7 @@ folder, loads no runtime and plays exactly like vanilla 26.3.
| `game` | `game-read` | `get-player()`: x y z, yaw, pitch, health, food, dimension; `get-clock()`: game time, day time |
| `chat` | `chat` | `show(text)`: a line only the local player sees, after the mod's name (8 per call) |
| `hud` | `hud` | `set-panel(corner, lines)`, `clear()`: up to 16 lines of 256 characters |
| `storage` | `storage` | `get(key)`, `set(key, value)`, `delete(key)`: a per-mod folder of files, 4 MiB total |
| `storage` | `storage` | `get(key)`, `set(key, value)`, `delete(key)`: a per-mod folder of up to 64 files, 4 MiB total, at most 1 MiB written per call |
| Hook (export) | When |
|---|---|
@@ -192,6 +192,10 @@ allocation, next to a healthy mod).
(`mod.<id>:true`).
3. A mod that failed to load or stopped shows why, in red, on its row.
Two turned-on mods never share an `id` while running (it is also capability
`storage`'s directory): the one `find` lists first starts, the other stays
off with the reason on its row.
Benchmarks (`--benchmark`) never load mods.
## Making a mod