... <= 0 or len(text) <= max_chars:
        return text
    head = int(max_chars * head_ratio)
    tail = max_chars - head - 40
    tail = max(0, tail)
    return text[:head] + "\n...\n[TRUNCATED]\n...\n" + (text[-tail:] if tail else "")


def extract_block_id_from_filename(p: Path) -> str:
    stem = p.stem
    stem = stem.replace("__EXTRACT", "").replace("_EXTRACT", "")
    return stem.stri...