test: pin that retiring a game cannot delete a reader's own events

Nothing in the client prunes reader data today — no store filters against the
feed, knownGames only appends, metaFor renders a lane whose game is gone — so a
retired source, page or game leaves completion marks, streaks and hand-entered
events untouched. That was true by construction and pinned nowhere.

The load path is what makes it worth pinning. useCustom reads through
validRecords, which drops a record that fails its schema, and the survivors are
what the next write persists. A record that stops parsing is therefore not
hidden until someone notices — it is deleted from the device, permanently, by
the act of opening the app, with no server-side copy to recover it from.

Which makes CustomEvent.game being z.string() rather than GameId the whole
safety property, and it currently reads like validation someone forgot. Anyone
narrowing it to the enum would be tightening a schema and arming every future
game removal to erase reader data on next launch. The tests state the premise,
the survival, and that one unreadable neighbour still does not take the rest
down; the field says why it is loose.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-19 04:40:04 +02:00
co-authored by Claude Opus 5
parent acadbfa17a
commit 239e970471
3 changed files with 86 additions and 2 deletions
+13 -1
View File
@@ -69,7 +69,19 @@ export type CustomGame = z.infer<typeof CustomGame>;
export const CustomEvent = z
.object({
id: CustomEventId,
/** A tracked game, or one of theirs — a source can miss an event too. */
/**
* A tracked game, or one of theirs — a source can miss an event too.
*
* **`z.string()` and not `GameId`, deliberately.** We retire games, sources
* and pages routinely, and this field is the only thing standing between
* that and a reader losing a row they typed: `useCustom` reads through
* `validRecords`, which drops a record that fails this schema, and the
* survivors are what the next write persists. Narrowing this to the enum
* would read as a tightening and would arm every future removal to erase
* reader data on next launch — silently, with no server-side recovery,
* exactly as § Event IDs are localStorage keys describes for `slugify`.
* `metaFor` is total so an id with no game behind it still renders.
*/
game: z.string().min(1),
title: z.string().min(1).max(200),
type: EventType,