"""A missing or short model shard is named with its numbers, a pack's verify reads back the source hash its manifest recorded, and a pack's build refuses an output directory that already holds one - over a minimal GGUF written here (no download, no model, no GPU). python -m unittest tools.test_shards """ from __future__ import annotations import contextlib import hashlib import io import json import struct import sys import tempfile import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "tools")) sys.path.insert(0, str(ROOT)) import setup as S # noqa: E402 import strata_pack # noqa: E402 class Stop(Exception): """setup.fail(), caught instead of exiting: the message is what the test reads.""" def write_gguf(path: Path, names=("blk.0.attn_q.weight", "blk.0.attn_k.weight")) -> int: """A GGUF v3 of F32[8] tensors 32 bytes apart from a 32-byte-aligned data start; returns its whole length.""" b = bytearray(struct.pack("