Metadata Module
Shared publication-metadata leaves consumed by the publishing, rendering,
documentation, and project layers. Extracted from infrastructure/publishing
so the rendering layer can import these surfaces without an inverted
dependency on the publishing package (RENDERING-LAYERING-1).
Repository URL normalization (repository_metadata.py)
from infrastructure.metadata.repository_metadata import normalized_repository_url
url = normalized_repository_url(publication) # explicit URL or owner/repo slug
Ebook metadata package (metadata_package.py)
from infrastructure.metadata.metadata_package import (
EbookPublicationMetadata,
ebook_metadata_from_config,
generate_epub_opf,
generate_metadata_json,
generate_metadata_package,
generate_onix_xml,
)
meta = ebook_metadata_from_config(config, project_slug)
paths = generate_metadata_package(meta, output_dir=Path("output/metadata"))
# paths == {"onix_xml": ..., "metadata_json": ..., "opf": ...} — the writer
# emits onix.xml, metadata.json, and package.opf itself; no manual write_text.
Invariants
- Leaf package: imports only stdlib plus
infrastructure.core; never imports publishing, rendering, or reporting. - Rendering may import this package directly; the layering guard
(
tests/infra_tests/rendering/test_layering.py) enforces zero rendering->publishing edges with an empty allowlist. - Consumers import repository and ebook metadata from
infrastructure.metadata.