Milestone 7 of 8

Save and replay the inspection

Write records, findings, examples, summaries, figures, source identity, and a manifest, then reproduce them in a separate directory.

The inspection should be reproducible from its recorded bytes, rules, and artifacts. Save the evidence before writing a broad conclusion.

Goal

Write document records, findings, examples, summaries, figures, configuration, source identity, runtime evidence, and a manifest. Replay the inspection in a separate directory and record agreement or the first mismatch.

Inputs

Use all artifacts from the earlier milestones and the original files under data/. The manifest must identify the corpus fixture, file paths and byte digests, UTF-8 and line-boundary rules, inspection configuration, output paths, relevant Python/runtime versions, and implementation revision.

The replay starts from the same source identity and saved configuration and writes under a separate directory such as output/replay/. Never overwrite the original inventory, measurements, findings, examples, summaries, or figures.

Deliverables

Extend src/main.py and src/report.py, or add a clearly separated replay function, to save:

  • output/document_inventory.csv;
  • output/document_measurements.csv;
  • output/corpus_summary.json and output/source_group_summary.csv;
  • output/inspection_findings.csv and output/selected_examples.json;
  • output/duplicate_content_groups.json;
  • document-length, line-length, and finding-count figures and plot data;
  • output/inspection_manifest.json; and
  • a replay agreement or mismatch record under output/replay/.

The manifest should reference artifacts rather than copying every measurement and excerpt into one large record. The replay record compares file identity, decode and line states, measurements, findings, examples, summaries, and plot data.

Checks

Read every required artifact back and check schema, identity, counts, state accounting, rule configuration, and example order. Replay an unchanged inspection in a separate directory and compare the structured records and figure data. Confirm that the original files remain unchanged.

Deliberately change one source byte, rule threshold, line-boundary result, or selected example and check that replay names the first differing field or artifact. A changed runtime or manifest identity must not be reported as exact agreement.

Workspace

Keep original artifacts under output/ and replay artifacts under a distinct child directory. Keep output/inspection_manifest.json and the project-level report.md at stable paths throughout the project.

Hints

HintReplay bytes before measurements
Compare file paths, byte counts, and digests before comparing decoded text or corpus totals.
HintExamples are part of the result
A replay must preserve deterministic document and line ordering, escaping, and truncation markers, not only aggregate counts.

Review

Open the original and replay directories side by side. Explain what agreement establishes for this fixture and why it does not establish that the corpus is representative or linguistically good.

How to check your work

Checks compare the manifest and replay record with the supplied fixture. The supplied fixture keeps original identity and source evidence immutable.