v0.8.4 — the multiplayer transport: server and browser
The second release from the audit. Every fault here was invisible in solitaire, and four of the five server faults were in the one file no test had ever stood up; `http.ts` now has an end-to-end suite on a real port. CHANGELOG has the reasoning. SERVER. Leaving a lobby freed the chair and kept the token, so a leaver could stream and move for whoever took the seat next — revoked now, in memory and on disk. The browser numbered intents from 1 per page load while the server remembered the seat's last number, so the first move after a reload was swallowed as a resend — the connect push carries the count and the client continues from it. Nothing serialised moves within a game and every write shared one `.tmp` name, so two moves at once tore `game.json` (measured: 6 of 200), and the boot's bare `JSON.parse` then took every game down — per-path write queues, a per-game move queue, and a boot that skips one bad file. An error after the SSE head was sent crashed the process. Bodies were unbounded before any secret check. BROWSER. A double-click did the thing twice: one submit in flight at a time. A failed submit is `false`, not an unhandled rejection. The documentation renderer flattened nested bullets into a literal "- " mid-sentence on the published home-deck page. The make-up panel promised cars the engine refuses; it asks `acceptsCar` now. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FrCWubm9GAftYCm2hWdKwK
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
4d222a7eba
commit
e47cd3d400
@@ -611,3 +611,24 @@ describe('narration reaches a seat exactly once, by one path (#97)', () => {
|
||||
assert.deepEqual(third.lines, opening.lines, 'a reconnect is the full log, every time');
|
||||
});
|
||||
});
|
||||
|
||||
describe('the intent sequence across a reconnect (v0.8.4)', () => {
|
||||
it('tells a connecting seat the last seq it had accepted, so a reloaded page continues the count', () => {
|
||||
const session = createSession(42, config, ['Alice', 'Bob']);
|
||||
const first = session.connect(0 as PlayerIndex);
|
||||
assert.equal(first.lastSeq, 0, 'a seat that has moved nothing should be told 0');
|
||||
const actor = (first.menu !== null ? 0 : 1) as PlayerIndex;
|
||||
const r = session.intent(actor, 1, { type: 'localOps.choose', option: 'draw' });
|
||||
assert.ok(r.accepted);
|
||||
// A reload: the client starts its own count from 1 again unless told otherwise.
|
||||
const again = session.connect(actor);
|
||||
assert.equal(again.lastSeq, 1, 'the reconnect push does not say where the count stands');
|
||||
// The repeat the old client would have sent — silently swallowed as a resend.
|
||||
const repeat = session.intent(actor, 1, { type: 'draw.fromHomeOffice' });
|
||||
assert.ok(repeat.accepted && repeat.pushes.size === 0, 'seq 1 should still read as an idempotent resend');
|
||||
// Continuing from lastSeq + 1 is a real move.
|
||||
const next = session.intent(actor, 2, { type: 'draw.fromHomeOffice' });
|
||||
assert.ok(next.accepted && next.pushes.size > 0, 'seq 2 was not applied');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user