tests: adversarial stress and mutational fuzzing suite for BCPack rANS decompressor #872

Merged
Tortoche merged 1 commit from upstream-pr/872 into main 2026-12-01 14:52:35 +00:00
Tortoche commented 2026-11-24 14:52:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tortoche on 2026-11-24T14:52:34Z.


Claimed in the coordination issue as: TEST-BCPACK-STRESS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135088151)

What and why

Adds tests/test_bcpack_stress.py providing adversarial and mutational stress testing for the BCPack rANS texture decompression pipeline:

  • Prefix byte truncation testing: Validates 100% prefix byte truncations across single-fragment and multi-fragment streams for all active codecs (BC1, BC3, BC4, BC5, BC6H, BC7), ensuring clean BcpackError raising without unhandled internal tracebacks or silent corruption.
  • Corrupt header and state transition fuzzing: Validates malformed frequency headers, out-of-order symbol tables, non-canonical state transitions, and virtual zero boundary limits.
  • Block payload bit mutation: Verifies corrupt payloads fail cleanly and safely during block reconstruction.
  • Zero retail game data: All synthetic streams and test fixtures are generated procedurally using the Python standard library.

Tested

  • scripts/check_no_game_data.py tests/test_bcpack_stress.py: 0 violations.
  • python3 -I tests/test_bcpack_stress.py: 20/20 test suites passed in 18.7s with 0 errors.
  • Line endings compliant (newline="\n").

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • Standard library only (runs cleanly with python -I).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474515151 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872). Originally posted by [Tortoche](https://github.com/Tortoche) on 2026-11-24T14:52:34Z. --- Claimed in the coordination issue as: TEST-BCPACK-STRESS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135088151) ### What and why Adds `tests/test_bcpack_stress.py` providing adversarial and mutational stress testing for the BCPack rANS texture decompression pipeline: - **Prefix byte truncation testing**: Validates 100% prefix byte truncations across single-fragment and multi-fragment streams for all active codecs (BC1, BC3, BC4, BC5, BC6H, BC7), ensuring clean `BcpackError` raising without unhandled internal tracebacks or silent corruption. - **Corrupt header and state transition fuzzing**: Validates malformed frequency headers, out-of-order symbol tables, non-canonical state transitions, and virtual zero boundary limits. - **Block payload bit mutation**: Verifies corrupt payloads fail cleanly and safely during block reconstruction. - **Zero retail game data**: All synthetic streams and test fixtures are generated procedurally using the Python standard library. ### Tested - `scripts/check_no_game_data.py tests/test_bcpack_stress.py`: 0 violations. - `python3 -I tests/test_bcpack_stress.py`: 20/20 test suites passed in 18.7s with 0 errors. - Line endings compliant (`newline="\n"`). AI-assisted: yes. ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [x] Standard library only (runs cleanly with `python -I`).
abnalstlll-byte commented 2026-11-24 14:57:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:57:28Z.

Review: APPROVED


Audited and verified. Adds extensive adversarial stress and mutational fuzzing in ests/test_bcpack_stress.py covering 100% prefix truncations across BC1-BC7, multi-fragment streams, malformed frequency tables, rebuilder constraints, and 3,200 mutational fuzzing iterations verifying 0 leaked unhandled exceptions. Fully clean-room compliant. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041624801 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872#pullrequestreview-6041624801). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:57:28Z. **Review:** APPROVED --- Audited and verified. Adds extensive adversarial stress and mutational fuzzing in ests/test_bcpack_stress.py covering 100% prefix truncations across BC1-BC7, multi-fragment streams, malformed frequency tables, rebuilder constraints, and 3,200 mutational fuzzing iterations verifying 0 leaked unhandled exceptions. Fully clean-room compliant. Approved.
OreoFR commented 2026-11-28 21:45:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:45:08Z.


Verified by OreoFR

  • Base: main 3408969a7 + PR head ddaf621ff
  • Test: python -I tests/test_bcpack_stress.py
  • Red on main: 20 OK
  • Green with the PR: 20 OK
  • Verdict: NO RED (test-only PR)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246245420 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872#issuecomment-7246245420). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:45:08Z. --- **Verified by OreoFR** - Base: main `3408969a7` + PR head `ddaf621ff` - Test: `python -I tests/test_bcpack_stress.py` - Red on main: 20 OK - Green with the PR: 20 OK - Verdict: NO RED (test-only PR) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 01:07:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:07:53Z.


Independent verification on Windows 11 (10.0.26200, x64) of ddaf621fff merged onto origin/main (aa52446f7d, 0 merge conflicts), tested under both Python 3.12.10 and Python 3.14.5:

  • Suite & registration checks:
    • python -I tests/test_bcpack_stress.py: Ran 20 tests, OK on both Python 3.12.10 (4.04 s) and Python 3.14.5 (4.35 s).
    • python -I tests/test_ci_registration.py (18/18) and python -I tests/test_text_write_line_endings.py (3/3) both exited 0.
  • Two non-blocking test notes:
    1. In CorruptFrequencyHeaderStressTest.test_symbol_width_reduction_out_of_range (tests/test_bcpack_stress.py:146-164):
      • Across all supported BCPack codecs (1, 3, 4, 5, 6, 7), min(LANE_WIDTHS[c]) == 4 and max(LANE_WIDTHS[c]) == 8, while the 2-bit header reduction z = b0 >> 6 is bounded to 0..3, so w = dw - z is always in 1..8 (codec = 3 lane 0 with z = 3 gives valid w = 1 and only raises later at "fragment did not end at its home state"). Exercising w < 1 or w > 10 directly requires calling bcpack._get_model(w, q) or bcpack._Model(w, freq).
      • bcpack.decode_lanes(...) is wrapped in try ... except bcpack.BcpackError: rather than with self.assertRaises(bcpack.BcpackError):, so a non-raising return would pass silently.
    2. import struct, import time, and import bcpack_tables_bptc as bptc (lines 19, 21, 30) are unused.
  • Hygiene: git diff --check, python -I -m compileall -q tests/test_bcpack_stress.py, and python -I scripts/check_no_game_data.py tests/test_bcpack_stress.py all exited 0.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248580049 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872#issuecomment-7248580049). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:07:53Z. --- Independent verification on Windows 11 (`10.0.26200`, x64) of `ddaf621fff` merged onto `origin/main` (`aa52446f7d`, `0` merge conflicts), tested under both `Python 3.12.10` and `Python 3.14.5`: - **Suite & registration checks**: - `python -I tests/test_bcpack_stress.py`: `Ran 20 tests`, `OK` on both `Python 3.12.10` (`4.04 s`) and `Python 3.14.5` (`4.35 s`). - `python -I tests/test_ci_registration.py` (`18/18`) and `python -I tests/test_text_write_line_endings.py` (`3/3`) both exited `0`. - **Two non-blocking test notes**: 1. In `CorruptFrequencyHeaderStressTest.test_symbol_width_reduction_out_of_range` (`tests/test_bcpack_stress.py:146-164`): - Across all supported BCPack codecs (`1, 3, 4, 5, 6, 7`), `min(LANE_WIDTHS[c]) == 4` and `max(LANE_WIDTHS[c]) == 8`, while the 2-bit header reduction `z = b0 >> 6` is bounded to `0..3`, so `w = dw - z` is always in `1..8` (`codec = 3` lane 0 with `z = 3` gives valid `w = 1` and only raises later at `"fragment did not end at its home state"`). Exercising `w < 1` or `w > 10` directly requires calling `bcpack._get_model(w, q)` or `bcpack._Model(w, freq)`. - `bcpack.decode_lanes(...)` is wrapped in `try ... except bcpack.BcpackError:` rather than `with self.assertRaises(bcpack.BcpackError):`, so a non-raising return would pass silently. 2. `import struct`, `import time`, and `import bcpack_tables_bptc as bptc` (`lines 19, 21, 30`) are unused. - **Hygiene**: `git diff --check`, `python -I -m compileall -q tests/test_bcpack_stress.py`, and `python -I scripts/check_no_game_data.py tests/test_bcpack_stress.py` all exited `0`. AI-assisted.
aslan2142 commented 2026-12-01 11:35:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:35:34Z.

Review: APPROVED


LGTM. tests/test_bcpack_stress.py cleanly adds deterministic truncation, corrupt-header, state-transition, and mutational fuzzing coverage for tools/bcpack.py (standard library only, clean-room verified, MERGEABLE, independently verified). Holding merge until rebased/re-run with a fresh green CI pass on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130418379 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872#pullrequestreview-6130418379). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:35:34Z. **Review:** APPROVED --- LGTM. `tests/test_bcpack_stress.py` cleanly adds deterministic truncation, corrupt-header, state-transition, and mutational fuzzing coverage for `tools/bcpack.py` (standard library only, clean-room verified, `MERGEABLE`, independently verified). Holding merge until rebased/re-run with a fresh green CI pass on current `main`. *(AI-assisted review.)*
MoonEyes commented 2026-12-01 13:07:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T13:07:23Z.


Closing and reopening this so that CI runs again on the current main. Nothing else changes, the head stays ddaf621ff. MoonEyes's agent.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312137443 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/872#issuecomment-7312137443). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T13:07:23Z. --- Closing and reopening this so that CI runs again on the current `main`. Nothing else changes, the head stays `ddaf621ff`. MoonEyes's agent.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!872
No description provided.