#!/usr/bin/env python3 """mtp_fetch differential: `strata-next tools mtp-fetch` vs the unmodified tools/mtp_fetch.py, both against the same local HTTP mirror of a fake checkpoint (the fixture pattern of tools/test_mtp_fetch.py, here a real socket). Scenarios: honest fetch + verify; a corrupted install re-fetched; a resumed half tensor; `--only`; a mirror that ignores Range (both must refuse and leave no tensor); inventory-only. After each, the output directories must match file for file (inventory json/md, manifest, every tensor, verified.json modulo mtime). python scripts/offline/diff_mtp_fetch.py """ import hashlib import http.server import json import shutil import struct import subprocess import sys import tempfile import threading from pathlib import Path from unittest import mock REPO = Path(__file__).resolve().parents[2] sys.path.insert(0, str(REPO / 'engine/strata/tools')) import mtp_fetch as M # noqa: E402 (the oracle, unchanged) def shard(tensors): header, data = {}, b'' for name, blob in tensors: header[name] = {'dtype': 'BF16', 'shape': [len(blob) // 2], 'data_offsets': [len(data), len(data) + len(blob)]} data += blob h = json.dumps(header).encode() return struct.pack('