Skip to content

awc_names: match conversation pairs across a carved continuation stream - #6693

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
cynbun:awc-names-continuation
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
cynbun:awc-names-continuation

Conversation

@cynbun

@cynbun cynbun commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #6603 (comment)

What and why

conversation_waves() (tools/awc_names.py:181-195 on main) matched CONVERSATION_PAIR in every carved stream on its own. A stream that inflates to a whole number of 64 KiB blocks continues in the next one (docs/page_directory.md, "Can a resource span zlib streams?"). A <ROOT>AU_<XXXX>\0<LABEL>\0 pair cut by that boundary therefore matched in neither file, and its key yielded one wave name too few. docs/audio.md (--conversations) says a key with N distinct labels yields <key>_01 .. <key>_<N>, and gives --conversations <carve dir>/story000 as the usage. tools/text_tables.py reads the same pairs through _chains(), which joins those streams, so the two tools counted different labels for one key.

Synthetic repro (no game data): story000/000000000000.bin is 65,536 bytes with a PSIN head, then the pairs SYNTHAU_ABCD\0SYN_LINE_ONE\0 and SYNTHAU_ABCD\0SYN_LINE_TWO\0, and the first 10 bytes of the third pair. 000000010000.bin holds the rest of that pair and a fourth. On main, conversation_waves() returns _01.._03, so the 4th stream of that key is never named. With this change it returns _01.._04.

Fix

New _blobs(): in a folder, a .bin file is read together with the .bin files that continue it. A file continues the one before when that file is a non-zero multiple of 64 KiB, is in the same folder, comes next in name (offset) order, does not start a new PSIN/RBF0/XML stream, and the total stays within MAX_SCAN_BYTES. The pairs are matched in the joined bytes. Other files are read on their own as before, and labels are still deduplicated per key in order of appearance. The helper sits after conversation_waves(), so the change merges cleanly with #5711, #5897, #6003 and #6646 (checked with git merge-tree).

Tested

Linux, Python 3.14.8, no GPU needed:

  • python -I tests/test_awc_names.py: OK. The new test_pair_across_a_continuation_boundary covers 64 KiB and 128 KiB first streams and fails on main. test_streams_that_do_not_continue_are_matched_apart covers a 65,535-byte stream and a new PSIN stream, and passes before and after.
  • tests/test_awc_manifest.py and tests/test_opus_tags.py pass. tests/test_joaat_agreement.py and tests/test_tool_stdout_encoding.py fail the same way on unmodified main.
  • python -m compileall -q make_game.py tools tests and git diff --check are clean.

AI-assisted: yes (Claude Code).

🤖 Generated with Claude Code

conversation_waves() matched CONVERSATION_PAIR in every carved stream on
its own. A stream that inflates to a whole number of 64 KiB blocks continues
in the next one (docs/page_directory.md), so a <ROOT>AU_<XXXX>\0<LABEL>\0
pair cut by that boundary matched in neither file, and its key yielded one
wave name too few: docs/audio.md has a key with N labels yield
<key>_01 .. <key>_<N>, and text_tables.py, which joins those streams in
_chains(), counts the label.

In a folder, a .bin stream is now read together with the .bin files that
continue it (previous file a non-zero multiple of 64 KiB, same folder, next
in name order, not a new PSIN/RBF0/XML stream), and the pairs are matched in
the joined bytes. Other files are read on their own as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kev-Ball

Copy link
Copy Markdown

Confirmed on two complete Xbox 1.0.2.1 archive carves at 62d63bf3. I compared the distinct wave candidates from conversation_waves() with the wave column independently exported by text_tables.py --dialogue from each original archive.

Carved streams Candidates on base 1cc6e3c12 Candidates on PR Reference
5,073 1,967 1,968 1,968
624 1,315 1,316 1,316

Each carve recovered one missing candidate. Both revised sets exactly matched their respective references.

I also ran the --conversations CLI against all 653 extracted banks from those archives. Both revisions named the same 1,966 bank/stream pairs. One previously inferred family match became a direct dialogue match with the same name. All output rows on the PR matched the independent dialogue-CSV result, and both salted controls had zero matches. CachyOS x86-64, CPython 3.14.10, CPU only. AI-assisted.

@wasonidas

Copy link
Copy Markdown

Windows CPU review of 62d63bf38ecbdfb524560fd7fab1885aca514246 over 1cc6e3c1. Both test_awc_names.py and test_text_tables.py passed 32/32. Twelve independent synthetic continuation checks also passed. They moved the split across every byte of a key/label pair, covered three or more consecutive streams, verified the new-record and directory boundaries, and checked deduplication and lexical offset order. Malformed pairs and a bounded seeded-noise control produced no matches. This complements the published archive counts with reproducible small inputs. No game files or GPU. AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified: Ran 32 OK (one pre-existing skip); on main the same file fails exactly the two continuation-boundary subtests, so the fix is exercised — a pair split across the 64 KiB block boundary is recovered, 65535-byte and PSIN-headed streams correctly stay unmatched. Join logic respects the per-file MAX_SCAN_BYTES budget and folder boundaries (_files walks sorted fixed-width names). Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 62d63bf merged with main 14b2e44 on Linux/Python 3.12.16: pass

  • python -I tests/test_awc_names.py: 32 tests OK (1 skipped)
  • Negative control: git checkout upstream/main -- tools/awc_names.py, same test: FAILED (failures=2, 1 skipped). Restored with git checkout HEAD --.

Diff read: conversation_waves now reads through _blobs(), which joins a carved .bin whose previous piece has a length that is a non-zero multiple of 65,536 with the next .bin of the same folder, unless that one starts with PSIN, RBF0 or an XML header, the joined size stays within MAX_SCAN_BYTES, and files that are unreadable or oversize break the chain; non-.bin files are read on their own as before. Sorted-name order within a folder is what _files already gave. docs/page_directory.md, which the comment cites, exists. Synthetic inputs only; the continuation rule itself comes from that doc and I did not check it against a real carve.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

tools/awc_names.py adds _blobs(), which joins carved .bin streams whose length is a whole number of 64 KiB blocks to the following stream in offset order unless that stream starts a fresh header (PSIN, RBF0, XML). conversation_waves() now scans these joined blobs; tests cover pairs split across a continuation boundary and streams that must stay apart.

Why merge

A dialogue key and label split between two carved pages formed no pair under per-file scanning, undercounting conversation waves. Joining continuation streams restores those pairs without merging genuinely separate streams.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

tools/awc_names.py adds _blobs(), which joins carved .bin streams whose length is a whole number of 64 KiB blocks to the following stream in offset order unless that stream starts a fresh header (PSIN, RBF0, XML). conversation_waves() now scans these joined blobs; tests cover pairs split across a continuation boundary and streams that must stay apart.

Why merge

A dialogue key and label split between two carved pages formed no pair under per-file scanning, undercounting conversation waves. Joining continuation streams restores those pairs without merging genuinely separate streams.

Verdict: Approve

@shayderrr
shayderrr merged commit 1f7c259 into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants