Files
uc2/lib/include
Eremey Valetov 7825eb47b2 ingest v2: self-contained archive (chunk pool inside the file)
Scope shift from the original "make output a real UC2 v3 archive"
issue: that requires a new entry type or compress.c refactor (UC2
archives have one master per file, not a chain).  This commit ships
the closest-in-spirit upgrade -- a self-contained format that solves
v1's main UX wart, the sidecar <archive>.blocks/ directory.

Format v2:
  +0   8B   magic "UC2INGST"
  +8   1B   version (2)
  +9   1B   cdc_bits
  +10  2B   reserved
  +12  4B   chunk_count
  +16  ...  chunk_count * 16B:  8B hash, 4B length, 4B offset
  ...       chunk pool: unique chunks back-to-back at recorded offsets

The dedup map has a small implementation note: cap must be a power
of two for the mask-based linear probe to terminate.  Caught when
test_ingest hung at 25 chunks -- initial_cap=50 is not power-of-two,
so probing wrapped to a non-empty slot indefinitely.  Now rounded up
in dedup_map_init.

Trade-off: cross-archive dedup is not preserved (each --ingest call
overwrites the archive).  v1 archives remain restorable through the
sidecar blockstore; the writer defaults to v2.

Tests: 6 cases (was 5).  test_intra_call_dedup verifies that
identical chunks within a single ingest dedup correctly
(buffer-twice produces > 0 saved bytes).  test_v2_self_contained
asserts the .blocks/ directory is NOT created for v2 archives.

Closes 96ef9b8.  v3 (real UC2 v3 archive output) is filed at 59bec0d.
2026-05-05 03:25:45 -04:00
..