tests: cover PerReasonRefusalCensus sanitization, bounds, ranking, and delta reports #3752

Manually merged
github merged 1 commit from github-bot/gh-3750 into main 2026-12-01 17:05:19 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-12-01 15:10 UTC · original
Ammmae0x:tests/per-reason-refusal-unit → main · +1801 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC

Refs #1149. Portable C++17 unit tests for x2w_startup::PerReasonRefusalCensus (src/startup_stubs/per_reason_refusal_census.h) with zero edits to existing files: 5 new files only (+1801/-0).

What landed — commit 21a2916f, branch tests/per-reason-refusal-unit:

  • tests/per_reason_refusal_unit_check.cpp: 26 cases — constructor/reason sanitization (nullptr/"" fallbacks, CR/LF to spaces, 31-char label and 63-char reason truncation), distinct (key, reason) pairs vs duplicates (first_frame preserved, frame -1 omitted vs 0 emitted), the detail_entries == 8 budget, max_entries == 128 saturation (overflow, total, distinct keys, per-key totals past the pair cap up to max_keys == 1024, unstored-key calls past 1024), key 0 ranked exclusion and pair cap, report() deltas (forced reports leave delta state intact, top_keys == 32 ranking with smaller-key tie-break, key-overflow omission/emission, unkeyed deltas), and multi-threaded note() + report() stress. All constants used inside lambdas are static constexpr; pure in-memory, no temp files.
  • tests/cmake/per_reason_refusal_unit.cmake: per-case CTests + _all, and 7 WILL_FAIL TRUE header-copy mutation controls (reason_overwrite, detail_budget, key_tie_order, key_zero_ranked, forced_report_delta, sanitize_newline, overflow_account).
  • tests/per_reason_refusal_unit_meta_check.py: audits the contract and compiles/runs the real C++ check and every mutation against a real C++ copy (1:1 sets, zero model-only mutants; temp dirs removed in finally). It runs real compiles with g++ when present, tries cl otherwise, and fails naming both when neither is present.
  • tests/checks/python-linux/per_reason_refusal_unit.txt and docs/experiments/per-reason-refusal-unit.md.

Linux verification (this host, g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror):

  • C++ check: PASS: per_reason_refusal_unit: 26/26 cases passed
  • Meta check: PASS: per_reason_refusal_unit: 26 cases, 7/7 mutations killed (g++)
  • Scratch CMake + CTest: 34/34 (26 cases + _all + 7 WILL_FAIL mutation controls)
  • form_coverage_check.py, docs_links_check.py (208 files / 802 links), and bidi_controls_check.py (2827 files) pass; diff --check clean; merge-tree vs origin/main exits 0; zero personal paths.

Caught in development: duplicate note() calls return false by design, so the delta cases assert them as plain calls, not as detailed notes; and a duplicated pair re-ranks first in the key totals, so the periodic-delta case pins key-total 1 for the changed key.

Caveat: no mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter.

Windows Verification (21a2916f)

  • git merge-tree --write-tree upstream/main HEAD -> 952585ae (exit 0), git diff --check upstream/main...HEAD clean
  • Repo checks: py_compile, form_coverage_check.py, docs_links_check.py (209 files, 806 links), bidi_controls_check.py (2830 files), per_reason_refusal_unit_meta_check.py (cl: 26 cases, 7/7 mutations killed) passed
  • Commands:
cmake --build --preset dev --target per_reason_refusal_unit_check per_reason_refusal_unit_reason_overwrite_mut per_reason_refusal_unit_detail_budget_mut per_reason_refusal_unit_key_tie_order_mut per_reason_refusal_unit_key_zero_ranked_mut per_reason_refusal_unit_forced_report_delta_mut per_reason_refusal_unit_sanitize_newline_mut per_reason_refusal_unit_overflow_account_mut
ctest --preset dev --no-tests=error -j16 -R "^per_reason_refusal_unit" --output-on-failure
cmake --build --preset release --target per_reason_refusal_unit_check per_reason_refusal_unit_reason_overwrite_mut per_reason_refusal_unit_detail_budget_mut per_reason_refusal_unit_key_tie_order_mut per_reason_refusal_unit_key_zero_ranked_mut per_reason_refusal_unit_forced_report_delta_mut per_reason_refusal_unit_sanitize_newline_mut per_reason_refusal_unit_overflow_account_mut
ctest --preset release --no-tests=error -j16 -R "^per_reason_refusal_unit" --output-on-failure
  • Results: dev 34/34 passed (1.08s); release 34/34 passed (0.98s); direct per_reason_refusal_unit_check.exe (dev & release): PASS: per_reason_refusal_unit: 26/26 cases passed. AI-assisted.
**@⁠Ammmae0x** on GitHub · 2026-12-01 15:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3750) `Ammmae0x:tests/per-reason-refusal-unit` → `main` · +1801 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC Refs #1149. Portable C++17 unit tests for `x2w_startup::PerReasonRefusalCensus` (`src/startup_stubs/per_reason_refusal_census.h`) with zero edits to existing files: 5 new files only (+1801/-0). What landed — commit `21a2916f`, branch `tests/per-reason-refusal-unit`: - `tests/per_reason_refusal_unit_check.cpp`: 26 cases — constructor/reason sanitization (nullptr/"" fallbacks, CR/LF to spaces, 31-char label and 63-char reason truncation), distinct `(key, reason)` pairs vs duplicates (first_frame preserved, frame -1 omitted vs 0 emitted), the `detail_entries == 8` budget, `max_entries == 128` saturation (overflow, total, distinct keys, per-key totals past the pair cap up to `max_keys == 1024`, unstored-key calls past 1024), key 0 ranked exclusion and pair cap, `report()` deltas (forced reports leave delta state intact, `top_keys == 32` ranking with smaller-key tie-break, key-overflow omission/emission, unkeyed deltas), and multi-threaded `note()` + `report()` stress. All constants used inside lambdas are `static constexpr`; pure in-memory, no temp files. - `tests/cmake/per_reason_refusal_unit.cmake`: per-case CTests + `_all`, and 7 `WILL_FAIL TRUE` header-copy mutation controls (`reason_overwrite`, `detail_budget`, `key_tie_order`, `key_zero_ranked`, `forced_report_delta`, `sanitize_newline`, `overflow_account`). - `tests/per_reason_refusal_unit_meta_check.py`: audits the contract and compiles/runs the real C++ check and every mutation against a real C++ copy (1:1 sets, zero model-only mutants; temp dirs removed in `finally`). It runs real compiles with `g++` when present, tries `cl` otherwise, and fails naming both when neither is present. - `tests/checks/python-linux/per_reason_refusal_unit.txt` and `docs/experiments/per-reason-refusal-unit.md`. Linux verification (this host, `g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror`): - C++ check: `PASS: per_reason_refusal_unit: 26/26 cases passed` - Meta check: `PASS: per_reason_refusal_unit: 26 cases, 7/7 mutations killed (g++)` - Scratch CMake + CTest: 34/34 (26 cases + `_all` + 7 `WILL_FAIL` mutation controls) - `form_coverage_check.py`, `docs_links_check.py` (208 files / 802 links), and `bidi_controls_check.py` (2827 files) pass; `diff --check` clean; merge-tree vs `origin/main` exits 0; zero personal paths. Caught in development: duplicate `note()` calls return false by design, so the delta cases assert them as plain calls, not as detailed notes; and a duplicated pair re-ranks first in the key totals, so the periodic-delta case pins `key-total 1` for the changed key. Caveat: no mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter. <!-- WIN-VERIFY: passed | sha=21a2916f2a6260b09ec33bfd7f817210c3ab301e | targets=per_reason_refusal_unit_check per_reason_refusal_unit_reason_overwrite_mut per_reason_refusal_unit_detail_budget_mut per_reason_refusal_unit_key_tie_order_mut per_reason_refusal_unit_key_zero_ranked_mut per_reason_refusal_unit_forced_report_delta_mut per_reason_refusal_unit_sanitize_newline_mut per_reason_refusal_unit_overflow_account_mut | ctest=^per_reason_refusal_unit | release=true --> ### Windows Verification (`21a2916f`) - `git merge-tree --write-tree upstream/main HEAD` -> `952585ae` (exit 0), `git diff --check upstream/main...HEAD` clean - Repo checks: `py_compile`, `form_coverage_check.py`, `docs_links_check.py` (209 files, 806 links), `bidi_controls_check.py` (2830 files), `per_reason_refusal_unit_meta_check.py` (`cl`: `26 cases, 7/7 mutations killed`) passed - Commands: ```text cmake --build --preset dev --target per_reason_refusal_unit_check per_reason_refusal_unit_reason_overwrite_mut per_reason_refusal_unit_detail_budget_mut per_reason_refusal_unit_key_tie_order_mut per_reason_refusal_unit_key_zero_ranked_mut per_reason_refusal_unit_forced_report_delta_mut per_reason_refusal_unit_sanitize_newline_mut per_reason_refusal_unit_overflow_account_mut ctest --preset dev --no-tests=error -j16 -R "^per_reason_refusal_unit" --output-on-failure cmake --build --preset release --target per_reason_refusal_unit_check per_reason_refusal_unit_reason_overwrite_mut per_reason_refusal_unit_detail_budget_mut per_reason_refusal_unit_key_tie_order_mut per_reason_refusal_unit_key_zero_ranked_mut per_reason_refusal_unit_forced_report_delta_mut per_reason_refusal_unit_sanitize_newline_mut per_reason_refusal_unit_overflow_account_mut ctest --preset release --no-tests=error -j16 -R "^per_reason_refusal_unit" --output-on-failure ``` - Results: `dev` 34/34 passed (1.08s); `release` 34/34 passed (0.98s); direct `per_reason_refusal_unit_check.exe` (`dev` & `release`): `PASS: per_reason_refusal_unit: 26/26 cases passed`. AI-assisted.
Refs #1149. Portable C++17 unit tests for
src/startup_stubs/per_reason_refusal_census.h with zero edits to
existing files: 26 cases (constructor/reason sanitization incl.
nullptr/empty fallbacks, CR/LF to spaces, 31-char label and 63-char
reason truncation; distinct (key, reason) pairs vs duplicates with
first_frame preserved and frame -1 omitted vs 0 emitted; the
detail_entries == 8 budget; max_entries == 128 saturation with
per-key totals past the pair cap up to max_keys == 1024 and
unstored-key calls past 1024; key 0 ranked exclusion and pair cap;
report() deltas with forced reports leaving delta state intact,
top_keys == 32 ranking with smaller-key tie-break, key-overflow
omission/emission rules, and unkeyed deltas; multi-threaded note()
+ report() stress) plus 7 WILL_FAIL TRUE header-mutation controls.
AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 15:11:52 +00:00
github manually merged commit 978d966852 into main 2026-12-01 17:05:19 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.