mamut_routing_publish.publish_roots¶
Explicit publication roots for site builds.
Historically every build path hung off <repo>/dist: the site output, the
build-time caches (atf-cache, route-geometry-cache), and the
persistent history state all shared one tree. That breaks release-style
staging builds (site build --site-output-dir <fresh-dir>): cache writes
leaked through the active dist (a symlink to the live release on
deployments), the fresh release shipped without the caches the payloads
reference, and the history ledger reset to "initial snapshot" on every
deploy because each release directory starts empty.
This module names the roots explicitly:
source_repo: read-only build inputs (benchmarks/,instances_v2/, committed assets).site_output: the only tree a build writes published bytes into (default<source_repo>/dist).state_dir: persistent publication state that must survive fresh site outputs: the history ledger and per-snapshot inventories (default<source_repo>/publish-state, git-ignored).
During a staging build the active <source_repo>/dist tree may be READ
(it seeds the staging caches via hardlinks) but never written.
PublishRoots
dataclass
¶
migrate_legacy_state
¶
Seed state_dir from the pre-roots layout (<dist>/site/) once.
Earlier builds kept the history ledger and snapshot inventories inside the site output itself. Copy them into the persistent state dir the first time a build runs with an empty state dir, so accumulated history survives the layout change. Returns True when a migration ran.
Source code in src/mamut_routing_publish/publish_roots.py
hardlink_tree
¶
Mirror source_dir into target_dir via hardlinks (copy fallback).
Existing target files are left untouched, so the operation is idempotent and safe over content-addressed caches. Returns the number of files linked or copied.