Refactor manifest.py into domain-specific modules #163

Merged
didericis merged 2 commits from issue-157-manifest-refactor into main 2026-06-03 00:35:43 -04:00
Collaborator

Closes #157.

Summary

  • Extracted ManifestError and _as_json_object into _manifest_util.py — a shared base that breaks the circular-import chain
  • manifest_git.pyGitEntry, GitUser, _parse_git_gate_config, URL/name validators
  • manifest_egress.pyEGRESS_AUTH_SCHEMES, PipelockRoutePolicy, EgressRoute, EgressConfig
  • manifest_agent.pyAgentProvider, Agent
  • manifest.py shrinks to ~280 lines: Bottle, Manifest, and re-exports of all public names so existing callers (from bot_bottle.manifest import X) are unaffected

Changes (1 commit)

All 867 unit tests pass.

Closes #157. ## Summary - Extracted `ManifestError` and `_as_json_object` into `_manifest_util.py` — a shared base that breaks the circular-import chain - `manifest_git.py` — `GitEntry`, `GitUser`, `_parse_git_gate_config`, URL/name validators - `manifest_egress.py` — `EGRESS_AUTH_SCHEMES`, `PipelockRoutePolicy`, `EgressRoute`, `EgressConfig` - `manifest_agent.py` — `AgentProvider`, `Agent` - `manifest.py` shrinks to ~280 lines: `Bottle`, `Manifest`, and re-exports of all public names so existing callers (`from bot_bottle.manifest import X`) are unaffected ## Changes (1 commit) All 867 unit tests pass.
didericis reviewed 2026-06-03 00:24:50 -04:00
@@ -73,2 +73,3 @@
"""Apply PRD 0025 merge rules."""
from .manifest import Bottle, GitUser, _validate_egress_routes
from .manifest import Bottle, GitUser
from .manifest_egress import _validate_egress_routes
Owner

This isn't really private/remove the underscore

This isn't really private/remove the underscore
didericis reviewed 2026-06-03 00:25:40 -04:00
@@ -0,0 +15,4 @@
EGRESS_AUTH_SCHEMES = ("Bearer", "token")
def _is_ip_literal(value: str) -> bool:
Owner

move this into the main bot-bottle, generic util.

Also kind of surprised there isn't a way to call this function in this way from ipaddress

move this into the main bot-bottle, generic util. Also kind of surprised there isn't a way to call this function in this way from `ipaddress`
didericis reviewed 2026-06-03 00:26:45 -04:00
@@ -0,0 +6,4 @@
from dataclasses import dataclass, field
from typing import cast
from ._manifest_util import ManifestError, _as_json_object
Owner

not really private/remove the underscore

not really private/remove the underscore
didericis reviewed 2026-06-03 00:27:06 -04:00
@@ -0,0 +9,4 @@
"""A manifest file (or the manifest tree) is invalid."""
def _as_json_object(value: object, label: str) -> dict[str, object]:
Owner

also not really private/remove underscore

also not really private/remove underscore
didericis reviewed 2026-06-03 00:27:32 -04:00
@@ -0,0 +44,4 @@
return (user, host, port, path)
def _validate_unique_git_names(bottle_name: str, git: tuple[GitEntry, ...]) -> None:
Owner

remove underscore

remove underscore
didericis reviewed 2026-06-03 00:27:39 -04:00
@@ -0,0 +15,4 @@
return value
def _parse_git_upstream(url: str, label: str) -> tuple[str, str, str, str]:
Owner

remove underscore

remove underscore
didericis reviewed 2026-06-03 00:27:53 -04:00
@@ -0,0 +180,4 @@
return not self.name and not self.email
def _parse_git_gate_config(
Owner

remove underscore

remove underscore
didericis added 2 commits 2026-06-03 00:33:05 -04:00
Closes #157. Distributes the 1,026-line manifest.py across four
focused modules:

- _manifest_util.py: ManifestError + _as_json_object (shared base)
- manifest_git.py: GitEntry, GitUser, git-gate config helpers
- manifest_egress.py: EgressRoute, EgressConfig, PipelockRoutePolicy
- manifest_agent.py: AgentProvider, Agent

manifest.py is now the residual orchestration layer: Bottle, Manifest,
and re-exports of all public names so existing callers are unaffected.
All 867 unit tests pass.
refactor: address PR review feedback — de-privatize helpers and rename modules
test / unit (pull_request) Successful in 34s
test / integration (pull_request) Successful in 43s
test / unit (push) Successful in 34s
test / integration (push) Successful in 43s
8c9d4fbc46
- Rename _manifest_util.py → manifest_util.py (module isn't private)
- Rename _as_json_object → as_json_object, _parse_git_upstream → parse_git_upstream,
  _parse_git_gate_config → parse_git_gate_config,
  _validate_unique_git_names → validate_unique_git_names,
  _validate_egress_routes → validate_egress_routes (none are private at
  module boundary — underscore prefix was a carry-over from the old
  monolithic manifest.py where everything lived in one namespace)
- Move _is_ip_literal → util.is_ip_literal (generic, belongs in the
  top-level util module)
- Update all import sites across manifest_*.py, manifest_extends.py,
  manifest_schema.py; existing callers of manifest.py are unaffected

All 867 unit tests pass.
didericis force-pushed issue-157-manifest-refactor from 5ac6c8199c to 8c9d4fbc46 2026-06-03 00:33:05 -04:00 Compare
didericis merged commit 8c9d4fbc46 into main 2026-06-03 00:35:43 -04:00
didericis deleted branch issue-157-manifest-refactor 2026-06-03 00:35:43 -04:00
Sign in to join this conversation.