3.5 KiB
3.5 KiB
Archive Streaming Reader, Atomic Staged Publication, Reproducible Creation & Child Isolation
Task ID: M-ARCHIVE-01..05 Phase: P2 (Wave 6B) Status: APPROVED Contracts: C-02, C-03, C-04, C-05, C-06, C-07
1. Context and baseline
Void::Archive preserves the existing incremental extract(path, destination, ExtractionOptions) API and anti-traversal/symlink-swap/size-limit tests while adding typed error reporting (kArchiveErrorDomain = 17), bounded streaming Reader (open_reader, next_entry, read_chunk, skip_entry, normal/forensic list_entries), atomic staged extraction and no-replace directory publication (StagedTree, extract_staged, publish, cleanup_stale_staging), reproducible tar/tar.zstd creation (create_archive), and hardened child-process isolated extraction (extract_staged_isolated, run_isolated_worker_main).
2. Deliverables
src/Archive/module.cmake(INTERNAL_DEPS Functional Time System,EXTERNAL_DEPS LibArchive::LibArchive).include/Void/Archive/Types.hpp:kArchiveErrorDomain = 17,ArchiveErrorCode,make_archive_error,ReadLimits(10,000 entries, 512 MiB file, 2 GiB total, 1 GiB compressed, 8 MiB metadata, 64 KiB transfer chunk, 4 KiB path, 255B component, 64 components),EntryInfo,ProgressEvent,PublicationOutcome,PublicationReceipt,CreationOptions,IsolationOptions(128 MiB RSS, 60s timeout),ByteSource/ByteSink+ span/vector/file adapters.include/Void/Archive/Archive.hpp,src/Archive/Archive.cpp,src/Archive/StagedArchive.cpp: preserveextract(); addReader,list_entries(normal + opt-in forensic),StagedTree,extract_staged(exclusive0700dir,O_NOFOLLOW,0644/0755, bottom-up dirfsync, completion inventory, no-follow cleanup),publishvia Linuxrenameat2(..., RENAME_NOREPLACE)(unsupported_capabilityonENOSYS/EINVAL,PublicationOutcome::Unknownon post-rename parentfsyncfailure),cleanup_stale_staging, reproduciblecreate_archive, andextract_staged_isolated/run_isolated_worker_mainviaVoid::Process::spawn(ASan-safe rlimits + parent verification of staged inventory).tests/helpers/ArchiveWorker.cppwired asVoidArchiveWorkerintests/CMakeLists.txt,tests/standalone/Archive/ArchiveHardening.cpp,tests/package/ArchiveOnly/*, registered intests/package/InstalledComponents.cmake.
3. Edge cases
skip_entrystill decodes and accounts for actual decompressed bytes against per-entry and total limits.- File-as-parent path conflicts (e.g. file
afollowed bya/b, ora/bfollowed by filea) and non-zero/zero invalid limits are rejected cleanly. - Diagnostics cap path rendering at 4 KiB and escape control characters / attacker newlines.
- Post-rename parent
fsyncfailure reportsPublicationOutcome::Unknownwithout falsely claiming rollback; pre-publish failure cleans only the owned staging descriptor and preserves primary error + staging id if cleanup fails. - Under
__SANITIZE_ADDRESS__, child worker avoids fatalRLIMIT_ASand enforcesRLIMIT_CPU/RLIMIT_FSIZE/RLIMIT_NOFILE+/proc/self/statmRSS enforcement.
4. Verification commands
dev cpp-gcc -p libarchive -c bash -lc 'cmake -S . -B /tmp/void-w6b-archive -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOID_ENABLED_MODULES="Archive;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w6b-archive && /tmp/void-w6b-archive/tests/VoidTests --filter "Archive*|archive_*" && ctest --test-dir /tmp/void-w6b-archive --output-on-failure --timeout 120'