A House Divided A House DividedDocumentation
↵
Changelog
Game Design/Legislature & Parties

Congress Speaker System

Last updated 2026-10-29
Source files

Summary#

The Congress Speaker System manages Speaker of the House elections in the US Congress. The Speaker is elected by plurality among sitting House members, and any seated member of any party may run and vote. A separate motion to vacate lets the House remove a sitting Speaker mid-term.

Player guide: Congress Leadership (Speaker and motion to vacate sections). The shared leadership framework for the other House and Senate roles is in Congress Leadership.

The rule is any-seated on purpose: the Speaker presides over the whole House and, unlike the Majority Leader, is not the head of one party's caucus, so the whole chamber chooses.

Location: src/lib/congress/speaker/

Key files:

The HTTP surface is GET and POST /api/congress/speaker (), rate limited to 30 requests per 60 seconds per user on POST.

Rules#

Constants#

Rule Value Source
Election window 24 hours (ELECTION_DURATION_MS = 24 * 60 * 60 * 1000); closes on endsOnTurn = currentTurn + 24 (one turn is one game hour) ,
Window close test If endsOnTurn is set, closed when currentTurn >= endsOnTurn; otherwise closed when effectiveNow >= endsAt (isLeadershipElectionClosed)
Who may run and vote Any sitting House member of any party (speaker_of_the_house: { kind: "any-seated" }) POLICY_BY_ROLE in
Winner Plurality of the seat-weighted vote
Tie-break Earlier createdAt on the nomination
Declare cost None handleDeclare in
Withdraw cost 3 political influence (NPI), at least 3 required
Vacate motion window 24 hours (same ELECTION_DURATION_MS), endsOnTurn = currentTurn + 24
Vacate motion threshold Math.floor(totalSeats / 2) + 1 votes for (absolute majority of all seats) vacateThreshold in
NPP stance distance Per-axis 2 on the -5 to +5 stance scale (NPP_VACATE_STANCE_DISTANCE), both axes must be within 2 to count as close
Coin flip rng() < 0.5 gives "for"; Math.random in production, injected in tests ,
Seat weight seatsHeld ?? 1 per electedOfficials row buildVoterPartyAndWeightMaps in
Speaker national influence tier 2.0 CONGRESS_LEADER_NI_BONUS in
Speaker action bonus +3 per turn (highest leadership bonus held, not stacked) LEADERSHIP_ACTION_BONUS in

Eligibility#

To run for Speaker:

  1. Must be a sitting House member (an electedOfficials row with officeType: "house" for the character).
  2. Any party. The Speaker policy is any-seated, so there is no majority-party or bloc gate (isPartyEligible only checks the member's party holds a House seat).
  3. Must not already have an open or voting candidacy for Speaker, or for any House or Senate leadership race.

To vote for Speaker:

  1. Must be a sitting House member.
  2. Any party. Each member has one active vote and can change it while the window is open.

Election timing rules#

NPPs#

Speaker races are player-only. NPPs do not run or vote in the election (). NPP blocs do vote on the motion to vacate, at window close only.

Action handlers#

Every handler except the three admin ones first requires a character and a House seat (403 "Only sitting House members can participate in Speaker elections.").

start_election#

Authorization: Admin only

Behavior:

  1. Check no active election exists (409 if one is live)
  2. Fail all open and voting nominations
  3. Create new 24-hour election window
  4. Auto-nominate incumbent Speaker if eligible (still holds a House seat and passes the policy), with nominatedByName: "Incumbent" and status voting

Response:

{
  "success": true,
  "message": "Speaker election started. Voting ends in 24 hours (<timestamp>). Only any seated chamber member may run and vote. Plurality wins."
}

reset_election#

Authorization: Admin only

Behavior:

  1. Set all open and voting nominations to "failed"
  2. Close the current election (upsert, so it works with no prior election)
  3. Allows starting fresh election

Response:

{
  "success": true,
  "message": "Speaker election reset. You can start a new 24-hour election."
}

force_end#

Authorization: Admin only

Behavior:

  1. Immediately resolve the current election (resolveSpeakerElection(..., force = true))
  2. Install the winner, or vacate the office if there are no candidates
  3. Returns 409 "No active election to end." if there is no election in voting

Response:

{
  "success": true,
  "message": "Speaker election ended. Winner or vacancy is set."
}

declare#

Authorization: Sitting House member (any party)

Checks:

  1. Election is in voting phase and its window has not closed (409)
  2. Character's party passes the Speaker policy (any party with a House seat) (403)
  3. No existing open or voting candidacy under the character or its NPP id (409)
  4. Not running for another leadership position: checked against houseLeadershipNominations and senateLeadershipNominations (409), then failNominationIfLeadershipConflict re-checks after the insert to close a race between two simultaneous declarations (409)

Cost: None

Effects:

  1. Create speakerNominations record with status open
  2. Trigger achievement check (speaker_candidate)

Response:

{
  "success": true,
  "message": "{name} has declared for Speaker. Voting ends {endTime}. Top vote-getter wins.",
  "status": 201
}

withdraw#

Authorization: House member with active candidacy

Checks:

  1. Election is in voting phase (409)
  2. Has active candidacy (404)
  3. Has 3 or more political influence (403)

Cost: 3 political influence

Effects:

  1. Deduct 3 NPI from character ($inc: { politicalInfluence: -3 })
  2. Log influence history (influenceHistory, reason "Withdrew from Speaker election")
  3. Set candidacy status to "failed"

Response:

{
  "success": true,
  "message": "Candidacy withdrawn. 3 NPI deducted."
}

vote#

Authorization: Sitting House member (any party)

Checks:

  1. Election is in voting phase (409)
  2. Character's party passes the Speaker policy (any party with a House seat) (403)
  3. Valid nomination ID (400), pointing at a nomination still open or voting (404)

Behavior:

Effects:

  1. Record the ballot in speakerLeadershipBallots (one per voter), replacing any previous one (castLeadershipVoteBallot in )
  2. Move the vote between nominations and adjust the votesFor counters
  3. Clear any Player Whip snapshot on the vote on both the new and the previous nomination (clearWhippedFromVote)

Response:

{
  "success": true,
  "message": "Vote recorded for {candidateName}. Top vote-getter when the window closes wins."
}

Vote structure#

Each nomination document carries a votes map, and each voter has one row in speakerLeadershipBallots that points at their current nomination:

votes: {
  "characterId1": "for",
  "characterId2": "for",
  // ...
}

Vote changing: When a member votes for a different candidate:

  1. The voter's ballot row is repointed to the new nomination (castLeadershipVoteBallot)
  2. The vote is removed from the old nomination and set on the new one
  3. votesFor counters are adjusted

Election resolution#

resolveSpeakerElection(), called when the election ends (window closed, or admin force-end):

  1. Find the current election; return if it is not in voting (or, when not forced, if the window has not closed).
  2. Load active nominations (open or voting).
  3. No candidates: vacate the role (vacateCongressLeadershipRole, leaving characterName: "Vacant") and close the election.
  4. Otherwise: count each candidate with the seat-scoped, seat-weighted tally (computeCongressLeadershipTally in ), not the cached votesFor, so votes from members who have since lost their seat do not count and the winner matches what the leadership page shows.
  5. Sort by count descending, then by earliest nomination createdAt. The top entry is confirmed, the others are set to failed.
  6. Upsert the speaker_of_the_house leader document with the winner, mark the leadership achievement (markCongressLeadershipHeld), and close the election with an atomic voting to closed claim (claimStatusTransition) so only one resolver posts the Discord result announcement.

Tie breaking. Ties on the seat-weighted count are broken by the earliest nomination (createdAt), so an auto-nominated incumbent beats a challenger who ties.

Auto-vacate logic#

vacateSpeakerIfLostSeat(): if the sitting Speaker no longer has a House seat (electedOfficials row with officeType: "house" matching characterId or nppId), the leader document is set to characterId: null / characterName: "Vacant" and openSpeakerElection opens a fresh 24-hour election with no incumbent nomination. The leader document is never deleted. Once vacant, later calls return early, so the election opens exactly once per vacancy.

Two paths run this:

A party switch does not vacate the Speaker, because eligibility is by seat, not party (qualifiesAfterPartySwitch in ).

Controlling-party trigger#

After a House general election, triggerLeadershipElectionsAfterChamberVote () opens a Speaker race when hasControllingPartyChanged is true: the House majority party is unknown, the chair is vacant, or the Speaker's recorded party differs from house.majorityParty. It skips this if a live election is already running, fails any dangling nominations, upserts the election with endsOnTurn = currentTurn + 24, and auto-nominates the sitting Speaker if still seated and eligible (autoNominateStandingIncumbent).

Motion to vacate#

A sitting House member can move to remove the current Speaker without waiting for the next general election.

Location: (handleFileVacateMotion, handleVoteVacateMotion), , collection speakerVacateMotions.

Filing (file_vacate_motion)#

Voting (vote_vacate_motion)#

Resolution (resolveSpeakerVacateMotion)#

Bloc Vote
No party against
Same party as the Speaker against
Both blocs' parties are Major, stances not within 2 on both axes (or no usable stance for either side) for
Both Major, stances within 2 on both axes coin flip
Not both Major (minor, unaligned or Speaker party unknown), stances not within 2 on both axes coin flip
Not both Major, stances close or no usable stance against

Existing ballots, including whipped ones, are never overwritten (each write is guarded by votes.<key> $exists: false). NPPs are deliberately not auto-voted while the motion is live, so they cannot carry it before players can whip them.

Error responses#

Status Condition
400 Invalid action, missing character, invalid nomination ID, vacate vote not "for" or "against"
403 Not a House member, not an eligible party, insufficient NPI to withdraw, non-admin on an admin action
404 Candidacy not found, no candidacy to withdraw
409 Election already running, already running for office, no election open, no sitting Speaker to vacate, motion already live, no motion open

Data#

Collections#

Collection Purpose Access Player-visible
speakerElections Current election state (_id: "current") read, write Yes: status and end time on the Speaker page
speakerNominations Candidacies and the votes map read, write Yes: candidates, vote counts, party split; individual ballots are not listed
speakerLeadershipBallots One ballot per voter, pointing at a nomination read, write Own vote only (isMyVote)
speakerVacateMotions Current motion to vacate (_id: "current") read, write Yes: motion status, counts, threshold, own vote
congressLeaders Installed Speaker (role: "speaker_of_the_house") read, write Yes: current Speaker
electedOfficials House membership, party and seatsHeld weight read Indirect
characters NPI deduction, party, stance (policies) read, write (politicalInfluence) NPI is shown on the profile
npps, politicalParties NPP party and stance, party tier for the vacate heuristic read No
influenceHistory NPI spending log write Own history
houseLeadershipNominations, senateLeadershipNominations Read only for the one-race-at-a-time guard read No

Document types#

The types below are from .

interface SpeakerElection {
  _id: "current"; // Singleton document
  status: "voting" | "closed" | "cancelled";
  startedAt: Date;
  endsAt: Date;
  endsOnTurn?: number; // turn on which voting closes; preferred over endsAt
  updatedAt: Date;
}

interface SpeakerNomination {
  _id: ObjectId;
  nomineeId: ObjectId;
  nomineeName: string;
  nomineeParty?: string;
  nomineeState?: string;
  nominatedById: ObjectId;
  nominatedByName: string;
  status: "open" | "voting" | "confirmed" | "failed" | "cancelled";
  votesFor: number; // cached, not used to pick the winner
  votesAgainst: number;
  votes: Record<string, "for" | "against">; // characterId -> vote
  whippedFromVote?: WhippedFromVoteMap;
  createdAt: Date;
  updatedAt: Date;
}

interface SpeakerVacateMotion {
  _id: "current";
  status: "voting" | "passed" | "failed";
  filedById: ObjectId;
  filedByName: string;
  filedByParty?: string;
  targetSpeakerId: ObjectId;
  targetSpeakerName: string;
  startedAt: Date;
  endsAt: Date;
  endsOnTurn?: number;
  votes: Record<string, "for" | "against">; // characterId or "npp_<id>" -> vote
  whippedFromVote?: WhippedFromVoteMap;
  resolvedAt?: Date;
  updatedAt: Date;
}

interface CongressLeader {
  _id: ObjectId;
  role: LeadershipRole; // "speaker_of_the_house" here
  characterId: ObjectId | null; // null while vacant
  characterName: string; // "Vacant" while vacant
  party?: string;
  nominatedBy?: ObjectId;
  electedAt?: Date;
  createdAt: Date;
  updatedAt: Date;
}

Configuration#

There is no gameConfig field for the Speaker system. Behaviour is set by constants and one policy table.

Setting Default Where set
Eligibility policy for speaker_of_the_house { kind: "any-seated" } POLICY_BY_ROLE in
Election and motion window 24 turns ELECTION_DURATION_MS in actions.ts and openSpeakerElection.ts; LEADERSHIP_ELECTION_DURATION_MS in leadershipElections.ts for the controlling-party trigger
Withdraw cost 3 NPI literals in handleWithdraw (actions.ts)
NPP closeness distance 2 per axis NPP_VACATE_STANCE_DISTANCE (nppVacateVote.ts)
Speaker NI tier and action bonus 2.0 and +3

Scope: the system is US only. Other countries' presiding officers (Bundestag, NPCSC, National Guard) use different role keys and the shared leadership framework, not this module. The motion to vacate has no flag or era gate; it is available whenever a Speaker is seated.

Timing#

Phases in the turn processor (), in order:

electionResolution            House general resolves -> controlling-party trigger may open a race
   |
leadershipVacate              Speaker without a House seat -> vacate + open refill race (every turn)
   |
leadershipPartyEligibility    does not touch the Speaker (any-seated)
   |
leadershipElections           resolveExpiredLeadershipElections: closed window -> resolveSpeakerElection

(outside the turn)  GET /api/congress/speaker -> vacateSpeakerIfLostSeat, resolve closed election,
                    resolveSpeakerVacateMotion
(outside the turn)  POST vote_vacate_motion   -> resolveSpeakerVacateMotion on every ballot
Phase What it does for the Speaker
electionResolution A House general election resolves; triggerLeadershipElectionsAfterChamberVote opens a Speaker race if the largest party differs from the Speaker's party or the chair is vacant, auto-nominating the sitting Speaker if still seated
leadershipVacate vacateLeadershipForLostSeats vacates a Speaker who lost their seat and opens a refill race (every turn)
leadershipPartyEligibility reconcileAllLeadershipPartyEligibility: does not touch the Speaker (any-seated), but runs just before the next phase
leadershipElections resolveExpiredLeadershipElections resolves a Speaker race whose window has closed

The motion to vacate is not resolved in a turn phase of its own: it resolves on the vote that reaches the threshold and lazily on each GET /api/congress/speaker. NPP ballots are added at window close, so with no one reading the page and no vote cast, a closed motion stays voting until the next read or vote. The window itself is turn-based (endsOnTurn), so game-clock drift does not move the deadline.

Worked trace#

Election. A House of 435 seats, each electedOfficials row weighing 1 (seatsHeld unset). The chair is vacant at turn 1000, so openSpeakerElection writes endsOnTurn = 1000 + 24 / 1 = 1024 (ELECTION_DURATION_MS / 3_600_000 = 24). Three candidates declare: X (turn 1002, createdAt earliest), Y (turn 1005), Z (turn 1010). The window is closed from currentTurn >= 1024, and the leadershipElections phase on turn 1024 calls resolveSpeakerElection. Seat-weighted votes: X 200, Y 200, Z 35, which sum to 435 with every seat voted. X and Y tie at 200; sorting by count descending, then createdAt ascending, puts X first. X is confirmed, Y and Z are set to failed, congressLeaders takes X, and the claim voting to closed posts one announcement. A candidate who lost a seat before turn 1024 has that ballot dropped by the tally even though the cached votesFor still shows it.

Motion to vacate. A member files against X at turn 1100; endsOnTurn = 1124, and the filer's vote is for. vacateThreshold(435) = floor(435 / 2) + 1 = 217 + 1 = 218. At turn 1124 players have cast 150 for (including the filer) and 120 against, and 165 seats are unvoted NPP blocs. autoVoteNppsForVacateMotion grades each bloc: blocs of X's party vote against, a Major opposition bloc not within 2 on both axes votes for, and so on. Say those blocs add 70 for votes and 95 against: for = 150 + 70 = 220, which is at least 218, so the claim flips to passed, X is vacated (characterName: "Vacant"), and openSpeakerElection opens a new race ending at turn 1148 with no incumbent. If the NPP blocs had added only 67 for votes, 217 for is under 218 and the motion is marked failed with X still seated. Had the 150 humans alone reached 218 earlier in the window, the vote that crossed it would have carried the motion at once and NPP blocs would never have been polled.

Withdraw. A candidate with 5 NPI withdraws: NPI becomes 2, an influenceHistory row of -3 is written, the nomination is failed. A candidate with 2 NPI is refused with 403 and stays in.

Edge cases and limits#

Invariants#

Failure and recovery#

Connections#

Driven by:

Affects:

Tests#

Gaps: leadershipRaceGuard.test.ts covers the cross-race guard in general, but no test goes through the Speaker declare handler. There is also no dedicated test for the plurality tie-break on createdAt, for withdraw's NPI check, or for the controlling-party trigger specifically for the Speaker role.

Known issues and history#

Last checked: 2026-10-29, version 1.18.0

Ask