Break manifest import cycle: extract ManifestBottle to a leaf module #314
Reference in New Issue
Block a user
Delete Branch "manifest-break-import-cycle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Removes the one legitimate architecture snag from the recent quality eval: a circular dependency in the manifest layer.
manifest.pyimported theextends:/loader resolvers (merge_bottles_runtime,resolve_bottles,load_bottle_chain_from_dir, …), while those resolvers neededManifestBottleback frommanifest.py— a true bidirectionalmanifest ↔ manifest_extends/manifest_loadercycle, papered over with in-function imports andTYPE_CHECKINGguards. That's the opposite of clear dependency inversion.Change
manifest_bottle.pyholdsManifestBottle. It depends only on the existing leaf modules (manifest_util,manifest_agent,manifest_egress,manifest_git,manifest_schema), so it sits at the bottom of the manifest layer.manifest.pyre-exportsManifestBottle(still in__all__), so everyfrom .manifest import ManifestBottlecaller —git_gate*.py,egress.py, tests — is unaffected. Public API unchanged.manifest_extends/manifest_loadernow importManifestBottlefrom the leaf and their other deps from the real source modules, all at module top;TYPE_CHECKINGblocks removed.manifest.pyimports the extends/loader/schema/yaml_subset/log helpers at module top; all per-function lazy imports in the cluster are gone.Resulting graph is a clean DAG:
manifest → {manifest_extends, manifest_loader, manifest_bottle, …},manifest_loader → manifest_extends → manifest_bottle → leaves.Verification
manifest.ManifestBottleresolves tomanifest_bottle.