tally.ts is pure (no Payload, no clock, no ambient randomness) so the vote
rules are testable on their own:
- Weights take the HIGHEST matching role tier, never a sum, so a member in two
weighted roles cannot outvote the unit. Equal multipliers resolve to the
earlier tier for determinism.
- Weighted scores accumulate as integer thousandths, so 1.1 + 1.1 ties 2.2
exactly instead of drifting apart on float addition; tie detection is an
equality test, so that matters.
- Duplicate keys in one ballot are deduped, answers naming options the poll no
longer carries are ignored, and a ballot naming only dead options is not
turnout.
service.ts is the single write path for both surfaces: launch (idempotent on
sourceKey, racing players join the winner), cast (replace or retract), close,
superuser tie decision, deadline fallback, and advancePoll as the one reconcile
entry point the bot tick and the poll page share. Weight is resolved at close
and frozen into the outcome, so the tie set a superuser is asked about cannot
shift while they decide, and a second close cannot rewrite the result.
surface.ts is the read model: it reads ballots with overrideAccess and includes
voter identities only for a public poll or a superuser.