← Back to Pull requests

S3a.3 — The bank, round cap and endings #166

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 07, 2026 18:28 UTC
Author

S3a.3: the bank, the round cap and the endings (design §4.2 step 8, §6, §7.5, §8; §17.1 for the server's timing).

Closes #90

What it does


  • The end check (design §4.2 step 8, §6.2): after every round that didn't bust, endCheck (end.ts) ends the game once the bank is empty or the round is the round cap (roundCap: 12 on the job, [tunable], overridable as contentOverrides.roundCap). Nothing below the end check runs: no alibi window and no meeting after the last round. Every ending still goes through gameEnded.

  • Success or sunk by theft (§7.5, §8.1, §8.4): at or above the honesty line (honestyLine: 2/3 on the job), the heist succeeds. Below it, the heist is sunk by theft (FailureReason "theft" replaces "target"). Honesty is the coins that reached the duffel ÷ the coins taken from the bank. Seized coins count neither way, and the meter reads full before any coin is taken. The coins that reached the duffel are the R6 Haul until S3a.4 builds the duffel (see Decisions).

  • Who wins (§8.2, §8.5): everyone tied for the biggest stash wins. There is no tie-break (shakedowns and hand-ins no longer decide), so the whole crew wins together when every stash is equal. On theft, only top-group members whose role wins it win; that is the Mole's winsOn, which S3a.6 moves into its handler. The bust path is unchanged.

  • Regular meetings stay "after every 3rd round" as the bridge until S3a.5 holds them at the bank's thirds. ActNumber widens to number (rounds 10–12 are act 4, and no meeting follows them). After a regular meeting the next round starts, with no checkpoint. Event cards and the bots' Rig/last-round logic read the cap.

  • Bots: the ending forecast's target becomes theft, read from public honesty (the Haul ÷ the bank's start minus the bank left minus the coins raids seized). A ★ role leans toward theft; the Mole rings only then. Team-minded bots pocket only while honesty stays at least 1.1 × the line (HONESTY_MARGIN, a bot setting). This replaces checkpoint pacing.

  • Sim: GameRecord gets reason: "theft" and capWithBankLeft. New report rows: "Ended at the cap, over ¼ of the bank left" (§21 G4, a suite rate gated ≤ 10%) and "Sunk by theft" (G8, reported only).

  • Server (§17.1, §17.3): each preset's round deadline is now the session length ÷ the round cap: 15 min → 75 s, 1 h → 5 min, 3 h → 15 min, 1 d → 2 h, 3 d → 6 h, 1 w → 14 h. Grace is per §17.3. The quick id is renamed 15m (cleanup audit: "renamed in S3a.3 with the timing table").

  • Web (kept minimal; S4 redraws): the HUD shows "Round x of 12" (with the next meeting only while one is still due) and the Haul number in place of the deleted target bar. The rulebook's game-in-a-minute line and endings table, the ending note, the reveal's "why" text, the game-over line and the ★ "How you win" line all use the theft ending. The landing chip says "Up to 12 rounds". The reveal gallery's third ending is "Sunk by theft (nobody)".

  • Tests (each citing design sections): end.test.ts is rewritten around §4.2/§6.2/§7.5/§8 (16 tests). It covers the bank emptying early with no meeting after it, a short last round, the 12-round cap with the shipped numbers, the cap as an override, exactly two-thirds as a success, below it as theft with the Mole winning, seized coins left out, ties with no tie-break, the whole-crew win and replay. New fuzz invariants: rounds stay within the cap; the game is over once the bank is empty or the cap is reached; a non-bust ending is the bank or the cap; success ⇔ honesty ≥ line. The fuzz outcomes must include theft, and a "short" tuning (cap 4) is added. Override validation covers roundCap. A server scenario has a crew pocketing every Lobby coin to the cap, which is sunk by theft. A reveal QA seed (qa55-5-t125) is sunk by theft with the Mole winning.

  • Leak scrub / samples: no new event or command type. checkpointChecked is removed from the samples, from the visibility pin and from the reveal's shown list. gameEnded (public) keeps its shape.
  • Deleted (cleanup audit list 3, S3a.3 rows, and what they superseded)


  • Checkpoint targets: CheckpointRules/job.checkpoints, checkpointTarget, the checkpointChecked event (type, sample, fold, reveal list, describe/away/meeting-result lines, the Meetings result banner), the act meeting's checkpoint and the final meeting's final check (checkpoint() in meeting.ts), the checkpoints content override, and the Rookie's checkpointMade token trigger.

  • The fixed 9-round game (3 × ROUNDS_PER_ACT as the game length in deck.ts, bots totalRounds, web 3 * ROUNDS_PER_ACT). ROUNDS_PER_ACT stays only for the meeting bridge (S3a.5).

  • The R6 tie-breaks (fewer shakedowns, more handed in) in ranking/leadersOf.

  • The S3a.1 bridges assigned to S3a.3: the scaled checkpoint pins (checkpoints in R6_COINS/V01_NUMBERS and the bots and sim pins), "the bank doesn't end the game until S3a.3", and grabs cut to 0 by an empty bank.

  • Bots: checkpoint pacing in choosePocket, the target forecast.

  • Sim: checkpointRankings, Standing/standing, afterAct1/afterAct2, act3MaxGain, endedAct, finalTarget, checkpointsMissed, the comeback and decided-early metrics and suite rates (R6 §17.4 gates with no R7 §21 counterpart), and the miss rate.

  • Web: TargetBar component and CSS, targetBar, nextTarget, targetName, the gallery's target-bar section, and checkpoint test cases.

  • Tests of removed rules: R6 final-meeting/final-target scripts, checkpoint-order tests, tie-break tests, and checkpointTarget unit tests.
  • Lines


    | Package | Added | Removed |
    |---|---:|---:|
    | apps/server | +88 | -88 |
    | apps/sim | +97 | -305 |
    | apps/web | +113 | -240 |
    | packages/bots | +70 | -59 |
    | packages/content | +28 | -36 |
    | packages/engine | +368 | -511 |
    | Total | +764 | -1239 |

    Results


  • pnpm typecheck and pnpm knip: clean. Vitest: engine 853, content 39, bots 160, sim 200, server + web 949 (1 skipped), all green.

  • pnpm precheck (Mac, load ~12): typecheck, knip, theme lint and scope check clean. Unit tests: 2249 passed, 1 skipped. e2e (scoped full tier): 388 passed and 1 failed. The failure was infotip.spec.ts "a scroll moves an open tip" [mobile], which this PR doesn't touch; it passed in an earlier precheck run and 63/63 on a --repeat-each=3 rerun, so it is a load flake. The changed game.spec.ts 15-min game passed 6/6 with --repeat-each=3.

  • Fix commits during precheck: game.spec.ts checked the deleted checkpoint ledger line. scheduler.test.ts assumed a bot game always reaches the first meeting, but a bust can end it first (the same issue S3a.2 hit).

  • Sim (content numbers, standard bots, events off), 0 refused bot commands. 2 players is refused at setup (minimum 3).

  • | | 3p | 6p | 8p | 12p |
    |---|---:|---:|---:|---:|
    | success | 52% | 36% | 8% | 1% |
    | bust | 33% | 60% | 88% | 99% |
    | sunk by theft | 15% | 5% | 4% | 0% |
    | cap with > ¼ bank left | 5% | 13% | 7% | 1% |
    | bank emptied | 22% | 4% | 0% | 0% |

    The bust rate was already far above its 8–20% band after S3a.2 (47% at 6p). Games now run up to 12 rounds instead of 9, so more of them reach the bust line. This is S5 tuning (bulbs, cooling, bot caution); see Follow-ups.

    Decisions


    Provisional, for the PM to fold into decisions.md.
  • The honesty check is built now, for the ending only. S3a.3 owns §6.2 and the §8 endings, and an ending with no failure condition would make every non-bust game a success. Until S3a.4 builds the duffel and the public honesty meter, "coins that reached the duffel" is the R6 Haul: hand-ins plus R6 shakedown takings, less R6 compensation. S3a.5 brings the real shakedown/Priest recovery credit. The line is content (honestyLine, 2/3); the round cap is content and overridable.

  • Ties: §8.5 is applied in ranking/leadersOf now (no tie-break; everyone at the top wins). It is the endings' winner rule, and the bust path already worked this way.

  • The getaway car (§6.3) is left to S3a.4. There is no kitty or unsplit duffel yet (the Haul is a running total, not a bag to split), so nothing pays for it. The end check is its seam.

  • Meeting bridge: a regular meeting after every 3rd round (3, 6, 9) until S3a.5. ActNumber widens to number. No meeting follows rounds 10–12, because the cap ends the game first.

  • quick → 15m, round time = session ÷ cap (75 s for 15 min). Stored lobbies with sessionLength: "quick" fall back to 1 h timing through the scheduler's existing default. The live game has no real players, so there is no migration shim.

  • Bot setting: team-minded bots keep honesty ≥ 1.1 × the line (HONESTY_MARGIN). The theft forecast is an even chance on the line and certain an eighth of the line below, the same shape as the old target forecast.

  • The sim's G4 cap-stall rate excludes busts that land in the cap round.
  • Follow-ups


  • Balance (S5): the bust rate is 33–99% across crew sizes against 8–20%, and worse at 8–12p. Success is 1–52%. Re-baseline docs/balance/baseline.json; its comeback/decided-early/miss rates no longer exist.

  • S3a.4: replace the Haul in honesty() with duffel credit, add the public honesty meter (§7.5) and the getaway car (§6.3), and update the bots' coinsTaken/forecast to read the new fact.

  • S3a.5: meetings at the bank's thirds, which retires ROUNDS_PER_ACT, ActNumber and the web meetingAfter/MeetingName wording.

  • The S4 HUD should show the cap and the bank (the Haul number replaced the target bar only as a stopgap).
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: github-actions[bot] Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.52) × (1 − Review Confidence (0.39)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 68% · Reviewer familiarity: 35%
    38%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #166"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 38.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 38.9% · Lower = rushed or shallow review
    38.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.8% · Safe to merge
    31.8%