Archive report versions without overwriting the audit trail
In this article (5 sections)
When a source correction or parameter change produces a new report, preserve the earlier artifact and record why the new version exists. Overwriting a file named latest makes it difficult to reproduce a decision made from yesterday's result.
An archive should identify versions by their evidence and status. The newest generated file is not automatically the newest approved or distributed report.
Retain distinct evidence as distinct bundles
The original automation lab names each output directory using a hash of the source, source manifest, configuration, pipeline code and Python version. Its manifest records output hashes and creation time.
An identical rerun verifies and reuses the same bundle. A changed region filter creates a new bundle. The first is not overwritten, so both scopes remain inspectable.
import json
from pathlib import Path
from tempfile import TemporaryDirectory
from pipeline import run,verify_bundle
config = json.loads(Path('report-config.json').read_text())
with TemporaryDirectory(prefix='report-archive-example-') as temporary:
root = Path(temporary)
all_regions,_ = run('events.csv','source-manifest.json',config,root)
original = {p.name:p.read_bytes() for p in all_regions.iterdir()}
north,_ = run('events.csv','source-manifest.json',dict(config,region='North'),root)
assert all_regions!=north
assert original=={p.name:p.read_bytes() for p in all_regions.iterdir()}
index = []
for folder in sorted(root.iterdir()):
manifest = verify_bundle(folder)
metrics = json.loads((folder/'metrics.json').read_text())
index.append({'run_id':manifest['run_id'],'region':metrics['region_filter'],
'amount_paise':metrics['amount_paise'],'status':manifest['status']})
assert len(index)==2
assert {(r['region'],r['amount_paise']) for r in index}=={('all',3500),('North',1000)}
assert all(r['status']=='prepared_for_review' for r in index)
print(index)The index lists both reports and their review status. It does not select one for publication or distribution merely because it was generated later.
Record the relationship between versions
A source correction, a changed business definition and a different regional scope are different reasons for creating a version. Record the reason and, where useful, the prior version it supersedes for a particular purpose.
The North report above is a separate scope, not necessarily a replacement for the all-region report. A single global “latest” pointer would hide that distinction. Select versions within a defined report family, period and audience.
For a corrected historical report, show the changed metrics and the source or rule change that explains them. A reviewer should not have to compare entire files manually to discover that one order was added after the original cutoff.
Keep approval and delivery history separate
An artifact can be prepared, rejected, approved, superseded or distributed. Those events belong to an auditable history bound to the exact version. Editing the artifact after approval should invalidate that approval binding rather than silently carrying it forward.
The approval example demonstrates local artifact binding with fictional review data. A deployed system also needs authorized reviewers, protected records and delivery reconciliation.
Do not infer that a report was received because a local file exists or a send was attempted. Preserve the evidence appropriate to each completed step.
Plan retention and restoration deliberately
Keeping every file forever is not automatically the right policy. Retention should reflect the business purpose, applicable obligations, sensitivity and storage constraints. The teaching lab does not implement deletion or a retention schedule.
Whatever policy applies, test whether a retained version can actually be opened and verified. An archive containing only a spreadsheet without its source contract, code version or required dependencies may be insufficient for reproduction.
Checksums can detect accidental changes against a trusted manifest, but they do not prevent modification or authenticate a manifest by themselves. Access controls, backups and stronger integrity measures may be needed for the real environment.
Exercise: create a corrected source extract and preserve both report versions. Write a short change record identifying the correction, affected total and intended replacement scope. Keep the original artifact byte-for-byte unchanged.
NeuraPath's Data Analytics with Generative AI course connects reproducible reporting with operational history. A useful archive preserves the evidence behind a decision and makes later corrections explainable.
Continue learning
This article is part of the Reliable reporting automation sequence. Use the neighbouring tasks when you need the prerequisite or the next application.
- Review the prerequisite or neighbouring task in Generate a management report from verified metrics.
- Continue with Test a reporting pipeline with failure injection.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Data Analytics with Generative AI programme — 3–4 months. The full analyst stack — Excel, SQL, Power BI and Python pipelines — then a generative-AI layer you can prove is right.
Explore Data Analytics with Generative AI