Seats are banked in a cookie the server sets, and a lost seat comes back by name to the address it was last used from

A seat lived in the browser's storage alone, and Safari clears that after a week away, or at a word from the person on another device. Now every seat taken is banked as well in an HttpOnly cookie the server writes, which such clearing leaves alone, and the hall takes its seats back from the bank on arrival. For a browser that lost even the cookie, the ledger notes the address each seat was last used from, as a salted hash, and a name given in the hall or at the table gets its seats back from the same address, with a new token; where the address differs, two people at the table share it, or the host gave the seat to a bot, the table is only counted, and the host's phrase or the keeper's link is the way back. The keeper's script finds a name across tables.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCLa2PaEeCj8njQZSWGqHx
This commit is contained in:
Eric WagonerandClaude Fable 5.1 committed 2026-11-10 21:22:10 -05:00
1 parent a66b0fe3f5
commit 29a15e7c89
9 files changed
+358 -14

No files matched your search

+13 -2
View File
@@ -2,7 +2,7 @@
// top: the engine is deterministic given the seed and the recorded inputs, so
// nothing else needs saving.
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
import type { SeatId, TableOptions } from '../../src/lib/game/spec';
@@ -43,7 +43,9 @@ export type LedgerLine =
/** A seat is held for the keeper of the site, called to the table. */
| { t: 'challenge'; at: number; by: SeatId; keeper: string }
/** A finished table called for a rematch: where it went, and who called. */
| { t: 'rematch'; at: number; to: string; by: SeatId };
| { t: 'rematch'; at: number; to: string; by: SeatId }
/** The address a person's seat was last used from, as a salted hash, so a seat a browser lost can go back to the same address. */
| { t: 'seen'; at: number; id: SeatId; addr: string };
export class Store {
constructor(private dir: string) {
@@ -72,6 +74,15 @@ export class Store {
return existsSync(this.path(roomId));
}
/** When the ledger was last written, for passing over tables long finished. */
updatedAt(roomId: string): number {
try {
return statSync(this.path(roomId)).mtimeMs;
} catch {
return 0;
}
}
roomIds(): string[] {
return readdirSync(this.dir)
.filter((f) => f.endsWith('.jsonl'))