Skip to content
AR
Architecture Review Library
Review library

SpireVault / Inside the build

Where does a relic’s win rate come from?

A relic card says 66.7% while the Overview says 50%. Follow seven fictional save files through SpireVault to see why both numbers are right.

SpireVault’s browser dashboard showing the Overview for Slay the Spire 2 run history.
The Overview summarizes the imported history. The worked example below uses a separate fictional set of runs.
On this page

System trace

Trace the number on the Anchor card

Player and browser file picker

The player selects the game profile’s history folder or individual save files. The browser reads the selected JSON.

State Seven illustrative files · one chosen batch
  1. Choose the history · Player and browser file picker

    The player selects the game profile’s history folder or individual save files. The browser reads the selected JSON. Seven illustrative files · one chosen batch

  2. Identify each attempt · Raw save parser and importer

    The importer keeps the first record for each ID and sets the newest unfinished attempt aside. Four completed runs remain. Four finished · one live · one duplicate · one unreadable

  3. Count the holdings · Browser statistics engine

    Three completed runs held Anchor. Listing it twice in one inventory still contributes a single observation for that run. Two wins among three holdings

  4. Display the result · Overview and relic card

    The card displays the percentage of runs won while holding Anchor. The Overview uses every completed run in the batch. Anchor 66.7% · overall 50%

Two percentages from one folder

Suppose the Overview says you won half your Slay the Spire 2 runs. Open the Anchor relic card and it says 66.7% over three runs. In this example, you have two victories, and both happened with Anchor in your inventory. A fourth run ended in defeat without it. The fourth run belongs in your overall record. It tells us nothing about how often you won while holding Anchor.

I built SpireVault so a player can answer questions like this from the files the game already writes. The browser imports a history, gives each attempt a common representation and computes the dashboard locally. A separate Steam-connected service supports cross-device history and finding co-op partners. You can read your own stats as a guest. Open the browser companion

The unit of evidence is a game attempt

Slay the Spire 2 writes completed attempts as individual JSON files with a .run extension. A typical directory inside the game’s save tree is steam/<account>/profile1/saves/history/. The browser reads the files or directory the player selects. Selecting just one profile’s history keeps the scope of an analysis intelligible. A broader folder can contain more than one profile.

The importer also accepts the desktop companion’s history.json rollup. It recognizes a raw save by a nonempty players list and a map history array. A dedicated parser reads the first player’s character and final inventory, the run outcome, and the start time. It strips the RELIC. prefix and lowercases the relic key, so RELIC.ANCHOR becomes anchor. A missing relic list becomes an empty list. A co-op save still provides one attempt in this calculation, with the first player’s inventory. Read the raw save parser

Architecture diagram

From selected files to a relic statistic

The browser owns the import, the active session and the statistics. Finished runs can also be persisted and, for a signed-in player, synchronized.

Full-size diagram

Calculate the card. The importer normalizes the selected records, sets the live run aside and removes repeated IDs. The statistics engine counts Anchor once per completed run that held it. The card divides victories in that group by the group size.

Restore and sync. IndexedDB retains completed records for a later visit. With a Steam session, normalized summaries can also travel to and from cloud history. The browser can recalculate from its local records when that service is unavailable.

What happened to the seven files?

I ran this fictional batch through the guest browser’s file input. Two files deliberately repeat information. One lists Anchor twice in the same inventory, and another is a copy of an entire run. These are different counting problems that the importer and statistics engine handle at different points.

InputContentsContribution to the finished history
Run ADefect won, Anchor listed twiceOne win, one Anchor holding
Run BSilent lost with AnchorOne loss, one Anchor holding
Run CIronclad won with AnchorOne win, one Anchor holding
Run DSilent lost with no relicsOne loss, zero Anchor holdings
Copy of ASame start time and record as AExisting run ID, skipped
Current saveAn attempt with no final outcomeAvailable as the current run
Torn fileIncomplete JSONParse error, other files continue

A raw run normally gets its ID from its start time in seconds. The first occurrence of that ID in an import batch wins. After that pass, SpireVault separates out the newest attempt marked as in progress. This matters because a live attempt often has no victory flag yet. Leaving it in the count would quietly turn an unfinished game into a loss. When the whole batch yields zero usable records, the importer reports the problem before replacing the current history.

The math behind the relic card

The stats engine walks the completed records once to count overall wins. For each record it also forms a set of its relics. One occurrence of Anchor adds one to its observed-run count, and a win on that record adds one to its win count. A second copy in that same record has no effect.

Three different questions now have precise answers. How often did I win? Two wins in four finished runs gives 50%. How often did I have Anchor at the end? Three of four gives 75%. How often did I win when I ended with Anchor? Two of three gives 66.7%. The relic card displays the last of these. A player could have acquired the relic on the final floor. The observation alone cannot tell us that it caused either victory.

The default relic table requires at least three observed runs. Among qualifying relics it ranks by the lower bound of a 95% Wilson interval, breaking ties by raw win rate and then by observation count. That gives a long, consistent history some protection against a lucky three-run streak while keeping the visible percentage readable. Inspect the aggregation and ranking

Closing the tab and coming back

After a file import, the completed records become the active history and are serialized to IndexedDB. On reload, the browser revives the records and computes the report again. The live attempt stays out of that snapshot. In the Chromium check, the Overview displayed 50%, the Anchor card displayed 66.7% over three runs, and a reload restored four completed attempts, two wins. The test ran with the application’s network services unavailable.

Persisting the browser’s data and retaining permission to reread its source folder are separate operations. A browser that supports saved directory handles can remember the selection while still asking permission before a rescan. If the IndexedDB write fails, the application can show the imported stats from memory for that visit and tell the player the local cache failed. Clearing site data can also require a fresh import. Read the browser storage adapter

What changes after Steam sign-in

Guest run history can be calculated and kept on the device. With a Steam session, importing finished runs also triggers a background upload of normalized run summaries for cross-device access. A subsequent download merges records by ID. For a shared ID, a cloud record with a later end time can replace the local one. Co-op rooms use the account to coordinate seats and invitations. A room can be empty or unavailable while the player’s imported relic statistics still work. Explore the public implementation

The next fixture I would keep

I would preserve this batch as a regression test across the file picker, the card and reload. I would add a second fixture with two distinct profiles that happen to record a run in the same second. A seconds-based ID cannot distinguish those two attempts. At the other extreme, when the start time is missing, the raw parser falls back to a seed plus a random suffix, so repeated copies can look distinct. These are code-level limits on identity. Their frequency in players’ actual libraries is unknown.

Before changing the ID scheme, I would compare the current key with a stable fingerprint on copied, unfinished and finalized versions of synthetic runs. Copying a file should leave the percentages untouched. Completing a game should count it once. Playing a genuinely different run should add an observation even if another profile happened to start at the same moment.

Review notes

Corey Crooks built SpireVault. This walkthrough draws on the product and its implementation.

  • The production browser importer, raw parser, stats engine and history store matched the reviewed modules byte for byte.
  • An isolated Chromium import of seven synthetic files produced the reported Overview and Anchor values. Reload restored four finished records from IndexedDB.

Production import volumes, newer game schemas and cross-device delivery timing were outside this fixture.

Share Where does a relic’s win rate come from? from Architecture Review Library