Skip to content

feat(#83): libarchive-backed archive reader as a standalone extra module - #437

Merged
helly25 merged 6 commits into
feature/83-archive-flagfrom
feature/83-archive-module
Aug 9, 2026
Merged

feat(#83): libarchive-backed archive reader as a standalone extra module#437
helly25 merged 6 commits into
feature/83-archive-flagfrom
feature/83-archive-module

Conversation

@helly25

@helly25 helly25 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Second archive slice (#83): the dependency and the reader, still with no walk integration. Stacked on #436.

extra_modules/archive/ is its own Bazel module @xff_archive, the same shape as the PCRE2 extra: it depends on @libarchive (from the BCR, no vendoring) and the shared @xff_extras_api seams, never back into the xff core, so deleting the directory drops the extra entirely. Verified: the lean //xff/cli:xff has zero libarchive in its dep graph, and the minimal-core build (delete extra_modules/ plus the extras' bazel_dep lines) still works.

archive_reader lists an archive's members from memory or by streaming a file. libarchive detects the format and compression filter from content, so tar / zip / cpio / ar and the gz / bz2 / xz / zstd / lz4 filters all come through one entry point. It reads headers only, never member content, so listing a huge archive stays cheap.

The error contract matters for the walk and is pinned by tests: "not an archive" (InvalidArgument) must stay distinct from "corrupt archive" (DataLoss) - the first is an ordinary file, the second a real error to report. Empty input is explicitly not an archive: libarchive opens zero bytes and reports EOF, which would otherwise make an empty file look like a valid archive holding nothing.

Licensing: libarchive is BSD-2-Clause and its codec closure (zlib, bzip2, liblzma, lz4, zstd on its BSD arm) is permissive throughout; mbedtls stays off, so no crypto arm is pulled. The notice self-registers from the reader's translation unit through the existing license-notice seam, so --help=notice and the NOTICE file stay complete by construction.

Tests write real tar and gzip-filtered tar archives with libarchive's own write API and read them back - no committed binary fixtures - and cover the streaming file path plus the missing-file case.

helly25 added 6 commits August 9, 2026 23:56
Second archive slice: the dependency and the reader, still with no walk
integration.

extra_modules/archive/ is its own Bazel module (@xff_archive), the same shape
as the PCRE2 extra: it depends on @libarchive (from the BCR, no vendoring) and
the shared @xff_extras_api seams, never back into the xff core, so deleting the
directory drops the extra entirely. Verified: the lean //xff/cli:xff has zero
libarchive in its dep graph.

archive_reader lists an archive's members from memory or by streaming a file.
libarchive detects the format and compression filter from content, so tar / zip
/ cpio / ar and the gz / bz2 / xz / zstd / lz4 filters all come through one
entry point. It reads headers only, never member content, so listing a huge
archive stays cheap.

The error contract matters for the walk and is pinned by tests: "not an
archive" (InvalidArgument) must stay distinct from "corrupt archive"
(DataLoss) - the first is an ordinary file, the second is a real error to
report. Empty input is explicitly not an archive: libarchive opens zero bytes
and reports EOF, which would otherwise make an empty file look like a valid
archive holding nothing.

Licensing: libarchive is BSD-2-Clause and its codec closure (zlib, bzip2,
liblzma, lz4, zstd on its BSD arm) is permissive throughout; mbedtls stays off,
so no crypto arm is pulled. The notice registers itself from the reader's
translation unit through the existing license-notice seam, so --help=notice
and the NOTICE file stay complete by construction.

Tests write real tar and gzip-filtered tar archives with libarchive's write API
and read them back, so there are no committed binary fixtures and the whole
dependency is exercised end to end.
Three more sites still printed or documented the non-existent flag: the help
renderer's not-built note, the --archive flag's own details prose, and a BUILD
comment. extras_test was pinning the wrong string, so it is corrected too (it
asserted the bug rather than the behavior). All four surfaces now name
--//xff:xff_archive, and XFF.md is regenerated.
@helly25
helly25 merged commit 9415e0c into feature/83-archive-flag Aug 9, 2026
2 checks passed
@helly25
helly25 deleted the feature/83-archive-module branch August 9, 2026 23:50
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