BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

Parity: how much is proven, and how it is counted

BF22142Heroes

bf2-rs is checked against the original programs function by function. One number cannot say how well: a function that a test was written about is proven in another way than one that merely ran while a scenario passed. So the count has three numbers per game, each inside the next: strict, named, any. This page says what each means, how a function gets counted, and what was taken out of the total and why.

A game's functions in the count: reached by a played game, not library code any: some proof stands (a scenario's traced run, a twin's test, ...) named: a test's text holds the address (a1 + a2) strict: a test written about it (a1) not tested yet out of the denominator destructors reference counters compiler and library code unreached code differs on purpose A row that takes a function out takes it out of the total and of the tested number alike. tools/bfheroes/parity_coverage.py (the counter), tools/bfheroes/parity_denominator.yaml (the rows taken out)
The three numbers, each inside the next, and what stands outside the count. The sizes are not to scale: the numbers themselves are in the table below.

The numbers#

GameFunctions in the countStrictNamedAnyNot tested yet
Battlefield 218,55413,657 (73.6 %)17,412 (93.8 %)18,227 (98.2 %)327
Battlefield 214213,3267,193 (54.0 %)9,926 (74.5 %)12,569 (94.3 %)757
Battlefield Heroes15,5704,524 (29.1 %)5,921 (38.0 %)13,659 (87.7 %)1,911
Battlefield 2
Battlefield 2142
Battlefield Heroes

strict named, not strict any other proof not tested yet

Read by the build from notes/bfheroes/parity_tested.md, line 101657: the three counters run once on the merged tree 92d82e2. The totals are the same note's last tested N of M for each game. That note is the workers' log of the counters' output, written by hand from the counters' printed lines. The counter can write its split to a file (parity_coverage.py --json), and the dashboard reads that file; but it is written outside the tree, into a folder the workers share, and belongs to whichever tree ran the counter last. So this page keeps the log's line, which names its commit.

The same count by class of proof (the classes are explained below):

Gamea1a2bdefc
Battlefield 213,6573,755815
Battlefield 21427,1932,7331,9806621
Battlefield Heroes4,5241,3972,7172,4591,128471,387

The counter also writes notes of its own into the tree (notes/bfheroes/parity_coverage*.md). They carry no split by kind of proof, and they are regenerated less often than the counter runs, so their numbers are older and are shown here only with their date:

GameGenerated onAt commitFunctionsCoveredTested (any proof)
Battlefield 22026-11-11d73a11518,39118,39116,611 (90.3 %)
Battlefield 21422026-11-11d73a11513,23812,9819,229 (69.7 %)
Battlefield Heroes2026-11-11d73a11518,59218,58112,558 (67.5 %)

Nothing in this section is typed into the page. The wiki's build reads the files named above each time it runs, so the page cannot say more than the tree does. The live figures, per system and per function, are on the parity dashboard.

Read the strict number first

The any number says "something of ours that stands for this function ran and nothing failed". The strict number says "somebody read this function in the original, wrote a test from what it does, and that test names it". Only the second is a statement about behaviour. Battlefield 2 is the oldest port and has the most tests written this way; Heroes is the youngest, and much of its count still rests on its Battlefield 2 and 2142 twins.

What the three numbers mean#

NumberA function counts whenIn the classes below
stricta test of its own, written from the original's code, cites it in the test's own text; or (Heroes) an oracle case ran the port beside the original function on the same inputs with equal outputs. The dashboard's headline calls this "checked against the original"a1
namedsome test's text holds its address at all: strict, plus the functions that only a link line names (// Calls .., // Reaches ..): a test calls the Rust function that carries the citation, but was not written about ita1 + a2
anyit has any proof: named, plus a scenario's passing traced run, a twin's test, a reached list, a scenario's own text, the areas rule. The dashboard calls this "exercised"a1 to c

"Named" as the sum of the first two classes is this page's reading of the counter's classes (PROOF_KINDS in tools/bfheroes/parity_coverage.py); the counter itself prints the classes, not that sum.

How a function gets counted#

  1. It is a function of the original that a played game can reach. The counter starts from roots (the functions the port's files of a system cite, named entry points, and every virtual slot of the system's classes) and walks the original's call graph from them to its end. A function no root reaches is not in the count.
  2. It is not library code. The C runtime, the standard containers, third-party kits and small helpers that only forward to them are recognised by rule and not expanded.
  3. It is covered when Rust code cites its address in a doc comment, as every page of this wiki does (bf2_w32ded.exe!0x0062a420, BFHeroes.exe@bfh126!0x007d0ead), or when an explicit decision about it is written down with its reason (skipped by design, out of scope).
  4. It is tested when at least one proof stands for it. The counter gives it the strongest proof it has.

The dedicated server's citations count for the client executable's function through a map of twins. A citation in a test file does not make a function covered: only the port's own code does.

The kinds of proof#

The counter gives every tested function the strongest proof it has, in this order:

ClassProofIn
a1A cargo test's own text cites the function, or an oracle case that calls the original function in-process passed (Heroes)strict, named, any
a2Only link lines cite it in a test (// Calls .., // Reaches ..): a test calls the Rust function that carries the citation, but was not written about itnamed, any
bThe record only: the Rust function that carries the citation ran in a scenario's passing traced runsany
dA twin's test only: a test cites the Battlefield 2 function this 2142 or Heroes function is a copy ofany
eA reached list only (Heroes: one coverage run of an older build)any
fA passing scenario's own text names the addressany
cThe areas rule alone (Heroes: a file that a passing scenario's areas map to)any
gNo proof at all: a fault of the counter, and its --check fails on itnot counted

What was taken out of the denominator, and why#

The total a percentage is taken of is not "every function of the executable". On 2026-11-16 the project's owner ruled, in these words: "remove destructors or unreached code from the denominator so that we aren't chasing useless numbers. where we have ported functions that differ from the original we should correct it unless we need it for compatibility or something (if that's the case we should also remove these from the denominator)".

Since then one file lists, function by function, what is out: tools/bfheroes/parity_denominator.yaml. A row takes its function out of the total and out of the tested number alike, so no percentage gains from it by itself. Every row carries a proof a reader can check; the file's rule is in doubt a function stays.

ClassWhat it isWhat stays in the count all the same
destructora destructor whose body only frees, releases, unlinks itself or calls other destructorsa destructor that does game work a player can meet: sends, plays, scores, spawns or removes an object, writes a file
refcountadd-reference, release, a smart pointer's copy, assign and reset
compiler-librarywhat the compiler or a library made: container bodies, compiler-generated copies of plain records, operator new and deletethird-party code a played game runs; a default constructor with start values (the values are the authors')
unreachedcode no played game reaches, with its proof: a mode, tool, command or data no shipped file names, or no caller with the virtual tables searcheda function a played game reaches and that does nothing
differs-on-purposea whole function the port differs from on purpose, for compatibility: another platform, the browser, the port's own services in place of hosts that no longer exist, a safety bounda function where only one statement differs on purpose: it stays counted

How many rows each game has today:

Gamedestructorrefcountcompiler-libraryunreacheddiffers-on-purposeAll
Battlefield 221257789140
Battlefield 2142415714132244
Battlefield Heroes25021,7463122912,601

Counted by the build from the rows of tools/bfheroes/parity_denominator.yaml.

The same file lists 26 Battlefield Heroes functions whose only credit was a twin's test while the twin's own game leaves the twin out: those stay in the total and count as not tested until they have a proof of their own.

Many destructor and reference-count rows were found by the shape of the machine code (a deleting destructor is a dozen instructions that always look the same), and only when every call in the body goes to another destructor, a reference counter or library code. The counter can be run without the file (--old-denominator) to see the count as it was before.

Why a twin is not a proof of its own#

Battlefield 2142 and Heroes were built from Battlefield 2's source, so most of their functions have a twin there. When the function map says a 2142 function is its Battlefield 2 twin "up to the struct layout", a test of the twin carries over (class d). It counts in any and not in strict, for a reason this project met again and again: twins differ in small ways that the map cannot see. Heroes stores intermediate results as 32-bit floats where Battlefield 2 keeps them in the x87 register (float precision); 2142's connection type table gives other packet sizes than Battlefield 2's while the code that reads the table is identical (the control block). A function moves from d to a1 when somebody has read it to its end in its own game and written its own test.

How to move a number#

  • Read the function in the original (the Ghidra export, the disassembly for anything about floats).
  • Write a test from what it does, with the address in the test's own text; where the function is pure, add an oracle case so the original computes the expected value itself (the oracle).
  • Run python tools/bfheroes/parity_coverage.py --check; the function's row moves to a1.

The whole way of one function, step by step: how a port is made. What is still open, row by row, from the wiki's own pages: what is still open.

What the count does not say#

  • It counts functions, not behaviour a player meets. A function can be strict and a played round can still differ, because of how functions are wired together; that is what scenarios and the differentials are for.
  • It does not see virtual calls: the call graph holds direct calls only. Every virtual slot of a system's classes is a root instead, and the counter reports what stays unreached.
  • A reading in the notes is not a proof and is in no number until a test stands.

How it is tested#

The counter has its own tests beside it (tools/bfheroes/test_parity_coverage.py, test_parity_denominator.py and others); its --check fails when a function counts as tested with no proof, when a citation names an address that is not a function's start, or when a system's missing count grows past its baseline. The wiki's test checks this page's reader on fixture lines of the three sources and that the built page shows a number for each game.

In the code#

WhatWhere
the countertools/bfheroes/parity_coverage.py (PROOF_KINDS, load_denominator)
the rows taken outtools/bfheroes/parity_denominator.yaml
the counter's own notesnotes/bfheroes/parity_coverage.md, parity_coverage_bf2.md, parity_coverage_bf2142.md
the workers' log of countsnotes/bfheroes/parity_tested.md
the dashboard's pagetools/bfheroes/parity_report.py, parity_history.py (the graph over time)
this page's readertools/devwiki/parity.py
Source: docs/dev/testing/parity.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.