Files
John Smith fdba4063f7 fix(ksy): unityfs.ksy + unity_addressables.ksy file-header layout + endianness
Post-run follow-up to the 2026-06-06-r01 stress test
(Output/2026-06-06-r01/gap-analysis.md).

The two KSY files had three classes of bugs (K1, K2 in the
gap-analysis):

- Wrong file-header layout in unityfs.ksy: parsed ONE
  unity_version strz + a phantom platform u4 +
  has_directory_info u1 + reserved u1. The actual file has
  TWO strz (bundle_format_version + unity_version) followed
  by file_size s8 — no platform, has_directory_info, or
  reserved. unityfs.ksy now matches the unity_addressables.ksy
  layout.
- Wrong endianness in both files: shipped as
  endian: le. The actual Addressables bundle on disk has
  00 00 00 07 at offset 8 (version=7 BE), not 07 00 00 00
  (version=117M LE). The 2026-06-06-r01 plan instructed
  flipping unity_addressables.ksy to LE based on
  speculation; the live file is the source of truth and it
  is big-endian. Reverted. Both files now correctly
  declare endian: be.
- compressed_block_info.uncompressed_size was s8 (8 bytes)
  but the upstream AssetStudio / UABE references declare
  it as u4 (4 bytes). The 8-byte read was walking into
  flags and num_blocks and producing nonsense values like
  279 GB for a 19 KB file. Fixed to u4 in BOTH files.

The inner bundle_header sub-type in unityfs.ksy lost the
has_directory_info param coercion (the flag is gone).
The inner directory block in both files is parsed
unconditionally. Deeper parse of the inner bundle_header
and directory blocks is a follow-up format-decode iteration.

tests/test_re_kaitai_formats.py: test_unityfs_ksy_parses_synthetic_header
docstring updated to document the deferred synthetic-buffer
rewrite (the buffer is still the pre-Cycle-2 layout; the
test soft-skips because the kaitai runtime isn't installed on
this host, so the buffer is dormant).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 15:56:38 -04:00
..