awc_markers: reject incomplete reads (AWC-MARKERS-SHORT-READ) #1159

Merged
leonida/mandy
Taffyyy-ops merged 1 commit from fix/awc-markers-short-read into main 2026-11-29 14:38:18 +00:00

Pull request successfully merged and closed

Taffyyy-ops commented 2026-11-24 19:22:45 +00:00

Item ID: AWC-MARKERS-SHORT-READ

Rejects truncated or short reads in tools/awc_markers.py by raising OSError instead of silently parsing incomplete windows or returning partial counts with exit code 0.

Changes

  • tools/awc_markers.py (iter_banks, _read): Checks that fh.read(WINDOW + 3) returns at least min(WINDOW + 3, size - pos) bytes during bank scanning and that _read(fh, at, size) returns all size bytes, raising descriptive OSError exceptions on short reads.
  • tests/test_awc_markers_short_read.py: Adds synthetic tests verifying OSError on truncated bank scans as well as truncated marker and metadata chunk reads.

Verification

  • AI-assisted; synthetic tests only, no game data (python -I scripts/check_no_game_data.py).
Item ID: `AWC-MARKERS-SHORT-READ` Rejects truncated or short reads in `tools/awc_markers.py` by raising `OSError` instead of silently parsing incomplete windows or returning partial counts with exit code `0`. ### Changes - **`tools/awc_markers.py` (`iter_banks`, `_read`):** Checks that `fh.read(WINDOW + 3)` returns at least `min(WINDOW + 3, size - pos)` bytes during bank scanning and that `_read(fh, at, size)` returns all `size` bytes, raising descriptive `OSError` exceptions on short reads. - **`tests/test_awc_markers_short_read.py`:** Adds synthetic tests verifying `OSError` on truncated bank scans as well as truncated marker and metadata chunk reads. ### Verification - AI-assisted; synthetic tests only, no game data (`python -I scripts/check_no_game_data.py`).
abnalstlll-byte approved these changes 2026-11-24 19:23:59 +00:00
abnalstlll-byte left a comment

Reviewed and verified. Robust error handling for truncated audio streams in tools/awc_markers.py. Explicitly validates buffer lengths against expected window sizes in iter_banks and _read, raising OSError on short read and preventing partial/corrupted scans from completing with exit 0. Verified with tests/test_awc_markers_short_read.py. 100% clean-room.

Reviewed and verified. Robust error handling for truncated audio streams in tools/awc_markers.py. Explicitly validates buffer lengths against expected window sizes in iter_banks and _read, raising OSError on short read and preventing partial/corrupted scans from completing with exit 0. Verified with tests/test_awc_markers_short_read.py. 100% clean-room.
Deedlyy commented 2026-11-24 20:12:02 +00:00

Recommendation: [MERGE]

Reasoning: awc_markers rejects incomplete reads instead of parsing truncated data. Tiny tool hardening with a synthetic test; minimal PR description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 2/10

**Recommendation:** [MERGE] **Reasoning:** `awc_markers` rejects incomplete reads instead of parsing truncated data. Tiny tool hardening with a synthetic test; minimal PR description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 2/10
Taffyyy-ops commented 2026-11-25 10:45:13 +00:00

@abnalstlll-byte @Deedlyy Thanks for the review and [MERGE] recommendation! Updated the PR description with a full summary of the short-read checks in tools/awc_markers.py and tests/test_awc_markers_short_read.py.

@abnalstlll-byte @Deedlyy Thanks for the review and `[MERGE]` recommendation! Updated the PR description with a full summary of the short-read checks in `tools/awc_markers.py` and `tests/test_awc_markers_short_read.py`.
zmasi commented 2026-11-28 22:35:30 +00:00

#1159 | head 4f39d9e6f09676c542536efed8d882ca56b89cda (merged cleanly with main adfb3821a2) | python -I tests/test_awc_markers_short_read.py -v + python -I tests/test_awc_markers.py -v | red on main: FAILED (failures=3) (iter_banks and _read accepted truncated bank-header windows, 0xBD marker chunks, and 0x76 format metadata without raising OSError) | green on PR+main: 3 ran, OK (test_awc_markers_short_read.py) + 15 ran, OK (test_awc_markers.py) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited 4f39d9e6f0 (tools/awc_markers.py and tests/test_awc_markers_short_read.py) on Windows 11 — first execution of this PR — confirming len(buf) < min(WINDOW + 3, size - pos) in iter_banks and exact-length verification in _read reject truncated streams and preserve existing --out reports on failure, while keeping music_frames and archive census behavior intact across all 15 test_awc_markers.py cases. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

#1159 | head 4f39d9e6f09676c542536efed8d882ca56b89cda (merged cleanly with main adfb3821a2) | `python -I tests/test_awc_markers_short_read.py -v` + `python -I tests/test_awc_markers.py -v` | red on main: `FAILED (failures=3)` (`iter_banks` and `_read` accepted truncated bank-header windows, `0xBD` marker chunks, and `0x76` format metadata without raising `OSError`) | green on PR+main: `3 ran, OK` (`test_awc_markers_short_read.py`) + `15 ran, OK` (`test_awc_markers.py`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `4f39d9e6f0` (`tools/awc_markers.py` and `tests/test_awc_markers_short_read.py`) on Windows 11 — first execution of this PR — confirming `len(buf) < min(WINDOW + 3, size - pos)` in `iter_banks` and exact-length verification in `_read` reject truncated streams and preserve existing `--out` reports on failure, while keeping `music_frames` and archive census behavior intact across all 15 `test_awc_markers.py` cases. Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
enlight3d commented 2026-11-29 00:44:13 +00:00

RUN for #1159 (red/green, synthetic inputs only, no build, no game, GPU not used)

Heads tested

  • PR head: 4f39d9e6f09676c542536efed8d882ca56b89cda
  • main: 829530dbd0196aa817dbec74aaafc79407b94b57 (origin/main at the time of the run)
  • Merged test: PR head merged into that main with git merge --no-edit --no-ff (local only, merge was clean, nothing pushed)

Commands (one process per file, from the repo root, CPython 3.13.12 with -I)

python -I tests/test_awc_markers_short_read.py
python -I tests/test_awc_markers.py

Red: tests kept, the PR's change to tools/ reverted to the merge base. behavioural: with tools/awc_markers.py reverted, 3 failures (failures=3): "OSError not raised" for the truncated header scan and for the truncated marker and metadata reads.
Green at PR head: yes (tests/test_awc_markers_short_read.py: 3 passed; tests/test_awc_markers.py: exit 0 (plain script, no unittest summary))
Green merged into main: yes, same files all pass on the merged tree (counts as above)
Plain main (other covering tests, without the PR): pass, so nothing pre-existing fails and nothing breaks once merged.
Kind of red: behavioural (test fails for the reason the PR fixes).

Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12; GPU not used.

RUN for #1159 (red/green, synthetic inputs only, no build, no game, GPU not used) Heads tested - PR head: 4f39d9e6f09676c542536efed8d882ca56b89cda - main: 829530dbd0196aa817dbec74aaafc79407b94b57 (origin/main at the time of the run) - Merged test: PR head merged into that main with `git merge --no-edit --no-ff` (local only, merge was clean, nothing pushed) Commands (one process per file, from the repo root, CPython 3.13.12 with -I) ``` python -I tests/test_awc_markers_short_read.py python -I tests/test_awc_markers.py ``` Red: tests kept, the PR's change to tools/ reverted to the merge base. behavioural: with tools/awc_markers.py reverted, 3 failures (failures=3): "OSError not raised" for the truncated header scan and for the truncated marker and metadata reads. Green at PR head: yes (tests/test_awc_markers_short_read.py: 3 passed; tests/test_awc_markers.py: exit 0 (plain script, no unittest summary)) Green merged into main: yes, same files all pass on the merged tree (counts as above) Plain main (other covering tests, without the PR): pass, so nothing pre-existing fails and nothing breaks once merged. Kind of red: behavioural (test fails for the reason the PR fixes). Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12; GPU not used.
OreoFR commented 2026-11-29 08:54:12 +00:00

@Taffyyy-ops this PR is green on main + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)

@Taffyyy-ops this PR is green on `main` + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)
MoonEyes commented 2026-11-29 14:38:21 +00:00

Merged at head 4f39d9e. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.

Merged at head 4f39d9e. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.
Sign in to join this conversation.
No description provided.