Skip to content

fix(export): refresh the member sha table after in-place member replacement - #99

Merged
ronaldtse merged 1 commit into
mainfrom
fix/rebuild-refresh-shas
Aug 30, 2026
Merged

fix(export): refresh the member sha table after in-place member replacement#99
ronaldtse merged 1 commit into
mainfrom
fix/rebuild-refresh-shas

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Symptom

Every rebuild_int8_head32 run (khm-latn, urd-g2p, urd-diac, heb-diac,
tha-g2p-small) died at the same place despite parity passing:

RuntimeError: cannot write parity into invalid zip:
['decoder-kv.onnx sha256 mismatch: zip has 5f22a5c9…,
  metadata says 30aca41b…']

Cause

The rebuild replaces the encoder/decoder members inside a copy of the
shipped int8 zip but never updates metadata.yaml's sha256 table.
write_parity validates strictly before writing, so the stale table
rejects the freshly rebuilt artifact — the zips existed on the volume
but could never receive their parity block or margin report.

Fix

  • imf.export.refresh_member_shas(zip) — recomputes the sha table
    from actual member bytes and rewrites the metadata member atomically
    (same tempfile + os.replace pattern as write_parity)
  • rebuild_int8_head32 calls it immediately after assembling the zip
  • Unit test: replace a member with a re-serialized (valid) ONNX graph
    → validation must fail on the stale table → refresh → validation
    passes and no other member changed

Verification

tests/test_imf_export.py — 6 passed (5 existing + new).

…cement

rebuild_int8_head32 rewrites the encoder/decoder graphs inside a copy
of the shipped int8 zip but left metadata.yaml's sha256 table pointing
at the old digests — write_parity validates strictly before writing,
so every rebuild died at exactly that point (parity itself passed).
refresh_member_shas recomputes the table and rewrites the member
atomically; the rebuild calls it right after assembling the zip.
@ronaldtse
ronaldtse merged commit f66a939 into main Aug 30, 2026
10 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.

1 participant