Independent CPU replay of the bounded SDSU input diagnostic
=========================================================

Entry point: replay_bounded_input.py
Requirement: Python 3.9+ and NumPy (tested with Python 3.12.14 / NumPy 1.26.4).
No Torch, GPU, original images, neural checkpoints or project imports are needed.

Run after extracting Online Resource 2:

  python replay_bounded_input.py --resource-root /path/to/extracted-resource --output-dir /path/to/new-replay-output

Use a NEW output directory OUTSIDE the extracted resource. The program refuses
existing output directories and refuses writes inside the resource. It reads
the archived scientific inputs and writes a separate replay report and CSVs.

Expected resource layout (member names are case sensitive on some systems):

  external/annotations.zip
  external/predictions/external/siteformal_r0_s17_e60_sz768/predictions.npz
  bounded/input/identities.json
  bounded/input/geometry.json
  bounded/input/protocol.json
  bounded/input/freeze.json
  bounded/input/gpu_accounting.json
  bounded/input/analysis_summary.json
  bounded/input/per_image_errors.csv
  bounded/input/annotation_network_pixel_scales.csv
  bounded/input/geometry_observations.csv
  bounded/input/date_metrics.csv
  bounded/input/predictions/siteformal_r0_s17_e60_sz768/complete.json
  bounded/input/predictions/siteformal_r0_s17_e60_sz768/<159 image packets>.npz

Other supplied diagnostic JSON/CSV/code files are retained as provenance.
Historical freeze paths are mapped to bounded/input/. Present members are
hash checked; any unbundled historical member is explicitly listed in the
report and is not falsely described as verified. Per-model completion and
all 159 packet hashes are mandatory. Optional top-level prediction completion
is checked when supplied. The old raw-count baseline is read by its named
raw column; the new inputs receive no count calibrator.

The replay independently reads all 18,790 released label records, recomputes
477 image/scheme rows, three aggregate metrics sets and descriptive date
metrics, and 56,370 annotation/scheme scale rows. It checks all stored root
numeric summaries without importing the root analysis implementation.
It also verifies zero-area counts and NumPy-only NMS invariants: retained
boxes are saved candidates, retained pairwise IoU does not exceed 0.6, and
every removed candidate is suppressed by a retained candidate of at least
its score or explained by the fixed 1,000-box cap. It does not impose an
alternative equal-score ordering and does not rerun detector inference.

Outputs:
  bounded_input_independent_replay.json
  input_nms_invariant_checks.csv
  recomputed_diagnostic_metrics.csv
  recomputed_per_image_errors.csv
  recomputed_pixel_scale_summary.csv

A PASS establishes numerical agreement and the specified implementation
invariants. It is not human review, a proof of annotation accuracy,
biological one-head/one-detection matching, or independent confirmation of
the retrospective single-model, single-location diagnostic. Tile sizes are
nominal full-object sizes from UNCLIPPED released quadrilaterals times 0.75;
actual tile seams may contain partial objects. Aggregate MAE divided by mean
reference count is not per-image MAPE. New inference was not performed by
this CPU replay.

Packaging note: portable_replay_sandbox/ is an audit-only local test fixture;
exclude it from the final Online Resource 2 to avoid duplicating resources.
The generator make_portable_replay.py and original replay_input_numbers.py
are audit provenance, not prerequisites for running this entry point.
