On this page
Parity: how much is proven, and how it is counted
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.
The numbers#
| Game | Functions in the count | Strict | Named | Any | Not tested yet |
|---|---|---|---|---|---|
| Battlefield 2 | 18,554 | 13,657 (73.6 %) | 17,412 (93.8 %) | 18,227 (98.2 %) | 327 |
| Battlefield 2142 | 13,326 | 7,193 (54.0 %) | 9,926 (74.5 %) | 12,569 (94.3 %) | 757 |
| Battlefield Heroes | 15,570 | 4,524 (29.1 %) | 5,921 (38.0 %) | 13,659 (87.7 %) | 1,911 |
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):
| Game | a1 | a2 | b | d | e | f | c |
|---|---|---|---|---|---|---|---|
| Battlefield 2 | 13,657 | 3,755 | 815 | ||||
| Battlefield 2142 | 7,193 | 2,733 | 1,980 | 662 | 1 | ||
| Battlefield Heroes | 4,524 | 1,397 | 2,717 | 2,459 | 1,128 | 47 | 1,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:
| Game | Generated on | At commit | Functions | Covered | Tested (any proof) |
|---|---|---|---|---|---|
| Battlefield 2 | 2026-11-11 | d73a115 | 18,391 | 18,391 | 16,611 (90.3 %) |
| Battlefield 2142 | 2026-11-11 | d73a115 | 13,238 | 12,981 | 9,229 (69.7 %) |
| Battlefield Heroes | 2026-11-11 | d73a115 | 18,592 | 18,581 | 12,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.
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#
| Number | A function counts when | In the classes below |
|---|---|---|
| strict | a 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 |
| named | some 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 it | a1 + a2 |
| any | it 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#
- 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.
- 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.
- 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). - 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:
| Class | Proof | In |
|---|---|---|
a1 | A cargo test's own text cites the function, or an oracle case that calls the original function in-process passed (Heroes) | strict, named, any |
a2 | Only link lines cite it in a test (// Calls .., // Reaches ..): a test calls the Rust function that carries the citation, but was not written about it | named, any |
b | The record only: the Rust function that carries the citation ran in a scenario's passing traced runs | any |
d | A twin's test only: a test cites the Battlefield 2 function this 2142 or Heroes function is a copy of | any |
e | A reached list only (Heroes: one coverage run of an older build) | any |
f | A passing scenario's own text names the address | any |
c | The areas rule alone (Heroes: a file that a passing scenario's areas map to) | any |
g | No proof at all: a fault of the counter, and its --check fails on it | not 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.
| Class | What it is | What stays in the count all the same |
|---|---|---|
| destructor | a destructor whose body only frees, releases, unlinks itself or calls other destructors | a destructor that does game work a player can meet: sends, plays, scores, spawns or removes an object, writes a file |
| refcount | add-reference, release, a smart pointer's copy, assign and reset | |
| compiler-library | what the compiler or a library made: container bodies, compiler-generated copies of plain records, operator new and delete | third-party code a played game runs; a default constructor with start values (the values are the authors') |
| unreached | code no played game reaches, with its proof: a mode, tool, command or data no shipped file names, or no caller with the virtual tables searched | a function a played game reaches and that does nothing |
| differs-on-purpose | a 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 bound | a function where only one statement differs on purpose: it stays counted |
How many rows each game has today:
| Game | destructor | refcount | compiler-library | unreached | differs-on-purpose | All |
|---|---|---|---|---|---|---|
| Battlefield 2 | 21 | 25 | 77 | 8 | 9 | 140 |
| Battlefield 2142 | 41 | 57 | 141 | 3 | 2 | 244 |
| Battlefield Heroes | 250 | 2 | 1,746 | 312 | 291 | 2,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 toa1.
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#
| What | Where |
|---|---|
| the counter | tools/bfheroes/parity_coverage.py (PROOF_KINDS, load_denominator) |
| the rows taken out | tools/bfheroes/parity_denominator.yaml |
| the counter's own notes | notes/bfheroes/parity_coverage.md, parity_coverage_bf2.md, parity_coverage_bf2142.md |
| the workers' log of counts | notes/bfheroes/parity_tested.md |
| the dashboard's page | tools/bfheroes/parity_report.py, parity_history.py (the graph over time) |
| this page's reader | tools/devwiki/parity.py |
docs/dev/testing/parity.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.