Source-level Elo QA
===================

From the repository root, with Python 3 and Node.js:

  python3 tests/elo/build_checks.py
  node tests/elo/checks.js

The builder extracts relevant functions from scripts/mp/elo_system.gsc and
mechanically adapts them to a mocked JS host. It checks full-file delimiters
and duplicate function definitions. Source/adapter SHA-256 checks reject stale
results. This harness is not an IW4x compiler/runtime and does not validate HUDs.
Pass another source path as the builder's first argument when needed.

Coverage includes conserved integer pools, unbiased cumulative rounding,
placements, future ranks, signed ratings, frozen original rosters, disconnected
players, fill-ins, bot invalidation, draws, surrender, half/round continuation,
pre-match loading, postgame cleanup races and read-only service-mode caches.

The standalone file-mode suite injects interrupted/torn saves, read failures,
write failures and repeated recovery failures into match and index journals.
It includes 983,040 integrated rounding-offset cases, 100,000 float32 cases,
196,608 conservation scenarios, 27,909 rank cases, 1,500 mocked settlements and
140,400 synthetic matches over thirty 180-day growth runs. Assumptions: 80
initial accounts, +1/day, 10-20 daily players and 10/15/30 minute match cycles.
Those simulations establish consistency, not optimal real-world prediction.

An optional independent grammar check:

  python3 tests/elo/check_syntax.py --tool /path/to/gsc-tool

Uses xensik/gsc-tool 1.6.0's IW5/PC parser. It does not validate IW4x linkage or
native event order. Tool: https://github.com/xensik/gsc-tool/releases/tag/1.6.0

Multi-server service/bridge, concurrency, retry, import and menu tests:

  python3 -m unittest discover -s tests -p 'test_*.py' -v

Native test-only script: tests/native/elo_smoke.gsc. It checks real GSC math and
file I/O through the bridge/HTTP/SQLite/reply path using eight synthetic GUIDs.
It requires comp_qa=1 and a NEW isolated test database. Never put this script
on a production server. See docs/QA.txt for recorded native runs and limitations.

Generated adapters and JSON reports are ignored by git. The GSC game code,
Python service and menu IWD are separate deployable components; tests are not.

Balance experiment (added 2026-10-12)
-----------------------------------
  python3 tests/elo/simulate_balance.py --matches 10000 --seeds 5 --seed 20261012
  python3 tests/elo/report_balance.py

Calls the production Python rating policy for 10,000 matches per run. Select
the team mode with --team-mode; see --help. The older captain-draft experiment
is historical and does not describe Ranked. Uses the standard library; the report
plotter also needs matplotlib. No game processes or player databases are used.
Results, raw primary-run match trace and figures: docs/qa/elo-10000/.
Read REPORT.txt for assumptions, measured limits and reproducibility details.

Small-community and contribution sensitivity (current v3.5)
----------------------------------------------------------
  python3 tests/elo/stress_balance.py --profiles 64/48/32/16 \
    --performance none noisy high_noise uninformative role_bias stat_farmer \
    --seed-base 20263012 --seeds 3 --workers 6 --output docs/qa/elo-performance

144 runs of 10,000 matches (1,440,000 total), eight population/skill scenarios.
Daily duos remain together; permanent-duo scenarios never split the partners.
The worker calls the production policy, temporarily setting the requested K
schedule in its own process. It does not edit production files. Three-weight
profiles switch at games 10/30; four-weight profiles also switch at game 100.
Separate random streams keep skills, attendance and match outcomes independent
of the policy's rounding. All models, including failures and limitations, are
reported in docs/qa/elo-performance/REPORT.txt. Performance scores are synthetic
assumptions; they are not copied from real player telemetry.
