tooling: pin stream limits, 29-bit ids and empty tags in awc_metadata_check #1830
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1837"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:20:28Z.
Change
tests/awc_metadata_check.pyexercised the AWC reader's rejections well, but several documented acceptance boundaries intools/awc_metadata.pyhad no case. A single-point change to each of them left the check green:entries[0]and raisesIndexErrorinstead of the specificValueError);entry & 0x1fffffffdecides between a sound-effect bank and a streamed music bank, and detects a second ID-0 stream in a music bank. ID0x10000000sets only bit 28;if length:), in both paths;I applied 14 single-point mutants by hand to
tools/awc_metadata.py, ran the check after each and reverted:1 <= count <= 4096->< 40964096 streams)1 <= count->0 <= countempty stream table)read_bank:entries[0] & 0x1fffffff->0x0fffffffstream id 0x10000000)read_formats:entries[0] & 0x1fffffff == 0->0x0fffffffstream id 0x10000000)kind == 0x55 and length->kind == 0x55empty data tag)if length:beforespans.append-> alwaysempty tag inside the format tag)left[1] > right[0]->>=data touching the format tag,4096 streams)0x1fffffff->0x0fffffffstream id 0x10000000)if length:beforespans.append-> alwaysempty tag inside the music header)table <= header_size->table < header_size>->>=header_size <= startsamples +=->samples =0xff020001droppedThe new cases:
test_rejects_invalid_metadatagains two patches of the existing fixture: a stream count of 0, and the first sound's data tag set to length 0 (that sound keeps its0x76tag, so it has no nonempty data tag).test_sfx_accepts_limitsreads four source-built banks throughread_bankand expects layoutsfxwith exact groups. Every0x76tag records 1 sample, 48,000 Hz and codec 11.4096 streams: each stream has a 1-byte data tag and a 32-byte format tag. The header is 16 + 4 × 4096 + 16 × 4096 = 81,936 bytes, followed by 33 bytes per stream; the data and format tags of each stream touch. Expected: one group with 4,096 streams and 4,096 samples.stream id 0x10000000: one stream whose word is2 << 29 | 0x10000000.data touching the format tag: data at 128..144, format at 144..176.empty tag inside the format tag: a zero-length0xBDtag at offset 170, inside the format tag at 160..192.test_music_accepts_limitsgains two cases: stream 1 with ID0x10000000, and a zero-length0xBDtag on the ID-0 stream at offset 100, inside the music header at 64..140. Both expect the existingMUSIC_FORMATSand four channels.Verification
Based on
origin/main813045b3c1. Windows 11 Pro 26300.9974, Python 3.12.10, no build needed.Before this change the check ran 13 tests and passed. With each of M1-M9 applied, the new check fails in exactly the subtest named in the table. M1-M4, M6-M9 fail with
ValueError(orIndexErrorfor M2) raised from an acceptance case, and M5 fails because no exception is raised for the empty data tag.Evidence and follow-up
header_size == tablemeans that no stream has a tag, and the original then rejects the bank with "Expected one data tag ..." (sound effects) or "Expected one 0x48 music header ..." (music). The mutant rejects the same bank with a different message, so the two differ only in wording.IndexError.The tool is not changed. All fixtures are synthetic and built inside the test.
Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:33:21Z.
Review: COMMENTED
Reviewed
tests/awc_metadata_check.pyat commit9314b151b96bff0579d5b46958340fff405f6003againsttools/awc_metadata.py(_header,read_formats,_music,read_bank). All new assertions pin real stream-table limits (0 refused, 4096 accepted), empty-data-tag refusal, 29-bit stream ID mask (0x10000000), touching tag spans, and zero-length tags inside format/music headers; clean-room and title-neutral, 0 P1/P2 defects found.Linux verification
git diff --check origin/main...HEAD— passedpython -B tests/bidi_controls_check.py— passed (1320 files checked)python -B tests/awc_metadata_check.py -v— 14/14 tests passed (0.650s)Windows Server 2025 verification (Build 26100, MSVC 14.44.35207 + D3D12 WARP)
--preset dev):ctest --preset dev -R '^audio_awc_metadata$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (0.67s)/O2(--preset release):ctest --preset release -R '^audio_awc_metadata$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (0.67s)Local mutation checks
tools/awc_metadata.pyinread_bankfromentries[0] & 0x1fffffffto0x0fffffff:python -B tests/awc_metadata_check.pyfailed (rc=1, killed).tools/awc_metadata.pyinread_formatsoverlap check fromleft[1] > right[0]toleft[1] >= right[0]:python -B tests/awc_metadata_check.pyfailed (rc=1, killed).AI-assisted; commands listed were executed locally.