Raise code quality toward all-5 rubric through focused cleanup and guardrails #444
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
The repo is in good shape overall: strong test coverage, explicit PRDs/ADRs, fail-closed security posture, and careful token handling. The main quality gap is not lack of care; it is architectural accretion. Some runtime modules and cross-backend flows are absorbing too much feature pressure, which makes future changes riskier than they need to be.
This issue tracks a general maintenance push to move the codebase toward an all-5s quality target across architecture, readability, resilience, testability, and SecOps.
Current Concerns
Proposed Work
Harden reconciliation behavior:
Add architecture guardrails:
Decompose large runtime modules:
Improve backend preparation boundaries:
Improve resilience and diagnostics:
Acceptance Criteria
Non-Goals
didericis referenced this issue2026-07-24 13:03:22 -04:00
Refactor landed on #477 — repo reorganization for enforceable separation of concerns
Behavior-preserving groundwork for this cleanup push: no functional change, full unit suite green throughout (2243). What the branch does, by theme:
Concerns now have one obvious home (packages by domain)
bot_bottle.store— the SQLite family (DbStorebase,migrations, theaudit/config/queuestores,StoreManager) pulled out of the package root.bot_bottle.gateway(the data plane) — split into per-service subpackagesegress/,supervisor/,git_gate/, plusbootstrap(the PID-1 daemon manager, renamed fromgateway_init; its inner_Supervisor→_DaemonManager) and the egress entrypoint. TheGatewayABC stays as the backend-neutral lifecycle contract;DockerGatewaymoved tobackend/docker/.bot_bottle.manifest— consolidated themanifest_*modules into a package (Manifest/ManifestIndex→manifest.index).bot_bottle.egress/bot_bottle.git_gate— turned into concrete service classes (Egress,GitGate) in their own packages, with neutral DTO tiers (plan.py) importable by any layer.bot_bottle.supervisor(neutral types/plan) +orchestrator.supervisor(theSupervisorservice the orchestrator owns) — split the supervise plane by tier so the data plane imports only neutral types.backend/— split the heavy__init__intobase(contract ABCs) +selection(registry) and thinned the per-backend inits; foldedrun_dockerintobackend/docker/util(dropped thedocker_cmdshim);OrchestratorService→DockerInfraServicein the docker backend.orchestrator/—control_plane.py→server.py;registry.py→store/registry_store.py; the single-filesupervisor/package collapsed back tosupervisor.py; per-service store managers.cli/commands/— the twelve subcommand handlers grouped into a package;helppromoted to a first-class command; the dispatchermain()moved to__main__, the registry tocommands/__init__; trimmed the_commonjunk drawer down to aconstantsleaf.One name per thing
Unified
control_plane/control_auth→orchestratoracross all code — modules, classes, identifiers, env vars (BOT_BOTTLE_ORCHESTRATOR_TOKEN/_AUTH_JWT), the wire header, and the on-disk token filename. The plane vocabulary ("control plane", "data plane") is now reserved for prose and the security argument, not for identifiers. The forthcoming host-side control server (#468) is named as its own tier — never a second "control plane".Import cost
Converted the remaining heavy
__init__modules to lazy__getattr__facades / thin registries:backend32→2,orchestrator27→2,cli.commands78→23 (plusmanifest/egress/git_gate). This also removed a real drag — the CLI's migration gate was transitively pulling the whole docker backend and an HTTP server on every command.Dead code / latent-bug cleanup
--gateway,Orchestrator.ensure_gateway, thegatewayctor arg) and fixed the latent shared-CA read it surfaced (it targeted a container name the consolidated flow never creates → now readsbot-bottle-infra).REPO_DIR) and pointless re-exports from the CLI.Next on this branch: the substantive backend-auth uniformity work (#476), now that each concern has a single home to enforce it in.