Add clean-checkout regeneration and reproducibility tests #65
No reviewers
Labels
No labels
area/deployment
area/governance
area/metadata
area/pipeline
area/search
type/data
type/design
type/implementation
type/testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Arkive/arkive!65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/issue-17-reproducibility-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
tests/test_reproducibility.py, proving automatically that the committed pilot corpus is reproducible rather than merely internally consistent.byte_size, SHA-256, and each chunk'stextagainst the half-open range it claims. The canonical validator compares records to other records and never opens a document file, andchunk_generation.validate_chunkscompares chunk text to its parent only in memory at generation time, so a stale checksum or a drifted offset would validate cleanly today.data/: the documented command on an intact checkout changes nothing, removing every generated artifact and rebuilding reproduces the committed bytes exactly, two consecutive runs are identical, committed identifiers are preserved, originals and source records are never rewritten, and processing one source restores only that source.docs/development.mdand recorded the change inCHANGELOG.md.No production behaviour, schema, source data, or record content changed. The only new file is a test module; the two documentation edits are additive.
Design notes for review
Identifiers are authoritative input, not recomputed output. Per the constraint recorded on #17, the intake contract makes a committed identifier immutable while deriving it from metadata that may later be corrected, so re-deriving one can legitimately differ from the committed value. The tests assert identifiers are preserved, never that they are rederivable. The second constraint from that comment —
checksum_sha256participating in document identity — was resolved under #9 and no longer applies.Nondeterministic fields: none are excluded. Generated document and chunk records carry no timestamps (
chunk.created_atis schema-optional and never emitted), so every comparison is whole-file byte equality rather than a filtered structural one.docs/development.mdrecords this and its consequence: a dependency upgrade that alters extracted or normalized output will fail these tests. That is the intended signal, handled as the reviewed compatibility change already documented for thepypdfpin.Clean checkout is modelled by copying
data/into a temporary root rather than shelling out togit archiveorgit worktree. This keeps the suite hermetic — it works from an exported tarball and needs no Git available to the test runner — at the cost of not exercising checkout itself, which is Git's behaviour rather than Arkive's.Chunk contiguity is deliberately not asserted. Committed chunks leave intentional gaps at page boundaries, so the offsets test asserts ordering, non-overlap, and in-bounds only.
One test drives
main()rather than the library call, because the documentation tells a contributor to run the command, and the existing CLI tests mock the pipeline out.Test verification
Every test was checked by breaking the property it guards and confirming it fails. Two did not, and were rewritten before this PR:
_restore_file_snapshotstubbed out it still passed, because the run rewrote bytes that were already there. It now perturbs a committed file first, so restored bytes and regenerated bytes actually differ.Both were confirmed to fail against the corresponding injected defect after the rewrite.
Verification
git diff --checkpython pipeline/validate/validate_records.py—PASS: 6 source(s), 14 document(s), 38 chunk(s), 0 rights profile(s), 0 recipe(s) across 18 record file(s)python -m unittest discover -s tests -v— 304 tests pass (289 before)python -m ruff check src pipeline testspython -m ruff format --check src pipeline testspython -m pip checkScope confirmation
Linked issue
Closes #17
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.