The lost-seat search has a limit of its own, and the hall speaks of a housecarl

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:30:23 -05:00
1 parent 41630f73cf
commit 070fe44a5e
3 files changed
+6 -3

No files matched your search

+4 -1
View File
@@ -95,6 +95,8 @@ const galleryVoices = new RateLimit(30, 10 * 60 * 1000);
const bells = new RateLimit(3, 60 * 60 * 1000); const bells = new RateLimit(3, 60 * 60 * 1000);
/** Claims on transfer phrases: a phrase is guessed, not brute-forced. */ /** Claims on transfer phrases: a phrase is guessed, not brute-forced. */
const claims = new RateLimit(10, 10 * 60 * 1000); const claims = new RateLimit(10, 10 * 60 * 1000);
/** Searches for lost seats: each reads every table written to lately, and a person loses their seats rarely. */
const searches = new RateLimit(5, 10 * 60 * 1000);
const MAX_AUDIENCE = 30; const MAX_AUDIENCE = 30;
/** How often each socket is asked to answer; one silent through a whole round is a browser gone, and is closed. */ /** How often each socket is asked to answer; one silent through a whole round is a browser gone, and is closed. */
const PING_MS = Number(process.env.PING_MS ?? 30_000); const PING_MS = Number(process.env.PING_MS ?? 30_000);
@@ -107,6 +109,7 @@ setInterval(() => {
galleryVoices.prune(); galleryVoices.prune();
bells.prune(); bells.prune();
claims.prune(); claims.prune();
searches.prune();
if (n) console.log(`evicted ${n} idle room${n === 1 ? '' : 's'} from memory; ${rooms.loaded} loaded`); if (n) console.log(`evicted ${n} idle room${n === 1 ? '' : 's'} from memory; ${rooms.loaded} loaded`);
}, 60 * 60 * 1000).unref(); }, 60 * 60 * 1000).unref();
@@ -345,7 +348,7 @@ async function handle(req: IncomingMessage, res: ServerResponse): Promise<void>
return send(res, 200, { seats }); return send(res, 200, { seats });
} }
if (parts[2] === 'find' && parts.length === 3) { if (parts[2] === 'find' && parts.length === 3) {
if (!claims.allow(clientOf(req))) throw new RoomError('Too many searches from here just now; try again later.', 429); if (!searches.allow(clientOf(req))) throw new RoomError('Too many searches from here just now; try again later.', 429);
const found = rooms.findSeats(String(body.name ?? ''), addrOf(req), typeof body.roomId === 'string' ? body.roomId : undefined); const found = rooms.findSeats(String(body.name ?? ''), addrOf(req), typeof body.roomId === 'string' ? body.roomId : undefined);
// The seats given back are banked at once, so the cookie and the browser agree. // The seats given back are banked at once, so the cookie and the browser agree.
if (found.seated.length) bankSeats(req, res, provenBank(req, found.seated, [])); if (found.seated.length) bankSeats(req, res, provenBank(req, found.seated, []));
+1 -1
View File
@@ -139,7 +139,7 @@
if (r.seated.length) seats = allSeats(); if (r.seated.length) seats = allSeats();
const back = r.seated.length ? `Seated again at ${r.seated.map((s) => s.roomId).join(', ')}.` : ''; const back = r.seated.length ? `Seated again at ${r.seated.map((s) => s.roomId).join(', ')}.` : '';
const n = r.elsewhere; const n = r.elsewhere;
const ask = n ? ` ${n === 1 ? 'One more table' : `${n} more tables`} in play ${n === 1 ? 'has' : 'have'} a seat under your name, last used from another address, or given to a bot by the host: ask the host there for a transfer phrase, or write to the keeper.` : ''; const ask = n ? ` ${n === 1 ? 'One more table' : `${n} more tables`} in play ${n === 1 ? 'has' : 'have'} a seat under your name, last used from another address, or given to a housecarl by the host: ask the host there for a transfer phrase, or write to the keeper.` : '';
found = back + ask || 'No table still in play has a seat under that name.'; found = back + ask || 'No table still in play has a seat under that name.';
} catch (e) { } catch (e) {
error = e instanceof Error ? e.message : 'The search did not go through.'; error = e instanceof Error ? e.message : 'The search did not go through.';
+1 -1
View File
@@ -130,7 +130,7 @@
const r = await api.findSeats(name.trim(), roomId).catch(() => null); const r = await api.findSeats(name.trim(), roomId).catch(() => null);
const mine = r?.seated.find((s) => s.roomId === roomId); const mine = r?.seated.find((s) => s.roomId === roomId);
if (!mine) { if (!mine) {
if (r?.elsewhere) error = 'A seat here is under that name, but it was last used from another address, or the host gave it to a bot. Ask the host for a transfer phrase, or write to the keeper.'; if (r?.elsewhere) error = 'A seat here is under that name, but it was last used from another address, or the host gave it to a housecarl. Ask the host for a transfer phrase, or write to the keeper.';
return false; return false;
} }
rememberSeat(roomId, { seat: mine.seat, token: mine.token }); rememberSeat(roomId, { seat: mine.seat, token: mine.token });