Skip to content

Test: reproduce/guard data.tar inflation over the archive lifecycle - #781

Draft
egpbos wants to merge 1 commit into
mainfrom
test/archive-snapshot-inflation
Draft

Test: reproduce/guard data.tar inflation over the archive lifecycle#781
egpbos wants to merge 1 commit into
mainfrom
test/archive-snapshot-inflation

Conversation

@egpbos

@egpbos egpbos commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

Phase 1 of an investigation into data.tar archive inflation. Production profiling of a 1.1 TiB, 54-run dataset found ~97–98% of data.tar bytes were byte-identical duplicates. This PR pins the behaviour with tests before any redesign (Phase 2, separate); no production code is changed.

Adds two end-to-end tests to tests/utils/test_archive.py that replay the full proteus.py archive lifecycle (rolling update + remove_old cycles, then the end-of-run update(remove_files=True) full archive) on a realistic mini output/data/, and measure inflation by member content (SHA-256), not just by name:

  • test_lifecycle_final_pass_stores_reference_data_once — regression guard that the static EOS table (spider_eos/) and fixed-name runtime files enter data.tar exactly once across the whole lifecycle. Extends the rolling-only coverage of test_update_snapshots_only_bounds_tar_growth_across_cycles (Super-Earth structure and thermal evolution: interior coupling, molten initial conditions #706) to the final remove_files=True pass, and adds a content-level check that a fixed-name file which legitimately changes each cycle (zalmoxis_output.dat) is preserved as distinct versions rather than mislabelled as duplication.

  • test_lifecycle_snapshot_reappend_no_inflation — encodes the target contract (store each snapshot once, inflation ≈ 1.0). Marked xfail(strict=True): on main every timestamped snapshot lands in data.tar ~2×, because the rolling archive keeps snapshots loose (remove_files=False) so each is re-appended on the next cycle before remove_old prunes it, and once more by the final full-archive pass (observed inflation ~1.45× on this fixture). strict so it flips to a hard failure — forcing the marker's removal — once the archive redesign removes the duplication.

Also adds a _tar_content_stats helper (gross/distinct bytes, per-name member and distinct-content counts). Pre-existing archive tests are unchanged.

Verdict recorded (measured on this fixture, not assumed): EOS/fixed-name files are fixed on main by #706's snapshots_only=True guard (green guard); .nc/.json snapshots still inflate on main (~2× per snapshot, strict xfail). The ~1.45× figure is fixture-specific and is not a claim about the production ratio.

No linked issue yet — Phase 1 of the archiving-inflation investigation.

Validation of changes

  • pytest tests/utils/test_archive.py -q21 passed, 1 xfailed, no regressions in the pre-existing archive tests.
  • pytest ... --runxfail confirms the xfail is a genuine assert 2 == 1 (snapshot stored twice), not an incidental error masquerading as expected-fail.
  • Quality/lint gates clean: tools/check_test_quality.py --check, ruff check/format, tools/validate_test_structure.sh.
  • Test configuration: macOS (Darwin) with Python 3.12; CI additionally runs Unit Tests on Linux and macOS — all green on this PR.

Open question for reviewers (feeds the redesign, not asserted here): the snapshots_only=False path also retains multiple distinct versions of zalmoxis_output.dat (append-only tar keeps every version under one name). Before deciding whether a redesign must preserve that version history, confirm whether any resume/extract path ever reads an older in-tar version or whether an overwrite was intended (tarfile.extractall lets the last member win).

Checklist

  • I have followed the contributing guidelines
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have checked that the tests still pass on my computer
  • I have updated the docs, as appropriate (n/a — test-only change)
  • I have added tests for these changes, as appropriate
  • I have checked that all dependencies have been updated, as required (n/a — no dependency changes)

Adds two tests to tests/utils/test_archive.py that replay the full
proteus.py archive lifecycle (rolling update+remove_old cycles followed
by the end-of-run full archive) on a realistic mini output/data/, and
measure tar inflation by member content (SHA-256), not just by name.

- test_lifecycle_final_pass_stores_reference_data_once: regression guard
  that the static EOS table and fixed-name runtime files enter data.tar
  exactly once across the whole lifecycle. Extends the rolling-only
  coverage of test_update_snapshots_only_bounds_tar_growth_across_cycles
  (#706) to the final remove_files=True pass, and adds a content-level
  check that a fixed-name file which legitimately changes each cycle
  (zalmoxis_output.dat) is preserved as distinct versions rather than
  counted as duplication.

- test_lifecycle_snapshot_reappend_no_inflation: encodes the target
  "store each snapshot once / inflation ~1.0" contract. Marked
  xfail(strict=True): on main every timestamped snapshot lands in
  data.tar ~2x because the rolling archive keeps snapshots loose
  (remove_files=False) so each is re-appended on the next cycle before
  remove_old prunes it, and once more by the final full-archive pass.
  Strict so it becomes a hard failure once the archive redesign removes
  the duplication.

Adds a _tar_content_stats helper (gross/distinct bytes, per-name member
and distinct-content counts). Pre-existing archive tests unchanged.
@egpbos
egpbos force-pushed the test/archive-snapshot-inflation branch from 1d20865 to c482dc0 Compare July 24, 2026 14:10
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (9881061) to head (c482dc0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #781   +/-   ##
=======================================
  Coverage   92.66%   92.67%           
=======================================
  Files         110      110           
  Lines       15807    15807           
  Branches     2846     2846           
=======================================
+ Hits        14648    14649    +1     
+ Misses       1159     1158    -1     
Flag Coverage Δ
unit-tests 83.64% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timlichtenberg

Copy link
Copy Markdown
Member

@egpbos Please can you use the PROTEUS PR templates when creating the PRs?

@egpbos

egpbos commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

@egpbos Please can you use the PROTEUS PR templates when creating the PRs?

Done.

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.

2 participants