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

Merged
Taffyyy-ops merged 1 commit from upstream-pr/1159 into main 2026-11-29 14:38:18 +00:00
Taffyyy-ops commented 2026-11-24 19:22:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T19:22:45Z.


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).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478805600 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T19:22:45Z. --- 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 commented 2026-11-24 19:23:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:23:59Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045862292 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159#pullrequestreview-6045862292). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:23:59Z. **Review:** APPROVED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:12:02Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143181103 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1159#issuecomment-7143181103). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:12:02Z. --- **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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T10:45:13Z.


@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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7160125456 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1159#issuecomment-7160125456). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T10:45:13Z. --- @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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:35:30Z.


#1159 | head 4f39d9e6f0 (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246843568 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159#issuecomment-7246843568). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:35:30Z. --- #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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:44:13Z.


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

Heads tested

  • PR head: 4f39d9e6f0
  • main: 829530dbd0 (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248316251 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159#issuecomment-7248316251). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T00:44:13Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:54:12Z.


@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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253406492 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159#issuecomment-7253406492). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:54:12Z. --- @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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:38:21Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257459459 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1159#issuecomment-7257459459). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:38:21Z. --- 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 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!1159
No description provided.