Skip to content

odrp_7a: charge each cached stored size to one carved file - #5891

Open
kacper-serewis wants to merge 1 commit into
ItsNotRexed:mainfrom
kacper-serewis:fix/odrp-cache-stored-once
Open

kacper-serewis wants to merge 1 commit into
ItsNotRexed:mainfrom
kacper-serewis:fix/odrp-cache-stored-once

Conversation

@kacper-serewis

Copy link
Copy Markdown
Contributor

Coordination item: odrp_7a cached directory accounting (claim on #5781). Independent of #5243 and #5157.

When two directory inputs share a hexadecimal offset, reserve the manifest's stored size for the canonical filename. With aliases alone, use the first in filename order. Preserve scan order and count each remaining file by its length. Only the selected input receives the archive span used for continuation detection.

CPU validation on Windows: python -I tests/test_odrp_7a.py passed all 16 tests. The new CLI regression checks copies sorting on either side, two alternate spellings and a sole short spelling. A separate private CLI check passed with one cached retail data-carve entry, alone and with an earlier-sorting copy. No raw archive scan. GPU and driver: unused. AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified against main 561b65a: merges cleanly, test_odrp_7a 16/16 with the four-way ownership matrix (canonical spelling wins, otherwise sorted-first; re-run), no double-charge and no KeyError path since hint_owner is set only for offsets present in by_off. One adjacent, pre-existing gap worth borrowing from the sibling: _carve_stored_map accepts any int for stored/off, so a corrupt index.json with stored<=0 charges as-is — #5896's _carve_rows has the min(size,stored)<=0 rejection odrp_7a could reuse. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@tahffo68hk-hash

Copy link
Copy Markdown
Contributor

At 680f8eb3, reserving the stored size for the canonical file fixes the accounting, but a same-offset alias can still change which bytes are joined. I reproduced both cases through the Windows CLI using the existing synthetic fixtures.

  • A standalone map split at 0x80, with canonical files at offsets 0x1000 and 0x10a0, gives one complete, two-stream record with four entities. Adding a zero-filled 0000000010a0-copy.bin of the same length changes it to an incomplete two-stream record with zero entities.
  • A PSIN split over 0x1000, 0x10a0, and 0x1150 gives one complete three-stream record. Adding a zero-filled 0000000010a0z.bin, which sorts after the canonical file at the middle offset, truncates the record to two incomplete streams.

The alias has no stored-size hint in both cases. _StreamConsumer.feed still compares its offset with the pending record's expected offset, so it can consume that continuation or flush a pending chain. The second case shows why canonical-first ordering at equal offsets alone is insufficient. Keeping duplicate aliases outside the manifest-backed chain would preserve both joins while still allowing separate file accounting. CPU only, synthetic fixtures, AI-assisted.

在 680f8eb3 上,压缩大小只记到规范文件的逻辑修正了统计,但同偏移的别名文件仍会改变参与拼接的数据。我用现有合成样本从 Windows CLI 复现了两个用例。

  • 一份独立地图在 0x80 处分成两段,规范文件的偏移为 0x1000 和 0x10a0。输出是一条完整的两段记录,包含四个实体。加入一个等长、全零的 0000000010a0-copy.bin 后,输出变成一条不完整的两段记录,实体数为零。
  • 一份 PSIN 在 0x1000、0x10a0 和 0x1150 分成三段。原先输出一条完整的三段记录。加入全零的 0000000010a0z.bin 后,它排在中间偏移的规范文件之后,输出变成不完整的两段记录。

两种情况下,别名文件都没有压缩大小提示。_StreamConsumer.feed 仍会把它的偏移与待完成记录的预期偏移比较,因此它可能抢占续段或使待拼接链提前结束。第二个用例说明,仅让规范文件在同偏移处排第一还不够。将重复别名排除在清单所标识的拼接链之外,可以保留两个拼接结果,同时仍能单独统计这些文件。仅用 CPU 和合成输入,AI 辅助。

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

Review

Reviewed change in PR #5891: odrp_7a: charge each cached stored size to one carved file.

Scope: tests/test_odrp_7a.py, tools/odrp_7a.py
Diff: +31 / -1 across 2 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

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.

4 participants