"""Materialization: manifest → OKF bundle (ingest-spec §5, §6, §8). Three explicit inputs — manifest path, bundle directory, ingested_at (no wall-clock default). Deterministic and offline for `file`/`sql`; zero model calls. All extractions execute and render in memory before the first disk mutation; the §3 collision gate runs before any mutation; only files carrying the ingest stamp are ever replaced. Output is LF-only raw bytes. """ from __future__ import annotations import hashlib import logging import re from dataclasses import dataclass from pathlib import Path from .connectors import read_csv, read_sql, safe_resolve from .errors import ManifestError, MaterializationError, NetworkGateError, SourceError from .manifest import ( Extraction, FileSource, HttpSource, Manifest, SqlSource, generated_filename, load_manifest_bytes, ) from .render import render_table _LOGGER = logging.getLogger(__name__) _INDEX_NAME = "index.md" _INGESTED_AT_RE = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$") # One managed index line: `- [