15. Repositories and the round reset register themselves
15. Repositories and the round reset register themselves (#317)
Section titled “15. Repositories and the round reset register themselves (#317)”- [E] Decided by the owner (2026-11-20, #317):
src/server/db/repos/index.ts, its test and theDELETElines ofnewRoundinsrc/server/game/admin.tsname no feature any more. - [V] Repositories (main agent’s proposal): a module in
src/server/db/repos/exportsrepository = { key, make } as const satisfies RepositoryModule(contract.ts).keyis the name onCtx(ctx.market),make(db)builds the repository and its return type is the type ofctx.<key>: the interface, not the class (the classes are no longer exported).scripts/gen-features.tswrites the git-ignoredrepositories.gen.ts(REPOSITORIES,[file, repository]pairs); the typeRepositoriesis derived from it, so every repository keeps its type without a line in a shared file.assembleRepositories(index.ts) throws when a key exists twice, naming both files; the guard issrc/server/db/repos/index.test.ts. - [V] The round reset: a file of
src/serverthat owns tables exportsroundReset, a list of steps (src/server/db/round-reset.ts):{ order, clears: [tables], when? }empties the tables withDELETE FROMin the order of the numbers (a table whose parent deletes it by cascade needs no entry; the referring table comes first where there is no cascade), and{ keeps: [tables], when? }says that a new round leaves them on purpose (accounts, settings, the round archive, the buddy list, the playtime).whentakes the rules of the new round (the guilds are emptied only in a round with guilds off). The list issrc/server/round-reset.gen.ts(ROUND_RESETS);newRoundcallsclearRound(ctx.db, rules, ROUND_RESETS)and keeps only what is not a table of a feature: the player loop (research, main planet, vacation, reports of the player, the new home planet).src/server/db/round-reset.test.tschecks the rules (a number or a table twice, a name that is no table of the schema);src/server/game/round-reset.test.tswrites one marked row into every table of the schema and runs a reset: the row of a table that is neither emptied nor declared as kept survives and fails the test, so a new table cannot be forgotten and no list has to be edited. - [V] The orders are the ones of the old code, ten apart: planets 10, guilds 20 (guilds off) and their chats 30, fleets 40, debris 50, last targets 60, surveys 70, market 80, push jobs 90, attack union invites 100, achievements 110.