v0.7.9.5 — two answers to one question, and the copy nobody read
Both faults are in what 0.7.9.4 had just built, and both are the same shape: a second copy of an answer that agreed with the first until it didn't. #96 — the §3.3 vote has no actor, and the screen named one anyway. The vote is PARALLEL: every un-voted seat may vote at any moment, in any order, one refusal ends it, and `apply.ts` says where it accepts one that there is no actor to be. The turn chart named the last seat to move before the timetable ran out — no more claim on the vote than anybody else — directly above a tally correctly showing three seats outstanding. The cause is worth more than the symptom. `currentActor(game)` (`web/game.ts`) guarded on `status !== 'active'`; `currentActorOfState` (`sim/view.ts`), added the same day in #95 and the one the frame calls, did not, so it handed back whatever `clock.currentActor` was left holding. The view now carries the guard and `currentActor` delegates to it. That matters more than the tidiness: `currentActor` is what REFUSES an intent, so a screen answering differently tells the table to wait on a player the server would turn away. The fourth of this class after Gitea#21, #22 and #94 — but the first found by asking a view helper its question in a state the game is not `active` in, which is the generalisation and is cheaper than finding the fifth the same way. #97 — narration reaches a seat once, by one path. `Frame.lines` carried the whole log on every push to every seat, and nothing read it: `RemoteSession` accumulates from `push.lines` alone and its `lines()` returns that accumulator, so the log was serialised into every frame, grew all game, and was discarded on arrival while `linesSince` sent the same text correctly beside it. The duplicate was masking a bug rather than merely wasting bandwidth. `connect()` cleared `lastFrame` but not `sentLines`, so a reconnecting seat was told "nothing new since your last push" while the browser it answered had just reloaded from an EMPTY accumulator — the history panel came back blank, mid-game, with the server holding the whole log. So the two halves are one change, and the plan's instruction taken alone ("stop passing the full game log into `frameFor()`") would have deleted a real behaviour rather than a duplicate. Every remaining reader of `Frame.lines` was checked before the field was emptied: all of them are the solitaire and replay path, which builds Frames through `snapshot()` directly and never goes near a session. One test was wrong before the code was. The first draft of the reconnect test connected inside its own fixture, so both sides of the comparison were the empty array and it passed against the broken server. Each test now asserts its premise is non-empty before comparing. Also: `docs/plans/jitsi-common-board.md` is committed. It was never added — not ignored, just missed — while TODO.md cites it twice as the plan for all of v0.8.0 and the last two releases were built from it, so a clone got a TODO pointing at a file that did not exist. 917 tests pass, up from 909. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y5boPxP6JHRYMm8adXaF5R
This commit is contained in:
co-authored by
Claude Opus 5
parent
ebd16983e2
commit
d5445badcc
@@ -24,6 +24,8 @@ import { applyIntent, check } from '../src/engine/apply.ts';
|
||||
import { STAGES_PER_DAY } from '../src/engine/content.ts';
|
||||
import { legalActions } from '../src/engine/legal.ts';
|
||||
import { createGame } from '../src/engine/setup.ts';
|
||||
import { currentActorOfState, publicSnapshot, snapshot } from '../src/sim/view.ts';
|
||||
import { currentActor } from '../src/web/game.ts';
|
||||
import { developerBot, playGame, randomBot } from '../src/sim/bot.ts';
|
||||
import type { GameConfig, GameState } from '../src/engine/state.ts';
|
||||
|
||||
@@ -254,3 +256,69 @@ describe('§3.3 extended play — bots play the timetable they were dealt (Gitea
|
||||
assert.equal('agree' in choice ? choice.agree : null, false, 'a bot asked for another Day');
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* §3.3 — WHO THE SCREEN SAYS THE TABLE IS WAITING ON, while the vote is open.
|
||||
*
|
||||
* The vote is PARALLEL, and `apply.ts` says so where it accepts one: "open to every seat at once:
|
||||
* it is a table decision rather than a ruling, so THERE IS NO ACTOR TO BE". Any seat that has not
|
||||
* voted may vote at any moment, in any order, and one refusal ends it. So the honest answer to "who
|
||||
* are we waiting on" is every un-voted seat — which is exactly what the vote tally beside the chart
|
||||
* already draws — and the honest answer to "whose turn is it" is nobody.
|
||||
*
|
||||
* The engine gave that answer and the screen did not. `currentActor(game)` guards on
|
||||
* `status !== 'active'` and returned null; `actingPlayer(state)` has no such guard and returned
|
||||
* `clock.currentActor`, which still holds whoever moved last before the timetable ran out. The
|
||||
* frame took the second, so the turn chart named one arbitrary seat — the last to act, who has no
|
||||
* more claim on the vote than anybody else — while the tally underneath correctly showed three
|
||||
* seats outstanding.
|
||||
*
|
||||
* The fourth of these in a row after Gitea#21, #22 and #94, and the first found by asking the
|
||||
* question of a state the game is not ACTIVE in. See TODO #96.
|
||||
*/
|
||||
describe('§3.3 extended play — the vote has no actor (#96)', () => {
|
||||
const table = (): GameState => {
|
||||
const s = atTheEnd(game({ mode: 'competitive' }, ['Ann', 'Bob', 'Cy']));
|
||||
advance(s);
|
||||
assert.equal(s.status, 'awaitingExtension', 'the table is not being asked');
|
||||
return s;
|
||||
};
|
||||
|
||||
it('reports nobody acting while the vote is open, to a player and to a spectator alike', () => {
|
||||
const s = table();
|
||||
assert.notEqual(s.clock.currentActor, null, 'the premise is gone: nothing was left on the clock');
|
||||
|
||||
assert.equal(currentActorOfState(s), null, 'the engine named an actor during a parallel vote');
|
||||
assert.equal(
|
||||
snapshot(s, [], null, null, null, false, 0).actor,
|
||||
null,
|
||||
'the turn chart named a seat while the whole table was voting',
|
||||
);
|
||||
assert.equal(publicSnapshot(s).actor, null, 'the common board named a seat during the vote');
|
||||
});
|
||||
|
||||
it('agrees with the session, which is the half that decides what is legal', () => {
|
||||
// The disagreement is the bug, not either answer on its own: `currentActor` is what refuses an
|
||||
// intent, so a screen that names somebody it would refuse is telling the table to wait on a
|
||||
// player who cannot act.
|
||||
const s = table();
|
||||
const g = { state: s, log: [] } as unknown as Parameters<typeof currentActor>[0];
|
||||
assert.equal(currentActorOfState(s), currentActor(g), 'the screen and the session disagree');
|
||||
});
|
||||
|
||||
it('still names the actor during ordinary play, which is the case that must not regress', () => {
|
||||
const s = game({ mode: 'competitive' }, ['Ann', 'Bob', 'Cy']);
|
||||
pump(s);
|
||||
assert.equal(s.status, 'active', 'the premise is gone: the game is not running');
|
||||
assert.equal(currentActorOfState(s), s.clock.currentActor, 'an active game lost its actor');
|
||||
assert.equal(snapshot(s, [], null, null, null, false, 0).actor, s.clock.currentActor);
|
||||
});
|
||||
|
||||
it('reports nobody once the table has declined and the game is finished', () => {
|
||||
const s = table();
|
||||
applyIntent(s, 1, { type: 'game.extend', player: 1, agree: false });
|
||||
assert.equal(s.status, 'finished', 'a refusal did not end it');
|
||||
assert.equal(currentActorOfState(s), null, 'a finished game still had somebody to move');
|
||||
assert.equal(publicSnapshot(s).actor, null, 'the common board named a seat after the game ended');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user